evmstore

package
v1.1.1-rc.2 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2022 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TriesInMemory = 16
)

Variables

View Source
var (
	// EmptyCode is the known hash of the empty EVM bytecode.
	EmptyCode = crypto.Keccak256(nil)
)

Functions

func IsMptKey

func IsMptKey(key []byte) bool

func IsPreimageKey

func IsPreimageKey(key []byte) bool

func UnwrapStorageReceipts

func UnwrapStorageReceipts(receiptsStorage []*types.ReceiptForStorage, n idx.Block, signer types.Signer, hash common.Hash, txs types.Transactions) (types.Receipts, error)

Types

type Store

type Store struct {
	EvmDb    ethdb.Database
	EvmState state.Database
	EvmLogs  *topicsdb.Index
	Snaps    *snapshot.Tree

	logger.Instance
	// contains filtered or unexported fields
}

Store is a node persistent storage working over physical key-value database.

func NewStore

func NewStore(mainDB kvdb.Store, cfg StoreConfig) *Store

NewStore creates store over key-value db.

func (*Store) ApplyGenesis

func (s *Store) ApplyGenesis(g genesis.Genesis) (err error)

ApplyGenesis writes initial state.

func (*Store) Cap

func (s *Store) Cap()

Cap flush matured singleton nodes to disk

func (*Store) CheckEvm

func (s *Store) CheckEvm(forEachState func(func(root common.Hash) (found bool, err error))) error

func (*Store) CleanCommit

func (s *Store) CleanCommit(block iblockproc.BlockState) error

CleanCommit clean old state trie and commit changes.

func (*Store) Commit

func (s *Store) Commit(block iblockproc.BlockState, flush bool) error

Commit changes.

func (*Store) Flush

func (s *Store) Flush(block iblockproc.BlockState)

func (*Store) GenerateEvmSnapshot

func (s *Store) GenerateEvmSnapshot(root common.Hash, rebuild, async bool) (err error)

func (*Store) GetBlockTxs

func (s *Store) GetBlockTxs(n idx.Block, block inter.Block, getEventPayload func(hash.Event) *inter.EventPayload) types.Transactions

func (*Store) GetCachedEvmBlock

func (s *Store) GetCachedEvmBlock(n idx.Block) *evmcore.EvmBlock

func (*Store) GetRawReceipts

func (s *Store) GetRawReceipts(n idx.Block) ([]*types.ReceiptForStorage, int)

func (*Store) GetRawReceiptsRLP

func (s *Store) GetRawReceiptsRLP(n idx.Block) rlp.RawValue

func (*Store) GetReceipts

func (s *Store) GetReceipts(n idx.Block, signer types.Signer, hash common.Hash, txs types.Transactions) types.Receipts

GetReceipts returns stored transaction receipts.

func (*Store) GetTx

func (s *Store) GetTx(txid common.Hash) *types.Transaction

GetTx returns stored non-event transaction.

func (*Store) GetTxPosition

func (s *Store) GetTxPosition(txid common.Hash) *TxPosition

GetTxPosition returns stored transaction block and position.

func (*Store) HasStateDB

func (s *Store) HasStateDB(from hash.Hash) bool

HasStateDB returns if state database exists

func (*Store) ImportEvm

func (s *Store) ImportEvm(r io.Reader) error

func (*Store) IndexLogs

func (s *Store) IndexLogs(recs ...*types.Log)

IndexLogs indexes EVM logs

func (*Store) IsEvmSnapshotPaused

func (s *Store) IsEvmSnapshotPaused() bool

func (*Store) PauseEvmSnapshot

func (s *Store) PauseEvmSnapshot()

func (*Store) RebuildEvmSnapshot

func (s *Store) RebuildEvmSnapshot(root common.Hash)

func (*Store) SetCachedEvmBlock

func (s *Store) SetCachedEvmBlock(n idx.Block, b *evmcore.EvmBlock)

func (*Store) SetRawReceipts

func (s *Store) SetRawReceipts(n idx.Block, receipts []*types.ReceiptForStorage) (size int)

SetRawReceipts stores raw transaction receipts.

func (*Store) SetReceipts

func (s *Store) SetReceipts(n idx.Block, receipts types.Receipts)

SetReceipts stores transaction receipts.

func (*Store) SetTx

func (s *Store) SetTx(txid common.Hash, tx *types.Transaction)

SetTx stores non-event transaction.

func (*Store) SetTxPosition

func (s *Store) SetTxPosition(txid common.Hash, position TxPosition)

SetTxPosition stores transaction block and position.

func (*Store) Snapshots

func (s *Store) Snapshots() *snapshot.Tree

func (*Store) StateDB

func (s *Store) StateDB(from hash.Hash) (*state.StateDB, error)

StateDB returns state database.

type StoreCacheConfig

type StoreCacheConfig struct {
	// Cache size for Receipts (size in bytes).
	ReceiptsSize uint
	// Cache size for Receipts (number of blocks).
	ReceiptsBlocks int
	// Cache size for TxPositions.
	TxPositions int
	// Cache size for EVM database.
	EvmDatabase int
	// Cache size for EVM snapshot.
	EvmSnap int
	// Cache size for EvmBlock (number of blocks).
	EvmBlocksNum int
	// Cache size for EvmBlock (size in bytes).
	EvmBlocksSize uint
	// Disk journal for saving clean cache entries.
	TrieCleanJournal string
	// Whether to disable trie write caching and GC altogether (archive node)
	TrieDirtyDisabled bool
	// Memory limit (MB) at which to start flushing dirty trie nodes to disk
	TrieDirtyLimit uint
	// Whether to enable greedy gc mode
	GreedyGC bool
}

StoreCacheConfig is a config for the db.

type StoreConfig

type StoreConfig struct {
	Cache StoreCacheConfig
	// Enables tracking of SHA3 preimages in the VM
	EnablePreimageRecording bool
}

StoreConfig is a config for store db.

func DefaultStoreConfig

func DefaultStoreConfig(scale cachescale.Func) StoreConfig

DefaultStoreConfig for product.

func LiteStoreConfig

func LiteStoreConfig() StoreConfig

LiteStoreConfig is for tests or inmemory.

type TxPosition

type TxPosition struct {
	Block       idx.Block
	Event       hash.Event
	EventOffset uint32
	BlockOffset uint32
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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