Skip to content

feat(payment): settle merkle sub-batches in batched payForMerkleTrees groups - #179

Draft
Nic-dorman wants to merge 1 commit into
mainfrom
feat/batched-merkle-wallet-path
Draft

feat(payment): settle merkle sub-batches in batched payForMerkleTrees groups#179
Nic-dorman wants to merge 1 commit into
mainfrom
feat/batched-merkle-wallet-path

Conversation

@Nic-dorman

Copy link
Copy Markdown
Member

Linear issue

V2-990 — https://linear.app/autonominetwork/issue/V2-990 (parent V2-949)

Risk tier

  • T0 — docs / tooling / CI / pure UX-output. Repo CI only.
  • T1 — client-only, no network-facing behavior change. CI + prod compat smoke.
  • T2 — node/client logic with behavioral surface, no protocol/format/economics change. Dev testnet + ADR.
  • T3 — protocol / storage format / payments / routing. T2 evidence + adversarial testing.

Client-side only: how many transactions carry the payments changes; the economics (per-tree median16 × 2^depth), the proof format, and node verification (getCompletedMerklePayment state getter) are untouched. The protocol-level decision is ADR-0011 / evmlib#15 (T3, adversarially tested there).

Compatibility

  • Wire: none (nodes are payment-tx-agnostic; per-chunk proofs unchanged)
  • Storage: none
  • API: additive — ant_core::data::MERKLE_TREES_PER_PAYMENT re-export (cap consumers should size batches from). pay_for_merkle_batch's signature and result types are unchanged; behavior changes only for >MAX_LEAVES uploads (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

  • breaking
  • feature
  • fix

Test evidence

  • cargo test --lib -p ant-core: 457/457 · clippy --all-targets --all-features -D warnings clean · fmt clean.
  • Live settlement e2e (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 two payForMerkleTrees transactions (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.
  • Not covered here (deliberate): old-vault fallback probing on the wallet path — release ordering is controlled by the V2-992 rollout instead (see Mitigation); ant-ui's external-signer path gets the runtime probe (V2-991).

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, and Cargo.lock re-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

… 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant