[FEAT] CommitmentRegistry: scope by (chainId, version)#68
Draft
roeezolantz wants to merge 1 commit intomasterfrom
Draft
[FEAT] CommitmentRegistry: scope by (chainId, version)#68roeezolantz wants to merge 1 commit intomasterfrom
roeezolantz wants to merge 1 commit intomasterfrom
Conversation
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
Stores FHE computation commitments by
(chainId, version, handle)instead of(version, handle). Same handle bytes posted from different source chains are now independent commitments — eliminates cross-chain shadowing/collision when TN later looks up commitment integrity.versionStatusis also now per(chainId, version). Chains have independent crypto-material lifecycles; one chain rotating keys says nothing about another. Multiple Active versions per chain are allowed (rotation overlap window).This is a fresh deploy of the v2 contract, not an upgrade of the existing one. The old contract's data was disposable and is left in place as orphaned storage.
API changes (breaking)
postCommitments(uint64 chainId, bytes32 version, bytes32[] handles, bytes32[] commitHashes)— chainId is now first, uint64.postCommitmentsSafe(...)— same shape.setVersionStatus(uint64 chainId, bytes32 version, VersionStatus newStatus)— per-chain lifecycle.chainIdas first arg:getCommitment,getSize,getHandleByIndex,getHandles,getVersionStatus.Events
CommitmentsPosted(uint64 indexed chainId, bytes32 indexed version, uint256 batchSize)CommitmentsPostedSafe(uint64 indexed chainId, bytes32 indexed version, uint256 newlyPosted, uint256 skipped)CommitmentMismatchSkipped(uint64 indexed chainId, bytes32 indexed version, bytes32 indexed handle, bytes32 stored, bytes32 attempted)— new; surfaces silent commitment drift inpostCommitmentsSafewhen a re-post has a different commitHash than what was stored. Strictly-equal redeliveries stay silent.VersionStatusChanged(uint64 indexed chainId, bytes32 indexed version, VersionStatus oldStatus, VersionStatus newStatus)Errors
InvalidChainId—chainId == 0rejected at every entry point as defense-in-depth.VersionNotActive(uint64 chainId, bytes32 version),CommitmentAlreadyExists(uint64 chainId, bytes32 version, bytes32 handle),InvalidVersionTransition(uint64, bytes32, …)gain chainId.Deploy script
scripts/deploy.tsnow takes aCHAIN_IDSenv var (comma-separated) and pre-activatesINITIAL_VERSION(0x…02 to match fhe-engine's bumpedCOMMITMENT_VERSION) on each chain. Default for local devnet is412346.Tests
CommitmentRegistry.behavior.ts— 99 tests passing. Net additions over the v1 suite:getSize/getHandlesdon't leak;chainId == 0rejected; chain B duplicate doesn't revert chain A's prior commitment).chainId == 0rejection at each entry point (postCommitments,postCommitmentsSafe,setVersionStatus).CommitmentMismatchSkipped(emit on disagreement; stay silent on identical redelivery).Gas costs unchanged from v1: ~47K per commitment at scale.
Test plan
pnpm compilecleanpnpm test— 99 passingnpx hardhat run scripts/estimateGasArbitrum.ts --network arbitrumSepolia(cosmetic — gas changed from v1 by <1%)Companion PR
This is paired with the outer-repo PR that bumps the submodule pointer + updates the blockchain-poster + fhe-engine. That PR depends on this one landing first.