Skip to content

[executor] simulate() logs raw revert bytes — no custom-error selector decoding; unreadable in production #166

@obchain

Description

@obchain

PR: #41 (feat/executor: transaction builder + eth_call simulator)
File: crates/charon-executor/src/simulation.rs — simulate()
Refs #41

Problem

On revert, simulate() logs:

warn!(error = %msg, "eth_call simulation reverted — opportunity dropped");

Venus, Aave V3, and PancakeSwap V3 all use ABI-encoded 4-byte custom errors. The raw err from alloy's provider.call() returns an opaque hex blob. Operators will see WARN lines like "simulation reverted: 0x..." with no way to distinguish:

  • Venus position no longer liquidatable (expected, discard)
  • Aave flash loan paused (circuit breaker, alert)
  • PancakeSwap insufficient output (slippage, adjust)
  • onlyOwner firing (misconfigured sender, bug — must alert)

Fix

Extract and log the 4-byte selector from the revert data, and implement a lookup table for known selectors from Venus Comptroller, vToken, Aave V3 Pool, and PancakeSwap V3 Router. At minimum, log the hex selector so it can be cross-referenced against ABI files:

// Extract leading 4 bytes from revert data if present
if let Some(selector) = extract_4byte_selector(&msg) {
    warn!(selector = %selector, error = %msg, "eth_call reverted");
} else {
    warn!(error = %msg, "eth_call reverted");
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    layer:rustRust crates (core / scanner / protocols / executor / cli)pr-reviewFindings from PR review processpriority:p2-polishNice-to-have / polishstatus:readyScoped and ready to pick uptype:choreMaintenance, config, tooling

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions