refactor(contracts): EVM accessor pattern — compile-time test-override generator (BBND-1672)#1222
Open
MiguelLZPF wants to merge 4 commits into
Open
refactor(contracts): EVM accessor pattern — compile-time test-override generator (BBND-1672)#1222MiguelLZPF wants to merge 4 commits into
MiguelLZPF wants to merge 4 commits into
Conversation
205efcf to
9c87a33
Compare
Add a declarative manifest plus generator that emits EvmAccessors.sol in two variants: production native-opcode getters (zero override machinery) and a test variant backed by ERC-7201 override storage with per-accessor readers and writers, selected by Configuration.isTestMode. The generated library is gitignored and prettier-ignored, regenerated before solc on every compile. A static-checks CI gate (ats:contracts:accessors:check:prod) compiles in prod mode and asserts the production artifact carries no override storage, assembly, reader or writer. Removes the obsolete naming utility. Signed-off-by: Miguel_LZPF <miguel.carpena@io.builders>
…nd wrappers (BBND-1672) Migrate every block.timestamp, block.number, msg.sender and block.chainid read from the TimeTravelStorageWrapper runtime pattern to the compile-time EvmAccessors library. Delete the entire testTimeTravel tree, the dead ContextProvider, and the hand-written EvmAccessors.sol. Add the test-only EvmAccessorsFacet writer (changeSystemTimestamp / Blocknumber / ChainId / Sender) and restore MockFactory to mark the facet ready post-deploy. Every facet sender read now routes through EvmAccessors.getMsgSender(). Signed-off-by: Miguel_LZPF <miguel.carpena@io.builders>
…nvironment (BBND-1672) Replace the TimeTravel-variant branching in the deployment and registry tooling with a single isTestMode-driven facet list built by facetEnvironment. Drop the useTimeTravel parameter from every createConfiguration entry point and update the registry generator, scanner, CLI, and workflow scripts. Signed-off-by: Miguel_LZPF <miguel.carpena@io.builders>
…t (BBND-1672) Add unit coverage for the generator (with drift-guard snapshots), the isTestMode config helper and buildFacetList, plus integration coverage for EvmAccessorsFacet: timestamp/blocknumber/chainid/sender override change, reset and zero-guards, override coexistence, and override-observed-by-a-real- facet guards (Lock release gate for timestamp, AccessControl resolution for sender). Refresh fixtures and developer guides, and add the release changeset. Signed-off-by: Miguel_LZPF <miguel.carpena@io.builders>
9c87a33 to
1439268
Compare
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.
Description
Replaces the runtime
TimeTravelstorage-wrapper time-control pattern with a compile-time, manifest-drivenEvmAccessorsgenerator.Production mode — native-opcode getters (
block.timestamp,block.number) with zero test machinery compiled in.Test mode — slot-fallback getters plus override writers exposed via a test-only
EvmAccessorsFacet, injected into the diamond at deploy time.Key integration points:
buildFacetListnow sourcesisTestMode()(from the mergedfacetEnvironment— PR refactor: facetEnvironment to control facets in tests/productions env… #1210) and conditionally appendsEvmAccessorsFacet.useTimeTravelparameter is removed from allcreate*Configurationsignatures and every deploy workflow / CLI entry point. This is a breaking deploy-script API change, fully documented in the changeset.Jira: BBND-1672
How it works
One source API —
EvmAccessors.getX()— compiled into two different bodies chosen at compile time byisTestMode(). Production gets the bare opcode (zero overhead); tests get an override slot with a sentinel fallback, driven by a test-only facet.Example — time-travel with no real time passing (the
P1.1guard test):Why it beats the old pattern:
TimeTravelStorageWrapperbaked anSLOAD + branchinto every native read in both prod and test — production paid a tax for a tests-only feature. Moving the decision to compile time gives prod the bare opcode (smaller bytecode, no override slot to attack) from a single manifest line.Type of change
Testing
Full contract suite run locally against Hardhat:
npm run ats:contracts:build— green (TypeChain + registry regenerated)npm run ats:contracts:format— green (no drift)npm run ats:contracts:lint— green (no new warnings)npm run ats:contracts:test— 3701 passing, 5 pending, 0 failingTest Results (if any)
3701 passing · 5 pending · 0 failing
Node version:
Checklist