modules

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: GPL-3.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// DatabaseInfo is used to store information about data layout.
	DatabaseInfo = "DbInfo"
	ChainConfig  = "ChainConfig"
)

StateInfo

View Source
const (
	//key - contract code hash
	//value - contract code
	Code    = "Code"    // contract code hash -> contract code
	Account = "Account" // address(un hashed) -> account encoded
	Storage = "Storage" // address (un hashed) + incarnation + storage key (un hashed) -> storage value(types.Hash)
	Reward  = "Reward"  // ...
	Deposit = "Deposit" // Deposit info

	//key - addressHash+incarnation
	//value - code hash
	ContractCode = "HashedCodeHash"

	PlainContractCode = "PlainCodeHash" // address+incarnation -> code hash

	// IncarnationMap "incarnation" - uint16 number - how much times given account was SelfDestruct'ed
	IncarnationMap = "IncarnationMap" // address -> incarnation of account when it was last deleted
)

PlainState

View Source
const (
	AccountChangeSet = "AccountChangeSet" // blockNum_u64 ->  address + account(encoded)
	AccountsHistory  = "AccountHistory"   // address + shard_id_u64 -> roaring bitmap  - list of block where it changed

	StorageChangeSet = "StorageChangeSet" // blockNum_u64 + address + incarnation_u64 ->  plain_storage_key + value
	StorageHistory   = "StorageHistory"   // address + storage_key + shard_id_u64 -> roaring bitmap - list of block where it changed
)

HistoryState

View Source
const (
	Headers         = "Header"                 // block_num_u64 + hash -> header
	HeaderNumber    = "HeaderNumber"           // header_hash -> num_u64
	HeaderTD        = "HeadersTotalDifficulty" // block_num_u64 + hash -> td
	HeaderCanonical = "CanonicalHeader"        // block_num_u64 -> header hash

	// headBlockKey tracks the latest know full block's hash.
	HeadBlockKey = "LastBlock"

	HeadHeaderKey = "LastHeader"

	BlockBody       = "BlockBody"               // block_num_u64 + hash -> block body
	BlockTx         = "BlockTransaction"        // tbl_sequence_u64 -> (tx)
	NonCanonicalTxs = "NonCanonicalTransaction" // tbl_sequence_u64 -> rlp(tx)
	MaxTxNum        = "MaxTxNum"                // block_number_u64 -> max_tx_num_in_block_u64
	TxLookup        = "BlockTransactionLookup"  // hash -> transaction/receipt lookup metadata

	BlockVerify  = "BlockVerify"
	BlockRewards = "BlockRewards"

	// Transaction senders - stored separately from the block bodies
	Senders = "TxSender" // block_num_u64 + blockHash -> sendersList (no serialization format, every 20 bytes is new sender)

	Receipts = "Receipt"        // block_num_u64 -> canonical block receipts (non-canonical are not stored)
	Log      = "TransactionLog" // block_num_u64 + txId -> logs of transaction

	// Stores bitmap indices - in which block numbers saw logs of given 'address' or 'topic'
	// [addr or topic] + [2 bytes inverted shard number] -> bitmap(blockN)
	// indices are sharded - because some bitmaps are >1Mb and when new incoming blocks process it
	//	 updates ~300 of bitmaps - by append small amount new values. It cause much big writes (MDBX does copy-on-write).
	//
	// if last existing shard size merge it with delta
	// if serialized size of delta > ShardLimit - break down to multiple shards
	// shard number - it's biggest value in bitmap
	LogTopicIndex   = "LogTopicIndex"
	LogAddressIndex = "LogAddressIndex"

	// CallTraceSet is the name of the table that contain the mapping of block number to the set (sorted) of all accounts
	// touched by call traces. It is DupSort-ed table
	// 8-byte BE block number -> account address -> two bits (one for "from", another for "to")
	CallTraceSet = "CallTraceSet"
	// Indices for call traces - have the same format as LogTopicIndex and LogAddressIndex
	// Store bitmap indices - in which block number we saw calls from (CallFromIndex) or to (CallToIndex) some addresses
	CallFromIndex = "CallFromIndex"
	CallToIndex   = "CallToIndex"

	Sequence = "Sequence" // tbl_name -> seq_u64

	Stake = "Stake" // stakes   amc_stake -> bytes

)

Block

View Source
const (
	SignersDB   = "signersDB"
	PoaSnapshot = "poaSnapshot"
)
View Source
const Incarnation = 2
View Source
const NumberLength = 8

Variables

View Source
var AmcTableCfg = kv.TableCfg{
	AccountChangeSet: {Flags: kv.DupSort},
	StorageChangeSet: {Flags: kv.DupSort},
	Storage: {
		Flags:                     kv.DupSort,
		AutoDupSortKeysConversion: true,
		DupFromLen:                54,
		DupToLen:                  34,
	},
}
View Source
var ErrInvalidSize = errors.New("bit endian number has an invalid size")

Functions

func AccountIndexChunkKey

func AccountIndexChunkKey(key []byte, blockNumber uint64) []byte

func AmcInit

func AmcInit()

func BlockBodyKey

func BlockBodyKey(number uint64, hash types.Hash) []byte

BlockBodyKey = num (uint64 big endian) + hash

func BodyStorageValue

func BodyStorageValue(baseTx uint64, txAmount uint32) []byte

func CompositeKeyWithoutIncarnation

func CompositeKeyWithoutIncarnation(key []byte) []byte

func ConfigKey

func ConfigKey(hash types.Hash) []byte

ConfigKey = configPrefix + hash

func DecodeBlockNumber

func DecodeBlockNumber(number []byte) (uint64, error)

func EncodeBlockNumber

func EncodeBlockNumber(number uint64) []byte

EncodeBlockNumber encodes a block number as big endian uint64

func GenerateCompositeStoragePrefix

func GenerateCompositeStoragePrefix(addressHash []byte, incarnation uint16, storageHashPrefix []byte) []byte

AddrHash + incarnation + StorageHashPrefix

func GenerateStoragePrefix

func GenerateStoragePrefix(addressHash []byte, incarnation uint16) []byte

address hash + incarnation prefix

func HeaderKey

func HeaderKey(number uint64, hash types.Hash) []byte

HeaderKey = num (uint64 big endian) + hash

func LogKey

func LogKey(blockNumber uint64, txId uint32) []byte

LogKey = blockN (uint64 big endian) + txId (uint32 big endian)

func PlainGenerateCompositeStorageKey

func PlainGenerateCompositeStorageKey(address []byte, incarnation uint16, key []byte) []byte

AddrHash + incarnation + KeyHash For contract storage (for plain state)

func PlainGenerateStoragePrefix

func PlainGenerateStoragePrefix(address []byte, incarnation uint16) []byte

address hash + incarnation prefix (for plain state)

func PlainParseCompositeStorageKey

func PlainParseCompositeStorageKey(compositeKey []byte) (types.Address, uint16, types.Hash)

func PlainParseStoragePrefix

func PlainParseStoragePrefix(prefix []byte) (types.Address, uint16)

func StorageIndexChunkKey

func StorageIndexChunkKey(key []byte, blockNumber uint64) []byte

Types

This section is empty.

Directories

Path Synopsis
event
v2
rpc
Package state provides a caching layer atop the Ethereum state trie.
Package state provides a caching layer atop the Ethereum state trie.

Jump to

Keyboard shortcuts

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