pgstatestorage

package
v0.5.0-RC18 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: AGPL-3.0, AGPL-3.0-or-later Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExecQuerier

type ExecQuerier interface {
	Exec(ctx context.Context, sql string, arguments ...interface{}) (commandTag pgconn.CommandTag, err error)
	Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
	QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row
}

type PostgresStorage

type PostgresStorage struct {
	*pgxpool.Pool
	// contains filtered or unexported fields
}

PostgresStorage implements the Storage interface

func NewPostgresStorage

func NewPostgresStorage(cfg state.Config, db *pgxpool.Pool) *PostgresStorage

NewPostgresStorage creates a new StateDB

func (*PostgresStorage) AddAccumulatedInputHash

func (p *PostgresStorage) AddAccumulatedInputHash(ctx context.Context, batchNum uint64, accInputHash common.Hash, dbTx pgx.Tx) error

AddAccumulatedInputHash adds the accumulated input hash

func (*PostgresStorage) AddBlock

func (p *PostgresStorage) AddBlock(ctx context.Context, block *state.Block, dbTx pgx.Tx) error

AddBlock adds a new block to the State Store

func (*PostgresStorage) AddForcedBatch

func (p *PostgresStorage) AddForcedBatch(ctx context.Context, forcedBatch *state.ForcedBatch, tx pgx.Tx) error

AddForcedBatch adds a new ForcedBatch to the db

func (*PostgresStorage) AddForkID

func (p *PostgresStorage) AddForkID(ctx context.Context, forkID state.ForkIDInterval, dbTx pgx.Tx) error

AddForkID adds a new forkID to the storage

func (*PostgresStorage) AddForkIDInterval

func (p *PostgresStorage) AddForkIDInterval(ctx context.Context, newForkID state.ForkIDInterval, dbTx pgx.Tx) error

AddForkIDInterval updates the forkID intervals

func (*PostgresStorage) AddGeneratedProof

func (p *PostgresStorage) AddGeneratedProof(ctx context.Context, proof *state.Proof, dbTx pgx.Tx) error

AddGeneratedProof adds a generated proof to the storage

func (*PostgresStorage) AddGlobalExitRoot

func (p *PostgresStorage) AddGlobalExitRoot(ctx context.Context, exitRoot *state.GlobalExitRoot, dbTx pgx.Tx) error

AddGlobalExitRoot adds a new ExitRoot to the db

func (*PostgresStorage) AddL1InfoRootToExitRoot

func (p *PostgresStorage) AddL1InfoRootToExitRoot(ctx context.Context, exitRoot *state.L1InfoTreeExitRootStorageEntry, dbTx pgx.Tx) error

AddL1InfoRootToExitRoot adds a new entry in ExitRoot and returns index of L1InfoTree and error

func (*PostgresStorage) AddL2Block

func (p *PostgresStorage) AddL2Block(ctx context.Context, batchNumber uint64, l2Block *state.L2Block, receipts []*types.Receipt, txsEGPData []state.StoreTxEGPData, dbTx pgx.Tx) error

AddL2Block adds a new L2 block to the State Store

func (*PostgresStorage) AddLog

func (p *PostgresStorage) AddLog(ctx context.Context, l *types.Log, dbTx pgx.Tx) error

AddLog adds a new log to the State Store

func (*PostgresStorage) AddLogs

func (p *PostgresStorage) AddLogs(ctx context.Context, logs []*types.Log, dbTx pgx.Tx) error

// AddLogs adds a list of logs to the State Store

func (*PostgresStorage) AddReceipt

func (p *PostgresStorage) AddReceipt(ctx context.Context, receipt *types.Receipt, dbTx pgx.Tx) error

AddReceipt adds a new receipt to the State Store

func (*PostgresStorage) AddReceipts

func (p *PostgresStorage) AddReceipts(ctx context.Context, receipts []*types.Receipt, dbTx pgx.Tx) error

AddReceipts adds a list of receipts to the State Store

func (*PostgresStorage) AddSequence

func (p *PostgresStorage) AddSequence(ctx context.Context, sequence state.Sequence, dbTx pgx.Tx) error

AddSequence stores the sequence information to allow the aggregator verify sequences.

func (*PostgresStorage) AddTrustedReorg

func (p *PostgresStorage) AddTrustedReorg(ctx context.Context, reorg *state.TrustedReorg, dbTx pgx.Tx) error

AddTrustedReorg is used to store trusted reorgs

func (*PostgresStorage) AddVerifiedBatch

func (p *PostgresStorage) AddVerifiedBatch(ctx context.Context, verifiedBatch *state.VerifiedBatch, dbTx pgx.Tx) error

AddVerifiedBatch adds a new VerifiedBatch to the db

func (*PostgresStorage) AddVirtualBatch

func (p *PostgresStorage) AddVirtualBatch(ctx context.Context, virtualBatch *state.VirtualBatch, dbTx pgx.Tx) error

AddVirtualBatch adds a new virtual batch to the storage.

func (*PostgresStorage) BatchNumberByL2BlockNumber

func (p *PostgresStorage) BatchNumberByL2BlockNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (uint64, error)

BatchNumberByL2BlockNumber gets a batch number by a l2 block number

func (*PostgresStorage) BuildChangeL2Block

func (p *PostgresStorage) BuildChangeL2Block(deltaTimestamp uint32, l1InfoTreeIndex uint32) []byte

BuildChangeL2Block returns a changeL2Block tx to use in the BatchL2Data

func (*PostgresStorage) CheckProofContainsCompleteSequences

func (p *PostgresStorage) CheckProofContainsCompleteSequences(ctx context.Context, proof *state.Proof, dbTx pgx.Tx) (bool, error)

CheckProofContainsCompleteSequences checks if a recursive proof contains complete sequences

func (*PostgresStorage) CleanupGeneratedProofs

func (p *PostgresStorage) CleanupGeneratedProofs(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error

CleanupGeneratedProofs deletes from the storage the generated proofs up to the specified batch number included.

func (*PostgresStorage) CleanupLockedProofs

func (p *PostgresStorage) CleanupLockedProofs(ctx context.Context, duration string, dbTx pgx.Tx) (int64, error)

CleanupLockedProofs deletes from the storage the proofs locked in generating state for more than the provided threshold.

func (*PostgresStorage) CloseBatchInStorage

func (p *PostgresStorage) CloseBatchInStorage(ctx context.Context, receipt state.ProcessingReceipt, dbTx pgx.Tx) error

CloseBatchInStorage closes a batch in the state storage

func (*PostgresStorage) CloseWIPBatchInStorage

func (p *PostgresStorage) CloseWIPBatchInStorage(ctx context.Context, receipt state.ProcessingReceipt, dbTx pgx.Tx) error

CloseWIPBatchInStorage is used by sequencer to close the wip batch in the state storage

func (*PostgresStorage) CountReorgs

func (p *PostgresStorage) CountReorgs(ctx context.Context, dbTx pgx.Tx) (uint64, error)

CountReorgs returns the number of reorgs

func (*PostgresStorage) DeleteGeneratedProofs

func (p *PostgresStorage) DeleteGeneratedProofs(ctx context.Context, batchNumber uint64, batchNumberFinal uint64, dbTx pgx.Tx) error

DeleteGeneratedProofs deletes from the storage the generated proofs falling inside the batch numbers range.

func (*PostgresStorage) DeleteUngeneratedProofs

func (p *PostgresStorage) DeleteUngeneratedProofs(ctx context.Context, dbTx pgx.Tx) error

DeleteUngeneratedProofs deletes ungenerated proofs. This method is meant to be use during aggregator boot-up sequence

func (*PostgresStorage) GetAllL1InfoRootEntries

func (p *PostgresStorage) GetAllL1InfoRootEntries(ctx context.Context, dbTx pgx.Tx) ([]state.L1InfoTreeExitRootStorageEntry, error)

func (*PostgresStorage) GetBatchByForcedBatchNum

func (p *PostgresStorage) GetBatchByForcedBatchNum(ctx context.Context, forcedBatchNumber uint64, dbTx pgx.Tx) (*state.Batch, error)

GetBatchByForcedBatchNum returns the batch with the given forced batch number.

func (*PostgresStorage) GetBatchByL2BlockNumber

func (p *PostgresStorage) GetBatchByL2BlockNumber(ctx context.Context, l2BlockNumber uint64, dbTx pgx.Tx) (*state.Batch, error)

GetBatchByL2BlockNumber returns the batch related to the l2 block accordingly to the provided l2 block number.

func (*PostgresStorage) GetBatchByNumber

func (p *PostgresStorage) GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error)

GetBatchByNumber returns the batch with the given number.

func (*PostgresStorage) GetBatchByTxHash

func (p *PostgresStorage) GetBatchByTxHash(ctx context.Context, transactionHash common.Hash, dbTx pgx.Tx) (*state.Batch, error)

GetBatchByTxHash returns the batch including the given tx

func (*PostgresStorage) GetBatchNumberOfL2Block

func (p *PostgresStorage) GetBatchNumberOfL2Block(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (uint64, error)

GetBatchNumberOfL2Block gets a batch number for l2 block by its number

func (*PostgresStorage) GetBlockByNumber

func (p *PostgresStorage) GetBlockByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.Block, error)

GetBlockByNumber returns the L1 block with the given number.

func (*PostgresStorage) GetBlockNumAndMainnetExitRootByGER

func (p *PostgresStorage) GetBlockNumAndMainnetExitRootByGER(ctx context.Context, ger common.Hash, dbTx pgx.Tx) (uint64, common.Hash, error)

GetBlockNumAndMainnetExitRootByGER gets block number and mainnet exit root by the global exit root

func (*PostgresStorage) GetBlockNumVirtualBatchByBatchNum

func (p *PostgresStorage) GetBlockNumVirtualBatchByBatchNum(ctx context.Context, batchNum uint64, dbTx pgx.Tx) (uint64, error)

GetBlockNumVirtualBatchByBatchNum get block num of virtual batch by block num

func (*PostgresStorage) GetDSBatches

func (p *PostgresStorage) GetDSBatches(ctx context.Context, firstBatchNumber, lastBatchNumber uint64, readWIPBatch bool, dbTx pgx.Tx) ([]*state.DSBatch, error)

GetDSBatches returns the DS batches

func (*PostgresStorage) GetDSGenesisBlock

func (p *PostgresStorage) GetDSGenesisBlock(ctx context.Context, dbTx pgx.Tx) (*state.DSL2Block, error)

GetDSGenesisBlock returns the genesis block

func (*PostgresStorage) GetDSL2Blocks

func (p *PostgresStorage) GetDSL2Blocks(ctx context.Context, firstBatchNumber, lastBatchNumber uint64, dbTx pgx.Tx) ([]*state.DSL2Block, error)

GetDSL2Blocks returns the L2 blocks

func (*PostgresStorage) GetDSL2Transactions

func (p *PostgresStorage) GetDSL2Transactions(ctx context.Context, firstL2Block, lastL2Block uint64, dbTx pgx.Tx) ([]*state.DSL2Transaction, error)

GetDSL2Transactions returns the L2 transactions

func (*PostgresStorage) GetEncodedTransactionsByBatchNumber

func (p *PostgresStorage) GetEncodedTransactionsByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (encodedTxs []string, effectivePercentages []uint8, err error)

GetEncodedTransactionsByBatchNumber returns the encoded field of all transactions in the given batch.

func (*PostgresStorage) GetExitRootByGlobalExitRoot

func (p *PostgresStorage) GetExitRootByGlobalExitRoot(ctx context.Context, ger common.Hash, dbTx pgx.Tx) (*state.GlobalExitRoot, error)

GetExitRootByGlobalExitRoot returns the mainnet and rollup exit root given a global exit root number.

func (*PostgresStorage) GetForcedBatch

func (p *PostgresStorage) GetForcedBatch(ctx context.Context, forcedBatchNumber uint64, dbTx pgx.Tx) (*state.ForcedBatch, error)

GetForcedBatch get an L1 forcedBatch.

func (*PostgresStorage) GetForcedBatchParentHash

func (p *PostgresStorage) GetForcedBatchParentHash(ctx context.Context, forcedBatchNumber uint64, dbTx pgx.Tx) (common.Hash, error)

GetForcedBatchParentHash returns the parent hash of the forced batch with the given number and the globalExitRoot.

func (*PostgresStorage) GetForcedBatchesSince

func (p *PostgresStorage) GetForcedBatchesSince(ctx context.Context, forcedBatchNumber, maxBlockNumber uint64, dbTx pgx.Tx) ([]*state.ForcedBatch, error)

GetForcedBatchesSince gets L1 forced batches since forcedBatchNumber

func (*PostgresStorage) GetForkIDByBatchNumber

func (p *PostgresStorage) GetForkIDByBatchNumber(batchNumber uint64) uint64

GetForkIDByBatchNumber returns the fork id for a given batch number

func (*PostgresStorage) GetForkIDByBlockNumber

func (p *PostgresStorage) GetForkIDByBlockNumber(blockNumber uint64) uint64

GetForkIDByBlockNumber returns the fork id for a given block number

func (*PostgresStorage) GetForkIDs

func (p *PostgresStorage) GetForkIDs(ctx context.Context, dbTx pgx.Tx) ([]state.ForkIDInterval, error)

GetForkIDs get all the forkIDs stored

func (*PostgresStorage) GetL1InfoRootLeafByIndex

func (p *PostgresStorage) GetL1InfoRootLeafByIndex(ctx context.Context, l1InfoTreeIndex uint32, dbTx pgx.Tx) (state.L1InfoTreeExitRootStorageEntry, error)

func (*PostgresStorage) GetL1InfoRootLeafByL1InfoRoot

func (p *PostgresStorage) GetL1InfoRootLeafByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) (state.L1InfoTreeExitRootStorageEntry, error)

func (*PostgresStorage) GetL2BlockByHash

func (p *PostgresStorage) GetL2BlockByHash(ctx context.Context, hash common.Hash, dbTx pgx.Tx) (*state.L2Block, error)

GetL2BlockByHash gets a l2 block from its hash

func (*PostgresStorage) GetL2BlockByNumber

func (p *PostgresStorage) GetL2BlockByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.L2Block, error)

GetL2BlockByNumber gets a l2 block by its number

func (*PostgresStorage) GetL2BlockHashesSince

func (p *PostgresStorage) GetL2BlockHashesSince(ctx context.Context, since time.Time, dbTx pgx.Tx) ([]common.Hash, error)

GetL2BlockHashesSince gets the block hashes added since the provided date

func (*PostgresStorage) GetL2BlockHeaderByHash

func (p *PostgresStorage) GetL2BlockHeaderByHash(ctx context.Context, hash common.Hash, dbTx pgx.Tx) (*state.L2Header, error)

GetL2BlockHeaderByHash gets the block header by block number

func (*PostgresStorage) GetL2BlockHeaderByNumber

func (p *PostgresStorage) GetL2BlockHeaderByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.L2Header, error)

GetL2BlockHeaderByNumber gets the block header by block number

func (*PostgresStorage) GetL2BlockTransactionCountByHash

func (p *PostgresStorage) GetL2BlockTransactionCountByHash(ctx context.Context, blockHash common.Hash, dbTx pgx.Tx) (uint64, error)

GetL2BlockTransactionCountByHash returns the number of transactions related to the provided block hash

func (*PostgresStorage) GetL2BlockTransactionCountByNumber

func (p *PostgresStorage) GetL2BlockTransactionCountByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (uint64, error)

GetL2BlockTransactionCountByNumber returns the number of transactions related to the provided block number

func (*PostgresStorage) GetL2BlocksByBatchNumber

func (p *PostgresStorage) GetL2BlocksByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) ([]state.L2Block, error)

GetL2BlocksByBatchNumber get all blocks associated to a batch accordingly to the provided batch number

func (*PostgresStorage) GetLastBatchNumber

func (p *PostgresStorage) GetLastBatchNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)

GetLastBatchNumber get last trusted batch number

func (*PostgresStorage) GetLastBatchTime

func (p *PostgresStorage) GetLastBatchTime(ctx context.Context, dbTx pgx.Tx) (time.Time, error)

GetLastBatchTime gets last trusted batch time

func (*PostgresStorage) GetLastBlock

func (p *PostgresStorage) GetLastBlock(ctx context.Context, dbTx pgx.Tx) (*state.Block, error)

GetLastBlock returns the last L1 block.

func (*PostgresStorage) GetLastClosedBatch

func (p *PostgresStorage) GetLastClosedBatch(ctx context.Context, dbTx pgx.Tx) (*state.Batch, error)

GetLastClosedBatch returns the latest closed batch

func (*PostgresStorage) GetLastClosedBatchNumber

func (p *PostgresStorage) GetLastClosedBatchNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)

GetLastClosedBatchNumber returns the latest closed batch

func (*PostgresStorage) GetLastConsolidatedL2BlockNumber

func (p *PostgresStorage) GetLastConsolidatedL2BlockNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)

GetLastConsolidatedL2BlockNumber gets the last l2 block verified

func (*PostgresStorage) GetLastL2Block

func (p *PostgresStorage) GetLastL2Block(ctx context.Context, dbTx pgx.Tx) (*state.L2Block, error)

GetLastL2Block retrieves the latest L2 Block from the State data base

func (*PostgresStorage) GetLastL2BlockCreatedAt

func (p *PostgresStorage) GetLastL2BlockCreatedAt(ctx context.Context, dbTx pgx.Tx) (*time.Time, error)

GetLastL2BlockCreatedAt gets the timestamp of the last l2 block

func (*PostgresStorage) GetLastL2BlockHeader

func (p *PostgresStorage) GetLastL2BlockHeader(ctx context.Context, dbTx pgx.Tx) (*state.L2Header, error)

GetLastL2BlockHeader gets the last l2 block number

func (*PostgresStorage) GetLastL2BlockNumber

func (p *PostgresStorage) GetLastL2BlockNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)

GetLastL2BlockNumber gets the last l2 block number

func (*PostgresStorage) GetLastNBatches

func (p *PostgresStorage) GetLastNBatches(ctx context.Context, numBatches uint, dbTx pgx.Tx) ([]*state.Batch, error)

GetLastNBatches returns the last numBatches batches.

func (*PostgresStorage) GetLastNBatchesByL2BlockNumber

func (p *PostgresStorage) GetLastNBatchesByL2BlockNumber(ctx context.Context, l2BlockNumber *uint64, numBatches uint, dbTx pgx.Tx) ([]*state.Batch, common.Hash, error)

GetLastNBatchesByL2BlockNumber returns the last numBatches batches along with the l2 block state root by l2BlockNumber if the l2BlockNumber parameter is nil, it means we want to get the most recent last N batches

func (*PostgresStorage) GetLastTrustedForcedBatchNumber

func (p *PostgresStorage) GetLastTrustedForcedBatchNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)

GetLastTrustedForcedBatchNumber get last trusted forced batch number

func (*PostgresStorage) GetLastVerifiedBatch

func (p *PostgresStorage) GetLastVerifiedBatch(ctx context.Context, dbTx pgx.Tx) (*state.VerifiedBatch, error)

GetLastVerifiedBatch gets last verified batch

func (*PostgresStorage) GetLastVerifiedBatchNumberUntilL1Block

func (p *PostgresStorage) GetLastVerifiedBatchNumberUntilL1Block(ctx context.Context, l1BlockNumber uint64, dbTx pgx.Tx) (uint64, error)

GetLastVerifiedBatchNumberUntilL1Block gets the last batch number that was verified in or before the provided l1 block number. This is used to identify if a batch is safe or finalized.

func (*PostgresStorage) GetLastVerifiedL2BlockNumberUntilL1Block

func (p *PostgresStorage) GetLastVerifiedL2BlockNumberUntilL1Block(ctx context.Context, l1FinalizedBlockNumber uint64, dbTx pgx.Tx) (uint64, error)

GetLastVerifiedL2BlockNumberUntilL1Block gets the last block number that was verified in or before the provided l1 block number. This is used to identify if a l2 block is safe or finalized.

func (*PostgresStorage) GetLastVirtualBatchNum

func (p *PostgresStorage) GetLastVirtualBatchNum(ctx context.Context, dbTx pgx.Tx) (uint64, error)

GetLastVirtualBatchNum gets last virtual batch num

func (*PostgresStorage) GetLastVirtualizedL2BlockNumber

func (p *PostgresStorage) GetLastVirtualizedL2BlockNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)

GetLastVirtualizedL2BlockNumber gets the last l2 block virtualized

func (*PostgresStorage) GetLatestBatchGlobalExitRoot

func (p *PostgresStorage) GetLatestBatchGlobalExitRoot(ctx context.Context, dbTx pgx.Tx) (common.Hash, error)

GetLatestBatchGlobalExitRoot gets the last GER that is not zero from batches

func (*PostgresStorage) GetLatestGer

func (p *PostgresStorage) GetLatestGer(ctx context.Context, maxBlockNumber uint64) (state.GlobalExitRoot, time.Time, error)

GetLatestGer is used to get the latest ger

func (*PostgresStorage) GetLatestGlobalExitRoot

func (p *PostgresStorage) GetLatestGlobalExitRoot(ctx context.Context, maxBlockNumber uint64, dbTx pgx.Tx) (state.GlobalExitRoot, time.Time, error)

GetLatestGlobalExitRoot get the latest global ExitRoot synced.

func (*PostgresStorage) GetLatestIndex

func (p *PostgresStorage) GetLatestIndex(ctx context.Context, dbTx pgx.Tx) (uint32, error)

func (*PostgresStorage) GetLatestL1InfoRoot

func (p *PostgresStorage) GetLatestL1InfoRoot(ctx context.Context, maxBlockNumber uint64) (state.L1InfoTreeExitRootStorageEntry, error)

GetLatestL1InfoRoot is used to get the latest L1InfoRoot

func (*PostgresStorage) GetLatestVirtualBatchTimestamp

func (p *PostgresStorage) GetLatestVirtualBatchTimestamp(ctx context.Context, dbTx pgx.Tx) (time.Time, error)

GetLatestVirtualBatchTimestamp gets last virtual batch timestamp

func (*PostgresStorage) GetLeafsByL1InfoRoot

func (p *PostgresStorage) GetLeafsByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) ([]state.L1InfoTreeExitRootStorageEntry, error)

func (*PostgresStorage) GetLocalExitRootByBatchNumber

func (p *PostgresStorage) GetLocalExitRootByBatchNumber(ctx context.Context, batchNum uint64, dbTx pgx.Tx) (common.Hash, error)

GetLocalExitRootByBatchNumber get local exit root by batch number

func (*PostgresStorage) GetLogs

func (p *PostgresStorage) GetLogs(ctx context.Context, fromBlock uint64, toBlock uint64, addresses []common.Address, topics [][]common.Hash, blockHash *common.Hash, since *time.Time, dbTx pgx.Tx) ([]*types.Log, error)

GetLogs returns the logs that match the filter

func (*PostgresStorage) GetLogsByBlockNumber

func (p *PostgresStorage) GetLogsByBlockNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) ([]*types.Log, error)

GetLogsByBlockNumber get all the logs from a specific block ordered by log index

func (*PostgresStorage) GetNativeBlockHashesInRange

func (p *PostgresStorage) GetNativeBlockHashesInRange(ctx context.Context, fromBlock, toBlock uint64, dbTx pgx.Tx) ([]common.Hash, error)

GetNativeBlockHashesInRange return the state root for the blocks in range

func (*PostgresStorage) GetNextForcedBatches

func (p *PostgresStorage) GetNextForcedBatches(ctx context.Context, nextForcedBatches int, dbTx pgx.Tx) ([]state.ForcedBatch, error)

GetNextForcedBatches gets the next forced batches from the queue.

func (*PostgresStorage) GetNumberOfBlocksSinceLastGERUpdate

func (p *PostgresStorage) GetNumberOfBlocksSinceLastGERUpdate(ctx context.Context, dbTx pgx.Tx) (uint64, error)

GetNumberOfBlocksSinceLastGERUpdate gets number of blocks since last global exit root update

func (*PostgresStorage) GetPreviousBlock

func (p *PostgresStorage) GetPreviousBlock(ctx context.Context, offset uint64, dbTx pgx.Tx) (*state.Block, error)

GetPreviousBlock gets the offset previous L1 block respect to latest.

func (*PostgresStorage) GetProcessingContext

func (p *PostgresStorage) GetProcessingContext(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.ProcessingContext, error)

GetProcessingContext returns the processing context for the given batch.

func (*PostgresStorage) GetProofReadyToVerify

func (p *PostgresStorage) GetProofReadyToVerify(ctx context.Context, lastVerfiedBatchNumber uint64, dbTx pgx.Tx) (*state.Proof, error)

GetProofReadyToVerify return the proof that is ready to verify

func (*PostgresStorage) GetProofsToAggregate

func (p *PostgresStorage) GetProofsToAggregate(ctx context.Context, dbTx pgx.Tx) (*state.Proof, *state.Proof, error)

GetProofsToAggregate return the next to proof that it is possible to aggregate

func (*PostgresStorage) GetRawBatchTimestamps

func (p *PostgresStorage) GetRawBatchTimestamps(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*time.Time, *time.Time, error)

GetRawBatchTimestamps returns the timestamp of the batch with the given number. it returns batch_num.tstamp and virtual_batch.batch_timestamp

func (*PostgresStorage) GetReorgedTransactions

func (p *PostgresStorage) GetReorgedTransactions(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) ([]*types.Transaction, error)

GetReorgedTransactions returns the transactions that were reorged

func (*PostgresStorage) GetSequences

func (p *PostgresStorage) GetSequences(ctx context.Context, lastVerifiedBatchNumber uint64, dbTx pgx.Tx) ([]state.Sequence, error)

GetSequences get the next sequences higher than an specify batch number

func (*PostgresStorage) GetStateRootByBatchNumber

func (p *PostgresStorage) GetStateRootByBatchNumber(ctx context.Context, batchNum uint64, dbTx pgx.Tx) (common.Hash, error)

GetStateRootByBatchNumber get state root by batch number

func (*PostgresStorage) GetSyncingInfo

func (p *PostgresStorage) GetSyncingInfo(ctx context.Context, dbTx pgx.Tx) (state.SyncingInfo, error)

GetSyncingInfo returns information regarding the syncing status of the node

func (*PostgresStorage) GetTimeForLatestBatchVirtualization

func (p *PostgresStorage) GetTimeForLatestBatchVirtualization(ctx context.Context, dbTx pgx.Tx) (time.Time, error)

GetTimeForLatestBatchVirtualization returns the timestamp of the latest virtual batch.

func (*PostgresStorage) GetTransactionByHash

func (p *PostgresStorage) GetTransactionByHash(ctx context.Context, transactionHash common.Hash, dbTx pgx.Tx) (*types.Transaction, error)

GetTransactionByHash gets a transaction accordingly to the provided transaction hash

func (*PostgresStorage) GetTransactionByL2BlockHashAndIndex

func (p *PostgresStorage) GetTransactionByL2BlockHashAndIndex(ctx context.Context, blockHash common.Hash, index uint64, dbTx pgx.Tx) (*types.Transaction, error)

GetTransactionByL2BlockHashAndIndex gets a transaction accordingly to the block hash and transaction index provided. since we only have a single transaction per l2 block, any index different from 0 will return a not found result

func (*PostgresStorage) GetTransactionByL2BlockNumberAndIndex

func (p *PostgresStorage) GetTransactionByL2BlockNumberAndIndex(ctx context.Context, blockNumber uint64, index uint64, dbTx pgx.Tx) (*types.Transaction, error)

GetTransactionByL2BlockNumberAndIndex gets a transaction accordingly to the block number and transaction index provided. since we only have a single transaction per l2 block, any index different from 0 will return a not found result

func (*PostgresStorage) GetTransactionByL2Hash

func (p *PostgresStorage) GetTransactionByL2Hash(ctx context.Context, l2TxHash common.Hash, dbTx pgx.Tx) (*types.Transaction, error)

GetTransactionByL2Hash gets a transaction accordingly to the provided transaction l2 hash

func (*PostgresStorage) GetTransactionEGPLogByHash

func (p *PostgresStorage) GetTransactionEGPLogByHash(ctx context.Context, transactionHash common.Hash, dbTx pgx.Tx) (*state.EffectiveGasPriceLog, error)

GetTransactionEGPLogByHash gets the EGP log accordingly to the provided transaction hash

func (*PostgresStorage) GetTransactionReceipt

func (p *PostgresStorage) GetTransactionReceipt(ctx context.Context, transactionHash common.Hash, dbTx pgx.Tx) (*types.Receipt, error)

GetTransactionReceipt gets a transaction receipt accordingly to the provided transaction hash

func (*PostgresStorage) GetTransactionsByBatchNumber

func (p *PostgresStorage) GetTransactionsByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (txs []types.Transaction, effectivePercentages []uint8, err error)

GetTransactionsByBatchNumber returns the transactions in the given batch.

func (*PostgresStorage) GetTxsByBatchNumber

func (p *PostgresStorage) GetTxsByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) ([]*types.Transaction, error)

GetTxsByBatchNumber returns all the txs in a given batch

func (*PostgresStorage) GetTxsByBlockNumber

func (p *PostgresStorage) GetTxsByBlockNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) ([]*types.Transaction, error)

GetTxsByBlockNumber returns all the txs in a given block

func (*PostgresStorage) GetTxsHashesByBatchNumber

func (p *PostgresStorage) GetTxsHashesByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (encoded []common.Hash, err error)

GetTxsHashesByBatchNumber returns the hashes of the transactions in the given batch.

func (*PostgresStorage) GetTxsOlderThanNL1Blocks

func (p *PostgresStorage) GetTxsOlderThanNL1Blocks(ctx context.Context, nL1Blocks uint64, dbTx pgx.Tx) ([]common.Hash, error)

GetTxsOlderThanNL1Blocks get txs hashes to delete from tx pool

func (*PostgresStorage) GetVerifiedBatch

func (p *PostgresStorage) GetVerifiedBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.VerifiedBatch, error)

GetVerifiedBatch get an L1 verifiedBatch.

func (*PostgresStorage) GetVirtualBatch

func (p *PostgresStorage) GetVirtualBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.VirtualBatch, error)

GetVirtualBatch get an L1 virtualBatch.

func (*PostgresStorage) GetVirtualBatchByNumber

func (p *PostgresStorage) GetVirtualBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error)

GetVirtualBatchByNumber gets batch from batch table that exists on virtual batch

func (*PostgresStorage) GetVirtualBatchParentHash

func (p *PostgresStorage) GetVirtualBatchParentHash(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (common.Hash, error)

GetVirtualBatchParentHash returns the parent hash of the virtual batch with the given number.

func (*PostgresStorage) GetVirtualBatchToProve

func (p *PostgresStorage) GetVirtualBatchToProve(ctx context.Context, lastVerfiedBatchNumber uint64, dbTx pgx.Tx) (*state.Batch, error)

GetVirtualBatchToProve return the next batch that is not proved, neither in proved process.

func (*PostgresStorage) GetWIPBatchInStorage

func (p *PostgresStorage) GetWIPBatchInStorage(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error)

GetWIPBatchInStorage returns the wip batch in the state

func (*PostgresStorage) IsBatchClosed

func (p *PostgresStorage) IsBatchClosed(ctx context.Context, batchNum uint64, dbTx pgx.Tx) (bool, error)

IsBatchClosed indicates if the batch referenced by batchNum is closed or not

func (*PostgresStorage) IsBatchConsolidated

func (p *PostgresStorage) IsBatchConsolidated(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (bool, error)

IsBatchConsolidated checks if batch is consolidated/verified.

func (*PostgresStorage) IsBatchVirtualized

func (p *PostgresStorage) IsBatchVirtualized(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (bool, error)

IsBatchVirtualized checks if batch is virtualized

func (*PostgresStorage) IsL2BlockConsolidated

func (p *PostgresStorage) IsL2BlockConsolidated(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (bool, error)

IsL2BlockConsolidated checks if the block ID is consolidated

func (*PostgresStorage) IsL2BlockVirtualized

func (p *PostgresStorage) IsL2BlockVirtualized(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (bool, error)

IsL2BlockVirtualized checks if the block ID is virtualized

func (*PostgresStorage) IsSequencingTXSynced

func (p *PostgresStorage) IsSequencingTXSynced(ctx context.Context, transactionHash common.Hash, dbTx pgx.Tx) (bool, error)

IsSequencingTXSynced checks if sequencing tx has been synced into the state

func (*PostgresStorage) OpenBatchInStorage

func (p *PostgresStorage) OpenBatchInStorage(ctx context.Context, batchContext state.ProcessingContext, dbTx pgx.Tx) error

OpenBatchInStorage adds a new batch into the state storage, with the necessary data to start processing transactions within it. It's meant to be used by sequencers, since they don't necessarily know what transactions are going to be added in this batch yet. In other words it's the creation of a WIP batch. Note that this will add a batch with batch number N + 1, where N it's the greatest batch number on the state.

func (*PostgresStorage) OpenWIPBatchInStorage

func (p *PostgresStorage) OpenWIPBatchInStorage(ctx context.Context, batch state.Batch, dbTx pgx.Tx) error

OpenWIPBatchInStorage adds a new wip batch into the state storage

func (*PostgresStorage) Reset

func (p *PostgresStorage) Reset(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) error

Reset resets the state to a block for the given DB tx

func (*PostgresStorage) ResetForkID

func (p *PostgresStorage) ResetForkID(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error

ResetForkID resets the state to reprocess the newer batches with the correct forkID

func (*PostgresStorage) ResetTrustedState

func (p *PostgresStorage) ResetTrustedState(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error

ResetTrustedState removes the batches with number greater than the given one from the database.

func (*PostgresStorage) SetInitSyncBatch

func (p *PostgresStorage) SetInitSyncBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error

SetInitSyncBatch sets the initial batch number where the synchronization started

func (*PostgresStorage) SetLastBatchInfoSeenOnEthereum

func (p *PostgresStorage) SetLastBatchInfoSeenOnEthereum(ctx context.Context, lastBatchNumberSeen, lastBatchNumberVerified uint64, dbTx pgx.Tx) error

SetLastBatchInfoSeenOnEthereum sets the last batch number that affected the roll-up and the last batch number that was consolidated on ethereum in order to allow the components to know if the state is synchronized or not

func (*PostgresStorage) StoreGenesisBatch

func (p *PostgresStorage) StoreGenesisBatch(ctx context.Context, batch state.Batch, dbTx pgx.Tx) error

func (*PostgresStorage) UpdateBatchL2Data

func (p *PostgresStorage) UpdateBatchL2Data(ctx context.Context, batchNumber uint64, batchL2Data []byte, dbTx pgx.Tx) error

UpdateBatchL2Data updates data tx data in a batch

func (*PostgresStorage) UpdateForkID

func (p *PostgresStorage) UpdateForkID(ctx context.Context, forkID state.ForkIDInterval, dbTx pgx.Tx) error

UpdateForkID updates the forkID stored in db

func (*PostgresStorage) UpdateForkIDIntervalsInMemory

func (p *PostgresStorage) UpdateForkIDIntervalsInMemory(intervals []state.ForkIDInterval)

UpdateForkIDIntervalsInMemory updates the forkID intervals in memory

func (*PostgresStorage) UpdateGERInOpenBatch

func (p *PostgresStorage) UpdateGERInOpenBatch(ctx context.Context, ger common.Hash, dbTx pgx.Tx) error

UpdateGERInOpenBatch update ger in open batch

func (*PostgresStorage) UpdateGeneratedProof

func (p *PostgresStorage) UpdateGeneratedProof(ctx context.Context, proof *state.Proof, dbTx pgx.Tx) error

UpdateGeneratedProof updates a generated proof in the storage

func (*PostgresStorage) UpdateWIPBatch

func (p *PostgresStorage) UpdateWIPBatch(ctx context.Context, receipt state.ProcessingReceipt, dbTx pgx.Tx) error

UpdateWIPBatch updates the data in a batch

Jump to

Keyboard shortcuts

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