-
Notifications
You must be signed in to change notification settings - Fork 171
feat(tests): Enforce EIP-7928 ordering rules #2138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
69b6c8b
to
81c22eb
Compare
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)
cddf6f9
to
4d695c0
Compare
- This becomes an issue when JSON-serializing the BAL object and then re-filling from the fixture. We should use `HexNumber` for any Number fields as this correctly serializes to JSON as hex representation.
4d695c0
to
303b9bf
Compare
The last commit here attempts to fix issues relate to Unrelated but maybe relevant, the current state of the tests on geth branch
^ This comment is mostly meant as a sanity check on the current state of the tests in case it helps to review with this context. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small comments for now! The validation functions look good to me. Will review the tests tmo :D
Sounds good, ty! I will address these today.
The tests here are mostly sanity checking unit tests (no actual BAL tests added here) to make sure things don't get moved around and break these expectations in the future. But yes it would be good to get a sanity check on the sanity check! 😄 edit: Suggestions applied in latest commit 🙏🏼 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks :)
🗒️ 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:
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
withaddress: 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 unordereddict
in the expectation test class. This is especially "nice" because utilities likepre.deploy_contract()
andpre.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 anOrderedDict
, 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
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
type(scope):
.