Validate known packed storage addresses#1452
Open
mds1 wants to merge 10 commits into
Open
Conversation
f957098 to
c74c3ed
Compare
Inline `Utils.contains(newContracts, account)` and reassign `value` in place instead of introducing `isNewContract`/`valueToCheck`, so the code/EOA validation lines stay unchanged from main. Shorten the packed-slot helpers to `_getPackedStorageAddr`/`_extractPackedAddr`, rewrite the `_getPackedStorageAddr` doc comment in plain terms, and explain why the `getChains()` try/catch is needed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Rename `_registerGlobalStorageAccount` to `_registerSentinelStorageAccount` to match the registry's vocabulary, and read the sentinel chain from the registry instead of re-hardcoding its keccak. DRY the two registration helpers through a shared `_registerStorageAccountOnChain`, drop the single-use 5-arg `createAccess` overload in favor of the existing mutate-after-build pattern, and document the storage-write and `_packAddress` helpers. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
767ec43 to
48c94ba
Compare
- Add NatSpec to `_isRegistryAddress` describing the sentinel-then-per-chain lookup and the SimpleAddressRegistry fallback. - Comment the test flag constants tying `0x0101`/spacer/`1 << 160` to the real Bedrock Initializable layout. - Explain why the "not treated as packed" test uses `type(uint256).max` to distinguish the full-word and packed paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
PR #1450 added
storageCodeExceptionsto silence false positives when a storage write contains a packed address. That worked, but it did so by skipping validation entirely for an(account, slot)pair — which also skips checking the address packed into that slot. This PR replaces that escape hatch with a check that actually validates the packed address.Why
Some L1 upgradeable contracts pack an address alongside smaller fields in the same 32-byte slot (e.g.
SystemConfigslot 108 packssuperchainConfigwithminBaseFee). The state-diff check reads the full 32-byte word, so the packed value is too large to look like an address and the embedded address slips past the normal code/EOA validation. We still want that address checked, not skipped.How
storageCodeExceptionsescape hatch.SystemConfigProxy), so an unrelated contract that happens to write the same slot number is left alone.Slots covered:
AnchorStateRegistryProxy/EthLockboxProxy/SuperchainConfigat slot 0,OptimismPortalProxy.superchainConfigat slot 53,OptimismPortalProxy.ethLockboxat slot 63, andSystemConfigProxy.superchainConfigat slot 108.