feat: centralize verifier state in ZoneFactory for O(1) hard fork upgrades#354
Open
feat: centralize verifier state in ZoneFactory for O(1) hard fork upgrades#354
Conversation
…rades Move verifier, forkVerifier, forkActivationBlock, and protocolVersion from per-portal storage to ZoneFactory. Hard fork upgrades now require a single setForkVerifier() call instead of iterating over all portals. - Add verifier lifecycle functions to IZoneFactory (verifier, forkVerifier, forkActivationBlock, protocolVersion, setForkVerifier, validateVerifier) - Remove verifier from ZoneInfo, CreateZoneParams, and ZoneCreated event - Replace portal.verifier with portal.zoneFactory; submitBatch now takes targetVerifier as first parameter and validates via factory - Update all Solidity tests for new signatures - Update overview.md and upgrades.md documentation Made-with: Cursor
…Factory Remove verifier field from CreateZoneParams, ZoneCreated event, and ZoneInfo struct. Add targetVerifier parameter to submitBatch. Add new factory functions (forkVerifier, forkActivationBlock, protocolVersion, setForkVerifier, validateVerifier). Update BatchSubmitter to accept and pass targetVerifier, read from ZoneFactory at startup. Change ZonePortal.verifier() to zoneFactory() in ABI. Co-authored-by: dankrad <[email protected]> Amp-Thread-ID: https://ampcode.com/threads/T-019d4f0a-d15e-751d-9f0f-f84e3c00eee9
Co-Authored-By: dankrad <[email protected]> Amp-Thread-ID: https://ampcode.com/threads/T-019d4f0a-d15e-751d-9f0f-f84e3c00eee9
Resolve conflicts:
- docs/pages/protocol/privacy/{overview,upgrades}.md: accept deletion
(docs site removed on main in #366)
- crates/tempo-zone/src/zonemonitor.rs: combine ZoneFactory import from
this branch with log_query_ranges from main
- docs/specs/src/zone/IZone.sol: keep natspec docs added on main while
preserving this branch's removal of verifier from CreateZoneParams
Made-with: Cursor
Reflect the PR's move of verifier state from per-portal storage to ZoneFactory in the spec: - Remove verifier from Zone Deployment parameters, ZoneInfo, CreateZoneParams, and ZoneCreated event. - Add targetVerifier as the first parameter of submitBatch (both prose and IZonePortal interface), and document that the portal calls ZoneFactory.validateVerifier before invoking IVerifier.verify. - Extend IZoneFactory with isZoneMessenger, isValidVerifier, verifier, forkVerifier, forkActivationBlock, protocolVersion, setForkVerifier, and validateVerifier. - Replace IZonePortal.verifier() with zoneFactory(). - Rewrite the Network Upgrades section to describe the centralized (O(1)) rotation: forkVerifier/forkActivationBlock/protocolVersion now live on the factory, setForkVerifier rotates all portals in a single call, and portal routing via validateVerifier enforces the two-verifier invariant with UnknownVerifier / UseForkVerifier errors. Made-with: Cursor
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.
Summary
verifier,forkVerifier,forkActivationBlock, andprotocolVersionfrom per-portal storage toZoneFactory, making hard fork upgrades O(1) instead of O(n) where n is the number of zones.submitBatchnow takestargetVerifieras its first parameter; portals validate viaZoneFactory.validateVerifier()instead of storing verifier state locally.setForkVerifier()on the factory handles verifier rotation andprotocolVersionincrement in a single call — no per-portal iteration needed.Changes
Solidity spec (
docs/specs/src/zone/)IZone.sol: Addverifier(),forkVerifier(),forkActivationBlock(),protocolVersion(),setForkVerifier(),validateVerifier()toIZoneFactory. RemoveverifierfromZoneInfo,CreateZoneParams,ZoneCreated. AddtargetVerifiertosubmitBatch. Replaceverifier()withzoneFactory()onIZonePortal.ZoneFactory.sol: Add centralized verifier state,setForkVerifier(), andvalidateVerifier().ZonePortal.sol: Replaceimmutable verifierwithimmutable zoneFactory.submitBatchvalidates via factory and passestargetVerifiertoIVerifier.verify().Tests (
docs/specs/test/zone/)submitBatchsignature and removedverifierfromCreateZoneParams.Documentation (
docs/pages/protocol/privacy/)overview.md: Updated interfaces, verifier routing, and two-verifier invariant sections.upgrades.md: Updated fork block execution and verifier lifecycle to reflect centralized factory state.Test plan
forge test --match-path test/zone/ZonePortal.t.sol— 76 passedforge test --match-path test/zone/ZoneFactory.t.sol— 11 passedforge test --match-path test/zone/ZoneIntegration.t.sol— 7 passedforge test --match-path test/zone/ZoneBridge.t.sol— 15 passedforge test --match-path test/zone/ZoneInbox.t.sol— 26 passedforge test --match-path test/zone/SwapAndDepositRouter.t.sol— 8 passedforge fmtpassesMade with Cursor