Skip to content

fix(store/genesis): use Smt to compute account root of genesis block#2151

Merged
kkovaacs merged 4 commits into
nextfrom
krisztian/use-smt-when-creating-genesis-block
May 28, 2026
Merged

fix(store/genesis): use Smt to compute account root of genesis block#2151
kkovaacs merged 4 commits into
nextfrom
krisztian/use-smt-when-creating-genesis-block

Conversation

@kkovaacs
Copy link
Copy Markdown
Contributor

LargeSmt is pretty expensive to construct and since the account tree in the genesis block is not expected to be huge we can safely avoid that initialization cost by simply using Smt instead of LargeSmt.

`LargeSmt` is pretty expensive to construct and since the account tree in
the genesis block is not expected to be huge we can safely avoid that
initialization cost by simply using `Smt` instead of `LargeSmt`.
@kkovaacs kkovaacs added the no changelog This PR does not require an entry in the `CHANGELOG.md` file label May 28, 2026
Copy link
Copy Markdown
Collaborator

@Mirko-von-Leipzig Mirko-von-Leipzig left a comment

Choose a reason for hiding this comment

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

Oh that's neat.

Copy link
Copy Markdown
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

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

Looks good! Thank you!

Is there a noticeable difference for how fast the tests run with this?

@kkovaacs
Copy link
Copy Markdown
Contributor Author

Looks good! Thank you!

Is there a noticeable difference for how fast the tests run with this?

Yes. For example, running all tests for the validator on my laptop before the change:

➤ /usr/bin/time ../../target/debug/deps/miden_validator-014f46be61300bbb 

running 12 tests
test db::migrations::tests::diesel_schema_is_in_sync_with_migrations ... ignored, requires diesel CLI; CI runs this in the diesel-schema job
test db::migrations::tests::migration_schema_hashes_are_stable ... ok
test server::tests::commitment_mismatch_rejected ... ok
test server::tests::chain_tip_plus_one_succeeds ... ok
test server::tests::empty_block_succeeds ... ok
test server::tests::unknown_transactions_rejected ... ok
test server::tests::validate_block_number_mismatch ... ok
test server::tests::chain_tip_plus_two_rejected ... ok
test server::tests::chain_tip_replacement_succeeds ... ok
test server::tests::chain_tip_minus_one_rejected ... ok
test server::tests::new_block_after_replacement_with_stale_commitment_rejected ... ok
test server::tests::replacement_commitment_mismatch_rejected ... ok

test result: ok. 11 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 14.26s

24.59user 89.58system 0:14.29elapsed 798%CPU (0avgtext+0avgdata 11525380maxresident)k
23976inputs+0outputs (1784914major+4582167minor)pagefaults 0swaps

After the change:

➤ /usr/bin/time ../../target/debug/deps/miden_validator-014f46be61300bbb

running 12 tests
test db::migrations::tests::diesel_schema_is_in_sync_with_migrations ... ignored, requires diesel CLI; CI runs this in the diesel-schema job
test db::migrations::tests::migration_schema_hashes_are_stable ... ok
test server::tests::unknown_transactions_rejected ... ok
test server::tests::new_block_after_replacement_with_stale_commitment_rejected ... ok
test server::tests::chain_tip_plus_one_succeeds ... ok
test server::tests::empty_block_succeeds ... ok
test server::tests::commitment_mismatch_rejected ... ok
test server::tests::chain_tip_plus_two_rejected ... ok
test server::tests::validate_block_number_mismatch ... ok
test server::tests::chain_tip_minus_one_rejected ... ok
test server::tests::chain_tip_replacement_succeeds ... ok
test server::tests::replacement_commitment_mismatch_rejected ... ok

test result: ok. 11 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 0.02s

0.04user 0.01system 0:00.02elapsed 309%CPU (0avgtext+0avgdata 20320maxresident)k
0inputs+0outputs (0major+2322minor)pagefaults 0swaps

@kkovaacs kkovaacs enabled auto-merge (squash) May 28, 2026 19:27
@kkovaacs kkovaacs merged commit a8c98bd into next May 28, 2026
20 checks passed
@kkovaacs kkovaacs deleted the krisztian/use-smt-when-creating-genesis-block branch May 28, 2026 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no changelog This PR does not require an entry in the `CHANGELOG.md` file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants