consensus: instrument script verification
This commit is contained in:
parent
d4da9609ee
commit
04acc9da6c
|
|
@ -1,6 +1,7 @@
|
||||||
use std::{pin::Pin, sync::Arc};
|
use std::{future::Future, pin::Pin, sync::Arc};
|
||||||
|
|
||||||
|
use tracing::Instrument;
|
||||||
|
|
||||||
use std::future::Future;
|
|
||||||
use zebra_chain::{parameters::ConsensusBranchId, transaction::Transaction, transparent};
|
use zebra_chain::{parameters::ConsensusBranchId, transaction::Transaction, transparent};
|
||||||
|
|
||||||
use crate::BoxError;
|
use crate::BoxError;
|
||||||
|
|
@ -65,25 +66,33 @@ where
|
||||||
|
|
||||||
match input {
|
match input {
|
||||||
transparent::Input::PrevOut { outpoint, .. } => {
|
transparent::Input::PrevOut { outpoint, .. } => {
|
||||||
let output = self.state.call(zebra_state::Request::AwaitUtxo(*outpoint));
|
let outpoint = *outpoint;
|
||||||
let transaction = req.transaction;
|
let transaction = req.transaction;
|
||||||
let branch_id = self.branch;
|
let branch_id = self.branch;
|
||||||
let input_index = req.input_index;
|
let input_index = req.input_index;
|
||||||
|
|
||||||
|
let span = tracing::trace_span!("script", ?outpoint);
|
||||||
|
let output =
|
||||||
|
span.in_scope(|| self.state.call(zebra_state::Request::AwaitUtxo(outpoint)));
|
||||||
|
|
||||||
async move {
|
async move {
|
||||||
|
tracing::trace!("awaiting outpoint lookup");
|
||||||
let previous_output = match output.await? {
|
let previous_output = match output.await? {
|
||||||
zebra_state::Response::Utxo(output) => output,
|
zebra_state::Response::Utxo(output) => output,
|
||||||
_ => unreachable!("AwaitUtxo always responds with Utxo"),
|
_ => unreachable!("AwaitUtxo always responds with Utxo"),
|
||||||
};
|
};
|
||||||
|
tracing::trace!(?previous_output, "got UTXO");
|
||||||
|
|
||||||
zebra_script::is_valid(
|
zebra_script::is_valid(
|
||||||
transaction,
|
transaction,
|
||||||
branch_id,
|
branch_id,
|
||||||
(input_index as u32, previous_output),
|
(input_index as u32, previous_output),
|
||||||
)?;
|
)?;
|
||||||
|
tracing::trace!("script verification succeeded");
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
.instrument(span)
|
||||||
.boxed()
|
.boxed()
|
||||||
}
|
}
|
||||||
transparent::Input::Coinbase { .. } => {
|
transparent::Input::Coinbase { .. } => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue