Purpose and Scope
This page describes the testing and debugging tools provided by StableNet for EVM bytecode execution, state transitions, and transaction validation.These tools are essential for developers performing smart contract development, consensus rule verification, and transaction execution debugging. The core tool is the
cmd/evm utility, which provides multiple subcommands supporting a wide range of testing scenarios.This document covers both command-line tools and programmatic testing interfaces. For more comprehensive testing infrastructure and JSON test fixtures, see
Test Framework.
Command-Line Tool Overview
Theevm command-line tool provides an isolated execution environment for testing EVM bytecode, transactions, and state transitions without running a full node.All commands support various tracing and debugging options.
Available Commands
evm runevm transition(t8n)evm transaction(t9n)evm block-builder(b11r)evm blocktest
evm run Command
Therun command executes arbitrary EVM bytecode in an isolated environment with configurable state and block context.
Key Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--code | string | - | Hex-encoded EVM bytecode |
--codefile | string | - | Bytecode file (- for stdin) |
--input | string | - | Call data (hex) |
--inputfile | string | - | Call data file |
--gas | uint64 | 10000000000 | Gas limit |
--price | big.Int | 0 | Gas price |
--value | big.Int | 0 | Transferred value |
--sender | address | default | Sender address |
--receiver | address | default | Receiver address |
--create | bool | false | Use CREATE instead of CALL |
--prestate | string | - | Genesis JSON for state initialization |
--debug | bool | false | Full trace output |
--json | bool | false | JSON output |
--dump | bool | false | Dump state after execution |
--bench | bool | false | Run benchmark |
Execution Process
runCmd orchestrates execution in the following order:
- Initialize StateDB with genesis or an empty state
- Load bytecode (
--code,--codefile, or positional argument) - Set up sender and receiver accounts
- Configure
runtime.Configwith gas, price, and block context - Execute one of
Execute,Call, orCreate - Output execution result, gas usage, and optional traces
evm transition (t8n) Command
Thetransition command implements the Ethereum state transition function, applying a set of transactions to a pre-state and producing a post-state.It is a core tool for validating consensus-level transaction processing.
Input Formats
t8n requires the following three inputs:
- alloc.json: Pre-state account allocation
- env.json: Block environment information
- txs.json or
txs.rlp: Transaction list
Output Formats
- alloc.json: Post-state
- result.json: Execution results
- body.rlp: Block body (optional)
Key Flags
| Flag | Default | Description |
|---|---|---|
--input.alloc | stdin | Pre-state allocation |
--input.env | stdin | Block environment |
--input.txs | stdin | Transactions |
--output.basedir | - | Output directory |
--output.alloc | alloc.json | Post-state |
--output.result | result.json | Execution result |
--output.body | body.rlp | Block body |
--state.fork | - | Fork name |
--state.chainid | 1 | Chain ID |
--state.reward | -1 | Mining reward |
--trace | false | JSON trace |
--trace.tracer | - | Custom tracer |
Fork Configuration
--state.fork specifies the consensus rules to apply.
Frontier,Homestead,EIP150,EIP158Byzantium,Constantinople,IstanbulBerlin,London,Shanghai,CancunAnzeon(StableNet-specific)
London+3855+3860.
Environment Validation Rules
Required fields are validated depending on the active fork.- London:
currentBaseFeeorparentBaseFeerequired - Shanghai:
withdrawalsrequired - Merge:
currentRandomrequired, difficulty must be 0 - Cancun:
parentBeaconBlockRootrequired
evm transaction (t9n) Command
Thet9n command validates transaction encoding and signature recovery without executing the transaction.
Validation Items
- Whether RLP decoding succeeds
- Sender recovery via ECDSA signature
- Compliance with fork-specific validation rules
Key Flags
| Flag | Default | Description |
|---|---|---|
--input.txs | stdin | Transaction input |
--state.fork | - | Fork rules |
--state.chainid | 1 | Chain ID |
evm block-builder (b11r) Command
Theblock-builder command constructs a complete block from transactions, ommers, and withdrawals.
Key Flags
| Flag | Default | Description |
|---|---|---|
--input.header | - | Header template |
--input.txs | - | Transaction RLP |
--input.ommers | - | Uncle headers |
--input.withdrawals | - | Withdrawal list |
--output.block | - | Output block RLP |
--seal.clique | - | Clique signing key |
evm blocktest Command
blocktest executes blockchain tests in JSON format to validate block validity and state transitions.The test structure and execution logic follow the same rules as the test framework.
Integration with the Test Framework
Theevm tool internally reuses the execution logic from the tests package.
Key Test Functions
| Function | Purpose |
|---|---|
StateTest.Run() | Execute State tests |
StateTest.RunNoVerify() | Execute without verification |
BlockTest.Run() | Execute Block tests |
TransactionTest.Run() | Validate transactions |
MakePreState() | Create pre-state |
GetChainConfig() | Parse fork configuration |
EVM Runtime Package
Thecore/vm/runtime package provides a programmatic interface for executing the EVM without blockchain infrastructure.
Default Behavior
runtime.Config provides reasonable defaults.
- All hard forks enabled
- Difficulty 0 (post-merge)
- Maximum GasLimit
- BaseFee 1 gwei
- BlobBaseFee 1 wei
State Preparation Steps
Before execution, the following steps are performed:- Access list warm-up (post-Berlin)
- Transient storage initialization (EIP-1153)
- Precompile address warm-up
- Transaction-related address warm-up
Test Workflow Summary
EVM testing tools are typically used in the following workflow:- Single bytecode testing (
evm run) - Consensus rule validation (
evm transition) - Transaction format validation (
evm transaction) - Block construction and validation (
evm block-builder,evm blocktest)

