Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### Features

- Added benchmark for ECDSA signed transaction ([#2967](https://github.com/0xMiden/protocol/pull/2967)).
- [BREAKING] Renamed `NoteId` to `NoteDetailsCommitment`, new `NoteId` struct now includes the NoteMetadata ([#1731](https://github.com/0xMiden/protocol/issues/1731)).
- Added lock/unlock path for Miden-native tokens in the AggLayer bridge: `is_native` flag in `faucet_registry_map`, bridge-local `faucet_metadata_map` (replacing FPI to faucets for conversion data), and `lock_asset` / `unlock_and_send` procedures so the bridge holds native assets in its own vault instead of burn/mint via a faucet ([#2771](https://github.com/0xMiden/protocol/pull/2771)).
- [BREAKING] Renamed `NoteId` to `NoteDetailsCommitment`, new `NoteId` struct now includes the NoteMetadata ([#2861](https://github.com/0xMiden/protocol/pull/2861)).
- [BREAKING] Updated note nullifiers to include note metadata and attachments commitment ([#2953](https://github.com/0xMiden/protocol/pull/2953)).
Expand Down
7 changes: 4 additions & 3 deletions bin/bench-transaction/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ Below we describe how to benchmark Miden transactions.

The following transactions are benchmarked:

- **P2ID notes**: Consume single/two P2ID notes, create single P2ID note
- **P2ID notes**: Consume single P2ID notes with Falcon or ECDSA signing, consume two P2ID
notes, create single P2ID note
- **CLAIM notes (agglayer bridge-in)**: Consume CLAIM note for L1-to-Miden bridging and L2-to-Miden bridging
- **B2AGG note (agglayer bridge-out)**: Consume B2AGG note for Miden-to-AggLayer bridging

Expand Down Expand Up @@ -45,7 +46,7 @@ Each of the above transactions is measured in two groups:

This group uses the [Criterion.rs](https://github.com/bheisler/criterion.rs) to collect the elapsed time. Results of this benchmark group are printed to the terminal and look like so:
```zsh
Execute transaction/Execute transaction which consumes single P2ID note
Execute transaction/Execute transaction which consumes single P2ID note with Falcon signing
time: [7.2611 ms 7.2772 ms 7.2929 ms]
change: [−0.9131% −0.5837% −0.3058%] (p = 0.00 < 0.05)
Change within noise threshold.
Expand All @@ -54,7 +55,7 @@ Each of the above transactions is measured in two groups:
change: [−1.2256% −0.7611% −0.3355%] (p = 0.00 < 0.05)
Change within noise threshold.

Execute and prove transaction/Execute and prove transaction which consumes single P2ID note
Execute and prove transaction/Execute and prove transaction which consumes single P2ID note with Falcon signing
time: [698.96 ms 703.92 ms 708.70 ms]
change: [−2.3061% −0.4274% +0.9653%] (p = 0.70 > 0.05)
No change in performance detected.
Expand Down
181 changes: 103 additions & 78 deletions bin/bench-transaction/bench-tx.json
Original file line number Diff line number Diff line change
@@ -1,149 +1,174 @@
{
"consume single P2ID note": {
"prologue": 3491,
"notes_processing": 1761,
"consume single P2ID note with Falcon signing": {
"prologue": 3512,
"notes_processing": 1757,
"note_execution": {
"0xcc9b6800b67338071874f6f8bcb9716c31a7b97626064eef34a713e2068fe21e": 1721
"0x2cc6f4f31352e856292d9daf412f97468ffce9993e8e9b403a5d4a4fb7be8163": 1717
},
"tx_script_processing": 42,
"epilogue": {
"total": 72345,
"auth_procedure": 70843,
"after_tx_cycles_obtained": 612
"total": 72815,
"auth_procedure": 71322,
"after_tx_cycles_obtained": 603
},
"trace": {
"core_rows": 77683,
"chiplets_rows": 123159,
"range_rows": 20179,
"core_rows": 78170,
"chiplets_rows": 61069,
"range_rows": 20367,
"chiplets_shape": {
"hasher_rows": 120384,
"bitwise_rows": 416,
"memory_rows": 2294,
"kernel_rom_rows": 64,
"hasher_rows": 58320,
"bitwise_rows": 392,
"memory_rows": 2301,
"kernel_rom_rows": 55,
"ace_rows": 0
}
}
},
"consume single P2ID note with ECDSA signing": {
"prologue": 3512,
"notes_processing": 1757,
"note_execution": {
"0x48854330460cc896ea9d2761baeff069b6deea60c70a590f06c0cca7c75ef30b": 1717
},
"tx_script_processing": 42,
"epilogue": {
"total": 4823,
"auth_procedure": 3330,
"after_tx_cycles_obtained": 603
},
"trace": {
"core_rows": 10178,
"chiplets_rows": 18845,
"range_rows": 1201,
"chiplets_shape": {
"hasher_rows": 17728,
"bitwise_rows": 392,
"memory_rows": 669,
"kernel_rom_rows": 55,
"ace_rows": 0
}
Comment on lines +27 to 49
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments about this result. If we compare Falcon-based vs. ECDSA-based transactions, we get something like this:

Falcon ECDSA Falcon/ECDSA
Core trace rows 78.2K 10.2K 7.7x
Chiplet trace rows 58.3K 18.8K 3.1x
Padded trace rows 128K 32K 4.0x
Proving time 1.38 sec 0.37 sec 3.7x

A few takeaways:

  • I was hoping that ECDSA transaction would end up with under 8K core trace rows, but it is slightly over 10K. My miscalculation was that I thought ECDSA verification would take a few hundred cycles, but it seems to be taking around 3K cycles. @Al-Kindi-0 - what's the driving factor of cycle count here?
  • I really underestimated the chiplets trace length for ECDSA (I guess my mental model is still biased by RPO). I did think that it would be more than the core trace, but I didn't think it'd be over 16K rows.
  • The net result is that instead of Falcon requiring ~8x more rows than ECDSA, the delta is about 4x, and the proving times show a similar picture as well.
    • The new multi-table structure should increase this delta - but I'm not sure by how much.
    • Maybe there is a way to reduce the number of hashes need to push the chiplets trace under 16K - but also, not something we should spend the time on before we settle on the hash function.

cc @Al-Kindi-0, @adr1anh, @WiktorStarczewski for visibility.

Separately, may be good to update synthetic benchmarks in the miden-vm repo with this scenario as well.

}
},
"consume two P2ID notes": {
"prologue": 4527,
"notes_processing": 3600,
"prologue": 4592,
"notes_processing": 3636,
"note_execution": {
"0x621c91b9a914d27fbc7e5d9a743e2ac72593e2b96d74d22edf3443b04ab01fbd": 1721,
"0xdc6a6014e58b417f8ed38e7092e7c885a534a27fcd746a20200bf1bc8e1b976d": 1830
"0x6a0b18f0dd3a23ac61b77ac70c4b1be62878087d3af8c235eac5ef6e453f964c": 1870,
"0xa469507fa4c9f2259e30a2052b5d700e0cfe6be3b6c3eb8f747ed8d86e8fb59a": 1717
},
"tx_script_processing": 42,
"epilogue": {
"total": 72293,
"auth_procedure": 70817,
"after_tx_cycles_obtained": 612
"total": 72763,
"auth_procedure": 71296,
"after_tx_cycles_obtained": 603
},
"trace": {
"core_rows": 80506,
"chiplets_rows": 141290,
"range_rows": 20129,
"core_rows": 81077,
"chiplets_rows": 63669,
"range_rows": 20335,
"chiplets_shape": {
"hasher_rows": 138240,
"bitwise_rows": 592,
"memory_rows": 2389,
"kernel_rom_rows": 68,
"hasher_rows": 60656,
"bitwise_rows": 560,
"memory_rows": 2397,
"kernel_rom_rows": 55,
"ace_rows": 0
}
}
},
"create single P2ID note": {
"prologue": 1756,
"prologue": 1791,
"notes_processing": 32,
"note_execution": {},
"tx_script_processing": 1659,
"tx_script_processing": 1661,
"epilogue": {
"total": 73237,
"auth_procedure": 71055,
"after_tx_cycles_obtained": 612
"total": 73917,
"auth_procedure": 71646,
"after_tx_cycles_obtained": 603
},
"trace": {
"core_rows": 76728,
"chiplets_rows": 118595,
"range_rows": 20011,
"core_rows": 77445,
"chiplets_rows": 59632,
"range_rows": 20271,
"chiplets_shape": {
"hasher_rows": 115968,
"hasher_rows": 57008,
"bitwise_rows": 328,
"memory_rows": 2235,
"kernel_rom_rows": 63,
"memory_rows": 2240,
"kernel_rom_rows": 55,
"ace_rows": 0
}
}
},
"consume CLAIM note (L1 to Miden)": {
"prologue": 2887,
"notes_processing": 28554,
"prologue": 2979,
"notes_processing": 29656,
"note_execution": {
"0xd7d99970e9793cd134b13b9f4894bdb10c2f80aafd3656cb390d76cf079e9958": 28514
"0xa1946d015e643cf1956ab511c73583f75c30017c417cd40961d38b8e17ad3ad3": 29616
},
"tx_script_processing": 42,
"epilogue": {
"total": 4090,
"auth_procedure": 880,
"after_tx_cycles_obtained": 612
"total": 5249,
"auth_procedure": 1781,
"after_tx_cycles_obtained": 603
},
"trace": {
"core_rows": 35617,
"chiplets_rows": 147222,
"range_rows": 2407,
"core_rows": 37970,
"chiplets_rows": 45953,
"range_rows": 2685,
"chiplets_shape": {
"hasher_rows": 141248,
"bitwise_rows": 2624,
"memory_rows": 3277,
"kernel_rom_rows": 72,
"hasher_rows": 39728,
"bitwise_rows": 2728,
"memory_rows": 3441,
"kernel_rom_rows": 55,
"ace_rows": 0
}
}
},
"consume CLAIM note (L2 to Miden)": {
"prologue": 2887,
"notes_processing": 40804,
"prologue": 2979,
"notes_processing": 41869,
"note_execution": {
"0xccad52dbae536daa8e0c5888e712446cc3aeb8f5dd455b907a31d6972eb89163": 40764
"0x7c4ab3b63bd083dfd2a48a147bf31d45d827a4caf46e3d6515798dbbccf1094e": 41829
},
"tx_script_processing": 42,
"epilogue": {
"total": 4090,
"auth_procedure": 880,
"after_tx_cycles_obtained": 612
"total": 5249,
"auth_procedure": 1781,
"after_tx_cycles_obtained": 603
},
"trace": {
"core_rows": 47867,
"chiplets_rows": 189924,
"range_rows": 2649,
"core_rows": 50183,
"chiplets_rows": 52159,
"range_rows": 2905,
"chiplets_shape": {
"hasher_rows": 182464,
"bitwise_rows": 2880,
"memory_rows": 4507,
"kernel_rom_rows": 72,
"hasher_rows": 44448,
"bitwise_rows": 2984,
"memory_rows": 4671,
"kernel_rom_rows": 55,
"ace_rows": 0
}
}
},
"consume B2AGG note (bridge-out)": {
"prologue": 3708,
"notes_processing": 145469,
"prologue": 3793,
"notes_processing": 145479,
"note_execution": {
"0x4214c8b99dc2ec5fb56584e35555762a379dd506904a4203a151691f7b2f7d9a": 145429
"0xa76b8bcf2daa5556bb5c2bd421dac2695996e86095648e16f8c608349025ff51": 145439
},
"tx_script_processing": 42,
"epilogue": {
"total": 13753,
"auth_procedure": 880,
"after_tx_cycles_obtained": 612
"total": 14898,
"auth_procedure": 1781,
"after_tx_cycles_obtained": 603
},
"trace": {
"core_rows": 163016,
"chiplets_rows": 911692,
"range_rows": 4111,
"core_rows": 164256,
"chiplets_rows": 178248,
"range_rows": 4361,
"chiplets_shape": {
"hasher_rows": 896832,
"bitwise_rows": 2608,
"memory_rows": 12042,
"kernel_rom_rows": 209,
"hasher_rows": 163312,
"bitwise_rows": 2680,
"memory_rows": 12200,
"kernel_rom_rows": 55,
"ace_rows": 0
}
}
Expand Down
14 changes: 10 additions & 4 deletions bin/bench-transaction/src/context_setups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,24 @@ pub fn tx_create_single_p2id_note() -> Result<TransactionContext> {
.build()
}

pub fn tx_consume_single_p2id_note_falcon() -> Result<TransactionContext> {
tx_consume_single_p2id_note_with_auth(AuthScheme::Falcon512Poseidon2)
}

pub fn tx_consume_single_p2id_note_ecdsa() -> Result<TransactionContext> {
tx_consume_single_p2id_note_with_auth(AuthScheme::EcdsaK256Keccak)
}

/// Returns the transaction context which could be used to run the transaction which consumes a
/// single P2ID note into a new basic wallet.
pub fn tx_consume_single_p2id_note() -> Result<TransactionContext> {
fn tx_consume_single_p2id_note_with_auth(auth_scheme: AuthScheme) -> Result<TransactionContext> {
// Create assets
let fungible_asset: Asset = FungibleAsset::mock(123);

let mut builder = MockChain::builder();

// Create target account
let target_account = builder.create_new_wallet(Auth::BasicAuth {
auth_scheme: AuthScheme::Falcon512Poseidon2,
})?;
let target_account = builder.create_new_wallet(Auth::BasicAuth { auth_scheme })?;

// Create the note
let note = builder
Expand Down
10 changes: 8 additions & 2 deletions bin/bench-transaction/src/cycle_counting_benchmarks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ pub mod utils;
/// Indicates the type of the transaction execution benchmark
#[derive(Clone, Copy)]
pub enum ExecutionBenchmark {
ConsumeSingleP2ID,
ConsumeSingleP2IDFalcon,
ConsumeSingleP2IDEcdsa,
ConsumeTwoP2ID,
CreateSingleP2ID,
ConsumeClaimNoteL1ToMiden,
Expand All @@ -19,7 +20,12 @@ pub enum ExecutionBenchmark {
impl fmt::Display for ExecutionBenchmark {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
ExecutionBenchmark::ConsumeSingleP2ID => write!(f, "consume single P2ID note"),
ExecutionBenchmark::ConsumeSingleP2IDFalcon => {
write!(f, "consume single P2ID note with Falcon signing")
},
ExecutionBenchmark::ConsumeSingleP2IDEcdsa => {
write!(f, "consume single P2ID note with ECDSA signing")
},
ExecutionBenchmark::ConsumeTwoP2ID => write!(f, "consume two P2ID notes"),
ExecutionBenchmark::CreateSingleP2ID => write!(f, "create single P2ID note"),
ExecutionBenchmark::ConsumeClaimNoteL1ToMiden => {
Expand Down
19 changes: 12 additions & 7 deletions bin/bench-transaction/src/cycle_counting_benchmarks/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,34 +201,39 @@ mod tests {

const COMMITTED_SCENARIO_EXPECTATIONS: &[ScenarioExpectation] = &[
ScenarioExpectation {
name: "consume single P2ID note",
name: "consume single P2ID note with Falcon signing",
padded_core_side: 131_072,
padded_chiplets: 131_072,
padded_chiplets: 65_536,
},
ScenarioExpectation {
name: "consume single P2ID note with ECDSA signing",
padded_core_side: 16_384,
padded_chiplets: 32_768,
},
ScenarioExpectation {
name: "consume two P2ID notes",
padded_core_side: 131_072,
padded_chiplets: 262_144,
padded_chiplets: 65_536,
},
ScenarioExpectation {
name: "create single P2ID note",
padded_core_side: 131_072,
padded_chiplets: 131_072,
padded_chiplets: 65_536,
},
ScenarioExpectation {
name: "consume CLAIM note (L1 to Miden)",
padded_core_side: 65_536,
padded_chiplets: 262_144,
padded_chiplets: 65_536,
},
ScenarioExpectation {
name: "consume CLAIM note (L2 to Miden)",
padded_core_side: 65_536,
padded_chiplets: 262_144,
padded_chiplets: 65_536,
},
ScenarioExpectation {
name: "consume B2AGG note (bridge-out)",
padded_core_side: 262_144,
padded_chiplets: 1_048_576,
padded_chiplets: 262_144,
},
];

Expand Down
Loading
Loading