diff --git a/docs/rpc/components/schemas/block-replay-transaction.schema.yaml b/docs/rpc/components/schemas/block-replay-transaction.schema.yaml
index c3bfad873bd..e4bb271f63f 100644
--- a/docs/rpc/components/schemas/block-replay-transaction.schema.yaml
+++ b/docs/rpc/components/schemas/block-replay-transaction.schema.yaml
@@ -40,6 +40,9 @@ properties:
cpu_ref_cycles:
type: [integer, "null"]
description: number of reference cycles executed
+ execution_time_millis:
+ type: integer
+ description: execution time in milliseconds
required:
- data
- events
@@ -51,6 +54,4 @@ required:
- tx_index
- txid
- vm_error
- - cpu_instructions
- - cpu_cycles
- - cpu_ref_cycles
+ - execution_time_millis
diff --git a/stackslib/src/net/api/blockreplay.rs b/stackslib/src/net/api/blockreplay.rs
index de10f5378c8..8590d19adc8 100644
--- a/stackslib/src/net/api/blockreplay.rs
+++ b/stackslib/src/net/api/blockreplay.rs
@@ -13,6 +13,8 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
+use std::time::{Duration, Instant};
+
use clarity::vm::costs::ExecutionCost;
use clarity::vm::Value;
use regex::{Captures, Regex};
@@ -261,6 +263,8 @@ where
for (i, tx) in transactions.iter().enumerate() {
let tx_len = tx.tx_len();
+ let start = Instant::now();
+
let mut profiler: Option = None;
let mut profiler_result = BlockReplayProfilerResult::default();
@@ -285,7 +289,7 @@ where
let err = match tx_result {
TransactionResult::Success(tx_result) => {
- txs_receipts.push((tx_result.receipt, profiler_result));
+ txs_receipts.push((tx_result.receipt, start.elapsed(), profiler_result));
Ok(())
}
TransactionResult::ProcessingError(e) => {
@@ -318,8 +322,12 @@ where
let mut rpc_replayed_block =
RPCReplayedBlock::from_block(&replayed_block, block_fees, tenure_id, parent_block_id);
- for (receipt, profiler_result) in &txs_receipts {
- let transaction = RPCReplayedBlockTransaction::from_receipt(receipt, &profiler_result);
+ for (receipt, execution_duration, profiler_result) in &txs_receipts {
+ let transaction = RPCReplayedBlockTransaction::from_receipt(
+ receipt,
+ execution_duration,
+ &profiler_result,
+ );
rpc_replayed_block.transactions.push(transaction);
}
@@ -394,11 +402,13 @@ pub struct RPCReplayedBlockTransaction {
pub cpu_instructions: Option,
pub cpu_cycles: Option,
pub cpu_ref_cycles: Option,
+ pub execution_time_millis: u64,
}
impl RPCReplayedBlockTransaction {
pub fn from_receipt(
receipt: &StacksTransactionReceipt,
+ execution_duration: &Duration,
profiler_result: &BlockReplayProfilerResult,
) -> Self {
let events = if receipt.post_condition_aborted {
@@ -437,6 +447,7 @@ impl RPCReplayedBlockTransaction {
cpu_instructions: profiler_result.cpu_instructions,
cpu_cycles: profiler_result.cpu_cycles,
cpu_ref_cycles: profiler_result.cpu_ref_cycles,
+ execution_time_millis: execution_duration.as_millis() as u64,
}
}
}