Files
rea/docs/evm-bytecode.md
T
morluto 52b0a54afd fix(evm): reject nested duplicate CBOR map keys
Preserve boundary facts and uncertainty through their consumers. Add focused production-boundary regressions and update affected documentation.

Fixes #6780
2026-10-23 23:49:26 +08:00

8.9 KiB

Offline EVM bytecode

inspect_evm_interface / inspect-evm-interface infers interface candidates from one explicitly selected local bytecode carrier. The capability is general: contract investigation, compatibility, audit and CTF showcases use the same portable primitive. It does not require an active native binary target.

rea inspect-evm-interface ./runtime.hex hex --json
rea inspect-evm-interface ./runtime.bin raw --json
{
  "name": "inspect_evm_interface",
  "arguments": { "path": "/artifacts/runtime.hex", "encoding": "hex" }
}

Initial real verification covers flat legacy bytecode on Linux x64 and unchanged bundled EVMole 0.9.3. EOF-style EF00 containers return unsupported_target, with the selected path and format reason. Selected-path resolution errors ENOENT, ENOTDIR, ELOOP, and ENAMETOOLONG are invalid_request path issues. Permission, resource, cancellation, provider, and cleanup failures retain their distinct classifications. The host must already provide util-linux prlimit, normally /usr/bin/prlimit; REA_EVM_PRLIMIT_COMMAND can select another absolute executable. REA installs no system tools and changes no user configuration. Upstream provenance and license are packaged.

Evidence semantics

  • encoding is required: raw bytes or UTF-8 hex, with optional 0x prefix and outer ASCII whitespace. Odd hex, interior separators, BOM, non-ASCII whitespace and invalid UTF-8 are rejected. Empty bytecode is valid and has unknown coverage.
  • Carrier SHA-256 identifies the exact original file, including prefix/casing and whitespace. Decoded-byte SHA-256 identifies actual selected EVM bytes. Neither digest is the Ethereum Keccak code hash.
  • Full bytecode, upstream function offsets and original producer representation are returned inline by default. Offsets are byte positions in decoded bytecode.
  • Upstream also returns terminal metadata during selector recovery. Its reported values remain in raw_result; integer precision and non-text-key coverage are unknown in the JS binding. Full bytecode retains the original encoded metadata.
  • bytecode.metadata independently interprets a plausible terminal CBOR root map from the selected bytes. Integers use decimal strings; byte strings use hex, and scalar keys retain their types. The recorded offset/length addresses the original bytecode, so summary delivery does not copy an opaque CBOR payload. Nested containers have partial scalar coverage; map keys are still checked for duplicates throughout nested maps and arrays. Unsupported or malformed candidates report not-decoded with a diagnostic. Decoding is bounded to 64 container levels and the terminal payload's encoded size.
  • An unavailable trailer does not prove metadata absence or Solidity origin. Compiler-version bytes/text are metadata declarations, not verified compiler, source-file or deployed-contract identity. Historical omission parses as a null unknown facet without changing the original Evidence record. Metadata/source URLs are not fetched.
  • Selectors, argument strings and state mutability are inferences. Function names/signatures are not looked up. Optimized code may produce different mutability candidates; recovered types are not a verified source ABI.
  • Runtime/init-code identity, depl