state

package
v0.0.0-...-215623d Latest Latest
Warning

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

Go to latest
Published: May 20, 2021 License: GPL-3.0 Imports: 32 Imported by: 0

Documentation

Overview

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

Index

Constants

View Source
const (
	//FirstContractIncarnation - first incarnation for contract accounts. After 1 it increases by 1.
	FirstContractIncarnation = 1
	//NonContractIncarnation incarnation for non contracts
	NonContractIncarnation = 0
)

Variables

This section is empty.

Functions

func FindByHistory

func FindByHistory(tx ethdb.Tx, storage bool, key []byte, timestamp uint64) ([]byte, error)

func GetAsOf

func GetAsOf(tx ethdb.Tx, storage bool, key []byte, timestamp uint64) ([]byte, error)

func WalkAsOfAccounts

func WalkAsOfAccounts(tx ethdb.Tx, startAddress common.Address, timestamp uint64, walker func(k []byte, v []byte) (bool, error)) error

func WalkAsOfStorage

func WalkAsOfStorage(tx ethdb.Tx, address common.Address, incarnation uint64, startLocation common.Hash, timestamp uint64, walker func(k1, k2, v []byte) (bool, error)) error

startKey is the concatenation of address and incarnation (BigEndian 8 byte)

Types

type CachedReader

type CachedReader struct {
	// contains filtered or unexported fields
}

CachedReader is a wrapper for an instance of type StateReader This wrapper only makes calls to the underlying reader if the item is not in the cache

func NewCachedReader

func NewCachedReader(r StateReader, cache *shards.StateCache) *CachedReader

NewCachedReader wraps a given state reader into the cached reader

func (*CachedReader) ReadAccountCode

func (cr *CachedReader) ReadAccountCode(address common.Address, incarnation uint64, codeHash common.Hash) ([]byte, error)

ReadAccountCode is called when code of an account needs to be fetched from the state Usually, one of (address;incarnation) or codeHash is enough to uniquely identify the code

func (*CachedReader) ReadAccountCodeSize

func (cr *CachedReader) ReadAccountCodeSize(address common.Address, incarnation uint64, codeHash common.Hash) (int, error)

func (*CachedReader) ReadAccountData

func (cr *CachedReader) ReadAccountData(address common.Address) (*accounts.Account, error)

ReadAccountData is called when an account needs to be fetched from the state

func (*CachedReader) ReadAccountIncarnation

func (cr *CachedReader) ReadAccountIncarnation(address common.Address) (uint64, error)

ReadAccountIncarnation is called when incarnation of the account is required (to create and recreate contract)

func (*CachedReader) ReadAccountStorage

func (cr *CachedReader) ReadAccountStorage(address common.Address, incarnation uint64, key *common.Hash) ([]byte, error)

ReadAccountStorage is called when a storage item needs to be fetched from the state

type CachedWriter

type CachedWriter struct {
	// contains filtered or unexported fields
}

CachedWriter is a wrapper for an instance of type StateWriter

func NewCachedWriter

func NewCachedWriter(w WriterWithChangeSets, cache *shards.StateCache) *CachedWriter

NewCachedWriter wraps a given state writer into a cached writer

func (*CachedWriter) CreateContract

func (cw *CachedWriter) CreateContract(address common.Address) error

func (*CachedWriter) DeleteAccount

func (cw *CachedWriter) DeleteAccount(ctx context.Context, address common.Address, original *accounts.Account) error

func (*CachedWriter) UpdateAccountCode

func (cw *CachedWriter) UpdateAccountCode(address common.Address, incarnation uint64, codeHash common.Hash, code []byte) error

func (*CachedWriter) UpdateAccountData

func (cw *CachedWriter) UpdateAccountData(ctx context.Context, address common.Address, original, account *accounts.Account) error

func (*CachedWriter) WriteAccountStorage

func (cw *CachedWriter) WriteAccountStorage(ctx context.Context, address common.Address, incarnation uint64, key *common.Hash, original, value *uint256.Int) error

func (*CachedWriter) WriteChangeSets

func (cw *CachedWriter) WriteChangeSets() error

func (*CachedWriter) WriteHistory

func (cw *CachedWriter) WriteHistory() error

type ChangeSetWriter

type ChangeSetWriter struct {
	// contains filtered or unexported fields
}

ChangeSetWriter is a mock StateWriter that accumulates changes in-memory into ChangeSets.

func NewChangeSetWriter

func NewChangeSetWriter() *ChangeSetWriter

func NewChangeSetWriterPlain

func NewChangeSetWriterPlain(db ethdb.RwTx, blockNumber uint64) *ChangeSetWriter

func (*ChangeSetWriter) CreateContract

func (w *ChangeSetWriter) CreateContract(address common.Address) error

func (*ChangeSetWriter) DeleteAccount

func (w *ChangeSetWriter) DeleteAccount(ctx context.Context, address common.Address, original *accounts.Account) error

func (*ChangeSetWriter) GetAccountChanges

func (w *ChangeSetWriter) GetAccountChanges() (*changeset.ChangeSet, error)

func (*ChangeSetWriter) GetStorageChanges

func (w *ChangeSetWriter) GetStorageChanges() (*changeset.ChangeSet, error)

func (*ChangeSetWriter) PrintChangedAccounts

func (w *ChangeSetWriter) PrintChangedAccounts()

func (*ChangeSetWriter) UpdateAccountCode

func (w *ChangeSetWriter) UpdateAccountCode(address common.Address, incarnation uint64, codeHash common.Hash, code []byte) error

func (*ChangeSetWriter) UpdateAccountData

func (w *ChangeSetWriter) UpdateAccountData(ctx context.Context, address common.Address, original, account *accounts.Account) error

func (*ChangeSetWriter) WriteAccountStorage

func (w *ChangeSetWriter) WriteAccountStorage(ctx context.Context, address common.Address, incarnation uint64, key *common.Hash, original, value *uint256.Int) error

func (*ChangeSetWriter) WriteChangeSets

func (w *ChangeSetWriter) WriteChangeSets() error

func (*ChangeSetWriter) WriteHistory

func (w *ChangeSetWriter) WriteHistory() error

type Code

type Code []byte

func (Code) String

func (c Code) String() string

type DbStateReader

type DbStateReader struct {
	// contains filtered or unexported fields
}

Implements StateReader by wrapping database only, without trie

func NewDbStateReader

func NewDbStateReader(db ethdb.Getter) *DbStateReader

func (*DbStateReader) ReadAccountCode

func (dbr *DbStateReader) ReadAccountCode(address common.Address, incarnation uint64, codeHash common.Hash) ([]byte, error)

func (*DbStateReader) ReadAccountCodeSize

func (dbr *DbStateReader) ReadAccountCodeSize(address common.Address, incarnation uint64, codeHash common.Hash) (codeSize int, err error)

func (*DbStateReader) ReadAccountData

func (dbr *DbStateReader) ReadAccountData(address common.Address) (*accounts.Account, error)

func (*DbStateReader) ReadAccountIncarnation

func (dbr *DbStateReader) ReadAccountIncarnation(address common.Address) (uint64, error)

func (*DbStateReader) ReadAccountStorage

func (dbr *DbStateReader) ReadAccountStorage(address common.Address, incarnation uint64, key *common.Hash) ([]byte, error)

func (*DbStateReader) SetAccountCache

func (dbr *DbStateReader) SetAccountCache(accountCache *fastcache.Cache)

func (*DbStateReader) SetCodeCache

func (dbr *DbStateReader) SetCodeCache(codeCache *fastcache.Cache)

func (*DbStateReader) SetCodeSizeCache

func (dbr *DbStateReader) SetCodeSizeCache(codeSizeCache *fastcache.Cache)

func (*DbStateReader) SetStorageCache

func (dbr *DbStateReader) SetStorageCache(storageCache *fastcache.Cache)

type DbStateWriter

type DbStateWriter struct {
	// contains filtered or unexported fields
}

func NewDbStateWriter

func NewDbStateWriter(db ethdb.Database, blockNr uint64) *DbStateWriter

func (*DbStateWriter) ChangeSetWriter

func (dsw *DbStateWriter) ChangeSetWriter() *ChangeSetWriter

func (*DbStateWriter) CreateContract

func (dsw *DbStateWriter) CreateContract(address common.Address) error

func (*DbStateWriter) DeleteAccount

func (dsw *DbStateWriter) DeleteAccount(ctx context.Context, address common.Address, original *accounts.Account) error

func (*DbStateWriter) UpdateAccountCode

func (dsw *DbStateWriter) UpdateAccountCode(address common.Address, incarnation uint64, codeHash common.Hash, code []byte) error

func (*DbStateWriter) UpdateAccountData

func (dsw *DbStateWriter) UpdateAccountData(ctx context.Context, address common.Address, original, account *accounts.Account) error

func (*DbStateWriter) WriteAccountStorage

func (dsw *DbStateWriter) WriteAccountStorage(ctx context.Context, address common.Address, incarnation uint64, key *common.Hash, original, value *uint256.Int) error

func (*DbStateWriter) WriteChangeSets

func (dsw *DbStateWriter) WriteChangeSets() error

WriteChangeSets causes accumulated change sets to be written into the database (or batch) associated with the `dsw`

func (*DbStateWriter) WriteHistory

func (dsw *DbStateWriter) WriteHistory() error

type Dump

type Dump struct {
	Root     string                         `json:"root"`
	Accounts map[common.Address]DumpAccount `json:"accounts"`
}

Dump represents the full dump in a collected format, as one large map.

func (*Dump) OnAccount

func (d *Dump) OnAccount(addr common.Address, account DumpAccount)

OnAccount implements DumpCollector interface

func (*Dump) OnRoot

func (d *Dump) OnRoot(root common.Hash)

OnRoot implements DumpCollector interface

type DumpAccount

type DumpAccount struct {
	Balance   string            `json:"balance"`
	Nonce     uint64            `json:"nonce"`
	Root      string            `json:"root"`
	CodeHash  string            `json:"codeHash"`
	Code      string            `json:"code,omitempty"`
	Storage   map[string]string `json:"storage,omitempty"`
	Address   *common.Address   `json:"address,omitempty"` // Address only present in iterative (line-by-line) mode
	SecureKey *hexutil.Bytes    `json:"key,omitempty"`     // If we don't have address, we can output the key
}

DumpAccount represents an account in the state.

type DumpCollector

type DumpCollector interface {
	// OnRoot is called with the state root
	OnRoot(common.Hash)
	// OnAccount is called once for each account in the trie
	OnAccount(common.Address, DumpAccount)
}

DumpCollector interface which the state trie calls during iteration

type Dumper

type Dumper struct {
	// contains filtered or unexported fields
}

func NewDumper

func NewDumper(db ethdb.Tx, blockNumber uint64) *Dumper

func (*Dumper) DefaultDump

func (d *Dumper) DefaultDump() []byte

DefaultDump returns a JSON string representing the state with the default params

func (*Dumper) DefaultRawDump

func (d *Dumper) DefaultRawDump() Dump

func (*Dumper) Dump

func (d *Dumper) Dump(excludeCode, excludeStorage, excludeMissingPreimages bool) []byte

Dump returns a JSON string representing the entire state as a single json-object

func (*Dumper) DumpToCollector

func (d *Dumper) DumpToCollector(c DumpCollector, excludeCode, excludeStorage, _ bool, startAddress common.Address, maxResults int) ([]byte, error)

func (*Dumper) IterativeDump

func (d *Dumper) IterativeDump(excludeCode, excludeStorage, excludeMissingPreimages bool, output *json.Encoder)

IterativeDump dumps out accounts as json-objects, delimited by linebreaks on stdout

func (*Dumper) IteratorDump

func (d *Dumper) IteratorDump(excludeCode, excludeStorage, excludeMissingPreimages bool, start common.Address, maxResults int) (IteratorDump, error)

IteratorDump dumps out a batch of accounts starts with the given start key

func (*Dumper) RawDump

func (d *Dumper) RawDump(excludeCode, excludeStorage, excludeMissingPreimages bool) Dump

RawDump returns the entire state an a single large object

type IntraBlockState

type IntraBlockState struct {
	// contains filtered or unexported fields
}

IntraBlockState is responsible for caching and managing state changes that occur during block's execution. NOT THREAD SAFE!

func New

func New(stateReader StateReader) *IntraBlockState

Create a new state from a given trie

func (*IntraBlockState) AddAddressToAccessList

func (sdb *IntraBlockState) AddAddressToAccessList(addr common.Address)

AddAddressToAccessList adds the given address to the access list

func (*IntraBlockState) AddBalance

func (sdb *IntraBlockState) AddBalance(addr common.Address, amount *uint256.Int)

AddBalance adds amount to the account associated with addr. DESCRIBED: docs/programmers_guide/guide.md#address---identifier-of-an-account

func (*IntraBlockState) AddLog

func (sdb *IntraBlockState) AddLog(log *types.Log)

func (*IntraBlockState) AddPreimage

func (sdb *IntraBlockState) AddPreimage(hash common.Hash, preimage []byte)

AddPreimage records a SHA3 preimage seen by the VM.

func (*IntraBlockState) AddRefund

func (sdb *IntraBlockState) AddRefund(gas uint64)

AddRefund adds gas to the refund counter

func (*IntraBlockState) AddSlotToAccessList

func (sdb *IntraBlockState) AddSlotToAccessList(addr common.Address, slot common.Hash)

AddSlotToAccessList adds the given (address, slot)-tuple to the access list

func (*IntraBlockState) AddressInAccessList

func (sdb *IntraBlockState) AddressInAccessList(addr common.Address) bool

AddressInAccessList returns true if the given address is in the access list.

func (*IntraBlockState) CommitBlock

func (sdb *IntraBlockState) CommitBlock(ctx context.Context, stateWriter StateWriter) error

CommitBlock finalizes the state by removing the self destructed objects and clears the journal as well as the refunds.

func (*IntraBlockState) Copy

func (sdb *IntraBlockState) Copy() *IntraBlockState

Copy creates a deep, independent copy of the state. Snapshots of the copied state cannot be applied to the copy.

func (*IntraBlockState) CreateAccount

func (sdb *IntraBlockState) CreateAccount(addr common.Address, contractCreation bool)

CreateAccount explicitly creates a state object. If a state object with the address already exists the balance is carried over to the new account.

CreateAccount is called during the EVM CREATE operation. The situation might arise that a contract does the following:

  1. sends funds to sha(account ++ (nonce + 1))
  2. tx_create(sha(account ++ nonce)) (note that this gets the address of 1)

Carrying over the balance ensures that Ether doesn't disappear.

func (*IntraBlockState) Empty

func (sdb *IntraBlockState) Empty(addr common.Address) bool

Empty returns whether the state object is either non-existent or empty according to the EIP161 specification (balance = nonce = code = 0)

func (*IntraBlockState) Error

func (sdb *IntraBlockState) Error() error

func (*IntraBlockState) Exist

func (sdb *IntraBlockState) Exist(addr common.Address) bool

Exist reports whether the given account address exists in the state. Notably this also returns true for suicided accounts.

func (*IntraBlockState) FinalizeTx

func (sdb *IntraBlockState) FinalizeTx(ctx context.Context, stateWriter StateWriter) error

FinalizeTx should be called after every transaction.

func (*IntraBlockState) GetBalance

func (sdb *IntraBlockState) GetBalance(addr common.Address) *uint256.Int

GetBalance retrieves the balance from the given address or 0 if object not found DESCRIBED: docs/programmers_guide/guide.md#address---identifier-of-an-account

func (*IntraBlockState) GetCode

func (sdb *IntraBlockState) GetCode(addr common.Address) []byte

DESCRIBED: docs/programmers_guide/guide.md#address---identifier-of-an-account

func (*IntraBlockState) GetCodeHash

func (sdb *IntraBlockState) GetCodeHash(addr common.Address) common.Hash

DESCRIBED: docs/programmers_guide/guide.md#address---identifier-of-an-account

func (*IntraBlockState) GetCodeSize

func (sdb *IntraBlockState) GetCodeSize(addr common.Address) int

DESCRIBED: docs/programmers_guide/guide.md#address---identifier-of-an-account

func (*IntraBlockState) GetCommittedState

func (sdb *IntraBlockState) GetCommittedState(addr common.Address, key *common.Hash, value *uint256.Int)

GetCommittedState retrieves a value from the given account's committed storage trie. DESCRIBED: docs/programmers_guide/guide.md#address---identifier-of-an-account

func (*IntraBlockState) GetIncarnation

func (sdb *IntraBlockState) GetIncarnation(addr common.Address) uint64

func (*IntraBlockState) GetLogs

func (sdb *IntraBlockState) GetLogs(hash common.Hash) []*types.Log

func (*IntraBlockState) GetNonce

func (sdb *IntraBlockState) GetNonce(addr common.Address) uint64

DESCRIBED: docs/programmers_guide/guide.md#address---identifier-of-an-account

func (*IntraBlockState) GetOrNewStateObject

func (sdb *IntraBlockState) GetOrNewStateObject(addr common.Address) *stateObject

Retrieve a state object or create a new state object if nil.

func (*IntraBlockState) GetRefund

func (sdb *IntraBlockState) GetRefund() uint64

GetRefund returns the current value of the refund counter.

func (*IntraBlockState) GetState

func (sdb *IntraBlockState) GetState(addr common.Address, key *common.Hash, value *uint256.Int)

GetState retrieves a value from the given account's storage trie. DESCRIBED: docs/programmers_guide/guide.md#address---identifier-of-an-account

func (*IntraBlockState) HasSuicided

func (sdb *IntraBlockState) HasSuicided(addr common.Address) bool

func (*IntraBlockState) Logs

func (sdb *IntraBlockState) Logs() []*types.Log

func (*IntraBlockState) Preimages

func (sdb *IntraBlockState) Preimages() map[common.Hash][]byte

Preimages returns a list of SHA3 preimages that have been submitted.

func (*IntraBlockState) Prepare

func (sdb *IntraBlockState) Prepare(thash, bhash common.Hash, ti int)

Prepare sets the current transaction hash and index and block hash which is used when the EVM emits new state logs.

func (*IntraBlockState) PrepareAccessList

func (sdb *IntraBlockState) PrepareAccessList(sender common.Address, dst *common.Address, precompiles []common.Address, list types.AccessList)

PrepareAccessList handles the preparatory steps for executing a state transition with regards to both EIP-2929 and EIP-2930:

- Add sender to access list (2929) - Add destination to access list (2929) - Add precompiles to access list (2929) - Add the contents of the optional tx access list (2930)

This method should only be called if Yolov3/Berlin/2929+2930 is applicable at the current number.

func (*IntraBlockState) Reset

func (sdb *IntraBlockState) Reset() error

Reset clears out all ephemeral state objects from the state db, but keeps the underlying state trie to avoid reloading data for the next operations.

func (*IntraBlockState) RevertToSnapshot

func (sdb *IntraBlockState) RevertToSnapshot(revid int)

RevertToSnapshot reverts all state changes made since the given revision.

func (*IntraBlockState) SetBalance

func (sdb *IntraBlockState) SetBalance(addr common.Address, amount *uint256.Int)

DESCRIBED: docs/programmers_guide/guide.md#address---identifier-of-an-account

func (*IntraBlockState) SetCode

func (sdb *IntraBlockState) SetCode(addr common.Address, code []byte)

DESCRIBED: docs/programmers_guide/guide.md#code-hash DESCRIBED: docs/programmers_guide/guide.md#address---identifier-of-an-account

func (*IntraBlockState) SetIncarnation

func (sdb *IntraBlockState) SetIncarnation(addr common.Address, incarnation uint64)

SetIncarnation sets incarnation for account if account exists

func (*IntraBlockState) SetNonce

func (sdb *IntraBlockState) SetNonce(addr common.Address, nonce uint64)

DESCRIBED: docs/programmers_guide/guide.md#address---identifier-of-an-account

func (*IntraBlockState) SetState

func (sdb *IntraBlockState) SetState(addr common.Address, key *common.Hash, value uint256.Int)

DESCRIBED: docs/programmers_guide/guide.md#address---identifier-of-an-account

func (*IntraBlockState) SetStorage

func (sdb *IntraBlockState) SetStorage(addr common.Address, storage Storage)

SetStorage replaces the entire storage for the specified account with given storage. This function should only be used for debugging.

func (*IntraBlockState) SetTrace

func (sdb *IntraBlockState) SetTrace(trace bool)

func (*IntraBlockState) SetTracer

func (sdb *IntraBlockState) SetTracer(tracer StateTracer)

func (*IntraBlockState) SlotInAccessList

func (sdb *IntraBlockState) SlotInAccessList(addr common.Address, slot common.Hash) (addressPresent bool, slotPresent bool)

SlotInAccessList returns true if the given (address, slot)-tuple is in the access list.

func (*IntraBlockState) Snapshot

func (sdb *IntraBlockState) Snapshot() int

Snapshot returns an identifier for the current revision of the state.

func (*IntraBlockState) SubBalance

func (sdb *IntraBlockState) SubBalance(addr common.Address, amount *uint256.Int)

SubBalance subtracts amount from the account associated with addr. DESCRIBED: docs/programmers_guide/guide.md#address---identifier-of-an-account

func (*IntraBlockState) SubRefund

func (sdb *IntraBlockState) SubRefund(gas uint64)

SubRefund removes gas from the refund counter. This method will panic if the refund counter goes below zero

func (*IntraBlockState) Suicide

func (sdb *IntraBlockState) Suicide(addr common.Address) bool

Suicide marks the given account as suicided. This clears the account balance.

The account's state object is still available until the state is committed, getStateObject will return a non-nil account after Suicide.

func (*IntraBlockState) TxIndex

func (sdb *IntraBlockState) TxIndex() int

TxIndex returns the current transaction index set by Prepare.

type IteratorDump

type IteratorDump struct {
	Root     string                         `json:"root"`
	Accounts map[common.Address]DumpAccount `json:"accounts"`
	Next     []byte                         `json:"next,omitempty"` // nil if no more accounts
}

IteratorDump is an implementation for iterating over data.

func (*IteratorDump) OnAccount

func (d *IteratorDump) OnAccount(addr common.Address, account DumpAccount)

OnAccount implements DumpCollector interface

func (*IteratorDump) OnRoot

func (d *IteratorDump) OnRoot(root common.Hash)

OnRoot implements DumpCollector interface

type NoopWriter

type NoopWriter struct {
}

func NewNoopWriter

func NewNoopWriter() *NoopWriter

func (*NoopWriter) CreateContract

func (nw *NoopWriter) CreateContract(address common.Address) error

func (*NoopWriter) DeleteAccount

func (nw *NoopWriter) DeleteAccount(_ context.Context, address common.Address, original *accounts.Account) error

func (*NoopWriter) UpdateAccountCode

func (nw *NoopWriter) UpdateAccountCode(address common.Address, incarnation uint64, codeHash common.Hash, code []byte) error

func (*NoopWriter) UpdateAccountData

func (nw *NoopWriter) UpdateAccountData(_ context.Context, address common.Address, original, account *accounts.Account) error

func (*NoopWriter) WriteAccountStorage

func (nw *NoopWriter) WriteAccountStorage(_ context.Context, address common.Address, incarnation uint64, key *common.Hash, original, value *uint256.Int) error

func (*NoopWriter) WriteChangeSets

func (nw *NoopWriter) WriteChangeSets() error

func (*NoopWriter) WriteHistory

func (nw *NoopWriter) WriteHistory() error

type PlainDBState deprecated

type PlainDBState struct {
	// contains filtered or unexported fields
}

Deprecated: use PlainKVState Implements StateReader by wrapping database only, without trie

func NewPlainDBState

func NewPlainDBState(db ethdb.GetterBeginner, blockNr uint64) *PlainDBState

func (*PlainDBState) CreateContract

func (dbs *PlainDBState) CreateContract(address common.Address) error

func (*PlainDBState) DeleteAccount

func (dbs *PlainDBState) DeleteAccount(_ context.Context, address common.Address, original *accounts.Account) error

func (*PlainDBState) ForEachStorage

func (dbs *PlainDBState) ForEachStorage(addr common.Address, startLocation common.Hash, cb func(key, seckey common.Hash, value uint256.Int) bool, maxResults int) error

func (*PlainDBState) GetBlockNr

func (dbs *PlainDBState) GetBlockNr() uint64

func (*PlainDBState) ReadAccountCode

func (dbs *PlainDBState) ReadAccountCode(address common.Address, incarnation uint64, codeHash common.Hash) ([]byte, error)

func (*PlainDBState) ReadAccountCodeSize

func (dbs *PlainDBState) ReadAccountCodeSize(address common.Address, incarnation uint64, codeHash common.Hash) (int, error)

func (*PlainDBState) ReadAccountData

func (dbs *PlainDBState) ReadAccountData(address common.Address) (*accounts.Account, error)

func (*PlainDBState) ReadAccountIncarnation

func (dbs *PlainDBState) ReadAccountIncarnation(address common.Address) (uint64, error)

func (*PlainDBState) ReadAccountStorage

func (dbs *PlainDBState) ReadAccountStorage(address common.Address, incarnation uint64, key *common.Hash) ([]byte, error)

func (*PlainDBState) SetBlockNr

func (dbs *PlainDBState) SetBlockNr(blockNr uint64)

func (*PlainDBState) UpdateAccountCode

func (dbs *PlainDBState) UpdateAccountCode(address common.Address, incarnation uint64, codeHash common.Hash, code []byte) error

func (*PlainDBState) UpdateAccountData

func (dbs *PlainDBState) UpdateAccountData(_ context.Context, address common.Address, original, account *accounts.Account) error

func (*PlainDBState) WriteAccountStorage

func (dbs *PlainDBState) WriteAccountStorage(_ context.Context, address common.Address, incarnation uint64, key *common.Hash, original, value *uint256.Int) error

type PlainKVState

type PlainKVState struct {
	// contains filtered or unexported fields
}

func NewPlainKvState

func NewPlainKvState(tx ethdb.Tx, blockNr uint64) *PlainKVState

func (*PlainKVState) CreateContract

func (s *PlainKVState) CreateContract(address common.Address) error

func (*PlainKVState) DeleteAccount

func (s *PlainKVState) DeleteAccount(_ context.Context, address common.Address, original *accounts.Account) error

func (*PlainKVState) ForEachStorage

func (s *PlainKVState) ForEachStorage(addr common.Address, startLocation common.Hash, cb func(key, seckey common.Hash, value uint256.Int) bool, maxResults int) error

func (*PlainKVState) GetBlockNr

func (s *PlainKVState) GetBlockNr() uint64

func (*PlainKVState) ReadAccountCode

func (s *PlainKVState) ReadAccountCode(address common.Address, incarnation uint64, codeHash common.Hash) ([]byte, error)

func (*PlainKVState) ReadAccountCodeSize

func (s *PlainKVState) ReadAccountCodeSize(address common.Address, incarnation uint64, codeHash common.Hash) (int, error)

func (*PlainKVState) ReadAccountData

func (s *PlainKVState) ReadAccountData(address common.Address) (*accounts.Account, error)

func (*PlainKVState) ReadAccountIncarnation

func (s *PlainKVState) ReadAccountIncarnation(address common.Address) (uint64, error)

func (*PlainKVState) ReadAccountStorage

func (s *PlainKVState) ReadAccountStorage(address common.Address, incarnation uint64, key *common.Hash) ([]byte, error)

func (*PlainKVState) SetBlockNr

func (s *PlainKVState) SetBlockNr(blockNr uint64)

func (*PlainKVState) UpdateAccountCode

func (s *PlainKVState) UpdateAccountCode(address common.Address, incarnation uint64, codeHash common.Hash, code []byte) error

func (*PlainKVState) UpdateAccountData

func (s *PlainKVState) UpdateAccountData(_ context.Context, address common.Address, original, account *accounts.Account) error

func (*PlainKVState) WriteAccountStorage

func (s *PlainKVState) WriteAccountStorage(_ context.Context, address common.Address, incarnation uint64, key *common.Hash, original, value *uint256.Int) error

type PlainStateReader

type PlainStateReader struct {
	// contains filtered or unexported fields
}

PlainStateReader reads data from so called "plain state". Data in the plain state is stored using un-hashed account/storage items as opposed to the "normal" state that uses hashes of merkle paths to store items.

func NewPlainStateReader

func NewPlainStateReader(db ethdb.KVGetter) *PlainStateReader

func (*PlainStateReader) ReadAccountCode

func (r *PlainStateReader) ReadAccountCode(address common.Address, incarnation uint64, codeHash common.Hash) ([]byte, error)

func (*PlainStateReader) ReadAccountCodeSize

func (r *PlainStateReader) ReadAccountCodeSize(address common.Address, incarnation uint64, codeHash common.Hash) (int, error)

func (*PlainStateReader) ReadAccountData

func (r *PlainStateReader) ReadAccountData(address common.Address) (*accounts.Account, error)

func (*PlainStateReader) ReadAccountIncarnation

func (r *PlainStateReader) ReadAccountIncarnation(address common.Address) (uint64, error)

func (*PlainStateReader) ReadAccountStorage

func (r *PlainStateReader) ReadAccountStorage(address common.Address, incarnation uint64, key *common.Hash) ([]byte, error)

type PlainStateWriter

type PlainStateWriter struct {
	// contains filtered or unexported fields
}

func NewPlainStateWriter

func NewPlainStateWriter(db ethdb.Database, changeSetsDB ethdb.RwTx, blockNumber uint64) *PlainStateWriter

func (*PlainStateWriter) ChangeSetWriter

func (w *PlainStateWriter) ChangeSetWriter() *ChangeSetWriter

func (*PlainStateWriter) CreateContract

func (w *PlainStateWriter) CreateContract(address common.Address) error

func (*PlainStateWriter) DeleteAccount

func (w *PlainStateWriter) DeleteAccount(ctx context.Context, address common.Address, original *accounts.Account) error

func (*PlainStateWriter) UpdateAccountCode

func (w *PlainStateWriter) UpdateAccountCode(address common.Address, incarnation uint64, codeHash common.Hash, code []byte) error

func (*PlainStateWriter) UpdateAccountData

func (w *PlainStateWriter) UpdateAccountData(ctx context.Context, address common.Address, original, account *accounts.Account) error

func (*PlainStateWriter) WriteAccountStorage

func (w *PlainStateWriter) WriteAccountStorage(ctx context.Context, address common.Address, incarnation uint64, key *common.Hash, original, value *uint256.Int) error

func (*PlainStateWriter) WriteChangeSets

func (w *PlainStateWriter) WriteChangeSets() error

func (*PlainStateWriter) WriteHistory

func (w *PlainStateWriter) WriteHistory() error

type PreimageWriter

type PreimageWriter struct {
	// contains filtered or unexported fields
}

func (*PreimageWriter) HashAddress

func (pw *PreimageWriter) HashAddress(address common.Address, save bool) (common.Hash, error)

func (*PreimageWriter) HashKey

func (pw *PreimageWriter) HashKey(key *common.Hash, save bool) (common.Hash, error)

func (*PreimageWriter) SetSavePreimages

func (pw *PreimageWriter) SetSavePreimages(save bool)

type StateReader

type StateReader interface {
	ReadAccountData(address common.Address) (*accounts.Account, error)
	ReadAccountStorage(address common.Address, incarnation uint64, key *common.Hash) ([]byte, error)
	ReadAccountCode(address common.Address, incarnation uint64, codeHash common.Hash) ([]byte, error)
	ReadAccountCodeSize(address common.Address, incarnation uint64, codeHash common.Hash) (int, error)
	ReadAccountIncarnation(address common.Address) (uint64, error)
}

type StateTracer

type StateTracer interface {
	CaptureAccountRead(account common.Address) error
	CaptureAccountWrite(account common.Address) error
}

type StateWriter

type StateWriter interface {
	UpdateAccountData(ctx context.Context, address common.Address, original, account *accounts.Account) error
	UpdateAccountCode(address common.Address, incarnation uint64, codeHash common.Hash, code []byte) error
	DeleteAccount(ctx context.Context, address common.Address, original *accounts.Account) error
	WriteAccountStorage(ctx context.Context, address common.Address, incarnation uint64, key *common.Hash, original, value *uint256.Int) error
	CreateContract(address common.Address) error
}

type Storage

type Storage map[common.Hash]uint256.Int

func (Storage) Copy

func (s Storage) Copy() Storage

func (Storage) String

func (s Storage) String() (str string)

type WriterWithChangeSets

type WriterWithChangeSets interface {
	StateWriter
	WriteChangeSets() error
	WriteHistory() error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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