diff --git a/miden-lib/asm/kernels/transaction/main.masm b/miden-lib/asm/kernels/transaction/main.masm index 7f228e8df..515c22807 100644 --- a/miden-lib/asm/kernels/transaction/main.masm +++ b/miden-lib/asm/kernels/transaction/main.masm @@ -64,6 +64,9 @@ proc.main.1 # Prologue # --------------------------------------------------------------------------------------------- + push.0 drop + emit.131077 + # execute the transaction prologue exec.prologue::prepare_transaction # => [] @@ -71,6 +74,9 @@ proc.main.1 # Note Processing # --------------------------------------------------------------------------------------------- + push.0 drop + emit.131077 + # get the total number of consumed notes exec.memory::get_total_num_consumed_notes # => [num_consumed_notes] @@ -112,6 +118,9 @@ proc.main.1 # Transaction Script Processing # --------------------------------------------------------------------------------------------- + push.0 drop + emit.131077 + # execute the transaction script exec.memory::get_tx_script_root # => [TX_SCRIPT_ROOT] @@ -136,6 +145,9 @@ proc.main.1 # Epilogue # --------------------------------------------------------------------------------------------- + push.0 drop + emit.131077 + # execute the transaction epilogue exec.epilogue::finalize_transaction # => [TX_SCRIPT_ROOT, CREATED_NOTES_COMMITMENT, FINAL_ACCOUNT_HASH] diff --git a/miden-lib/src/transaction/events.rs b/miden-lib/src/transaction/events.rs index be4bc9d84..a615885f7 100644 --- a/miden-lib/src/transaction/events.rs +++ b/miden-lib/src/transaction/events.rs @@ -20,6 +20,7 @@ pub enum TransactionEvent { AccountStorageSetItem = 0x2_0002, // 131074 AccountIncrementNonce = 0x2_0003, // 131075 AccountPushProcedureIndex = 0x2_0004, // 131076 + AccountBenchData = 0x2_0005, // 131077 } impl TransactionEvent { @@ -47,6 +48,7 @@ impl TryFrom for TransactionEvent { 0x2_0002 => Ok(TransactionEvent::AccountStorageSetItem), 0x2_0003 => Ok(TransactionEvent::AccountIncrementNonce), 0x2_0004 => Ok(TransactionEvent::AccountPushProcedureIndex), + 0x2_0005 => Ok(TransactionEvent::AccountBenchData), _ => Err(TransactionEventParsingError::InvalidTransactionEvent(value)), } } diff --git a/miden-tx/src/host/mod.rs b/miden-tx/src/host/mod.rs index 60f72fa74..273271d56 100644 --- a/miden-tx/src/host/mod.rs +++ b/miden-tx/src/host/mod.rs @@ -1,4 +1,5 @@ use alloc::{collections::BTreeMap, string::ToString}; +use std::println; use miden_lib::transaction::{TransactionEvent, TransactionKernelError}; use miden_objects::{ @@ -61,6 +62,14 @@ impl TransactionHost { .expect("failed to push value onto advice stack"); Ok(()) } + + fn on_account_print_cycle_data( + &self, + process: &S, + ) -> Result<(), TransactionKernelError> { + println!("Event emitted at step {} in context {}", process.clk(), process.ctx(),); + Ok(()) + } } impl Host for TransactionHost { @@ -101,6 +110,7 @@ impl Host for TransactionHost { AccountStorageSetItem => self.on_account_storage_set_item(process), AccountIncrementNonce => self.on_account_increment_nonce(process), AccountPushProcedureIndex => self.on_account_push_procedure_index(process), + AccountBenchData => self.on_account_print_cycle_data(process), } .map_err(|err| ExecutionError::EventError(err.to_string()))?; diff --git a/miden-tx/src/tests.rs b/miden-tx/src/tests.rs index 3598eb639..a6e12aa7b 100644 --- a/miden-tx/src/tests.rs +++ b/miden-tx/src/tests.rs @@ -354,7 +354,7 @@ fn test_tx_script() { // ================================================================================================ #[derive(Clone)] -struct MockDataStore { +pub struct MockDataStore { pub account: Account, pub block_header: BlockHeader, pub block_chain: ChainMmr, diff --git a/miden-tx/tests/integration/bench/mod.rs b/miden-tx/tests/integration/bench/mod.rs new file mode 100644 index 000000000..62e4a01ba --- /dev/null +++ b/miden-tx/tests/integration/bench/mod.rs @@ -0,0 +1 @@ +mod tx_benchmark; diff --git a/miden-tx/tests/integration/bench/tx_benchmark.rs b/miden-tx/tests/integration/bench/tx_benchmark.rs new file mode 100644 index 000000000..b41c1e8ee --- /dev/null +++ b/miden-tx/tests/integration/bench/tx_benchmark.rs @@ -0,0 +1,16 @@ +use crate::MockDataStore; +use miden_tx::TransactionExecutor; + +#[test] +fn benchmark_default_tx() { + let data_store = MockDataStore::default(); + let mut executor = TransactionExecutor::new(data_store.clone()); + + let account_id = data_store.account.id(); + executor.load_account(account_id).unwrap(); + + let block_ref = data_store.block_header.block_num(); + let note_ids = data_store.notes.iter().map(|note| note.id()).collect::>(); + + executor.execute_transaction(account_id, block_ref, ¬e_ids, None).unwrap(); +} diff --git a/miden-tx/tests/integration/main.rs b/miden-tx/tests/integration/main.rs index 65c8036ab..e6cf8b2eb 100644 --- a/miden-tx/tests/integration/main.rs +++ b/miden-tx/tests/integration/main.rs @@ -1,3 +1,4 @@ +mod bench; mod scripts; mod wallet;