state

package
v1.16.20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2025 License: GPL-3.0, LGPL-3.0 Imports: 8 Imported by: 11

Documentation

Overview

Package state provides a caching layer atop the Ethereum state trie.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database = ethstate.Database

func NewDatabase

func NewDatabase(db ethdb.Database) Database

func NewDatabaseWithConfig

func NewDatabaseWithConfig(db ethdb.Database, config *triedb.Config) Database

func NewDatabaseWithNodeDB

func NewDatabaseWithNodeDB(db ethdb.Database, tdb *triedb.Database) Database

type Dump

type Dump = ethstate.Dump

type DumpAccount

type DumpAccount = ethstate.DumpAccount

type DumpCollector

type DumpCollector = ethstate.DumpCollector

type DumpConfig

type DumpConfig = ethstate.DumpConfig

type StateDB

type StateDB struct {
	*ethstate.StateDB
	// contains filtered or unexported fields
}

StateDB structs within the ethereum protocol are used to store anything within the merkle trie. StateDBs take care of caching and storing nested states. It's the general query interface to retrieve:

* Contracts * Accounts

Once the state is committed, tries cached in stateDB (including account trie, storage tries) will no longer be functional. A new state instance must be created with new root and updated database for accessing post- commit states.

func New

func New(root common.Hash, db Database, snaps *snapshot.Tree) (*StateDB, error)

New creates a new state from a given trie.

func (*StateDB) Copy

func (s *StateDB) Copy() *StateDB

func (*StateDB) GetState

func (s *StateDB) GetState(addr common.Address, hash common.Hash) common.Hash

GetState retrieves a value from the given account's storage trie.

func (*StateDB) GetTxHash

func (s *StateDB) GetTxHash() common.Hash

GetTxHash returns the current tx hash on the StateDB set by SetTxContext.

func (*StateDB) SetCode added in v0.8.1

func (s *StateDB) SetCode(addr common.Address, code []byte, reason tracing.CodeChangeReason) []byte

SetCode delegates to the underlying StateDB This wrapper handles compatibility between different geth API versions

func (*StateDB) SetState

func (s *StateDB) SetState(addr common.Address, key, value common.Hash) common.Hash

func (*StateDB) SetTxContext

func (s *StateDB) SetTxContext(thash common.Hash, ti int)

SetTxContext sets the current transaction hash and index which are used when the EVM emits new state logs. It should be invoked before transaction execution.

func (*StateDB) VMStateDBAdapter added in v0.8.8

func (s *StateDB) VMStateDBAdapter() *ethstate.StateDB

VMStateDBAdapter provides VM interface compatibility by exposing the underlying geth StateDB

type StateUpgradeAdapter added in v0.8.6

type StateUpgradeAdapter struct {
	*StateDB
}

StateUpgradeAdapter adapts the new geth StateDB interface (with BalanceChangeReason) to the legacy stateupgrade.StateDB interface that doesn't use BalanceChangeReason.

func NewStateUpgradeAdapter added in v0.8.6

func NewStateUpgradeAdapter(stateDB *StateDB) *StateUpgradeAdapter

NewStateUpgradeAdapter creates a new adapter for state upgrade compatibility

func (*StateUpgradeAdapter) AddBalance added in v0.8.6

func (a *StateUpgradeAdapter) AddBalance(addr common.Address, amount *uint256.Int)

AddBalance implements the legacy AddBalance without BalanceChangeReason

func (*StateUpgradeAdapter) SetCode added in v0.8.6

func (a *StateUpgradeAdapter) SetCode(addr common.Address, code []byte)

SetCode implements the stateupgrade.StateDB interface (no return value)

func (*StateUpgradeAdapter) SetNonce added in v0.8.6

func (a *StateUpgradeAdapter) SetNonce(addr common.Address, nonce uint64)

SetNonce implements the legacy SetNonce without NonceChangeReason

func (*StateUpgradeAdapter) SetState added in v0.8.6

func (a *StateUpgradeAdapter) SetState(addr common.Address, key, value common.Hash)

SetState implements the stateupgrade.StateDB interface

type Trie

type Trie = ethstate.Trie

Directories

Path Synopsis
Package snapshot implements a journalled, dynamic state dump.
Package snapshot implements a journalled, dynamic state dump.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL