[FEAT] Add postCommitmentsSafe — idempotent variant#64
Merged
Conversation
…y-posted handles Reverts on duplicates (CommitmentAlreadyExists) break callers like blockchain-poster whose batches can re-post the same handle (deterministic FHE outputs, RabbitMQ redeliveries). The Safe variant silently skips and emits CommitmentsPostedSafe(version, newlyPosted, skipped) so observability isn't lost. ZeroCommitHash, EmptyBatch, LengthMismatch, VersionNotActive, OnlyPosterAllowed still revert — those indicate caller bugs. Tracks PRO-300.
c70de08 to
73a38ab
Compare
Pairs with the genesis allocation + keystore in the parent repo. The previous default 0x3f1Eae… is the test wallet and races with Hardhat-driven txs for the same nonce sequence — see PRO-300 / PR-#676 deployment requirements.
liorbond
approved these changes
Apr 28, 2026
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
Adds
postCommitmentsSafetoCommitmentRegistry— an idempotent counterpart topostCommitmentsthat silently skips handles already committed under the given version, instead of reverting the entire batch withCommitmentAlreadyExists.postCommitments(strict) is unchanged; this is purely additive.Why
Callers like
blockchain-poster(CoFHE) batch many handles into one tx. The same handle can appear across batches because:Under
postCommitments, the first duplicate reverts the whole batch → nack-requeue → retry → revert again → eventually DLQ. Slim-listener's block tracker stalls. WithpostCommitmentsSafe, already-committed handles are skipped, the batch progresses, and the on-chain end state is identical.Tracks PRO-300.
What's reverted/preserved
postCommitmentsSafe:EmptyBatch,LengthMismatch,VersionNotActive,OnlyPosterAllowed— caller bugs / lifecycle violationsZeroCommitHash— indicates upstream bug producing invalid input(version, handle)in storageObservability
New event:
newlyPosted + skipped == handles.length. Lets dashboards distinguish "real" commitments from idempotent re-posts.Tests
13 new tests in
CommitmentRegistry.behavior.tscovering:skipped=0newlyPosted=0,skipped=NhandlesByVersiondoesn't double-count on re-postsAll 87 tests pass (
pnpm hardhat test).Test plan
postCommitmentsSafeFollow-up
Once merged + redeployed, the consuming PR in
cofhe(PR #676 —feat/blockchain-poster-event-completion) bumps the submodule SHA and switchesblockchain-poster/src/abi.rsto callpostCommitmentsSafe.