rawdb

package
v0.0.0-...-92d349b Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SnapshotsHistoryKey = []byte("snapshots_history")
View Source
var SnapshotsKey = []byte("snapshots")

Functions

func AppendReceipts

func AppendReceipts(tx kv.StatelessWriteTx, blockNumber uint64, receipts types.Receipts) error

AppendReceipts stores all the transaction receipts belonging to a block.

func CanonicalBlockByNumberWithSenders

func CanonicalBlockByNumberWithSenders(db kv.Tx, number uint64) (*types.Block, []libcommon.Address, error)

func CanonicalTransactions

func CanonicalTransactions(db kv.Getter, baseTxId uint64, amount uint32) ([]types.Transaction, error)

func CanonicalTxnByID

func CanonicalTxnByID(db kv.Getter, id uint64, blockHash libcommon.Hash, transactionsV3 bool) (types.Transaction, error)

func DeleteAncientBlocks

func DeleteAncientBlocks(tx kv.RwTx, blockTo uint64, blocksDeleteLimit int) error

DeleteAncientBlocks - delete [1, to) old blocks after moving it to snapshots. keeps genesis in db: [1, to) doesn't change sequences of kv.EthTx and kv.NonCanonicalTxs doesn't delete Receipts, Senders, Canonical markers, TotalDifficulty

func DeleteChainConfig

func DeleteChainConfig(db kv.Deleter, hash libcommon.Hash) error

DeleteChainConfig retrieves the consensus settings based on the given genesis hash.

func DeleteHeaderNumber

func DeleteHeaderNumber(db kv.Deleter, hash libcommon.Hash)

DeleteHeaderNumber removes hash->number mapping.

func DeleteNewerEpochs

func DeleteNewerEpochs(tx kv.RwTx, number uint64) error

func DeleteTransactions

func DeleteTransactions(db kv.RwTx, txsCount, baseTxId uint64, blockHash *libcommon.Hash) error

func DeleteTxLookupEntry

func DeleteTxLookupEntry(db kv.Deleter, hash libcommon.Hash) error

DeleteTxLookupEntry removes all transaction data associated with a hash.

func FindEpochBeforeOrEqualNumber

func FindEpochBeforeOrEqualNumber(tx kv.Tx, n uint64) (blockNum uint64, blockHash libcommon.Hash, transitionProof []byte, err error)

func GetStateVersion

func GetStateVersion(tx kv.Tx) (uint64, error)

func HasBlock

func HasBlock(db kv.Getter, hash libcommon.Hash, number uint64) bool

HasBlock - is more efficient than ReadBlock because doesn't read transactions. It's is not equivalent of HasHeader because headers and bodies written by different stages

func HasBorReceipts

func HasBorReceipts(db kv.Has, number uint64) bool

HasBorReceipt verifies the existence of all block receipt belonging to a block.

func HasHeader

func HasHeader(db kv.Has, hash libcommon.Hash, number uint64) bool

HasHeader verifies the existence of a block header corresponding to the hash.

func HasReceipts

func HasReceipts(db kv.Has, hash libcommon.Hash, number uint64) bool

HasReceipts verifies the existence of all the transaction receipts belonging to a block.

func IncrementStateVersion

func IncrementStateVersion(tx kv.RwTx) (uint64, error)

func IsCanonicalHash

func IsCanonicalHash(db kv.Getter, hash libcommon.Hash) (bool, error)

IsCanonicalHash determines whether a header with the given hash is on the canonical chain.

func IsPosBlock

func IsPosBlock(db kv.Getter, blockHash libcommon.Hash) (trans bool, err error)

IsPosBlock returns true if the block number comes after POS transition or is the last POW block

func MakeBodiesCanonical

func MakeBodiesCanonical(tx kv.RwTx, from uint64, ctx context.Context, logPrefix string, logEvery *time.Ticker, transactionsV3 bool, cb func(blockNum, lastTxnNum uint64) error) error

MakeBodiesCanonical - move all txs of non-canonical blocks from NonCanonicalTxs table to EthTx table

func MakeBodiesNonCanonical

func MakeBodiesNonCanonical(tx kv.RwTx, from uint64, deleteBodies bool, ctx context.Context, logPrefix string, logEvery *time.Ticker) error

MakeBodiesNonCanonical - move all txs of canonical blocks to NonCanonicalTxs bucket

func NonCanonicalBlockWithSenders

func NonCanonicalBlockWithSenders(tx kv.Getter, hash libcommon.Hash, number uint64) (*types.Block, []libcommon.Address, error)

func NonCanonicalBodyRLP

func NonCanonicalBodyRLP(db kv.Tx, hash libcommon.Hash, number uint64) rlp.RawValue

func NonCanonicalBodyWithTransactions

func NonCanonicalBodyWithTransactions(db kv.Getter, hash libcommon.Hash, number uint64) *types.Body

func NonCanonicalTransactions

func NonCanonicalTransactions(db kv.Getter, baseTxId uint64, amount uint32) ([]types.Transaction, error)

func PruneTable

func PruneTable(tx kv.RwTx, table string, pruneTo uint64, ctx context.Context, limit int) error

PruneTable has `limit` parameter to avoid too large data deletes per one sync cycle - better delete by small portions to reduce db.FreeList size

func PruneTableDupSort

func PruneTableDupSort(tx kv.RwTx, table string, logPrefix string, pruneTo uint64, logEvery *time.Ticker, ctx context.Context) error

func RawTransactionsRange

func RawTransactionsRange(db kv.Getter, from, to uint64) (res [][]byte, err error)

func ReadAccount

func ReadAccount(db kv.Tx, addr libcommon.Address, acc *accounts.Account) (bool, error)

func ReadAncestor

func ReadAncestor(db kv.Getter, hash libcommon.Hash, number, ancestor uint64, maxNonCanonical *uint64, blockReader services.HeaderAndCanonicalReader) (libcommon.Hash, uint64)

func ReadBlock

func ReadBlock(tx kv.Getter, hash libcommon.Hash, number uint64) *types.Block

ReadBlock retrieves an entire block corresponding to the hash, assembling it back from the stored header and body. If either the header or body could not be retrieved nil is returned.

Note, due to concurrent download of header and block body the header and thus canonical hash can be stored in the database but the body data not (yet).

func ReadBlockByHash

func ReadBlockByHash(db kv.Tx, hash libcommon.Hash) (*types.Block, error)

func ReadBlockByNumber

func ReadBlockByNumber(db kv.Tx, number uint64) (*types.Block, error)

func ReadBlockWithSenders

func ReadBlockWithSenders(db kv.Getter, hash libcommon.Hash, number uint64) (*types.Block, []libcommon.Address, error)

func ReadBody

func ReadBody(db kv.Getter, hash libcommon.Hash, number uint64) (*types.Body, uint64, uint32)

func ReadBodyByNumber

func ReadBodyByNumber(db kv.Tx, number uint64) (*types.Body, uint64, uint32, error)

ReadBodyByNumber - returns canonical block body

func ReadBodyForStorageByKey

func ReadBodyForStorageByKey(db kv.Getter, k []byte) (*types.BodyForStorage, error)

func ReadBodyRLP

func ReadBodyRLP(db kv.Tx, hash libcommon.Hash, number uint64) rlp.RawValue

ReadBodyRLP retrieves the block body (transactions and uncles) in RLP encoding.

func ReadBodyWithTransactions

func ReadBodyWithTransactions(db kv.Getter, hash libcommon.Hash, number uint64) (*types.Body, error)

func ReadBorReceipt

func ReadBorReceipt(db kv.Tx, blockHash libcommon.Hash, blockNumber uint64, receipts types.Receipts) (*types.Receipt, error)

func ReadBorTransaction

func ReadBorTransaction(db kv.Tx, borTxHash libcommon.Hash) (types.Transaction, libcommon.Hash, uint64, uint64, error)

ReadBorTransaction returns a specific bor (fake) transaction by txn hash, along with its added positional metadata.

func ReadBorTransactionForBlock

func ReadBorTransactionForBlock(db kv.Tx, block *types.Block) (types.Transaction, libcommon.Hash, uint64, uint64)

ReadBorTransactionForBlock retrieves a specific bor (fake) transaction associated with a block, along with its added positional metadata.

func ReadBorTransactionForBlockNumber

func ReadBorTransactionForBlockNumber(db kv.Tx, blockNumber uint64) (types.Transaction, libcommon.Hash, uint64, uint64, error)

ReadBorTransactionForBlockNumber returns a bor (fake) transaction by block number, along with its added positional metadata.

func ReadBorTransactionForBlockNumberAndHash

func ReadBorTransactionForBlockNumberAndHash(db kv.Tx, blockNumber uint64, blockHash libcommon.Hash) (types.Transaction, libcommon.Hash, uint64, uint64, error)

ReadBorTransactionForBlockNumberAndHash returns a bor (fake) transaction by block number and block hash, along with its added positional metadata.

func ReadBorTxLookupEntry

func ReadBorTxLookupEntry(db kv.Tx, borTxHash libcommon.Hash) (*uint64, error)

func ReadCanonicalBodyWithTransactions

func ReadCanonicalBodyWithTransactions(db kv.Getter, hash libcommon.Hash, number uint64) *types.Body

func ReadCanonicalHash

func ReadCanonicalHash(db kv.Getter, number uint64) (libcommon.Hash, error)

ReadCanonicalHash retrieves the hash assigned to a canonical block number.

func ReadChainConfig

func ReadChainConfig(db kv.Getter, hash libcommon.Hash) (*chain.Config, error)

ReadChainConfig retrieves the consensus settings based on the given genesis hash.

func ReadCumulativeGasUsed

func ReadCumulativeGasUsed(db kv.Getter, number uint64) (*big.Int, error)

func ReadCurrentBlock

func ReadCurrentBlock(db kv.Tx) *types.Block

func ReadCurrentBlockNumber

func ReadCurrentBlockNumber(db kv.Getter) *uint64

func ReadCurrentHeader

func ReadCurrentHeader(db kv.Getter) *types.Header

func ReadEpoch

func ReadEpoch(tx kv.Tx, blockNum uint64, blockHash libcommon.Hash) (transitionProof []byte, err error)

func ReadForkchoiceFinalized

func ReadForkchoiceFinalized(db kv.Getter) libcommon.Hash

ReadForkchoiceFinalized retrieves finalizedBlockHash from the last Engine API forkChoiceUpdated.

func ReadForkchoiceHead

func ReadForkchoiceHead(db kv.Getter) libcommon.Hash

ReadForkchoiceHead retrieves headBlockHash from the last Engine API forkChoiceUpdated.

func ReadForkchoiceSafe

func ReadForkchoiceSafe(db kv.Getter) libcommon.Hash

ReadForkchoiceSafe retrieves safeBlockHash from the last Engine API forkChoiceUpdated.

func ReadHeadBlockHash

func ReadHeadBlockHash(db kv.Getter) libcommon.Hash

ReadHeadBlockHash retrieves the hash of the current canonical head block.

func ReadHeadHeaderHash

func ReadHeadHeaderHash(db kv.Getter) libcommon.Hash

ReadHeadHeaderHash retrieves the hash of the current canonical head header.

func ReadHeader

func ReadHeader(db kv.Getter, hash libcommon.Hash, number uint64) *types.Header

ReadHeader retrieves the block header corresponding to the hash.

func ReadHeaderByHash

func ReadHeaderByHash(db kv.Getter, hash libcommon.Hash) (*types.Header, error)

func ReadHeaderByNumber

func ReadHeaderByNumber(db kv.Getter, number uint64) *types.Header

func ReadHeaderNumber

func ReadHeaderNumber(db kv.Getter, hash libcommon.Hash) *uint64

ReadHeaderNumber returns the header number assigned to a hash.

func ReadHeaderRLP

func ReadHeaderRLP(db kv.Getter, hash libcommon.Hash, number uint64) rlp.RawValue

ReadHeaderRLP retrieves a block header in its raw RLP database encoding.

func ReadHeadersByNumber

func ReadHeadersByNumber(db kv.Tx, number uint64) ([]*types.Header, error)

func ReadLastBlockSynced

func ReadLastBlockSynced(db kv.Tx) (*types.Block, error)

func ReadPendingEpoch

func ReadPendingEpoch(tx kv.Tx, blockNum uint64, blockHash libcommon.Hash) (transitionProof []byte, err error)

func ReadRawBorReceipt

func ReadRawBorReceipt(db kv.Tx, number uint64) (*types.Receipt, bool, error)

func ReadRawReceipts

func ReadRawReceipts(db kv.Tx, blockNum uint64) types.Receipts

ReadRawReceipts retrieves all the transaction receipts belonging to a block. The receipt metadata fields are not guaranteed to be populated, so they should not be used. Use ReadReceipts instead if the metadata is needed.

func ReadReceipt

func ReadReceipt(db kv.Tx, txHash libcommon.Hash) (*types.Receipt, libcommon.Hash, uint64, uint64, error)

func ReadReceipts

func ReadReceipts(db kv.Tx, block *types.Block, senders []libcommon.Address) types.Receipts

ReadReceipts retrieves all the transaction receipts belonging to a block, including its corresponding metadata fields. If it is unable to populate these metadata fields then nil is returned.

The current implementation populates these metadata fields by reading the receipts' corresponding block body, so if the block body is not found it will return nil even if the receipt itself is stored.

func ReadReceiptsByHash

func ReadReceiptsByHash(db kv.Tx, hash libcommon.Hash) (types.Receipts, error)

func ReadSenders

func ReadSenders(db kv.Getter, hash libcommon.Hash, number uint64) ([]libcommon.Address, error)

func ReadSnapshots

func ReadSnapshots(tx kv.Tx) ([]string, []string, error)

func ReadStorageBody

func ReadStorageBody(db kv.Getter, hash libcommon.Hash, number uint64) (types.BodyForStorage, error)

func ReadStorageBodyRLP

func ReadStorageBodyRLP(db kv.Getter, hash libcommon.Hash, number uint64) rlp.RawValue

func ReadTd

func ReadTd(db kv.Getter, hash libcommon.Hash, number uint64) (*big.Int, error)

ReadTd retrieves a block's total difficulty corresponding to the hash.

func ReadTdByHash

func ReadTdByHash(db kv.Getter, hash libcommon.Hash) (*big.Int, error)

func ReadTotalBurnt

func ReadTotalBurnt(db kv.Getter, number uint64) (*big.Int, error)

func ReadTotalIssued

func ReadTotalIssued(db kv.Getter, number uint64) (*big.Int, error)

func ReadTransaction

func ReadTransaction(db kv.Tx, hash libcommon.Hash, blockNumber uint64) (types.Transaction, libcommon.Hash, uint64, uint64, error)

ReadTransaction retrieves a specific transaction from the database, along with its added positional metadata.

func ReadTransactionByHash

func ReadTransactionByHash(db kv.Tx, hash libcommon.Hash) (types.Transaction, libcommon.Hash, uint64, uint64, error)

ReadTransactionByHash retrieves a specific transaction from the database, along with its added positional metadata.

func ReadTxLookupEntry

func ReadTxLookupEntry(db kv.Getter, txnHash libcommon.Hash) (*uint64, error)

ReadTxLookupEntry retrieves the positional metadata associated with a transaction hash to allow retrieving the transaction or receipt by hash.

func ReadVerkleNode

func ReadVerkleNode(tx kv.RwTx, root libcommon.Hash) (verkle.VerkleNode, error)

func ReadVerkleRoot

func ReadVerkleRoot(tx kv.Tx, blockNum uint64) (libcommon.Hash, error)

func ReceiptsAvailableFrom

func ReceiptsAvailableFrom(tx kv.Tx) (uint64, error)

func ResetSequence

func ResetSequence(tx kv.RwTx, bucket string, newValue uint64) error

ResetSequence - allow set arbitrary value to sequence (for example to decrement it to exact value)

func Transitioned

func Transitioned(db kv.Getter, blockNum uint64, terminalTotalDifficulty *big.Int) (trans bool, err error)

Transitioned returns true if the block number comes after POS transition or is the last POW block

func TruncateBlocks

func TruncateBlocks(ctx context.Context, tx kv.RwTx, blockFrom uint64) error

TruncateBlocks - delete block >= blockFrom does decrement sequences of kv.EthTx and kv.NonCanonicalTxs doesn't delete Receipts, Senders, Canonical markers, TotalDifficulty

func TruncateBodies

func TruncateBodies(tx kv.RwTx, blockNum uint64) error

func TruncateBorReceipts

func TruncateBorReceipts(db kv.RwTx, number uint64) error

TruncateBorReceipts removes all bor receipt for given block number or newer

func TruncateCanonicalHash

func TruncateCanonicalHash(tx kv.RwTx, blockFrom uint64, deleteHeaders bool) error

TruncateCanonicalHash removes all the number to hash canonical mapping from block number N

func TruncateReceipts

func TruncateReceipts(db kv.RwTx, number uint64) error

TruncateReceipts removes all receipt for given block number or newer

func TruncateTd

func TruncateTd(tx kv.RwTx, blockFrom uint64) error

TruncateTd removes all block total difficulty from block number N

func WriteBlock

func WriteBlock(db kv.RwTx, block *types.Block) error

WriteBlock serializes a block into the database, header and body separately.

func WriteBody

func WriteBody(db kv.RwTx, hash libcommon.Hash, number uint64, body *types.Body) error

func WriteBodyForStorage

func WriteBodyForStorage(db kv.Putter, hash libcommon.Hash, number uint64, body *types.BodyForStorage) error

WriteBodyForStorage stores an RLP encoded block body into the database.

func WriteBorReceipt

func WriteBorReceipt(tx kv.RwTx, hash libcommon.Hash, number uint64, borReceipt *types.Receipt) error

WriteBorReceipt stores all the bor receipt belonging to a block (storing the state sync recipt and log).

func WriteCanonicalHash

func WriteCanonicalHash(db kv.Putter, hash libcommon.Hash, number uint64) error

WriteCanonicalHash stores the hash assigned to a canonical block number.

func WriteChainConfig

func WriteChainConfig(db kv.Putter, hash libcommon.Hash, cfg *chain.Config) error

WriteChainConfig writes the chain config settings to the database.

func WriteCumulativeGasUsed

func WriteCumulativeGasUsed(db kv.Putter, number uint64, cumulativeGasUsed *big.Int) error

func WriteEpoch

func WriteEpoch(tx kv.RwTx, blockNum uint64, blockHash libcommon.Hash, transitionProof []byte) (err error)

func WriteForkchoiceFinalized

func WriteForkchoiceFinalized(db kv.Putter, hash libcommon.Hash)

WriteForkchoiceFinalized stores finalizedBlockHash from the last Engine API forkChoiceUpdated.

func WriteForkchoiceHead

func WriteForkchoiceHead(db kv.Putter, hash libcommon.Hash)

WriteForkchoiceHead stores headBlockHash from the last Engine API forkChoiceUpdated.

func WriteForkchoiceSafe

func WriteForkchoiceSafe(db kv.Putter, hash libcommon.Hash)

WriteForkchoiceSafe stores safeBlockHash from the last Engine API forkChoiceUpdated.

func WriteHeadBlockHash

func WriteHeadBlockHash(db kv.Putter, hash libcommon.Hash)

WriteHeadBlockHash stores the head block's hash.

func WriteHeadHeaderHash

func WriteHeadHeaderHash(db kv.Putter, hash libcommon.Hash) error

WriteHeadHeaderHash stores the hash of the current canonical head header.

func WriteHeader

func WriteHeader(db kv.Putter, header *types.Header)

WriteHeader stores a block header into the database and also stores the hash- to-number mapping.

func WriteHeaderNumber

func WriteHeaderNumber(db kv.Putter, hash libcommon.Hash, number uint64) error

WriteHeaderNumber stores the hash->number mapping.

func WritePendingEpoch

func WritePendingEpoch(tx kv.RwTx, blockNum uint64, blockHash libcommon.Hash, transitionProof []byte) (err error)

func WriteRawBody

func WriteRawBody(db kv.RwTx, hash libcommon.Hash, number uint64, body *types.RawBody) (ok bool, lastTxnID uint64, err error)

func WriteRawBodyIfNotExists

func WriteRawBodyIfNotExists(db kv.RwTx, hash libcommon.Hash, number uint64, body *types.RawBody) (ok bool, lastTxnNum uint64, err error)

func WriteRawTransactions

func WriteRawTransactions(tx kv.RwTx, txs [][]byte, baseTxId uint64, blockHash *common2.Hash) error

func WriteReceipts

func WriteReceipts(tx kv.Putter, number uint64, receipts types.Receipts) error

WriteReceipts stores all the transaction receipts belonging to a block.

func WriteSenders

func WriteSenders(db kv.Putter, hash libcommon.Hash, number uint64, senders []libcommon.Address) error

func WriteSnapshots

func WriteSnapshots(tx kv.RwTx, list, histList []string) error

func WriteTd

func WriteTd(db kv.Putter, hash libcommon.Hash, number uint64, td *big.Int) error

WriteTd stores the total difficulty of a block into the database.

func WriteTotalBurnt

func WriteTotalBurnt(db kv.Putter, number uint64, totalBurnt *big.Int) error

func WriteTotalIssued

func WriteTotalIssued(db kv.Putter, number uint64, totalIssued *big.Int) error

func WriteTransactions

func WriteTransactions(db kv.RwTx, txs []types.Transaction, baseTxId uint64, blockHash *libcommon.Hash) error

func WriteTxLookupEntries

func WriteTxLookupEntries(db kv.Putter, block *types.Block)

WriteTxLookupEntries stores a positional metadata for every transaction from a block, enabling hash based transaction and receipt lookups.

func WriteVerkleNode

func WriteVerkleNode(tx kv.RwTx, node verkle.VerkleNode) error

func WriteVerkleRoot

func WriteVerkleRoot(tx kv.RwTx, blockNum uint64, root libcommon.Hash) error

Types

type TxLookupEntry

type TxLookupEntry struct {
	BlockHash  libcommon.Hash
	BlockIndex uint64
	Index      uint64
}

TxLookupEntry is a positional metadata to help looking up the data content of a transaction or receipt given only its hash.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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