PR: #41 (feat/executor: transaction builder + eth_call simulator)
File: crates/charon-executor/src/builder.rs — const PROTOCOL_VENUS: u8 = 3
Refs #41
Problem
builder.rs defines:
const PROTOCOL_VENUS: u8 = 3;
CharonLiquidator.sol defines:
uint8 internal constant PROTOCOL_VENUS = 3;
The selector pin test validates the ABI function selector (the tuple shape), not the protocolId field value. If the Solidity constant is renumbered during a refactor, the Rust encoder silently writes the old value. The contract branch:
if (params.protocolId != PROTOCOL_VENUS) revert UnsupportedProtocol(params.protocolId);
will fire on every call. The simulation gate will catch this (every sim returns Err) and no funds are lost, but all opportunities are silently dropped until the constant is manually re-synced.
Fix
Add a unit test that ABI-decodes the output of encode_calldata and asserts the protocolId byte equals 3 explicitly:
#[test]
fn encode_calldata_protocol_id_equals_venus_constant() {
let builder = TxBuilder::new(mk_signer(), 56, address!("ff...ff"));
let bytes = builder.encode_calldata(&mk_opportunity(), &mk_params()).unwrap();
// uint8 is right-padded to 32 bytes; last byte of first word after selector
let protocol_id = bytes[4 + 31];
assert_eq!(protocol_id, 3u8, "protocolId must equal PROTOCOL_VENUS in CharonLiquidator.sol");
}
Add a comment on the Rust constant referencing contracts/src/CharonLiquidator.sol and the line number so future maintainers know where to sync.
PR: #41 (feat/executor: transaction builder + eth_call simulator)
File: crates/charon-executor/src/builder.rs — const PROTOCOL_VENUS: u8 = 3
Refs #41
Problem
builder.rs defines:
CharonLiquidator.sol defines:
The selector pin test validates the ABI function selector (the tuple shape), not the protocolId field value. If the Solidity constant is renumbered during a refactor, the Rust encoder silently writes the old value. The contract branch:
will fire on every call. The simulation gate will catch this (every sim returns Err) and no funds are lost, but all opportunities are silently dropped until the constant is manually re-synced.
Fix
Add a unit test that ABI-decodes the output of encode_calldata and asserts the protocolId byte equals 3 explicitly:
Add a comment on the Rust constant referencing contracts/src/CharonLiquidator.sol and the line number so future maintainers know where to sync.