Documentation ¶
Index ¶
- Constants
- Variables
- 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 GetSender(tx *types.Transaction) (common.Address, error)
- func RlpFieldsToLegacyTx(fields [][]byte, v, r, s []byte) (tx *types.LegacyTx, err error)
- type Batch
- type BatchRawV2
- type BatchResources
- type BatchV2Encoder
- type ChangeL2BlockHeader
- type ForcedBatchRawV2
- type Genesis
- type GenesisAction
- type L2BlockRaw
- type L2TxRaw
- type ZKCounters
Constants ¶
const ( // StreamTypeSequencer represents a Sequencer stream StreamTypeSequencer datastreamer.StreamType = 1 // EntryTypeBookMark represents a bookmark entry EntryTypeBookMark datastreamer.EntryType = datastreamer.EtBookmark )
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 )
const ( // MaxEffectivePercentage is the maximum value that can be used as effective percentage MaxEffectivePercentage = uint8(255) // EfficiencyPercentageByteLength is the length of the effective percentage in bytes EfficiencyPercentageByteLength uint64 = 1 )
Variables ¶
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") )
Functions ¶
func DecodeTx ¶
func DecodeTx(encodedTx string) (*types.Transaction, error)
DecodeTx decodes a string rlp tx representation into a types.Transaction instance
func EncodeBatchV2 ¶
func EncodeBatchV2(batch *BatchRawV2) ([]byte, error)
EncodeBatchV2 encodes a batch of transactions into a byte slice.
func GetSender ¶
func GetSender(tx *types.Transaction) (common.Address, error)
GetSender gets the sender from the transaction's signature
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 // WIP: if WIP == true is a openBatch WIP bool }
Batch struct
type BatchRawV2 ¶
type BatchRawV2 struct {
Blocks []L2BlockRaw
}
BatchRawV2 is the representation of a batch of transactions.
func DecodeBatchV2 ¶
func DecodeBatchV2(txsData []byte) (*BatchRawV2, error)
DecodeBatchV2 decodes a batch of transactions from a byte slice.
func (*BatchRawV2) String ¶
func (b *BatchRawV2) String() string
type BatchResources ¶
type BatchResources struct { ZKCounters ZKCounters Bytes uint64 }
BatchResources is a struct that contains the ZKEVM resources used by a batch/tx
type BatchV2Encoder ¶
type BatchV2Encoder struct {
// contains filtered or unexported fields
}
BatchV2Encoder is a builder of the batchl2data used by EncodeBatchV2
func NewBatchV2Encoder ¶
func NewBatchV2Encoder() *BatchV2Encoder
NewBatchV2Encoder creates a new BatchV2Encoder.
func (*BatchV2Encoder) AddBlockHeader ¶
func (b *BatchV2Encoder) AddBlockHeader(l2BlockHeader ChangeL2BlockHeader)
AddBlockHeader adds a block header to the batch.
func (*BatchV2Encoder) AddTransaction ¶
func (b *BatchV2Encoder) AddTransaction(transaction *L2TxRaw) error
AddTransaction adds a transaction to the batch.
func (*BatchV2Encoder) AddTransactions ¶
func (b *BatchV2Encoder) AddTransactions(transactions []L2TxRaw) error
AddTransactions adds a set of transactions to the batch.
func (*BatchV2Encoder) GetResult ¶
func (b *BatchV2Encoder) GetResult() []byte
GetResult returns the batch data.
type ChangeL2BlockHeader ¶
ChangeL2BlockHeader is the header of a L2 block.
func (ChangeL2BlockHeader) Encode ¶
func (c ChangeL2BlockHeader) Encode(batchData []byte) []byte
Encode encodes a batch of l2blocks header into a byte slice.
type ForcedBatchRawV2 ¶
type ForcedBatchRawV2 struct {
Transactions []L2TxRaw
}
ForcedBatchRawV2 is the representation of a forced batch of transactions.
func DecodeForcedBatchV2 ¶
func DecodeForcedBatchV2(txsData []byte) (*ForcedBatchRawV2, error)
DecodeForcedBatchV2 decodes a forced batch V2 (Etrog) Is forbidden changeL2Block, so are just the set of transactions
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 L2BlockRaw ¶
type L2BlockRaw struct { BlockNumber uint64 ChangeL2BlockHeader Transactions []L2TxRaw }
L2BlockRaw is the raw representation of a L2 block.
type L2TxRaw ¶
type L2TxRaw struct { EfficiencyPercentage uint8 // valid always TxAlreadyEncoded bool // If true the tx is already encoded (data field is used) Tx *types.Transaction // valid if TxAlreadyEncoded == false Data []byte // valid if TxAlreadyEncoded == true }
L2TxRaw is the raw representation of a L2 transaction inside a L2 block.
func DecodeTxRLP ¶
DecodeTxRLP decodes a transaction from a byte slice.