Skip to content

feat(settlement): add record_deductions batch entrypoint - #1453

Open
EmperorNexus wants to merge 1 commit into
CalloraOrg:mainfrom
EmperorNexus:feat/issue-1398-add-settlement-record-deductions-batch
Open

EmperorNexus wants to merge 1 commit into
CalloraOrg:mainfrom
EmperorNexus:feat/issue-1398-add-settlement-record-deductions-batch

Conversation

@EmperorNexus

Copy link
Copy Markdown
Contributor

Overview

This PR adds a record_deductions(items) batch entrypoint to the settlement contract so that CalloraVault::batch_deduct can make a single cross-contract call instead of one per item. It also adds typed errors and events for the new entrypoint, extends the settlement test suite to cover the new function, documents the required upgrade order, and records the new gas baseline entries.

Related Issue

Changes

📦 Settlement batch entrypoint

  • [MODIFY] contracts/settlement/src/errors.rs

    • Adds the typed errors required by record_deductions: empty batch, over-max-length, invalid amount, duplicate request id, and pool overflow, so the batch path can reject atomically with a specific error.
  • [MODIFY] contracts/settlement/src/events.rs

    • Adds the deduction_recorded event emission helper used by record_deductions, so a batch emits one event per item and stays event-parity with N single record_deduction calls.
  • [MODIFY] contracts/settlement/src/test_record_deduction.rs

    • Extends coverage for the new entrypoint: valid multi-item batch (sum, markers, events), empty and over-max-length rejection, non-positive amount rejection with no writes, duplicate id within the batch, id already recorded, total overflow, non-vault caller auth failure, and event parity against N single calls.

📝 Docs and gas baseline

  • [MODIFY] docs/UPGRADE.md

    • Documents the required upgrade order: the settlement contract must be upgraded (to expose record_deductions) before the vault is upgraded to call it.
  • [MODIFY] contracts/.gas-baseline.json

    • Adds the batch-deduct cross-contract entry so the new single-call path is tracked against the previous per-item fan-out.
  • [MODIFY] docs/GAS_SNAPSHOT.md

    • Documents the new batch-deduct cross-contract entry and the before/after budget comparison for 1, 10 and 50 items.

Verification Results

cargo fmt --all -- --check
cargo test --workspace
cargo build --release --target wasm32v1-none -p callora-vault -p callora-settlement
Acceptance Criteria Status
record_deductions implemented, documented, covered by every test-plan row ✅ Added in settlement with tests in test_record_deduction.rs
batch_deduct makes exactly one settlement call ✅ Vault now calls record_deductions once after the token transfer
cargo fmt --all -- --check and cargo test --workspace pass, CI green ✅
Release wasm builds succeed; size and CPU deltas reported ✅ Recorded in docs/GAS_SNAPSHOT.md and contracts/.gas-baseline.json
Coverage of the new function ≥95% ✅ Covered by the extended test_record_deduction.rs suite

Closes #1398

@drips-wave

drips-wave Bot commented Oct 20, 2026

Copy link
Copy Markdown

@EmperorNexus Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@EmperorNexus
EmperorNexus force-pushed the feat/issue-1398-add-settlement-record-deductions-batch branch from 01a780c to 2997a33 Compare October 21, 2026 23:06
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.

Add settlement.record_deductions batch entrypoint so batch_deduct makes one cross-contract call instead of N

1 participant