Skip to content

[executor] selector test is self-referential — no canonical keccak256 pin for batchExecute #210

@obchain

Description

@obchain

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

The selector test asserts:

assert_eq!(
    &bytes[..4],
    &ICharonBatch::batchExecuteCall::SELECTOR,
    "calldata selector drifted from batchExecute"
);

Both the left side (computed by encoding via ICharonBatch) and the right side (the constant from the same sol! block) come from the same alloy::sol! declaration. The test verifies internal consistency within Rust only. If the Solidity batchExecute function signature changes on-chain but the Rust sol! macro is not updated in lockstep, the test continues to pass while the deployed selector diverges.

Impact: The selector pin provides false assurance. The only way to detect Rust-vs-Solidity ABI drift using this test is if a human manually updates the sol! block — the test does not catch the case where neither side is updated after an on-chain change.

Fix: Add a hardcoded expected-selector constant:

const BATCH_EXECUTE_SELECTOR: [u8; 4] = [0xXX, 0xXX, 0xXX, 0xXX];
// keccak256("batchExecute((uint8,address,address,address,address,address,uint256,uint256)[])")[..4]

Assert against that constant instead of (or in addition to) the sol!-derived value.

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:p2-polishNice-to-have / polishstatus:readyScoped and ready to pick up

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions