Skip to content

fix(batch-processor): implement real batched token transfers - #474

Open
johnbiliyaminu-bit wants to merge 1 commit into
conduit-protocol:mainfrom
johnbiliyaminu-bit:fix/batch-processor-real-transfers
Open

fix(batch-processor): implement real batched token transfers#474
johnbiliyaminu-bit wants to merge 1 commit into
conduit-protocol:mainfrom
johnbiliyaminu-bit:fix/batch-processor-real-transfers

Conversation

@johnbiliyaminu-bit

Copy link
Copy Markdown

Replace the arithmetic-only stub with a genuine batch transfer contract.

Previous implementation:

  • Took only Vec amounts, no addresses or token
  • Summed amounts with checked_add and returned the total
  • Contained dead state-version race-condition checks (always snapshot+1 under Soroban's single-transaction, non-reentrant model)
  • Contained dead re-entrancy guard (redundant given Soroban's execution model)
  • Emitted no transfers despite the contract name and BatchTooLarge error

New implementation:

  • Signature: process_batch(env, funder, token, recipients, amounts)
  • funder.require_auth() called before any token movement
  • Validates lengths match, batch <= 100, all amounts > 0
  • Accumulates total in one pass, pulls a single lump sum from funder, then fans out to each recipient individually
  • Error enum: LengthMismatch=1, BatchTooLarge=2, InvalidAmount=3, ArithmeticOverflow=4

Closes #248, #104, #246

What does this PR do?

Type of change

  • Bug fix
  • New feature
  • Refactor (no behaviour change)
  • Test coverage
  • Documentation
  • Security fix

Related issue

Closes #

Changes

File Change

Checklist

  • cargo fmt --all — no diff
  • cargo clippy --all-targets -- -D warnings — zero warnings
  • cargo test --all — all tests pass
  • New public functions have tests covering the happy path and each error variant
  • All arithmetic uses checked_* methods
  • require_auth() called before any state mutation in modified functions
  • State mutations happen before cross-contract calls (token transfers)
  • Events emitted for all external state changes
  • CHANGELOG.md updated under [Unreleased]
  • docs/architecture.md updated if design changed
  • ADR written if a significant design decision was made

Security notes

Testing notes

closes #361

Replace the arithmetic-only stub with a genuine batch transfer contract.

Previous implementation:
- Took only Vec<u64> amounts, no addresses or token
- Summed amounts with checked_add and returned the total
- Contained dead state-version race-condition checks (always snapshot+1
  under Soroban's single-transaction, non-reentrant model)
- Contained dead re-entrancy guard (redundant given Soroban's execution model)
- Emitted no transfers despite the contract name and BatchTooLarge error

New implementation:
- Signature: process_batch(env, funder, token, recipients, amounts)
- funder.require_auth() called before any token movement
- Validates lengths match, batch <= 100, all amounts > 0
- Accumulates total in one pass, pulls a single lump sum from funder,
  then fans out to each recipient individually
- Error enum: LengthMismatch=1, BatchTooLarge=2, InvalidAmount=3,
  ArithmeticOverflow=4

Closes conduit-protocol#248, conduit-protocol#104, conduit-protocol#246
@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@johnbiliyaminu-bit 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant