Repository navigation
fix: keep peg-in instances from stalling on lagging backends and missed messages - #542
Merged
Merged
Conversation
blake-pro
approved these changes
Nov 16, 2026
added 2 commits
November 16, 2026 07:12
eigmax
force-pushed
the
audit/19-instance-liveness
branch
from
November 16, 2026 07:50
8e0bb33 to
d12fe4c
Compare
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.
Audit items L16, L18, L19, L21, L23. Open against
dev.Answering with unsettled inputs (L19). A committee member answers a peg-in request once. Any input the Bitcoin backend did not know, or that a mempool transaction spent, made the request permanently invalid, and the member never answered. The input check now runs in the answer job: only a spend by a confirmed transaction rejects the request (the rule #516 uses for the scan). An unknown outpoint or a mempool spend retries the job every 30 seconds. Leaving
UserInitedcancels it.Underivable peg-in txids (L21). Entering
CommitteesAnswered, the node derives the Prepare, Confirm and Cancel txids from the answers. When that failed it only logged a warning: the instance stayed inCommitteesAnsweredwith no Prepare txid, was rescanned every block and never moved. The derivation only uses the stored row and the answers, so it cannot succeed later. The instance now goes toNoEnoughCommitteesAnsweredand raisespegin_txids_underivable. A request whose own fields cannot make the peg-in transactions (no inputs, inputs short of amount plus fees, fees pastMAX_MONEY) is now rejected before answering: the node builds them with a placeholder committee key, since the key does not change what can be built. What is left for the derivation to fail on is a bad answer (a pubkey off the curve or shared by two members, which the contract accepts). A member who sends one could block the peg-in just as well by not signing, since every member who answered must sign.T0 gate without a Prepare height (L23). When the scan had not stored the Prepare height yet, the signing gate was open, so a node with a lagging scan could sign after T0. The gate now looks up the Prepare on Bitcoin: confirmed, T0 counts from its block; not confirmed or not seen, the gate is open because T0 cannot have passed. With no Prepare txid at all the gate returns an error and the job retries instead of signing.
Partial signatures after the Confirm broadcast (L18). Entering
RelayerL1Broadcastedclosed every Confirm-phase delivery, including the member'sPeginConfirmPartialSig. That message carries the endorsementpostPeginDataneeds from every member, so a relayer that missed one could never post. Only thePeginConfirmNonceandPeginConfirmNonceConsensusrows close there now; the partial signature keeps being resent untilRelayerL2Mintedor a failure closes the phase.Parked instances in the scan (L16). Instances in
CommitteesAnsweredorTimeoutthat never move again shared the Bitcoin scan's page with the live ones. They now page separately (instance_btc_scan_parked), so each tick scans one page of live instances and one page of parked ones.Tests: the answer waits for an unknown or mempool-spent input and rejects a confirmed conflicting spend; answers that yield no txids fail the instance; a request with no inputs, short inputs or overflowing fees is not answered; the T0 gate without a stored height asks Bitcoin (no txid: error, unconfirmed: open, confirmed: closed past T0); the partial-signature delivery stays open after the Confirm broadcast; parked statuses are paged apart. Two instance tests now use answers that derive valid txids. Node tests, clippy with
-D warningsand fmt pass.The test coverage and validation notes above are from the zkm PR notes. Branch scope and diff formatting were checked locally; builds and tests were not rerun during publication.