Skip to content

core: settle multi-packet batch commitments on child settlement#155

Open
notJoon wants to merge 7 commits into
mainfrom
core/settle-batch-commitments
Open

core: settle multi-packet batch commitments on child settlement#155
notJoon wants to merge 7 commits into
mainfrom
core/settle-batch-commitments

Conversation

@notJoon

@notJoon notJoon commented Jun 12, 2026

Copy link
Copy Markdown
Member

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-packet BatchSend also creates a parent batch commitment at BatchPacketsPath(CommitPackets(batch)). Child acknowledgements/timeouts settled only the child mirrors, allowing the parent batch commitment to remain at COMMITMENT_MAGIC even 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)

  • Track parent/child relationships for multi-packet batches via two in-memory maps (packetBatches, batchChildren) populated during BatchSend (single-packet sends remain untracked).
  • Add markParentBatchAcknowledgedIfSettled, which marks the parent batch commitment as COMMITMENT_MAGIC_ACK once no child remains outstanding, then prunes tracking state.
  • Invoke the helper from both settlement paths (PacketAcknowledgement and PacketTimeout) so full-batch ack, per-child ack, and per-child timeout all converge to the same parent commitment state.
  • Reuse per-packet hashes computed during BatchSend validation instead of recomputing CommitPacket.

Tests (core_test.gno)

  • TestPacketAcknowledgementMarksBatchCommitment
  • TestPacketAcknowledgementMarksBatchAfterIndividualChildren
  • TestPacketTimeoutMarksMultiPacketBatchAfterAllChildren

Notes

No current production caller emits multi-packet batches (all existing BatchSend call 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.

notJoon added 3 commits June 12, 2026 11:34
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.
@github-actions github-actions Bot added the A-ibc IBC core, light client, packet/channel/connection label Jun 12, 2026
notJoon and others added 2 commits June 12, 2026 12:26
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>
@notJoon notJoon added this to the deploy rc1 milestone Jun 12, 2026
@github-actions github-actions Bot added the A-doc Documentation: README, specs, godoc label Jun 12, 2026
Base automatically changed from fix/issue-152 to main June 12, 2026 09:34
@github-actions github-actions Bot added the A-zkgm ZKGM realm, opcodes, forward, integration label Jun 12, 2026
@github-actions github-actions Bot removed the A-zkgm ZKGM realm, opcodes, forward, integration label Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-doc Documentation: README, specs, godoc A-ibc IBC core, light client, packet/channel/connection

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant