feat(payment): settle merkle sub-batches in batched payForMerkleTrees groups - #179
Draft
Nic-dorman wants to merge 1 commit into
Draft
feat(payment): settle merkle sub-batches in batched payForMerkleTrees groups#179Nic-dorman wants to merge 1 commit into
Nic-dorman wants to merge 1 commit into
Conversation
… groups Wallet-path multi-batch uploads now pay MERKLE_TREES_PER_PAYMENT (4) trees per on-chain transaction instead of one transaction per tree, and the cap is re-exported as ant_core::data::MERKLE_TREES_PER_PAYMENT so consumers don't hardcode it. Partial-payment semantics keep their shape at group granularity: a failed group returns prior groups' proofs and pays nothing itself (the batched entry point is atomic). Carries a draft-only [patch.crates-io] pin on evmlib#15 and ant-protocol#26 until those release. Co-Authored-By: Claude Fable 5 <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.
Linear issue
V2-990 — https://linear.app/autonominetwork/issue/V2-990 (parent V2-949)
Risk tier
Client-side only: how many transactions carry the payments changes; the economics (per-tree
median16 × 2^depth), the proof format, and node verification (getCompletedMerklePaymentstate getter) are untouched. The protocol-level decision is ADR-0011 / evmlib#15 (T3, adversarially tested there).Compatibility
ant_core::data::MERKLE_TREES_PER_PAYMENTre-export (cap consumers should size batches from).pay_for_merkle_batch's signature and result types are unchanged; behavior changes only for >MAX_LEAVESuploads (grouped transactions, partial results at group granularity). Deployment coupling: the batched entry point exists only on the V2-992 vault redeployment — multi-batch wallet uploads against the current production vaults would revert (typed error, nothing paid), which is why this PR must not release before the vault lands (single-tree ≤256-chunk uploads stay on the legacy entry point and are unaffected). Local Anvil devnets deploy the new artifact and work today.Semver impact
Test evidence
cargo test --lib -p ant-core: 457/457 · clippy--all-targets --all-features -D warningsclean · fmt clean.test_merkle_payment_across_batch_boundary, extended): 35-node in-process testnet + Anvil (deploys the new vault artifact), paying 65 / 257 / 1025 addresses. 1025 partitions as five trees[256,256,256,255,2]→ settles as twopayForMerkleTreestransactions (4-tree group + singleton group). All proofs returned; settlements scale with padded leaves (128 / 258 / 1026 → 1.5 / 3.02 / 12.02 ANT-atto×10¹⁸, ratios within tolerance). 252 s locally, first attempt.New dependency
none (a draft-only
[patch.crates-io]pins evmlib → WithAutonomi/evmlib#15 and ant-protocol → WithAutonomi/ant-protocol#26; both drop at undraft when the releases land, andCargo.lockre-locks to the released versions).ADR
ADR-0011 (Proposed):
docs/adr/ADR-0011-batched-merkle-tree-payments.md— filed via WithAutonomi/ant-node#213.Mitigation / rollback
Rollback = revert; the legacy per-tree entry point stays in the contract and in evmlib forever. Release gating: hold until the V2-992 vault deployment + node-first rollout completes — releasing earlier breaks >1 GiB wallet-path uploads against production vaults (they'd revert typed, with nothing paid). Draft status + the patch pins enforce the hold mechanically.
🤖 Generated with Claude Code