fix(multiproof): batch at HashedPostState level instead of EvmState
3c60275
14 hours ago
by yongkangc
+0.2%
chore: remove outdated comment
e2864b3
12 hours ago
by yongkangc
+0.05%
perf(multiproof): optimize state update batching
- Remove state.clone() by accepting &EvmState in evm_state_to_hashed_post_state
- Call update_with_state once on merged state instead of per sub-update
(MultiAddedRemovedKeys only cares about final values, not intermediates)
e8fadf3
11 hours ago
by yongkangc
-0.08%
perf(multiproof): defer hashing with SealedStateUpdate
Introduce SealedStateUpdate to capture is_changed semantics at seal time
while deferring expensive keccak256 hashing until after batching.
Key changes:
- SealedStateUpdate stores unhashed addresses/slots (20-byte keys)
- seal() captures is_changed filter per-TX (cheap, no hashing)
- extend() merges sealed updates safely (no flags to corrupt)
- into_hashed_post_state() hashes once after batch merge
Performance: For 10 TXs touching same address with 50 slots:
- Before: 510 hashes on EVM thread (per-TX hashing)
- After: 51 hashes on multiproof thread (once per batch)
3dacccf
10 hours ago
by yongkangc
+0.13%
chore(multiproof): remove local benchmark test
Remove bench_clone_vs_hash_conversion_small_updates test that was
used for local performance sanity checks during development.
115be9c
10 hours ago
by yongkangc
-0.24%
test(multiproof): add unit tests for SealedStateUpdate
Add comprehensive unit tests covering:
- extend() with selfdestruct scenarios
- extend() with selfdestruct-then-recreate
- extend() storage last-writer-wins semantics
- into_hashed_post_state() key hashing
- into_hashed_post_state() with wiped accounts
- into_hashed_post_state() wiped accounts with new storage
- estimate_targets() calculation
- seal() filtering of touched accounts and changed storage
- seal() handling of selfdestructed accounts
Also marks evm_state_to_hashed_post_state as #[cfg(test)] since it's
only used in tests, and fixes doc comment formatting.
0a92dc3
10 hours ago
by yongkangc
+0.03%
chore: clarify state sealing comment
3a12525
7 hours ago
by yongkangc
+0.13%
refactor(multiproof): replace SealedStateUpdate with merge_evm_state
This simplifies the batching fix by using a custom merge function instead
of a separate sealed type.
The core issue: EvmState::extend overwrites storage slots including their
original_value, breaking is_changed() semantics. The previous fix (SealedStateUpdate)
captured is_changed at seal time and deferred hashing.
The new approach is simpler: merge_evm_state() merges EvmState updates while
preserving original_value from the base state. This ensures is_changed()
returns correct results after batching, without needing a separate type.
Changes:
- Remove SealedStateUpdate struct and its seal/extend/into_hashed_post_state methods
- Add merge_evm_state() that preserves base.original_value when merging slots
- Add estimate_evm_state_targets() for batching decisions
- Update MultiProofMessage::StateUpdate to use EvmState directly
- Update state_hook to clone EvmState instead of sealing
- Update tests to use EvmState and merge_evm_state