Skip to main content

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

The Message 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

The StateTransition structure manages the lifecycle of a single transaction and tracks gas consumption.

State Transition Flow

Diagram: Complete State Transition Flow

Converting a Transaction to a Message

Before execution, a transaction is converted into a Message 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.
For EIP-1559 transactions, the effective gas price is calculated as
min(gasTipCap + baseFee, gasFeeCap).

Pre-Execution Validation

preCheck() Method

The preCheck() method validates whether a transaction satisfies consensus rules before any state changes occur.

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. If 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

For call transactions, the nonce is incremented before execution.

Blacklist Validation (Anzeon)

In the Anzeon network, a blacklist managed by GovValidator is checked before execution.
When fee delegation is enabled, the FeePayer is also subject to blacklist checks.

Gas Refunds and Fee Distribution

Gas Refund Calculation

Refunds are returned to the account that actually paid for gas (either the FeePayer or the sender).

Fee Distribution

In StableNet’s Anzeon network, validators receive the full fee corresponding to the effective gas price.
  • msg.GasPrice is the final effective gas price computed during TransactionToMessage
  • 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.
  • 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 the StateProcessor during block processing. Diagram: Block Processing Loop applyTransaction() coordinates EVM context creation, execution, and receipt generation.

Error Handling

These errors may cause a block to be considered invalid during block verification.

State Transition Testing

StableNet includes the t8n state transition testing tool.
This tool outputs the pre-state, post-state root, and receipts for deterministic verification of state transitions.