Documentation ¶
Index ¶
- Constants
- Variables
- func CalculateEffectiveGasPricePercentage(gasPrice *big.Int, effectiveGasPrice *big.Int) (uint8, error)
- func CheckLogOrder(logs []*types.Log) bool
- func CheckSignature(tx types.Transaction) error
- func CheckSupersetBatchTransactions(existingTxHashes []common.Hash, processedTxs []*ProcessTransactionResponse) error
- func ConstructErrorFromRevert(err error, returnValue []byte) error
- func DecodeTx(encodedTx string) (*types.Transaction, error)
- func DecodeTxs(txsData []byte, forkID uint64) ([]types.Transaction, []byte, []uint8, error)
- func EncodeBatchV2(batch *BatchRawV2) ([]byte, error)
- func EncodeBlockHeaderV2(batchData []byte, block L2BlockRaw) ([]byte, error)
- func EncodeTransaction(tx types.Transaction, effectivePercentage uint8, forkID uint64) ([]byte, error)
- func EncodeTransactionWithoutEffectivePercentage(tx types.Transaction) ([]byte, error)
- func EncodeTransactions(txs []types.Transaction, effectivePercentages []uint8, forkID uint64) ([]byte, error)
- func EncodeTransactionsWithoutEffectivePercentage(txs []types.Transaction) ([]byte, error)
- func EncodeUnsignedTransaction(tx types.Transaction, chainID uint64, forcedNonce *uint64, forkID uint64) ([]byte, error)
- func GenerateDataStreamFile(ctx context.Context, streamServer *datastreamer.StreamServer, stateDB DSState, ...) error
- func GenerateReceipt(blockNumber *big.Int, processedTx *ProcessTransactionResponse, txIndex uint, ...) *types.Receipt
- func GetMockL1InfoRoot() common.Hash
- func GetSender(tx types.Transaction) (common.Address, error)
- func GetSystemSCPosition(blockNumber uint64) []byte
- func HashByteArray(data []byte) common.Hash
- func HexToAddressPtr(hex string) *common.Address
- func HexToHashPtr(hex string) *common.Hash
- func InfiniteSafeRun(fn func(), errorMessage string, restartInterval time.Duration)
- func IsPreEIP155Tx(tx types.Transaction) bool
- func IsStateRootChanged(err executor.RomError) bool
- func Ptr[T any](v T) *T
- func RlpFieldsToLegacyTx(fields [][]byte, v, r, s []byte) (tx *types.LegacyTx, err error)
- func SafeRun(fn func(), errorMessage string)
- type Batch
- type BatchConfig
- type BatchConstraintsCfg
- type BatchRawV2
- type BatchRemainingResourcesUnderflowError
- type BatchResources
- type Block
- type ClosingReason
- type Config
- type DSBatch
- type DSFullBatch
- type DSL2Block
- type DSL2FullBlock
- type DSL2Transaction
- type DSState
- type EffectiveGasPriceLog
- type FakeDB
- func (f *FakeDB) AddAddressToAccessList(addr common.Address)
- func (f *FakeDB) AddBalance(common.Address, *big.Int)
- func (f *FakeDB) AddLog(*types.Log)
- func (f *FakeDB) AddPreimage(common.Hash, []byte)
- func (f *FakeDB) AddRefund(gas uint64)
- func (f *FakeDB) AddSlotToAccessList(addr common.Address, slot common.Hash)
- func (f *FakeDB) AddressInAccessList(addr common.Address) bool
- func (f *FakeDB) CreateAccount(common.Address)
- func (f *FakeDB) Empty(address common.Address) bool
- func (f *FakeDB) Exist(address common.Address) bool
- func (f *FakeDB) GetBalance(address common.Address) *big.Int
- func (f *FakeDB) GetCode(address common.Address) []byte
- func (f *FakeDB) GetCodeHash(address common.Address) common.Hash
- func (f *FakeDB) GetCodeSize(address common.Address) int
- func (f *FakeDB) GetCommittedState(common.Address, common.Hash) common.Hash
- func (f *FakeDB) GetNonce(address common.Address) uint64
- func (f *FakeDB) GetRefund() uint64
- func (f *FakeDB) GetState(address common.Address, hash common.Hash) common.Hash
- func (f *FakeDB) GetTransientState(addr common.Address, key common.Hash) common.Hash
- func (f *FakeDB) HasSuicided(common.Address) bool
- func (f *FakeDB) Prepare(rules params.Rules, sender, coinbase common.Address, dest *common.Address, ...)
- func (f *FakeDB) RevertToSnapshot(int)
- func (f *FakeDB) SetCode(common.Address, []byte)
- func (f *FakeDB) SetNonce(common.Address, uint64)
- func (f *FakeDB) SetState(common.Address, common.Hash, common.Hash)
- func (f *FakeDB) SetStateRoot(stateRoot []byte)
- func (f *FakeDB) SetTransientState(addr common.Address, key, value common.Hash)
- func (f *FakeDB) SlotInAccessList(addr common.Address, slot common.Hash) (addressOk bool, slotOk bool)
- func (f *FakeDB) Snapshot() int
- func (f *FakeDB) SubBalance(common.Address, *big.Int)
- func (f *FakeDB) SubRefund(gas uint64)
- func (f *FakeDB) Suicide(common.Address) bool
- type ForcedBatch
- type ForcedBatchRawV2
- type ForkIDInterval
- type Genesis
- type GenesisAction
- type GlobalExitRoot
- type InfoReadWrite
- type L1DataV2
- type L1InfoTreeExitRootStorageEntry
- type L1InfoTreeLeaf
- type L2Block
- type L2BlockRaw
- type L2Header
- type L2TxRaw
- type NewL2BlockEvent
- type NewL2BlockEventHandler
- type ProcessBatchResponse
- type ProcessBlockResponse
- type ProcessRequest
- type ProcessTransactionResponse
- type ProcessingContext
- type ProcessingContextV2
- type ProcessingReceipt
- type Proof
- type Queue
- type Sequence
- type Stack
- type State
- func (s *State) AddForkIDInterval(ctx context.Context, newForkID ForkIDInterval, dbTx pgx.Tx) error
- func (s *State) AddL1InfoTreeLeaf(ctx context.Context, l1InfoTreeLeaf *L1InfoTreeLeaf, dbTx pgx.Tx) (*L1InfoTreeExitRootStorageEntry, error)
- func (s *State) BeginStateTransaction(ctx context.Context) (pgx.Tx, error)
- func (s *State) CloseBatch(ctx context.Context, receipt ProcessingReceipt, dbTx pgx.Tx) error
- func (s *State) CloseWIPBatch(ctx context.Context, receipt ProcessingReceipt, dbTx pgx.Tx) error
- func (s *State) DebugTransaction(ctx context.Context, transactionHash common.Hash, traceConfig TraceConfig, ...) (*runtime.ExecutionResult, error)
- func (s *State) EstimateGas(transaction *types.Transaction, senderAddress common.Address, ...) (uint64, []byte, error)
- func (s *State) ExecuteBatch(ctx context.Context, batch Batch, updateMerkleTree bool, dbTx pgx.Tx) (*executor.ProcessBatchResponse, error)
- func (s *State) ExecuteBatchV2(ctx context.Context, batch Batch, L1InfoTreeRoot common.Hash, ...) (*executor.ProcessBatchResponseV2, error)
- func (s *State) FlushMerkleTree(ctx context.Context, newStateRoot common.Hash) error
- func (s *State) GetBalance(ctx context.Context, address common.Address, root common.Hash) (*big.Int, error)
- func (s *State) GetBalanceByStateRoot(ctx context.Context, address common.Address, root common.Hash) (*big.Int, error)
- func (s *State) GetBatchTimestamp(ctx context.Context, batchNumber uint64, forcedForkId *uint64, dbTx pgx.Tx) (*time.Time, error)
- func (s *State) GetCode(ctx context.Context, address common.Address, root common.Hash) ([]byte, error)
- func (s *State) GetCurrentL1InfoRoot(ctx context.Context, dbTx pgx.Tx) (common.Hash, error)
- func (s *State) GetForkIDByBatchNumber(batchNumber uint64) uint64
- func (s *State) GetForkIDByBlockNumber(blockNumber uint64) uint64
- func (s *State) GetL1InfoTreeDataFromBatchL2Data(ctx context.Context, batchL2Data []byte, dbTx pgx.Tx) (map[uint32]L1DataV2, common.Hash, common.Hash, error)
- func (s *State) GetLastBatch(ctx context.Context, dbTx pgx.Tx) (*Batch, error)
- func (s *State) GetLastStateRoot(ctx context.Context, dbTx pgx.Tx) (common.Hash, error)
- func (s *State) GetNonce(ctx context.Context, address common.Address, root common.Hash) (uint64, error)
- func (s *State) GetNonceByStateRoot(ctx context.Context, address common.Address, root common.Hash) (*big.Int, error)
- func (s *State) GetStorageAt(ctx context.Context, address common.Address, position *big.Int, ...) (*big.Int, error)
- func (s *State) GetStoredFlushID(ctx context.Context) (uint64, string, error)
- func (p *State) GetSyncingInfo(ctx context.Context, dbTx pgx.Tx) (SyncingInfo, error)
- func (s *State) GetTree() *merkletree.StateTree
- func (s *State) GetWIPBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*Batch, error)
- func (s *State) OpenBatch(ctx context.Context, processingContext ProcessingContext, dbTx pgx.Tx) error
- func (s *State) OpenWIPBatch(ctx context.Context, batch Batch, dbTx pgx.Tx) error
- func (s *State) PreProcessTransaction(ctx context.Context, tx *types.Transaction, dbTx pgx.Tx) (*ProcessBatchResponse, error)
- func (s *State) PreProcessUnsignedTransaction(ctx context.Context, tx *types.Transaction, sender common.Address, ...) (*ProcessBatchResponse, error)
- func (s *State) ProcessAndStoreClosedBatch(ctx context.Context, processingCtx ProcessingContext, encodedTxs []byte, ...) (common.Hash, uint64, string, error)
- func (s *State) ProcessAndStoreClosedBatchV2(ctx context.Context, processingCtx ProcessingContextV2, dbTx pgx.Tx, ...) (common.Hash, uint64, string, error)
- func (s *State) ProcessBatch(ctx context.Context, request ProcessRequest, updateMerkleTree bool) (*ProcessBatchResponse, error)
- func (s *State) ProcessBatchV2(ctx context.Context, request ProcessRequest, updateMerkleTree bool) (*ProcessBatchResponse, string, error)
- func (s *State) ProcessSequencerBatch(ctx context.Context, batchNumber uint64, batchL2Data []byte, ...) (*ProcessBatchResponse, error)
- func (s *State) ProcessUnsignedTransaction(ctx context.Context, tx *types.Transaction, senderAddress common.Address, ...) (*runtime.ExecutionResult, error)
- func (s *State) RegisterNewL2BlockEventHandler(h NewL2BlockEventHandler)
- func (s *State) Reset(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) error
- func (s *State) ResetL1InfoTree()
- func (s *State) SetGenesis(ctx context.Context, block Block, genesis Genesis, m metrics.CallerLabel, ...) (common.Hash, error)
- func (s *State) StartToMonitorNewL2Blocks()
- func (s *State) StoreL2Block(ctx context.Context, batchNumber uint64, l2Block *ProcessBlockResponse, ...) (common.Hash, error)
- func (s *State) StoreTransaction(ctx context.Context, batchNumber uint64, ...) (*L2Header, error)
- func (s *State) StoreTransactions(ctx context.Context, batchNumber uint64, ...) error
- func (s *State) TestConvertToProcessBatchResponse(batchResponse *executor.ProcessBatchResponse) (*ProcessBatchResponse, error)
- func (s *State) TestConvertToProcessBatchResponseV2(batchResponse *executor.ProcessBatchResponseV2) (*ProcessBatchResponse, error)
- func (s *State) UpdateForkIDIntervalsInMemory(intervals []ForkIDInterval)
- type StateTx
- type StoreTxEGPData
- type SyncInfoDataOnStorage
- type SyncingInfo
- type TraceConfig
- type TrustedReorg
- type VerifiedBatch
- type VirtualBatch
- type ZKCounters
Constants ¶
const ( // StreamTypeSequencer represents a Sequencer stream StreamTypeSequencer datastreamer.StreamType = 1 // EntryTypeBookMark represents a bookmark entry EntryTypeBookMark datastreamer.EntryType = datastreamer.EtBookmark // SystemSC is the system smart contract address SystemSC = "0x000000000000000000000000000000005ca1ab1e" )
const ( // FORKID_BLUEBERRY is the fork id 4 FORKID_BLUEBERRY = 4 // FORKID_DRAGONFRUIT is the fork id 5 FORKID_DRAGONFRUIT = 5 // FORKID_INCABERRY is the fork id 6 FORKID_INCABERRY = 6 // FORKID_ETROG is the fork id 7 FORKID_ETROG = 7 // FORKID_ELDERBERRY is the fork id 8 FORKID_ELDERBERRY = 8 // FORKID_9 is the fork id 9 FORKID_9 = 9 )
const ( // EfficiencyPercentageByteLength is the length of the effective percentage in bytes EfficiencyPercentageByteLength uint64 = 1 )
const ( // MaxEffectivePercentage is the maximum value that can be used as effective percentage MaxEffectivePercentage = uint8(255) )
const ( // MaxL2BlockGasLimit is the gas limit allowed per L2 block in a batch MaxL2BlockGasLimit = uint64(1125899906842624) )
const ( // MaxTxGasLimit is the gas limit allowed per tx in a batch MaxTxGasLimit = uint64(30000000) )
const ( // MockL1InfoRootHex is used to send batches to the Executor // the number below represents this formula: // // mockL1InfoRoot := common.Hash{} // for i := 0; i < len(mockL1InfoRoot); i++ { // mockL1InfoRoot[i] = byte(i) // } MockL1InfoRootHex = "0x000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" )
Variables ¶
var ( // ErrEffectiveGasPriceEmpty happens when the effectiveGasPrice or gasPrice is nil or zero ErrEffectiveGasPriceEmpty = errors.New("effectiveGasPrice or gasPrice cannot be nil or zero") // ErrEffectiveGasPriceIsZero happens when the calculated EffectiveGasPrice is zero ErrEffectiveGasPriceIsZero = errors.New("effectiveGasPrice cannot be zero") )
var ( // ErrBatchV2DontStartWithChangeL2Block is returned when the batch start directly with a trsansaction (without a changeL2Block) ErrBatchV2DontStartWithChangeL2Block = errors.New("batch v2 must start with changeL2Block before Tx (suspect a V1 Batch or a ForcedBatch?))") // ErrInvalidBatchV2 is returned when the batch is invalid. ErrInvalidBatchV2 = errors.New("invalid batch v2") // ErrInvalidRLP is returned when the rlp is invalid. ErrInvalidRLP = errors.New("invalid rlp codification") )
var ( // ErrInvalidBatchHeader indicates the batch header is invalid ErrInvalidBatchHeader = errors.New("invalid batch header") // ErrUnexpectedBatch indicates that the batch is unexpected ErrUnexpectedBatch = errors.New("unexpected batch") // ErrStateNotSynchronized indicates the state database may be empty ErrStateNotSynchronized = errors.New("state not synchronized") // ErrNotFound indicates an object has not been found for the search criteria used ErrNotFound = errors.New("object not found") // ErrNilDBTransaction indicates the db transaction has not been properly initialized ErrNilDBTransaction = errors.New("database transaction not properly initialized") // ErrAlreadyInitializedDBTransaction indicates the db transaction was already initialized ErrAlreadyInitializedDBTransaction = errors.New("database transaction already initialized") // ErrNotEnoughIntrinsicGas indicates the gas is not enough to cover the intrinsic gas cost ErrNotEnoughIntrinsicGas = fmt.Errorf("not enough gas supplied for intrinsic gas costs") // ErrParsingExecutorTrace indicates an error occurred while parsing the executor trace ErrParsingExecutorTrace = fmt.Errorf("error while parsing executor trace") // ErrInvalidBatchNumber indicates the provided batch number is not the latest in db ErrInvalidBatchNumber = errors.New("provided batch number is not latest") // ErrLastBatchShouldBeClosed indicates that last batch needs to be closed before adding a new one ErrLastBatchShouldBeClosed = errors.New("last batch needs to be closed before adding a new one") // ErrBatchAlreadyClosed indicates that batch is already closed ErrBatchAlreadyClosed = errors.New("batch is already closed") // ErrClosingBatchWithoutTxs indicates that the batch attempted to close does not have txs. ErrClosingBatchWithoutTxs = errors.New("can not close a batch without transactions") // ErrTimestampGE indicates that timestamp needs to be greater or equal ErrTimestampGE = errors.New("timestamp needs to be greater or equal") // ErrDBTxNil indicates that the method requires a dbTx that is not nil ErrDBTxNil = errors.New("the method requires a dbTx that is not nil") // ErrExistingTxGreaterThanProcessedTx indicates that we have more txs stored // in db than the txs we want to process. ErrExistingTxGreaterThanProcessedTx = errors.New("there are more transactions in the database than in the processed transaction set") // ErrOutOfOrderProcessedTx indicates the the processed transactions of an // ongoing batch are not in the same order as the transactions stored in the // database for the same batch. ErrOutOfOrderProcessedTx = errors.New("the processed transactions are not in the same order as the stored transactions") // ErrInsufficientFundsForTransfer is returned if the transaction sender doesn't // have enough funds for transfer(topmost call only). ErrInsufficientFundsForTransfer = errors.New("insufficient funds for transfer") // ErrExecutorNil indicates that the method requires an executor that is not nil ErrExecutorNil = errors.New("the method requires an executor that is not nil") // ErrStateTreeNil indicates that the method requires a state tree that is not nil ErrStateTreeNil = errors.New("the method requires a state tree that is not nil") // ErrUnsupportedDuration is returned if the provided unit for a time // interval is not supported by our conversion mechanism. ErrUnsupportedDuration = errors.New("unsupported time duration") // ErrInvalidData is the error when the raw txs is unexpected ErrInvalidData = errors.New("invalid data") // ErrInvalidBlockRange returned when the selected block range is invalid, generally // because the toBlock is bigger than the fromBlock ErrInvalidBlockRange = errors.New("invalid block range") // ErrMaxLogsCountLimitExceeded returned when the number of logs is bigger than the // configured limit ErrMaxLogsCountLimitExceeded = errors.New("query returned more than %v results") // ErrMaxLogsBlockRangeLimitExceeded returned when the range between block number range // to filter logs is bigger than the configured limit ErrMaxLogsBlockRangeLimitExceeded = errors.New("logs are limited to a %v block range") // ErrMaxNativeBlockHashBlockRangeLimitExceeded returned when the range between block number range // to filter native block hashes is bigger than the configured limit ErrMaxNativeBlockHashBlockRangeLimitExceeded = errors.New("native block hashes are limited to a %v block range") )
var ( // DefaultSenderAddress is the address that jRPC will use // to communicate with the state for eth_EstimateGas and eth_Call when // the From field is not specified because it is optional DefaultSenderAddress = "0x1111111111111111111111111111111111111111" // ZeroHash is the hash 0x0000000000000000000000000000000000000000000000000000000000000000 ZeroHash = common.Hash{} // ZeroAddress is the address 0x0000000000000000000000000000000000000000 ZeroAddress = common.Address{} )
var ( // ErrExecutingBatchOOC process batch fails because OOC (Out of counters) ErrExecutingBatchOOC = errors.New("Batch execution fails because: out of counters") )
var ( // ErrInvalidSig indicates the signature of the transaction is not valid ErrInvalidSig = errors.New("invalid transaction v, r, s values") )
var ErrQueueEmpty = fmt.Errorf("queue is empty")
ErrQueueEmpty is returned when a queue operation depends on the queue to not be empty, but it is empty
var ErrStackEmpty = errors.New("Empty Stack")
ErrStackEmpty returned when Pop is called and the stack is empty
Functions ¶
func CalculateEffectiveGasPricePercentage ¶ added in v0.6.5
func CalculateEffectiveGasPricePercentage(gasPrice *big.Int, effectiveGasPrice *big.Int) (uint8, error)
CalculateEffectiveGasPricePercentage calculates the gas price's effective percentage
func CheckLogOrder ¶ added in v0.0.990
CheckLogOrder checks the order of the logs. The order should be incremental
func CheckSignature ¶
func CheckSignature(tx types.Transaction) error
CheckSignature checks a transaction signature
func CheckSupersetBatchTransactions ¶
func CheckSupersetBatchTransactions(existingTxHashes []common.Hash, processedTxs []*ProcessTransactionResponse) error
CheckSupersetBatchTransactions verifies that processedTransactions is a superset of existingTxs and that the existing txs have the same order, returns a non-nil error if that is not the case.
func ConstructErrorFromRevert ¶ added in v0.5.13
ConstructErrorFromRevert extracts the reverted reason from the provided returnValue and creates an instance of error that wraps the original error + the reverted reason
func DecodeTx ¶
func DecodeTx(encodedTx string) (*types.Transaction, error)
DecodeTx decodes a string rlp tx representation into a types.Transaction instance
func EncodeBatchV2 ¶ added in v0.5.0
func EncodeBatchV2(batch *BatchRawV2) ([]byte, error)
EncodeBatchV2 encodes a batch of transactions into a byte slice.
func EncodeBlockHeaderV2 ¶ added in v0.5.0
func EncodeBlockHeaderV2(batchData []byte, block L2BlockRaw) ([]byte, error)
EncodeBlockHeaderV2 encodes a batch of l2blocks header into a byte slice.
func EncodeTransaction ¶
func EncodeTransaction(tx types.Transaction, effectivePercentage uint8, forkID uint64) ([]byte, error)
EncodeTransaction RLP encodes the given transaction
func EncodeTransactionWithoutEffectivePercentage ¶ added in v0.0.990
func EncodeTransactionWithoutEffectivePercentage(tx types.Transaction) ([]byte, error)
EncodeTransactionWithoutEffectivePercentage RLP encodes the given transaction without the effective percentage
func EncodeTransactions ¶
func EncodeTransactions(txs []types.Transaction, effectivePercentages []uint8, forkID uint64) ([]byte, error)
EncodeTransactions RLP encodes the given transactions
func EncodeTransactionsWithoutEffectivePercentage ¶ added in v0.0.990
func EncodeTransactionsWithoutEffectivePercentage(txs []types.Transaction) ([]byte, error)
EncodeTransactionsWithoutEffectivePercentage RLP encodes the given transactions without the effective percentage
func EncodeUnsignedTransaction ¶
func EncodeUnsignedTransaction(tx types.Transaction, chainID uint64, forcedNonce *uint64, forkID uint64) ([]byte, error)
EncodeUnsignedTransaction RLP encodes the given unsigned transaction
func GenerateDataStreamFile ¶ added in v0.7.0
func GenerateDataStreamFile(ctx context.Context, streamServer *datastreamer.StreamServer, stateDB DSState, readWIPBatch bool, imStateRoots *map[uint64][]byte, chainID uint64, upgradeEtrogBatchNumber uint64) error
GenerateDataStreamFile generates or resumes a data stream file
func GenerateReceipt ¶ added in v0.5.0
func GenerateReceipt(blockNumber *big.Int, processedTx *ProcessTransactionResponse, txIndex uint, forkID uint64) *types.Receipt
GenerateReceipt generates a receipt from a processed transaction
func GetMockL1InfoRoot ¶ added in v0.5.12
GetMockL1InfoRoot returns an instance of common.Hash set with the value provided by the const MockL1InfoRootHex
func GetSender ¶
func GetSender(tx types.Transaction) (common.Address, error)
GetSender gets the sender from the transaction's signature
func GetSystemSCPosition ¶ added in v0.4.3
GetSystemSCPosition computes the position of the intermediate state root for the system smart contract
func HashByteArray ¶ added in v0.5.0
HashByteArray returns the hash of the given byte array
func HexToAddressPtr ¶
HexToAddressPtr create an address from a hex and returns its pointer
func HexToHashPtr ¶
HexToHashPtr create a hash from a hex and returns its pointer
func InfiniteSafeRun ¶ added in v0.4.0
InfiniteSafeRun executes a function and in case it fails, runs the function again infinitely
func IsPreEIP155Tx ¶ added in v0.0.990
func IsPreEIP155Tx(tx types.Transaction) bool
IsPreEIP155Tx checks if the tx is a tx that has a chainID as zero and V field is either 27 or 28
func IsStateRootChanged ¶ added in v0.0.990
IsStateRootChanged returns true if the transaction changes the state root
func RlpFieldsToLegacyTx ¶
RlpFieldsToLegacyTx parses the rlp fields slice into a type.LegacyTx in this specific order:
required fields: [0] Nonce uint64 [1] GasPrice *big.Int [2] Gas uint64 [3] To *common.Address [4] Value *big.Int [5] Data []byte
optional fields: [6] V *big.Int [7] R *big.Int [8] S *big.Int
Types ¶
type Batch ¶
type Batch struct { BatchNumber uint64 Coinbase common.Address BatchL2Data []byte StateRoot common.Hash LocalExitRoot common.Hash AccInputHash common.Hash // Timestamp (<=incaberry) -> batch time // (>incaberry) -> minTimestamp used in batch creation, real timestamp is in virtual_batch.batch_timestamp Timestamp time.Time Transactions []types.Transaction GlobalExitRoot common.Hash ForcedBatchNum *uint64 Resources BatchResources HighReservedZKCounters ZKCounters // WIP: if WIP == true is a openBatch WIP bool }
Batch struct
type BatchConfig ¶ added in v0.0.990
type BatchConfig struct {
Constraints BatchConstraintsCfg `mapstructure:"Constraints"`
}
BatchConfig represents the configuration of the batch constraints
type BatchConstraintsCfg ¶ added in v0.0.990
type BatchConstraintsCfg struct { MaxTxsPerBatch uint64 `mapstructure:"MaxTxsPerBatch"` MaxBatchBytesSize uint64 `mapstructure:"MaxBatchBytesSize"` MaxCumulativeGasUsed uint64 `mapstructure:"MaxCumulativeGasUsed"` MaxKeccakHashes uint32 `mapstructure:"MaxKeccakHashes"` MaxPoseidonHashes uint32 `mapstructure:"MaxPoseidonHashes"` MaxPoseidonPaddings uint32 `mapstructure:"MaxPoseidonPaddings"` MaxMemAligns uint32 `mapstructure:"MaxMemAligns"` MaxArithmetics uint32 `mapstructure:"MaxArithmetics"` MaxBinaries uint32 `mapstructure:"MaxBinaries"` MaxSteps uint32 `mapstructure:"MaxSteps"` MaxSHA256Hashes uint32 `mapstructure:"MaxSHA256Hashes"` }
BatchConstraintsCfg represents the configuration of the batch constraints
func (BatchConstraintsCfg) CheckNodeLevelOOC ¶ added in v0.7.2
func (c BatchConstraintsCfg) CheckNodeLevelOOC(counters ZKCounters) error
CheckNodeLevelOOC checks if the counters are within the batch constraints
type BatchRawV2 ¶ added in v0.5.0
type BatchRawV2 struct {
Blocks []L2BlockRaw
}
BatchRawV2 is the representation of a batch of transactions.
func DecodeBatchV2 ¶ added in v0.5.0
func DecodeBatchV2(txsData []byte) (*BatchRawV2, error)
DecodeBatchV2 decodes a batch of transactions from a byte slice.
func (*BatchRawV2) String ¶ added in v0.5.0
func (b *BatchRawV2) String() string
type BatchRemainingResourcesUnderflowError ¶ added in v0.0.990
type BatchRemainingResourcesUnderflowError struct { Message string Code int Err error ResourceName string }
BatchRemainingResourcesUnderflowError happens when the execution of a batch runs out of counters
func (BatchRemainingResourcesUnderflowError) Error ¶ added in v0.0.990
func (b BatchRemainingResourcesUnderflowError) Error() string
Error returns the error message
type BatchResources ¶ added in v0.0.990
type BatchResources struct { ZKCounters ZKCounters Bytes uint64 }
BatchResources is a struct that contains the limited resources of a batch
func (*BatchResources) Fits ¶ added in v0.6.0
func (r *BatchResources) Fits(other BatchResources) (bool, string)
Fits check if the other batch resources fit in the batch resources. If there is a resource underflow it returns false and the name of the resource that caused the overflow
func (*BatchResources) Sub ¶ added in v0.0.990
func (r *BatchResources) Sub(other BatchResources) (bool, string)
Sub subtracts the batch resources from "other". If there is a resource overflow it returns true and the name of the resource that caused the overflow
func (*BatchResources) SumUp ¶ added in v0.5.0
func (r *BatchResources) SumUp(other BatchResources)
SumUp sum ups the batch resources from other
type Block ¶
type Block struct { BlockNumber uint64 BlockHash common.Hash ParentHash common.Hash ReceivedAt time.Time Checked bool }
Block struct
type ClosingReason ¶ added in v0.0.990
type ClosingReason string
ClosingReason represents the reason why a batch is closed.
const ( // EmptyClosingReason is the closing reason used when a batch is not closed EmptyClosingReason ClosingReason = "" // MaxTxsClosingReason is the closing reason used when a batch reachs the max transactions per batch MaxTxsClosingReason ClosingReason = "Max transactions" // ResourceExhaustedClosingReason is the closing reason used when a batch has a resource (zkCounter or Bytes) exhausted ResourceExhaustedClosingReason ClosingReason = "Resource exhausted" // ResourceMarginExhaustedClosingReason is the closing reason used when a batch has a resource (zkCounter or Bytes) margin exhausted ResourceMarginExhaustedClosingReason ClosingReason = "Resource margin exhausted" // ForcedBatchClosingReason is the closing reason used when a batch is a forced batch ForcedBatchClosingReason ClosingReason = "Forced batch" // ForcedBatchDeadlineClosingReason is the closing reason used when forced batch deadline is reached ForcedBatchDeadlineClosingReason ClosingReason = "Forced batch deadline" // MaxDeltaTimestampClosingReason is the closing reason used when max delta batch timestamp is reached MaxDeltaTimestampClosingReason ClosingReason = "Max delta timestamp" // NoTxFitsClosingReason is the closing reason used when any of the txs in the pool (worker) fits in the remaining resources of the batch NoTxFitsClosingReason ClosingReason = "No transaction fits" // L2BlockReorgClonsingReason is the closing reason used when we have a L2 block reorg (unexpected error, like OOC, when processing L2 block) L2BlockReorgClonsingReason ClosingReason = "L2 block reorg" // SyncL1EventInitialBatchClosingReason is the closing reason used when a batch is closed by the synchronizer due to an initial batch (first batch mode forced) SyncL1EventInitialBatchClosingReason ClosingReason = "Sync L1: initial" // SyncL1EventSequencedBatchClosingReason is the closing reason used when a batch is closed by the synchronizer due to a sequenced batch event from L1 SyncL1EventSequencedBatchClosingReason ClosingReason = "Sync L1: sequenced" // SyncL1EventSequencedForcedBatchClosingReason is the closing reason used when a batch is closed by the synchronizer due to a sequenced forced batch event from L1 SyncL1EventSequencedForcedBatchClosingReason ClosingReason = "Sync L1: forced" // SyncL1EventUpdateEtrogSequenceClosingReason is the closing reason used when a batch is closed by the synchronizer due to an UpdateEtrogSequence event from L1 that inject txs SyncL1EventUpdateEtrogSequenceClosingReason ClosingReason = "Sync L1: injected" // SyncL2TrustedBatchClosingReason is the closing reason used when a batch is closed by the synchronizer due to a trusted batch from L2 SyncL2TrustedBatchClosingReason ClosingReason = "Sync L2: trusted" // SyncGenesisBatchClosingReason is the closing reason used when genesis batch is created by synchronizer SyncGenesisBatchClosingReason ClosingReason = "Sync: genesis" )
type Config ¶
type Config struct { // MaxCumulativeGasUsed is the max gas allowed per batch MaxCumulativeGasUsed uint64 // ChainID is the L2 ChainID provided by the Network Config ChainID uint64 // ForkIdIntervals is the list of fork id intervals ForkIDIntervals []ForkIDInterval // MaxResourceExhaustedAttempts is the max number of attempts to make a transaction succeed because of resource exhaustion MaxResourceExhaustedAttempts int // WaitOnResourceExhaustion is the time to wait before retrying a transaction because of resource exhaustion WaitOnResourceExhaustion types.Duration // Batch number from which there is a forkid change (fork upgrade) ForkUpgradeBatchNumber uint64 // New fork id to be used for batches greaters than ForkUpgradeBatchNumber (fork upgrade) ForkUpgradeNewForkId uint64 // DB is the database configuration DB db.Config `mapstructure:"DB"` // Configuration for the batch constraints Batch BatchConfig `mapstructure:"Batch"` // MaxLogsCount is a configuration to set the max number of logs that can be returned // in a single call to the state, if zero it means no limit MaxLogsCount uint64 // MaxLogsBlockRange is a configuration to set the max range for block number when querying TXs // logs in a single call to the state, if zero it means no limit MaxLogsBlockRange uint64 // MaxNativeBlockHashBlockRange is a configuration to set the max range for block number when querying // native block hashes in a single call to the state, if zero it means no limit MaxNativeBlockHashBlockRange uint64 // AvoidForkIDInMemory is a configuration that forces the ForkID information to be loaded // from the DB every time it's needed AvoidForkIDInMemory bool }
Config is state config
type DSFullBatch ¶ added in v0.4.0
type DSFullBatch struct { DSBatch L2Blocks []DSL2FullBlock }
DSFullBatch represents a data stream batch ant its L2 blocks
type DSL2Block ¶ added in v0.0.990
type DSL2Block struct { BatchNumber uint64 L2BlockNumber uint64 Timestamp uint64 MinTimestamp uint64 L1InfoTreeIndex uint32 L1BlockHash common.Hash GlobalExitRoot common.Hash Coinbase common.Address ForkID uint64 ChainID uint64 BlockHash common.Hash StateRoot common.Hash BlockGasLimit uint64 BlockInfoRoot common.Hash }
DSL2Block is a full l2 block
type DSL2FullBlock ¶ added in v0.0.990
type DSL2FullBlock struct { DSL2Block Txs []DSL2Transaction }
DSL2FullBlock represents a data stream L2 full block and its transactions
type DSL2Transaction ¶ added in v0.0.990
type DSL2Transaction struct { L2BlockNumber uint64 ImStateRoot common.Hash EffectiveGasPricePercentage uint8 IsValid uint8 Index uint64 StateRoot common.Hash EncodedLength uint32 Encoded []byte }
DSL2Transaction represents a data stream L2 transaction
type DSState ¶ added in v0.0.990
type DSState interface { GetDSGenesisBlock(ctx context.Context, dbTx pgx.Tx) (*DSL2Block, error) GetDSBatches(ctx context.Context, firstBatchNumber, lastBatchNumber uint64, readWIPBatch bool, dbTx pgx.Tx) ([]*DSBatch, error) GetDSL2Blocks(ctx context.Context, firstBatchNumber, lastBatchNumber uint64, dbTx pgx.Tx) ([]*DSL2Block, error) GetDSL2Transactions(ctx context.Context, firstL2Block, lastL2Block uint64, dbTx pgx.Tx) ([]*DSL2Transaction, error) GetStorageAt(ctx context.Context, address common.Address, position *big.Int, root common.Hash) (*big.Int, error) GetVirtualBatchParentHash(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (common.Hash, error) GetForcedBatchParentHash(ctx context.Context, forcedBatchNumber uint64, dbTx pgx.Tx) (common.Hash, error) GetL1InfoRootLeafByIndex(ctx context.Context, l1InfoTreeIndex uint32, dbTx pgx.Tx) (L1InfoTreeExitRootStorageEntry, error) }
DSState gathers the methods required to interact with the data stream state.
type EffectiveGasPriceLog ¶ added in v0.4.0
type EffectiveGasPriceLog struct { Enabled bool ValueFinal *big.Int ValueFirst *big.Int ValueSecond *big.Int FinalDeviation *big.Int MaxDeviation *big.Int GasUsedFirst uint64 GasUsedSecond uint64 GasPrice *big.Int Percentage uint8 Reprocess bool GasPriceOC bool BalanceOC bool L1GasPrice uint64 L2GasPrice uint64 Error string }
EffectiveGasPriceLog contains all the data needed to calculate the effective gas price for logging purposes
type FakeDB ¶
type FakeDB struct { State *State // contains filtered or unexported fields }
FakeDB is the implementation of the fakeevm.FakeDB interface
func (*FakeDB) AddAddressToAccessList ¶
AddAddressToAccessList not implemented// even if the feature/fork is not active yet
func (*FakeDB) AddBalance ¶
AddBalance not implemented
func (*FakeDB) AddPreimage ¶
AddPreimage not implemented
func (*FakeDB) AddSlotToAccessList ¶
AddSlotToAccessList not implemented// even if the feature/fork is not active yet
func (*FakeDB) AddressInAccessList ¶
AddressInAccessList not implemented
func (*FakeDB) CreateAccount ¶
CreateAccount not implemented
func (*FakeDB) Empty ¶
Empty returns whether the given account is empty. Empty is defined according to EIP161 (balance = nonce = code = 0).
func (*FakeDB) Exist ¶
Exist reports whether the given account exists in state. Notably this should also return true for suicided accounts.
func (*FakeDB) GetBalance ¶
GetBalance returns the balance of the given address.
func (*FakeDB) GetCodeHash ¶
GetCodeHash gets the hash for the code at a given address
func (*FakeDB) GetCodeSize ¶
GetCodeSize get address code size
func (*FakeDB) GetCommittedState ¶
GetCommittedState not implemented
func (*FakeDB) GetTransientState ¶
GetTransientState not implemented
func (*FakeDB) HasSuicided ¶
HasSuicided not implemented
func (*FakeDB) Prepare ¶
func (f *FakeDB) Prepare(rules params.Rules, sender, coinbase common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList)
Prepare not implemented
func (*FakeDB) RevertToSnapshot ¶
RevertToSnapshot not implemented
func (*FakeDB) SetStateRoot ¶
SetStateRoot is the stateRoot setter.
func (*FakeDB) SetTransientState ¶
SetTransientState not implemented
func (*FakeDB) SlotInAccessList ¶
func (f *FakeDB) SlotInAccessList(addr common.Address, slot common.Hash) (addressOk bool, slotOk bool)
SlotInAccessList not implemented
func (*FakeDB) SubBalance ¶
SubBalance not implemented
type ForcedBatch ¶
type ForcedBatch struct { BlockNumber uint64 ForcedBatchNumber uint64 Sequencer common.Address GlobalExitRoot common.Hash RawTxsData []byte ForcedAt time.Time }
ForcedBatch represents a ForcedBatch
type ForcedBatchRawV2 ¶ added in v0.5.0
type ForcedBatchRawV2 struct {
Transactions []L2TxRaw
}
ForcedBatchRawV2 is the representation of a forced batch of transactions.
func DecodeForcedBatchV2 ¶ added in v0.5.0
func DecodeForcedBatchV2(txsData []byte) (*ForcedBatchRawV2, error)
DecodeForcedBatchV2 decodes a forced batch V2 (Etrog) Is forbidden changeL2Block, so are just the set of transactions
type ForkIDInterval ¶
type ForkIDInterval struct { FromBatchNumber uint64 ToBatchNumber uint64 ForkId uint64 Version string BlockNumber uint64 }
ForkIDInterval is a fork id interval
type Genesis ¶
type Genesis struct { // BlockNumber is the block number where the polygonZKEVM smc was deployed on L1 BlockNumber uint64 // Root hash of the genesis block Root common.Hash // Actions is the data to populate into the state trie Actions []*GenesisAction }
Genesis contains the information to populate state on creation
type GenesisAction ¶
type GenesisAction struct { Address string `json:"address"` Type int `json:"type"` StoragePosition string `json:"storagePosition"` Bytecode string `json:"bytecode"` Key string `json:"key"` Value string `json:"value"` Root string `json:"root"` }
GenesisAction represents one of the values set on the SMT during genesis.
type GlobalExitRoot ¶
type GlobalExitRoot struct { BlockNumber uint64 Timestamp time.Time MainnetExitRoot common.Hash RollupExitRoot common.Hash GlobalExitRoot common.Hash }
GlobalExitRoot struct
type InfoReadWrite ¶
InfoReadWrite has information about modified addresses during the execution
type L1DataV2 ¶ added in v0.5.0
type L1DataV2 struct { GlobalExitRoot common.Hash BlockHashL1 common.Hash MinTimestamp uint64 SmtProof [][]byte }
L1DataV2 represents the L1InfoTree data used in ProcessRequest.L1InfoTreeData_V2 parameter
type L1InfoTreeExitRootStorageEntry ¶ added in v0.5.0
type L1InfoTreeExitRootStorageEntry struct { L1InfoTreeLeaf L1InfoTreeRoot common.Hash L1InfoTreeIndex uint32 }
L1InfoTreeExitRootStorageEntry entry of the Database
type L1InfoTreeLeaf ¶ added in v0.5.0
type L1InfoTreeLeaf struct { GlobalExitRoot PreviousBlockHash common.Hash }
L1InfoTreeLeaf leaf of the L1InfoTree
func (*L1InfoTreeLeaf) Hash ¶ added in v0.5.0
func (l *L1InfoTreeLeaf) Hash() common.Hash
Hash returns the hash of the leaf
type L2Block ¶ added in v0.5.0
type L2Block struct { ReceivedAt time.Time ReceivedFrom interface{} // contains filtered or unexported fields }
L2Block represents a block from L2
func NewL2Block ¶ added in v0.5.0
func NewL2Block(h *L2Header, txs []*types.Transaction, uncles []*L2Header, receipts []*types.Receipt, hasher types.TrieHasher) *L2Block
NewL2Block creates a new block. The input data is copied, changes to header and to the field values will not affect the block.
The values of TxHash, UncleHash, ReceiptHash and Bloom in header are ignored and set to values derived from the given txs, uncles and receipts.
func NewL2BlockWithHeader ¶ added in v0.5.0
NewL2BlockWithHeader creates a block with the given header data. The header data is copied, changes to header and to the field values will not affect the block.
func (*L2Block) BlockInfoRoot ¶ added in v0.5.0
BlockInfoRoot returns the header BlockInfoRoot
func (*L2Block) GlobalExitRoot ¶ added in v0.5.0
GlobalExitRoot returns the header GlobalExitRoot
type L2BlockRaw ¶ added in v0.5.0
L2BlockRaw is the raw representation of a L2 block.
type L2Header ¶ added in v0.5.0
type L2Header struct { GlobalExitRoot common.Hash `json:"globalExitRoot"` BlockInfoRoot common.Hash `json:"blockInfoRoot"` // contains filtered or unexported fields }
L2Header represents a block header in the L2.
func CopyHeader ¶ added in v0.5.0
CopyHeader creates a deep copy of a block header.
func NewL2Header ¶ added in v0.5.0
NewL2Header creates an instance of L2Header from a types.Header
func (*L2Header) Hash ¶ added in v0.5.0
Hash returns the block hash of the header, which is simply the keccak256 hash of its RLP encoding.
func (*L2Header) MarshalJSON ¶ added in v0.5.0
MarshalJSON encodes a json object
func (*L2Header) UnmarshalJSON ¶ added in v0.5.0
UnmarshalJSON decodes a json object
type L2TxRaw ¶ added in v0.5.0
type L2TxRaw struct { Tx types.Transaction EfficiencyPercentage uint8 }
L2TxRaw is the raw representation of a L2 transaction inside a L2 block.
type NewL2BlockEvent ¶
NewL2BlockEvent is a struct provided from the state to the NewL2BlockEventHandler when a new l2 block is detected with data related to this new l2 block.
type NewL2BlockEventHandler ¶
type NewL2BlockEventHandler func(e NewL2BlockEvent)
NewL2BlockEventHandler represent a func that will be called by the state when a NewL2BlockEvent is triggered
type ProcessBatchResponse ¶
type ProcessBatchResponse struct { NewStateRoot common.Hash NewAccInputHash common.Hash NewLocalExitRoot common.Hash NewBatchNumber uint64 UsedZkCounters ZKCounters ReservedZkCounters ZKCounters // TransactionResponses_V1 []*ProcessTransactionResponse BlockResponses []*ProcessBlockResponse ExecutorError error ReadWriteAddresses map[common.Address]*InfoReadWrite IsRomLevelError bool IsExecutorLevelError bool IsRomOOCError bool FlushID uint64 StoredFlushID uint64 ProverID string GasUsed_V2 uint64 SMTKeys_V2 []merkletree.Key ProgramKeys_V2 []merkletree.Key ForkID uint64 InvalidBatch_V2 bool RomError_V2 error }
ProcessBatchResponse represents the response of a batch process.
type ProcessBlockResponse ¶ added in v0.5.0
type ProcessBlockResponse struct { ParentHash common.Hash Coinbase common.Address GasLimit uint64 BlockNumber uint64 Timestamp uint64 GlobalExitRoot common.Hash BlockHashL1 common.Hash GasUsed uint64 BlockInfoRoot common.Hash BlockHash common.Hash TransactionResponses []*ProcessTransactionResponse Logs []*types.Log RomError_V2 error }
ProcessBlockResponse represents the response of a block
type ProcessRequest ¶
type ProcessRequest struct { BatchNumber uint64 GlobalExitRoot_V1 common.Hash L1InfoRoot_V2 common.Hash L1InfoTreeData_V2 map[uint32]L1DataV2 OldStateRoot common.Hash OldAccInputHash common.Hash Transactions []byte Coinbase common.Address ForcedBlockHashL1 common.Hash Timestamp_V1 time.Time TimestampLimit_V2 uint64 Caller metrics.CallerLabel SkipFirstChangeL2Block_V2 bool SkipWriteBlockInfoRoot_V2 bool SkipVerifyL1InfoRoot_V2 bool ForkID uint64 ExecutionMode uint64 }
ProcessRequest represents the request of a batch process.
type ProcessTransactionResponse ¶
type ProcessTransactionResponse struct { // TxHash is the hash of the transaction TxHash common.Hash // TxHashL2_V2 is the hash of the transaction in the L2 TxHashL2_V2 common.Hash // Type indicates legacy transaction // It will be always 0 (legacy) in the executor Type uint32 // ReturnValue is the returned data from the runtime (function result or data supplied with revert opcode) ReturnValue []byte // GasLeft is the total gas left as result of execution GasLeft uint64 // GasUsed is the total gas used as result of execution or gas estimation GasUsed uint64 // CumulativeGasUsed is the accumulated gas used (sum of tx GasUsed and CumulativeGasUsed of the previous tx in the L2 block) CumulativeGasUsed uint64 // GasRefunded is the total gas refunded as result of execution GasRefunded uint64 // RomError represents any error encountered during the execution RomError error // CreateAddress is the new SC Address in case of SC creation CreateAddress common.Address // StateRoot is the State Root StateRoot common.Hash // Logs emitted by LOG opcode Logs []*types.Log // ChangesStateRoot indicates if this tx affects the state ChangesStateRoot bool // Tx is the whole transaction object Tx types.Transaction // FullTrace contains the call trace. FullTrace instrumentation.FullTrace // EffectiveGasPrice effective gas price used for the tx EffectiveGasPrice string // EffectivePercentage effective percentage used for the tx EffectivePercentage uint32 // HasGaspriceOpcode flag to indicate if opcode 'GASPRICE' has been called HasGaspriceOpcode bool // HasBalanceOpcode flag to indicate if opcode 'BALANCE' has been called HasBalanceOpcode bool // Status of the transaction, 1 = success, 0 = failure Status uint32 }
ProcessTransactionResponse represents the response of a tx process.
type ProcessingContext ¶
type ProcessingContext struct { BatchNumber uint64 Coinbase common.Address Timestamp time.Time GlobalExitRoot common.Hash ForcedBatchNum *uint64 BatchL2Data *[]byte ClosingReason ClosingReason }
ProcessingContext is the necessary data that a batch needs to provide to the runtime, without the historical state data (processing receipt from previous batch)
type ProcessingContextV2 ¶ added in v0.5.0
type ProcessingContextV2 struct { BatchNumber uint64 Coinbase common.Address Timestamp *time.Time // Batch timeStamp and also TimestampLimit L1InfoRoot common.Hash L1InfoTreeData map[uint32]L1DataV2 ForcedBatchNum *uint64 BatchL2Data *[]byte ForcedBlockHashL1 *common.Hash SkipVerifyL1InfoRoot uint32 GlobalExitRoot common.Hash // GlobalExitRoot is not use for execute but use to OpenBatch (data on DB) ExecutionMode uint64 ClosingReason ClosingReason }
ProcessingContextV2 is the necessary data that a batch needs to provide to the runtime, without the historical state data (processing receipt from previous batch)
type ProcessingReceipt ¶
type ProcessingReceipt struct { BatchNumber uint64 StateRoot common.Hash LocalExitRoot common.Hash GlobalExitRoot common.Hash AccInputHash common.Hash // Txs []types.Transaction BatchL2Data []byte ClosingReason ClosingReason BatchResources BatchResources HighReservedZKCounters ZKCounters }
ProcessingReceipt indicates the outcome (StateRoot, AccInputHash) of processing a batch
type Proof ¶
type Proof struct { BatchNumber uint64 BatchNumberFinal uint64 Proof string InputProver string ProofID *string // Prover name, unique identifier across prover reboots. Prover *string // ProverID prover process identifier. ProverID *string // GeneratingSince holds the timestamp for the moment in which the // proof generation has started by a prover. Nil if the proof is not // currently generating. GeneratingSince *time.Time CreatedAt time.Time UpdatedAt time.Time }
Proof struct
type Queue ¶ added in v0.3.4
type Queue[T any] struct { // contains filtered or unexported fields }
Queue is a generic queue implementation that implements FIFO
func (*Queue[T]) IsEmpty ¶ added in v0.3.4
IsEmpty returns false if the queue has itens, otherwise true
type Stack ¶ added in v0.0.990
type Stack[T any] struct { // contains filtered or unexported fields }
Stack is a thread safe stack data structure implementation implementing generics
type State ¶
type State struct {
// contains filtered or unexported fields
}
State is an implementation of the state
func NewState ¶
func NewState(cfg Config, storage storage, executorClient executor.ExecutorServiceClient, stateTree *merkletree.StateTree, eventLog *event.EventLog, mt *l1infotree.L1InfoTree) *State
NewState creates a new State
func (*State) AddForkIDInterval ¶ added in v0.0.990
func (s *State) AddForkIDInterval(ctx context.Context, newForkID ForkIDInterval, dbTx pgx.Tx) error
AddForkIDInterval updates the forkID intervals
func (*State) AddL1InfoTreeLeaf ¶ added in v0.5.0
func (s *State) AddL1InfoTreeLeaf(ctx context.Context, l1InfoTreeLeaf *L1InfoTreeLeaf, dbTx pgx.Tx) (*L1InfoTreeExitRootStorageEntry, error)
AddL1InfoTreeLeaf adds a new leaf to the L1InfoTree and returns the entry and error
func (*State) BeginStateTransaction ¶
BeginStateTransaction starts a state transaction
func (*State) CloseBatch ¶
func (s *State) CloseBatch(ctx context.Context, receipt ProcessingReceipt, dbTx pgx.Tx) error
CloseBatch is used to close a batch
func (*State) CloseWIPBatch ¶ added in v0.5.0
func (s *State) CloseWIPBatch(ctx context.Context, receipt ProcessingReceipt, dbTx pgx.Tx) error
CloseWIPBatch is used by sequencer to close the wip batch
func (*State) DebugTransaction ¶
func (s *State) DebugTransaction(ctx context.Context, transactionHash common.Hash, traceConfig TraceConfig, dbTx pgx.Tx) (*runtime.ExecutionResult, error)
DebugTransaction re-executes a tx to generate its trace
func (*State) EstimateGas ¶
func (s *State) EstimateGas(transaction *types.Transaction, senderAddress common.Address, l2BlockNumber *uint64, dbTx pgx.Tx) (uint64, []byte, error)
EstimateGas for a transaction
func (*State) ExecuteBatch ¶
func (s *State) ExecuteBatch(ctx context.Context, batch Batch, updateMerkleTree bool, dbTx pgx.Tx) (*executor.ProcessBatchResponse, error)
ExecuteBatch is used by the synchronizer to reprocess batches to compare generated state root vs stored one It is also used by the sequencer in order to calculate used zkCounter of a WIPBatch
func (*State) ExecuteBatchV2 ¶ added in v0.5.0
func (s *State) ExecuteBatchV2(ctx context.Context, batch Batch, L1InfoTreeRoot common.Hash, l1InfoTreeData map[uint32]L1DataV2, timestampLimit time.Time, updateMerkleTree bool, skipVerifyL1InfoRoot uint32, forcedBlockHashL1 *common.Hash, dbTx pgx.Tx) (*executor.ProcessBatchResponseV2, error)
ExecuteBatchV2 is used by the synchronizer to reprocess batches to compare generated state root vs stored one
func (*State) FlushMerkleTree ¶
FlushMerkleTree persists updates in the Merkle tree
func (*State) GetBalance ¶
func (s *State) GetBalance(ctx context.Context, address common.Address, root common.Hash) (*big.Int, error)
GetBalance from a given address
func (*State) GetBalanceByStateRoot ¶
func (s *State) GetBalanceByStateRoot(ctx context.Context, address common.Address, root common.Hash) (*big.Int, error)
GetBalanceByStateRoot gets balance from the MT Service using the provided state root
func (*State) GetBatchTimestamp ¶ added in v0.5.0
func (s *State) GetBatchTimestamp(ctx context.Context, batchNumber uint64, forcedForkId *uint64, dbTx pgx.Tx) (*time.Time, error)
GetBatchTimestamp returns the batch timestamp.
for >= etrog is stored on virtual_batch.batch_timestamp previous batches is stored on batch.timestamp
func (*State) GetCode ¶
func (s *State) GetCode(ctx context.Context, address common.Address, root common.Hash) ([]byte, error)
GetCode from a given address
func (*State) GetCurrentL1InfoRoot ¶ added in v0.5.0
GetCurrentL1InfoRoot Return current L1InfoRoot
func (*State) GetForkIDByBatchNumber ¶ added in v0.0.990
GetForkIDByBatchNumber returns the fork id for a given batch number
func (*State) GetForkIDByBlockNumber ¶ added in v0.5.0
GetForkIDByBlockNumber returns the fork id for a given block number
func (*State) GetL1InfoTreeDataFromBatchL2Data ¶ added in v0.5.0
func (s *State) GetL1InfoTreeDataFromBatchL2Data(ctx context.Context, batchL2Data []byte, dbTx pgx.Tx) (map[uint32]L1DataV2, common.Hash, common.Hash, error)
GetL1InfoTreeDataFromBatchL2Data returns a map with the L1InfoTreeData used in the L2 blocks included in the batchL2Data, the last L1InfoRoot used and the highest globalExitRoot used in the batch
func (*State) GetLastBatch ¶
GetLastBatch gets latest batch (closed or not) on the data base
func (*State) GetLastStateRoot ¶
GetLastStateRoot returns the latest state root
func (*State) GetNonce ¶
func (s *State) GetNonce(ctx context.Context, address common.Address, root common.Hash) (uint64, error)
GetNonce returns the nonce of the given account at the given block number
func (*State) GetNonceByStateRoot ¶
func (s *State) GetNonceByStateRoot(ctx context.Context, address common.Address, root common.Hash) (*big.Int, error)
GetNonceByStateRoot gets nonce from the MT Service using the provided state root
func (*State) GetStorageAt ¶
func (s *State) GetStorageAt(ctx context.Context, address common.Address, position *big.Int, root common.Hash) (*big.Int, error)
GetStorageAt from a given address
func (*State) GetStoredFlushID ¶ added in v0.0.990
GetStoredFlushID returns the stored flush ID and Prover ID
func (*State) GetSyncingInfo ¶ added in v0.5.4
func (p *State) GetSyncingInfo(ctx context.Context, dbTx pgx.Tx) (SyncingInfo, error)
GetSyncingInfo returns information regarding the syncing status of the node
func (*State) GetTree ¶
func (s *State) GetTree() *merkletree.StateTree
GetTree returns State inner tree
func (*State) GetWIPBatch ¶ added in v0.5.0
GetWIPBatch returns the wip batch in the state
func (*State) OpenBatch ¶
func (s *State) OpenBatch(ctx context.Context, processingContext ProcessingContext, dbTx pgx.Tx) error
OpenBatch adds a new batch into the state, 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 (*State) OpenWIPBatch ¶ added in v0.5.0
OpenWIPBatch adds a new WIP batch into the state
func (*State) PreProcessTransaction ¶
func (s *State) PreProcessTransaction(ctx context.Context, tx *types.Transaction, dbTx pgx.Tx) (*ProcessBatchResponse, error)
PreProcessTransaction processes the transaction in order to calculate its zkCounters before adding it to the pool
func (*State) PreProcessUnsignedTransaction ¶ added in v0.5.13
func (s *State) PreProcessUnsignedTransaction(ctx context.Context, tx *types.Transaction, sender common.Address, l2BlockNumber *uint64, dbTx pgx.Tx) (*ProcessBatchResponse, error)
PreProcessUnsignedTransaction processes the unsigned transaction in order to calculate its zkCounters
func (*State) ProcessAndStoreClosedBatch ¶
func (s *State) ProcessAndStoreClosedBatch(ctx context.Context, processingCtx ProcessingContext, encodedTxs []byte, dbTx pgx.Tx, caller metrics.CallerLabel) (common.Hash, uint64, string, error)
ProcessAndStoreClosedBatch is used by the Synchronizer to add a closed batch into the data base. Values returned are the new stateRoot, the flushID (incremental value returned by executor), the ProverID (executor running ID) the result of closing the batch.
func (*State) ProcessAndStoreClosedBatchV2 ¶ added in v0.5.0
func (s *State) ProcessAndStoreClosedBatchV2(ctx context.Context, processingCtx ProcessingContextV2, dbTx pgx.Tx, caller metrics.CallerLabel) (common.Hash, uint64, string, error)
ProcessAndStoreClosedBatchV2 is used by the Synchronizer to add a closed batch into the data base. Values returned are the new stateRoot, the flushID (incremental value returned by executor), the ProverID (executor running ID) the result of closing the batch.
func (*State) ProcessBatch ¶
func (s *State) ProcessBatch(ctx context.Context, request ProcessRequest, updateMerkleTree bool) (*ProcessBatchResponse, error)
ProcessBatch processes a batch
func (*State) ProcessBatchV2 ¶ added in v0.5.0
func (s *State) ProcessBatchV2(ctx context.Context, request ProcessRequest, updateMerkleTree bool) (*ProcessBatchResponse, string, error)
ProcessBatchV2 processes a batch for forkID >= ETROG
func (*State) ProcessSequencerBatch ¶
func (s *State) ProcessSequencerBatch(ctx context.Context, batchNumber uint64, batchL2Data []byte, caller metrics.CallerLabel, dbTx pgx.Tx) (*ProcessBatchResponse, error)
ProcessSequencerBatch is used by the sequencers to process transactions into an open batch
func (*State) ProcessUnsignedTransaction ¶
func (s *State) ProcessUnsignedTransaction(ctx context.Context, tx *types.Transaction, senderAddress common.Address, l2BlockNumber *uint64, noZKEVMCounters bool, dbTx pgx.Tx) (*runtime.ExecutionResult, error)
ProcessUnsignedTransaction processes the given unsigned transaction.
func (*State) RegisterNewL2BlockEventHandler ¶
func (s *State) RegisterNewL2BlockEventHandler(h NewL2BlockEventHandler)
RegisterNewL2BlockEventHandler add the provided handler to the list of handlers that will be triggered when a new l2 block event is triggered
func (*State) ResetL1InfoTree ¶ added in v0.6.6
func (s *State) ResetL1InfoTree()
ResetL1InfoTree resets the L1InfoTree
func (*State) SetGenesis ¶
func (s *State) SetGenesis(ctx context.Context, block Block, genesis Genesis, m metrics.CallerLabel, dbTx pgx.Tx) (common.Hash, error)
SetGenesis populates state with genesis information
func (*State) StartToMonitorNewL2Blocks ¶ added in v0.0.990
func (s *State) StartToMonitorNewL2Blocks()
StartToMonitorNewL2Blocks starts 2 go routines that will monitor new blocks and execute handlers registered to be executed when a new l2 block is detected. This is used by the RPC WebSocket filter subscription but can be used by any other component that needs to react to a new L2 block added to the state.
func (*State) StoreL2Block ¶ added in v0.5.0
func (s *State) StoreL2Block(ctx context.Context, batchNumber uint64, l2Block *ProcessBlockResponse, txsEGPLog []*EffectiveGasPriceLog, dbTx pgx.Tx) (common.Hash, error)
StoreL2Block stores a l2 block into the state
func (*State) StoreTransaction ¶
func (s *State) StoreTransaction(ctx context.Context, batchNumber uint64, processedTx *ProcessTransactionResponse, coinbase common.Address, timestamp uint64, egpLog *EffectiveGasPriceLog, globalExitRoot, blockInfoRoot common.Hash, dbTx pgx.Tx) (*L2Header, error)
StoreTransaction is used by the trusted state synchronizer to add process a transaction.
func (*State) StoreTransactions ¶
func (s *State) StoreTransactions(ctx context.Context, batchNumber uint64, processedBlocks []*ProcessBlockResponse, txsEGPLog []*EffectiveGasPriceLog, dbTx pgx.Tx) error
StoreTransactions is used by the synchronizer through the method ProcessAndStoreClosedBatch.
func (*State) TestConvertToProcessBatchResponse ¶
func (s *State) TestConvertToProcessBatchResponse(batchResponse *executor.ProcessBatchResponse) (*ProcessBatchResponse, error)
TestConvertToProcessBatchResponse for test purposes
func (*State) TestConvertToProcessBatchResponseV2 ¶ added in v0.5.0
func (s *State) TestConvertToProcessBatchResponseV2(batchResponse *executor.ProcessBatchResponseV2) (*ProcessBatchResponse, error)
TestConvertToProcessBatchResponseV2 for test purposes
func (*State) UpdateForkIDIntervalsInMemory ¶ added in v0.0.990
func (s *State) UpdateForkIDIntervalsInMemory(intervals []ForkIDInterval)
UpdateForkIDIntervalsInMemory updates the forkID intervals in memory
type StateTx ¶ added in v0.6.6
type StateTx struct { pgx.Tx L1InfoTreeModified bool // contains filtered or unexported fields }
StateTx is the state transaction that extends the database tx
func (*StateTx) Rollback ¶ added in v0.6.6
Rollback do the dbTx rollback + modifications in cache mechanism
func (*StateTx) SetL1InfoTreeModified ¶ added in v0.6.6
func (tx *StateTx) SetL1InfoTreeModified()
SetL1InfoTreeModified sets the flag to true to save that the L1InfoTree has been modified
type StoreTxEGPData ¶ added in v0.4.0
type StoreTxEGPData struct { EGPLog *EffectiveGasPriceLog EffectivePercentage uint8 }
StoreTxEGPData contains the data related to the effective gas price that needs to be stored when storing a tx
type SyncInfoDataOnStorage ¶ added in v0.5.4
type SyncInfoDataOnStorage struct { InitialSyncingBatch uint64 LastBatchNumberSeen uint64 LastBatchNumberConsolidated uint64 }
SyncInfoDataOnStorage stores information regarding the syncing status of the node in the database
type SyncingInfo ¶
type SyncingInfo struct { InitialSyncingBlock uint64 // L2Block corresponding to InitialSyncingBatch CurrentBlockNumber uint64 // last L2Block in state EstimatedHighestBlock uint64 // estimated highest L2Block in state // IsSynchronizing indicates if the node is syncing (true -> syncing, false -> fully synced) IsSynchronizing bool }
SyncingInfo stores information regarding the syncing status of the node
type TraceConfig ¶
type TraceConfig struct { DisableStorage bool DisableStack bool EnableMemory bool EnableReturnData bool Tracer *string TracerConfig json.RawMessage }
TraceConfig sets the debug configuration for the executor
func (*TraceConfig) Is4ByteTracer ¶
func (t *TraceConfig) Is4ByteTracer() bool
Is4ByteTracer returns true when should use 4byteTracer
func (*TraceConfig) IsCallTracer ¶
func (t *TraceConfig) IsCallTracer() bool
IsCallTracer returns true when should use callTracer
func (*TraceConfig) IsDefaultTracer ¶
func (t *TraceConfig) IsDefaultTracer() bool
IsDefaultTracer returns true when no custom tracer is set
func (*TraceConfig) IsJSCustomTracer ¶
func (t *TraceConfig) IsJSCustomTracer() bool
IsJSCustomTracer returns true when should use js custom tracer
func (*TraceConfig) IsNoopTracer ¶
func (t *TraceConfig) IsNoopTracer() bool
IsNoopTracer returns true when should use noopTracer
func (*TraceConfig) IsPrestateTracer ¶
func (t *TraceConfig) IsPrestateTracer() bool
IsPrestateTracer returns true when should use prestateTracer
type TrustedReorg ¶
TrustedReorg represents a trusted reorg
type VerifiedBatch ¶
type VerifiedBatch struct { BlockNumber uint64 BatchNumber uint64 Aggregator common.Address TxHash common.Hash StateRoot common.Hash IsTrusted bool }
VerifiedBatch represents a VerifiedBatch
type VirtualBatch ¶
type VirtualBatch struct { BatchNumber uint64 TxHash common.Hash Coinbase common.Address SequencerAddr common.Address BlockNumber uint64 L1InfoRoot *common.Hash // TimestampBatchEtrog etrog: Batch timestamp comes from L1 block timestamp // for previous batches is NULL because the batch timestamp is in batch table TimestampBatchEtrog *time.Time }
VirtualBatch represents a VirtualBatch
type ZKCounters ¶
type ZKCounters struct { GasUsed uint64 KeccakHashes uint32 PoseidonHashes uint32 PoseidonPaddings uint32 MemAligns uint32 Arithmetics uint32 Binaries uint32 Steps uint32 Sha256Hashes_V2 uint32 }
ZKCounters counters for the tx
func (*ZKCounters) Fits ¶ added in v0.6.0
func (z *ZKCounters) Fits(other ZKCounters) (bool, string)
Fits checks if other zk counters fits in the zk counters. if there is a counter underflow it returns false and the name of the counter that caused the underflow
func (*ZKCounters) Sub ¶
func (z *ZKCounters) Sub(other ZKCounters) (bool, string)
Sub subtract zk counters with passed zk counters (not safe). if there is a counter underflow it returns true and the name of the counter that caused the underflow
func (*ZKCounters) SumUp ¶
func (z *ZKCounters) SumUp(other ZKCounters)
SumUp sum ups zk counters with passed tx zk counters
Source Files ¶
- batch.go
- batchV2.go
- block.go
- config.go
- converters.go
- convertersV2.go
- crypto.go
- datastream.go
- effectivegasprice.go
- encoding_batch_v2.go
- errors.go
- fakedb.go
- forcedbatch.go
- forkid.go
- genesis.go
- globalexitroot.go
- helper.go
- infinite.go
- interfaces.go
- l1infotree.go
- l2block.go
- proof.go
- queue.go
- reset.go
- stack.go
- state.go
- syncinginfo.go
- trace.go
- transaction.go
- types.go
Directories ¶
Path | Synopsis |
---|---|
instrumentation/js/internal/tracers
Package tracers contains the actual JavaScript tracer assets.
|
Package tracers contains the actual JavaScript tracer assets. |
instrumentation/tracers
Package tracers is a manager for transaction tracing engines.
|
Package tracers is a manager for transaction tracing engines. |
test
|
|