Skip to content

feat: merkle batch payment support for large uploads - #2

Merged
Nic-dorman merged 3 commits into
masterfrom
feat-merkle-external-signer
Apr 6, 2026
Merged

feat: merkle batch payment support for large uploads#2
Nic-dorman merged 3 commits into
masterfrom
feat-merkle-external-signer

Conversation

@Nic-dorman

Copy link
Copy Markdown
Contributor

Summary

  • Adds automatic merkle batch payment handling for uploads >= 64 chunks
  • The antd daemon auto-selects payment_type: "merkle" for large files — Indelible reads this and uses the gas-efficient payForMerkleTree() contract call
  • No user-facing config needed — switching is fully transparent

Changes

  • internal/evm/abi.gopayForMerkleTree ABI + MerklePaymentMade event + MerklePoolCommitment/MerkleCandidateNode structs
  • internal/evm/signer.goPayForMerkleTree() method: converts SDK types to ABI structs, ensures token allowance, submits tx, parses winnerPoolHash from event logs. Refactored sendTxWithReceipt() shared by both payment methods
  • internal/worker/upload.go — Branches on PaymentType: merkle uses PayForMerkleTree + FinalizeMerkleUpload, wave_batch uses existing PayForQuotes + FinalizeUpload. Gas fee check skipped for merkle (cost determined on-chain). Transaction logging unified

Depends on

Test plan

  • go build ./... — compiles clean
  • go test ./... — all existing tests pass
  • E2E: upload large file (>= 64 chunks) on devnet → verify merkle payment flow
  • E2E: upload small file (< 64 chunks) → verify wave_batch unchanged

🤖 Generated with Claude Code

Nic-dorman and others added 3 commits April 2, 2026 19:36
Drop UNIQUE(upload_id, tag_key) constraint to support multi-value tags
(e.g. multiple authors, multiple categories per document). Change tag
type from map[string]string to map[string][]string throughout services,
handlers, webhooks, and tests. Upload endpoint accepts both legacy
single-value {"key":"val"} and new {"key":["v1","v2"]} JSON formats.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Each Open(sqlite://:memory:) now creates a uniquely-named shared-cache
DB (file:memdbN?mode=memory&cache=shared). This ensures all connections
from the same pool see the same database (fixing 401s from webhook
goroutines hitting empty DBs), while separate test cases each get
their own isolated instance.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds automatic merkle batch payment handling for uploads with >= 64
chunks. The antd daemon now returns payment_type "merkle" for large
files, and Indelible branches on this to use the gas-efficient
payForMerkleTree() contract call instead of per-quote payForQuotes().

Changes:
- internal/evm/abi.go: payForMerkleTree ABI, MerklePaymentMade event,
  MerklePoolCommitment and MerkleCandidateNode structs
- internal/evm/signer.go: PayForMerkleTree() method with event parsing
  to extract winner_pool_hash, refactored sendTxWithReceipt()
- internal/worker/upload.go: Branch on PreparedUpload.PaymentType,
  skip gas fee check for merkle (cost determined on-chain),
  unified transaction logging for both payment types

The switching is fully automatic — antd decides based on chunk count
and Indelible follows the payment_type in the prepare response.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Nic-dorman
Nic-dorman merged commit 6b610d9 into master Apr 6, 2026
@Nic-dorman
Nic-dorman deleted the feat-merkle-external-signer branch April 9, 2026 16:17
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