Skip to content

Conversation

fselmo
Copy link
Collaborator

@fselmo fselmo commented Sep 11, 2025

🗒️ Description

To be clear, the current tests are not broken because the spec is implemented correctly. However, we were not enforcing certain validation rules that are required by EIP-7928. These changes introduce an initial up-front check on the entire order of the BAL coming from t8n as defined in EIP-7928:

Ordering and Determinism

The following ordering rules MUST apply:

- Addresses: lexicographic (bytewise).
- Storage keys: lexicographic within each account.
- Block access indices: ascending within each change list.

BlockAccessList (t8n model)

We fully validate all ordering upfront, based on the above rules, for the entire BAL coming from t8n. This is crucial that it meets all the requirements for the EIP implementation.

BlockAccessListExpectation (test expectation definition class)

Address Ordering

We define the expectation as a dict with address: BalAccountChanges. We don't need to check that our ordering is correct here because we will validate that the BAL coming from t8n is already in the correct order. So if the addresses we define are present at all, they will be in the correct order already, and we are free to define this as an unordered dict in the expectation test class. This is especially "nice" because utilities like pre.deploy_contract() and pre.fund_eoa() will generate addresses for us and it would be very difficult to put the burden on the test writer to place these within an OrderedDict, for example.

Transaction Index and Slot Ordering

We DO validate that the transaction indexes and slots appear in the correct order, but only as a sub-sequence of the full list - there’s no need to define every element. Since these are defined within a Python list, we do impose on the test writer that the sub-sequence they define here should be in order to maintain readability and reduce confusion for a reader of the test. I don't think this is too much to ask nor too big of a burden to place.

✅ Checklist

  • All: Ran fast tox checks to avoid unnecessary CI fails, see also Code Standards and Enabling Pre-commit Checks:
    uvx --with=tox-uv tox -e lint,typecheck,spellcheck,markdownlint
  • All: PR title adheres to the repo standard - it will be used as the squash commit message and should start type(scope):.
  • All: Considered adding an entry to CHANGELOG.md.
  • All: Considered updating the online docs in the ./docs/ directory.
  • All: Set appropriate labels for the changes (only maintainers can apply labels).

@fselmo fselmo force-pushed the fix/bal-address-order-check branch from 49ea239 to 5b5c45b Compare September 11, 2025 21:37
The specs are currently correctly written, but we were not validating
all of the ordering according to EIP-7928:
  - Addresses: lexicographic (bytewise).
  - Storage keys: lexicographic within each account.
  - Block access indices: ascending within each change list.

This change validates the order of the BAL before we even begin to
compare against our expectation. We also now validate that the
expectations we define are subsequences within the BAL (expected order).

- refactor: Explicit check for the fields we care about up front for `model_fields_set`

- refactor: awkward comparison method should just be a validation method (_validate_change_lists)
@fselmo fselmo force-pushed the fix/bal-address-order-check branch from 69b6c8b to 81c22eb Compare September 11, 2025 21:53
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