Skip to content

fix: payment hardening -- pricing, panics, external signer#5

Open
grumbach wants to merge 4 commits intomainfrom
fix/payment-upload-hardening
Open

fix: payment hardening -- pricing, panics, external signer#5
grumbach wants to merge 4 commits intomainfrom
fix/payment-upload-hardening

Conversation

@grumbach
Copy link
Copy Markdown
Contributor

@grumbach grumbach commented Apr 2, 2026

Summary

  • Replace expect() panics with proper Result propagation in PoolCommitment::to_packed() and get_payment_packed_commitments()
  • Add calculate_price() to quoting_metrics.rs so client and node share the same deterministic pricing formula
  • Fix per-node pricing: when contract returns single aggregate price, compute individual prices locally instead of duplicating the same value to all nodes
  • Add merkle payment calldata generation for external signers (pay_for_merkle_tree_calldata())

Dependency note

ant-node and ant-client depend on evmlib 0.5.0 from crates.io. This PR needs a new evmlib release before the other two PRs can use it.

Related PRs

  • WithAutonomi/ant-node — fix/payment-upload-hardening
  • WithAutonomi/ant-client — fix/payment-upload-hardening

Test plan

  • cfd passes
  • 3-agent adversarial review (2 Claude Opus + 1 Codex gpt-5.4) — all issues fixed

grumbach added 4 commits April 2, 2026 15:36
Replace two .expect() calls that could panic in production:

- PoolCommitment::to_packed(): Vec-to-array conversion now uses
  .map_err(|_| CostUnitOverflow)? instead of .expect()
- get_payment_packed_commitments(): on-chain calldata decoding now
  returns Error::Rpc with candidate count details instead of .expect()

Both changes maintain identical behavior on the happy path while
preventing process crashes on malformed data.
…regate

- Add calculate_price() to quoting_metrics.rs (same formula as ant-node
  and the on-chain MerklePaymentVault contract)
- In get_market_price(): when contract returns 1 price for N nodes,
  compute individual prices from each node's QuotingMetrics locally
- Replace FIXME workaround in handler.rs with clean padding logic
- This ensures per-node fullness-based pricing works correctly
- Make pay_for_merkle_tree_calldata public in handler
- Add pay_for_merkle_tree_calldata() to external_signer.rs with
  MerklePaymentCalldataReturn type containing calldata, contract
  address, and approval details for external wallet signing
- Remove padding in get_quote handler that expanded single-price to
  N-prices, defeating the local per-node pricing fallback in mod.rs
- Replace inline paths with top-level use imports in external_signer.rs
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