Skip to content

[executor] encode_calldata has no guard against exceeding Solidity MAX_BATCH_SIZE=10 #206

@obchain

Description

@obchain

PR: #45 (feat/20-multi-liq-batcher)
File: crates/charon-executor/src/batcher.rs, encode_calldata

Batcher::new(max_batch_size) accepts any value. plan() produces LiquidationBatch objects with up to max_batch_size opportunities. encode_calldata accepts any LiquidationBatch without asserting batch.opportunities.len() <= 10.

A caller using Batcher::new(15) will receive validly encoded calldata for a 15-item batch. That calldata will pass through TxBuilder and Simulator (which simulates the encoded call, not the batch size), get signed, and be broadcast. On-chain batchExecute will revert with 'batch too large', consuming the full estimated gas without executing any liquidation.

Impact: Predictable on-chain revert and gas waste for any max_batch_size > 10 configuration. The failure mode is invisible until broadcast.

Fix:

  1. Declare const SOLIDITY_MAX_BATCH_SIZE: usize = 10; in batcher.rs.
  2. At the top of encode_calldata, return Err(BatcherError::BatchTooLarge { len: batch.opportunities.len(), limit: SOLIDITY_MAX_BATCH_SIZE }) if the length exceeds the constant.
  3. Add a unit test that asserts this error for an over-limit batch.

Refs #45

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinglayer:rustRust crates (core / scanner / protocols / executor / cli)pr-reviewFindings from PR review processpriority:p1-coreCore MVP scopestatus:readyScoped and ready to pick up

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions