core: settle multi-packet batch commitments on child settlement#155
Open
notJoon wants to merge 7 commits into
Open
core: settle multi-packet batch commitments on child settlement#155notJoon wants to merge 7 commits into
notJoon wants to merge 7 commits into
Conversation
Reject duplicate packet commitments in PacketSend and BatchSend before recordinf any new commitment state. This prevents relayed or repeated sends from overwritting existing commitment state and keeps failed batch sends from leaving partial commitment entries.
H-1 (retain settled packet commitments) marks the source commitment COMMITMENT_MAGIC_ACK on ack instead of deleting it, so HasPacketCommitment stays true after ack. Update the gnokey native-refund smoke assertion to match, alongside the filetest and doc updates already in this PR. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Follow-up to #154 (depends on it; base branch:
fix/issue-152). Closes a multi-packet batch commitment cleanup gap identified during review of #154.#154 makes settled packet commitments permanent via
COMMITMENT_MAGIC_ACK, but multi-packetBatchSendalso creates a parent batch commitment atBatchPacketsPath(CommitPackets(batch)). Child acknowledgements/timeouts settled only the child mirrors, allowing the parent batch commitment to remain atCOMMITMENT_MAGICeven after all children had settled. This PR keeps parent and child commitments in sync by settling the parent once all children are resolved.Changes
Core logic (
packet.gno,state.gno)packetBatches,batchChildren) populated duringBatchSend(single-packet sends remain untracked).markParentBatchAcknowledgedIfSettled, which marks the parent batch commitment asCOMMITMENT_MAGIC_ACKonce no child remains outstanding, then prunes tracking state.PacketAcknowledgementandPacketTimeout) so full-batch ack, per-child ack, and per-child timeout all converge to the same parent commitment state.BatchSendvalidation instead of recomputingCommitPacket.Tests (
core_test.gno)TestPacketAcknowledgementMarksBatchCommitmentTestPacketAcknowledgementMarksBatchAfterIndividualChildrenTestPacketTimeoutMarksMultiPacketBatchAfterAllChildrenNotes
No current production caller emits multi-packet batches (all existing
BatchSendcall sites send a single packet), so this is a defensive fix. It was intentionally kept separate from the security-critical changes in #154 to keep that PR focused.