Repository navigation
Conversation
Collaborator
🟡 Heimdall Review Status
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
jackchuma
marked this pull request as ready for review
December 5, 2026 19:41
jackchuma
marked this pull request as draft
December 5, 2026 19:45
jackchuma
force-pushed
the
toshi/contracts-protocolversions-portal-invariants-2eb47af0
branch
from
December 6, 2026 02:19
8482767 to
b3ef497
Compare
Co-authored-by: Toshi <toshi-noreply@coinbase.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 changed? Why?
Adds a Foundry invariant suite for
ProtocolVersionsintest/invariants/ProtocolVersions.t.solcovering both the deploy-scriptProtocolVersionsproxy (ProtocolVersions_Invariant_Test) and an imported historical schedule with a static zero hole and active incident responder (ProtocolVersions_ImportedSchedule_Invariant_Test). Tests only; nosrc/files change.What the suite checks:
_validateWriteTransitionspecification against pre/post schedule state — append-only length, non-target entries untouched,MIN_NOTICEfloor, frozen-entry immutability (ts <= now + FREEZE_WINDOW), static-hole immutability below scheduled successors, strict increase ondelayTimestamp, and unauthorized callers never mutating state.FREEZE_WINDOW(ts <= now + FREEZE_WINDOW) never change, andscheduleId(i)/scheduleId()match a fresh from-seed recomputation across every upgrade id.activatedScheduleId(t)matches an independent forward-scan prefix recomputation and stays immutable fort < block.timestamp + min(FREEZE_WINDOW, MIN_NOTICE). Each upgrade's(ts - 1)andtsare pinned permanently once inside the immutable window alongside a 16-slot check-before-evict sliding window, verified on every write, on everywarp, and via latest-observation checks insideinvariant_protocolVersions(). Warps snap tots - FREEZE_WINDOW - 1,ts - FREEZE_WINDOW,ts - FREEZE_WINDOW + 1, andts.setMinimumProtocolVersionandregisterUpgrade'sminProtocolVersionparameter across0,1..uint128.max, and> uint128.max, assertingminimumProtocolVersion()stays in1..uint128.max, matches the model, and never mutatesscheduleIdoractivatedScheduleId.invariant_protocolVersions()tests pinfail-on-revert = trueacrossdefault,ci,ciheavy, andliteprofiles so any unintended panic inside the harness fails immediately rather than being discarded.Notes to reviewers
OptimismPortal2invariants now live in test(L1): add OptimismPortal2 invariant suite #467.ProtocolVersions_Invariant_Base._assertProtocolVersionsInvariants(),ProtocolVersions_Invariant_Harness._validateWriteTransition(), and_verifyAfterWrite(), then read the six mutating handlers.ProtocolVersions(seetest/L1/ProtocolVersions.t.sol).ProtocolVersions_ImportedSchedule_Invariant_Testseeds a historical schedule containing a static hole behind a proxy over the deploy-script implementation.git revertremoves the test file and leaves no state behind.FOUNDRY_PROFILE=ci).How has it been tested?
FOUNDRY_PROFILE=ci forge test --offline --match-path test/invariants/ProtocolVersions.t.sol(2 suites, 64 runs × 32 depth = 2048 calls each, 0 reverts): pass in 753ms.FOUNDRY_PROFILE=lite forge test --offline --match-path test/invariants/ProtocolVersions.t.sol(optimizer = false, 2 suites, 8 runs × 8 depth = 64 calls each, 0 reverts): pass in 139ms.forge test --offline --match-path test/invariants/ProtocolVersions.t.sol(2 suites, 64 runs × 500 depth = 32000 calls each, 0 reverts): pass in 15.03s.just lint-check(forge fmt --check): pass.go run ./scripts/checks/test-validation: pass.FOUNDRY_PROFILE=ci(all reverted before committing):minProtocolVersion > type(uint128).maxinregisterUpgrade: FAIL on both suites (registerUpgrade: oversized minProtocolVersion succeeded).protocolVersion == 0 || protocolVersion > type(uint128).maxinsetMinimumProtocolVersion: FAIL on both suites (setMinimumProtocolVersion: invalid version succeeded).activatedScheduleIddrift pastblock.timestamp > 100 days + 1 hours(warp-only): FAIL (activatedScheduleId: boundary changed).warp: FAIL (harness_panic), confirmingfail-on-revert = trueis enforced on the concrete test contracts.