Skip to main content

mega_evme/
lib.rs

1//! `mega-evme` library.
2//!
3//! Holds all of the executable EVM logic for the `mega-evme` CLI. The binary
4//! at `src/main.rs` is a thin wrapper that only parses arguments and
5//! dispatches into this crate; integration tests in `tests/*.rs` link against
6//! the library directly and exercise the public API the same way an external
7//! consumer would.
8
9/// Top-level CLI command parser and dispatch (`MainCmd`, `Commands`, `Error`).
10pub mod cmd;
11/// Shared building blocks: RPC provider/session, state, env, error, output
12/// formatting, tracing, transaction utilities.
13pub mod common;
14/// Historical transaction replay command.
15pub mod replay;
16/// Arbitrary EVM bytecode execution command.
17pub mod run;
18/// Single-transaction execution command.
19pub mod tx;
20
21// Internal modules reach for `crate::ChainArgs`, `crate::EvmeState`, etc.;
22// these re-exports keep those call sites working unchanged.
23pub use cmd::*;
24pub use common::*;
25
26/// Install a thread panic hook that prints a custom backtrace and exits with a
27/// non-zero status. Lets failing tests and CLI runs surface a useful trace
28/// without relying on `RUST_BACKTRACE`.
29pub fn set_thread_panic_hook() {
30    use std::{
31        backtrace::Backtrace,
32        panic::{set_hook, take_hook},
33        process::exit,
34    };
35    let orig_hook = take_hook();
36    set_hook(Box::new(move |panic_info| {
37        // Raw stderr rather than `tracing`: the subscriber may not be
38        // installed yet when a panic fires during CLI startup.
39        eprintln!("Custom backtrace: {}", Backtrace::capture());
40        orig_hook(panic_info);
41        exit(1);
42    }));
43}