Skip to content

Conversation

@doocho
Copy link
Contributor

@doocho doocho commented Jan 7, 2026

Summary

From/TryFrom implementations for Alloy EIP-7928 types now use Self::new()
to ensure writes are sorted by block_access_index.

Problem

BalWrites::get() relies on sorted data for correct binary/linear search.
However, Alloy types (Vec<BalanceChange>, etc.) do not guarantee ordering.
Using direct struct initialization (Self { writes: ... }) bypassed sorting,
potentially causing incorrect lookups.

Solution

Replace Self { writes: ... } with Self::new(...) which sorts the data.

Changes

  • alloy.rs: 4 conversions updated (BalanceChange, NonceChange, StorageChange, CodeChange)

…writes

Use Self::new() instead of direct struct initialization in From/TryFrom
implementations for Alloy types. This ensures writes are always sorted,
which is required for correct behavior of BalWrites::get() method.
@codspeed-hq
Copy link

codspeed-hq bot commented Jan 7, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing doocho:fix/bal-writes-sorting (a1fbd1e) with main (191e2e3)

Summary

✅ 173 untouched benchmarks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant