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/// Custom hasher used by the env-derived bucket capacity tables.
15pub mod hasher;
16/// Historical transaction replay command.
17pub mod replay;
18/// Arbitrary EVM bytecode execution command.
19pub mod run;
20/// Single-transaction execution command.
21pub mod tx;
22
23// Internal modules reach for `crate::ChainArgs`, `crate::EvmeState`, etc.;
24// these re-exports keep those call sites working unchanged.
25pub use cmd::*;
26pub use common::*;
27
28/// Install a thread panic hook that prints a custom backtrace and exits with a
29/// non-zero status. Lets failing tests and CLI runs surface a useful trace
30/// without relying on `RUST_BACKTRACE`.
31pub fn set_thread_panic_hook() {
32 use std::{
33 backtrace::Backtrace,
34 panic::{set_hook, take_hook},
35 process::exit,
36 };
37 let orig_hook = take_hook();
38 set_hook(Box::new(move |panic_info| {
39 // Raw stderr rather than `tracing`: the subscriber may not be
40 // installed yet when a panic fires during CLI startup.
41 eprintln!("Custom backtrace: {}", Backtrace::capture());
42 orig_hook(panic_info);
43 exit(1);
44 }));
45}