Skip to content

feat: centralize verifier state in ZoneFactory for O(1) hard fork upgrades#354

Open
dankrad wants to merge 5 commits intomainfrom
feat/centralize-verifier-state
Open

feat: centralize verifier state in ZoneFactory for O(1) hard fork upgrades#354
dankrad wants to merge 5 commits intomainfrom
feat/centralize-verifier-state

Conversation

@dankrad
Copy link
Copy Markdown
Collaborator

@dankrad dankrad commented Apr 1, 2026

Summary

  • Moves verifier, forkVerifier, forkActivationBlock, and protocolVersion from per-portal storage to ZoneFactory, making hard fork upgrades O(1) instead of O(n) where n is the number of zones.
  • submitBatch now takes targetVerifier as its first parameter; portals validate via ZoneFactory.validateVerifier() instead of storing verifier state locally.
  • setForkVerifier() on the factory handles verifier rotation and protocolVersion increment in a single call — no per-portal iteration needed.

Changes

Solidity spec (docs/specs/src/zone/)

  • IZone.sol: Add verifier(), forkVerifier(), forkActivationBlock(), protocolVersion(), setForkVerifier(), validateVerifier() to IZoneFactory. Remove verifier from ZoneInfo, CreateZoneParams, ZoneCreated. Add targetVerifier to submitBatch. Replace verifier() with zoneFactory() on IZonePortal.
  • ZoneFactory.sol: Add centralized verifier state, setForkVerifier(), and validateVerifier().
  • ZonePortal.sol: Replace immutable verifier with immutable zoneFactory. submitBatch validates via factory and passes targetVerifier to IVerifier.verify().

Tests (docs/specs/test/zone/)

  • All test files updated for new submitBatch signature and removed verifier from CreateZoneParams.

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 passed
  • forge test --match-path test/zone/ZoneFactory.t.sol — 11 passed
  • forge test --match-path test/zone/ZoneIntegration.t.sol — 7 passed
  • forge test --match-path test/zone/ZoneBridge.t.sol — 15 passed
  • forge test --match-path test/zone/ZoneInbox.t.sol — 26 passed
  • forge test --match-path test/zone/SwapAndDepositRouter.t.sol — 8 passed
  • forge fmt passes
  • Rust tests expected to need ABI regeneration (not in scope for this PR)

Made with Cursor

…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
decofe and others added 4 commits April 2, 2026 17:04
…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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants