Purpose and Scope
This page documents the state transition process in StableNet, which defines how a transaction modifies the blockchain state.It covers gas mechanics, transaction validation, execution flow, fee delegation, and StableNet-specific features, including the gas policy of the Anzeon network. For details on internal EVM execution, see EVM Execution.
For gas fee policy and pricing, see Gas Fee Policy.
For transaction types and encoding, see Transaction Types and Encoding.
Overview
A state transition refers to the process of applying a single transaction to the current chain state (StateDB).The
StateTransition type in core/state_transition.go orchestrates this process, handling nonce validation, gas purchase, value transfer, EVM execution, and gas refunds.This process is tightly integrated with the EVM to execute contract code and update account balances and storage.
Core Data Structures
Message
TheMessage structure represents transaction data prepared for state processing.It is derived from a signed transaction and includes execution-time computed fields such as the effective gas price.
StateTransition
TheStateTransition structure manages the lifecycle of a single transaction and tracks gas consumption.
| Field | Type | Purpose |
|---|---|---|
gp | *GasPool | Block-level gas limit tracker |
msg | *Message | Transaction message being processed |
gasRemaining | uint64 | Unspent gas during execution |
initialGas | uint64 | Starting gas limit |
state | vm.StateDB | State database interface |
evm | *vm.EVM | EVM instance for execution |
State Transition Flow
Diagram: Complete State Transition FlowConverting a Transaction to a Message
Before execution, a transaction is converted into aMessage via TransactionToMessage().At this stage, the effective gas price is calculated, and the governance-based gas tip policy of the Anzeon network is applied.
Gas Tip Override (Anzeon)
In the Anzeon network, a network-enforced gas tip included in the block header is applied to unauthorized accounts, while only authorized accounts may use the tip specified in the transaction itself.min(gasTipCap + baseFee, gasFeeCap).
Pre-Execution Validation
preCheck() Method
ThepreCheck() method validates whether a transaction satisfies consensus rules before any state changes occur.
| Check | Error | Description |
|---|---|---|
| Nonce correctness | ErrNonceTooLow / ErrNonceTooHigh | Nonce must exactly match the state nonce |
| Nonce overflow | ErrNonceMax | Nonce cannot be uint64 max value |
| Sender is EOA | ErrSenderNoEOA | Sender must not have contract code |
| Gas fee cap | ErrFeeCapTooLow | Fee cap must exceed the base fee |
| Tip sanity | ErrTipVeryHigh | Tip cannot exceed 256 bits |
| Fee cap sanity | ErrFeeCapVeryHigh | Fee cap cannot exceed 256 bits |
| Tip vs cap | ErrTipAboveFeeCap | Tip cannot exceed the fee cap |
| Blob validity | ErrBlobTxCreate | Blob transactions cannot create contracts |
| Blob fee cap | ErrBlobFeeCapTooLow | Blob fee cap must meet the minimum |
Gas Purchase (buyGas)
After validation,buyGas() deducts gas costs upfront.The paying account depends on whether fee delegation is used. Diagram: Gas Purchase Flow with Fee Delegation
- Without delegation: The sender pays both gas costs and value transfer
- With delegation: The FeePayer pays for gas, while the sender pays only for value transfer
Intrinsic Gas Calculation
Intrinsic gas is the minimum gas required for a transaction to be executed.| Component | Cost | Condition |
|---|---|---|
| Base transaction | 21,000 gas | All transactions |
| Contract creation | +32,000 gas | to == nil and Homestead+ |
| Zero byte data | 4 gas/byte | Each zero byte |
| Non-zero byte data | 16 gas/byte (Istanbul+) | Each non-zero byte |
| 68 gas/byte (Frontier–Byzantium) | ||
| Access list | 2,400 gas/address | Per address |
| 1,900 gas/key | Per storage key | |
| Init code size | 2 gas/word | Contract creation (Shanghai+) |
gasRemaining < intrinsicGas, the transaction is immediately rejected with ErrIntrinsicGas.
EVM Execution Integration
After intrinsic gas is deducted, the remaining gas is used for EVM execution.Contract Calls
Blacklist Validation (Anzeon)
In the Anzeon network, a blacklist managed byGovValidator is checked before execution.
Gas Refunds and Fee Distribution
Gas Refund Calculation
| Fork | Refund Cap | Constant |
|---|---|---|
| Pre-London | gasUsed / 2 | params.RefundQuotient |
| London+ | gasUsed / 5 | params.RefundQuotientEIP3529 |
Fee Distribution
In StableNet’s Anzeon network, validators receive the full fee corresponding to the effective gas price.msg.GasPriceis the final effective gas price computed duringTransactionToMessage- Unlike Ethereum London, there is no baseFee burn
- This design preserves the 1:1 fiat backing principle of the stablecoin
Fee Delegation Details
Balance Validation
With fee delegation, balance checks are clearly separated between sender and FeePayer.Gas Cost Calculation
Transfer Log Generation
In Anzeon, explicit Transfer logs are generated for native coin movements.Execution Result
ExecutionResult represents the outcome of a state transition.
| Field | Type | Description |
|---|---|---|
UsedGas | uint64 | Gas consumed excluding refunds |
RefundedGas | uint64 | Refunded gas |
Err | error | EVM execution error |
ReturnData | []byte | EVM return data |
- Consensus errors: The transaction itself is rejected
- EVM errors: The transaction is included but recorded as failed
Integration with Block Processing
State transitions are invoked sequentially by theStateProcessor during block processing.
Diagram: Block Processing Loop
applyTransaction() coordinates EVM context creation, execution, and receipt generation.
Error Handling
| Error | Code Location | Meaning |
|---|---|---|
ErrNonceTooLow | state_transition.go | Already executed |
ErrNonceTooHigh | state_transition.go | Nonce gap |
ErrInsufficientFunds | state_transition.go | Cannot afford cost |
ErrIntrinsicGas | state_transition.go | Gas limit too low |
ErrGasLimitReached | gas_pool.go | Block gas exhausted |
ErrBlacklistedAccount | state_transition.go | Blacklisted |
ErrTxTypeNotSupported | types/transaction.go | Fork not active |
State Transition Testing
StableNet includes thet8n state transition testing tool.

