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:
- Declare
const SOLIDITY_MAX_BATCH_SIZE: usize = 10; in batcher.rs.
- 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.
- Add a unit test that asserts this error for an over-limit batch.
Refs #45
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()producesLiquidationBatchobjects with up tomax_batch_sizeopportunities.encode_calldataaccepts anyLiquidationBatchwithout assertingbatch.opportunities.len() <= 10.A caller using
Batcher::new(15)will receive validly encoded calldata for a 15-item batch. That calldata will pass throughTxBuilderandSimulator(which simulates the encoded call, not the batch size), get signed, and be broadcast. On-chainbatchExecutewill 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 > 10configuration. The failure mode is invisible until broadcast.Fix:
const SOLIDITY_MAX_BATCH_SIZE: usize = 10;in batcher.rs.encode_calldata, returnErr(BatcherError::BatchTooLarge { len: batch.opportunities.len(), limit: SOLIDITY_MAX_BATCH_SIZE })if the length exceeds the constant.Refs #45