types

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2024 License: AGPL-3.0, AGPL-3.0-or-later Imports: 16 Imported by: 7

Documentation

Index

Constants

View Source
const (
	// EarliestBlockNumber represents the earliest block number, always 0
	EarliestBlockNumber = BlockNumber(-1)
	// LatestBlockNumber represents the latest block number
	LatestBlockNumber = BlockNumber(-2)
	// PendingBlockNumber represents the pending block number
	PendingBlockNumber = BlockNumber(-3)
	// SafeBlockNumber represents the last verified block number that is safe on Ethereum
	SafeBlockNumber = BlockNumber(-4)
	// FinalizedBlockNumber represents the last verified block number that is finalized on Ethereum
	FinalizedBlockNumber = BlockNumber(-5)

	// EarliestBatchNumber represents the earliest batch number, always 0
	EarliestBatchNumber = BatchNumber(-1)
	// LatestBatchNumber represents the last closed batch number
	LatestBatchNumber = BatchNumber(-2)
	// PendingBatchNumber represents the last batch in the trusted state
	PendingBatchNumber = BatchNumber(-3)
	// SafeBatchNumber represents the last batch verified in a block that is safe on Ethereum
	SafeBatchNumber = BatchNumber(-4)
	// FinalizedBatchNumber represents the last batch verified in a block that has been finalized on Ethereum
	FinalizedBatchNumber = BatchNumber(-5)

	// Earliest contains the string to represent the earliest block known.
	Earliest = "earliest"
	// Latest contains the string to represent the latest block known.
	Latest = "latest"
	// Pending contains the string to represent the pending block known.
	Pending = "pending"
	// Safe contains the string to represent the last virtualized block known.
	Safe = "safe"
	// Finalized contains the string to represent the last verified block known.
	Finalized = "finalized"

	// BlockNumberKey is the key for the block number for EIP-1898
	BlockNumberKey = "blockNumber"
	// BlockHashKey is the key for the block hash for EIP-1898
	BlockHashKey = "blockHash"
	// RequireCanonicalKey is the key for the require canonical for EIP-1898
	RequireCanonicalKey = "requireCanonical"
)
View Source
const (
	// DefaultErrorCode rpc default error code
	DefaultErrorCode = -32000
	// RevertedErrorCode error code for reverted txs
	RevertedErrorCode = 3
	// InvalidRequestErrorCode error code for invalid requests
	InvalidRequestErrorCode = -32600
	// NotFoundErrorCode error code for not found objects
	NotFoundErrorCode = -32601
	// InvalidParamsErrorCode error code for invalid parameters
	InvalidParamsErrorCode = -32602
	// ParserErrorCode error code for parsing errors
	ParserErrorCode = -32700
)

Variables

View Source
var (
	// ErrBatchRequestsDisabled returned by the server when a batch request
	// is detected and the batch requests are disabled via configuration
	ErrBatchRequestsDisabled = fmt.Errorf("batch requests are disabled")

	// ErrBatchRequestsLimitExceeded returned by the server when a batch request
	// is detected and the number of requests are greater than the configured limit.
	ErrBatchRequestsLimitExceeded = fmt.Errorf("batch requests limit exceeded")
)

Functions

This section is empty.

Types

type ArgAddress

type ArgAddress common.Address

ArgAddress represents a common.Address that accepts strings shorter than 32 bytes, like 0x00

func (*ArgAddress) Address

func (arg *ArgAddress) Address() common.Address

Address returns an instance of common.Address

func (*ArgAddress) UnmarshalText

func (b *ArgAddress) UnmarshalText(input []byte) error

UnmarshalText unmarshals from text

type ArgBig

type ArgBig big.Int

ArgBig helps to marshal big number values provided in the RPC requests

func (ArgBig) Hex

func (b ArgBig) Hex() string

Hex returns a hexadecimal representation

func (ArgBig) MarshalText

func (a ArgBig) MarshalText() ([]byte, error)

MarshalText marshals an array of bytes into an instance of ArgBig

func (*ArgBig) UnmarshalText

func (a *ArgBig) UnmarshalText(input []byte) error

UnmarshalText unmarshals an instance of ArgBig into an array of bytes

type ArgBytes

type ArgBytes []byte

ArgBytes helps to marshal byte array values provided in the RPC requests

func ArgBytesPtr

func ArgBytesPtr(b []byte) *ArgBytes

ArgBytesPtr helps to marshal byte array values provided in the RPC requests

func (ArgBytes) Hex

func (b ArgBytes) Hex() string

Hex returns a hexadecimal representation

func (ArgBytes) MarshalText

func (b ArgBytes) MarshalText() ([]byte, error)

MarshalText marshals into text

func (*ArgBytes) UnmarshalText

func (b *ArgBytes) UnmarshalText(input []byte) error

UnmarshalText unmarshals from text

type ArgHash

type ArgHash common.Hash

ArgHash represents a common.Hash that accepts strings shorter than 64 bytes, like 0x00

func (*ArgHash) Hash

func (arg *ArgHash) Hash() common.Hash

Hash returns an instance of common.Hash

func (*ArgHash) UnmarshalText

func (arg *ArgHash) UnmarshalText(input []byte) error

UnmarshalText unmarshals from text

type ArgUint64

type ArgUint64 uint64

ArgUint64 helps to marshal uint64 values provided in the RPC requests

func ArgUint64Ptr

func ArgUint64Ptr(a ArgUint64) *ArgUint64

ArgUint64Ptr returns the pointer of the provided ArgUint64

func (ArgUint64) Hex

func (b ArgUint64) Hex() string

Hex returns a hexadecimal representation

func (ArgUint64) MarshalText

func (b ArgUint64) MarshalText() ([]byte, error)

MarshalText marshals into text

func (*ArgUint64) UnmarshalText

func (b *ArgUint64) UnmarshalText(input []byte) error

UnmarshalText unmarshals from text

type Batch

type Batch struct {
	Number              ArgUint64           `json:"number"`
	ForcedBatchNumber   *ArgUint64          `json:"forcedBatchNumber,omitempty"`
	Coinbase            common.Address      `json:"coinbase"`
	StateRoot           common.Hash         `json:"stateRoot"`
	GlobalExitRoot      common.Hash         `json:"globalExitRoot"`
	MainnetExitRoot     common.Hash         `json:"mainnetExitRoot"`
	RollupExitRoot      common.Hash         `json:"rollupExitRoot"`
	LocalExitRoot       common.Hash         `json:"localExitRoot"`
	AccInputHash        common.Hash         `json:"accInputHash"`
	Timestamp           ArgUint64           `json:"timestamp"`
	SendSequencesTxHash *common.Hash        `json:"sendSequencesTxHash"`
	VerifyBatchTxHash   *common.Hash        `json:"verifyBatchTxHash"`
	Closed              bool                `json:"closed"`
	Blocks              []BlockOrHash       `json:"blocks"`
	Transactions        []TransactionOrHash `json:"transactions"`
	BatchL2Data         ArgBytes            `json:"batchL2Data"`
}

Batch structure

func NewBatch

func NewBatch(ctx context.Context, st StateInterface, batch *state.Batch, virtualBatch *state.VirtualBatch, verifiedBatch *state.VerifiedBatch, blocks []state.L2Block, receipts []types.Receipt, fullTx, includeReceipts bool, ger *state.GlobalExitRoot, dbTx pgx.Tx) (*Batch, error)

NewBatch creates a Batch instance

type BatchNumber

type BatchNumber int64

BatchNumber is the number of a ethereum block

func (*BatchNumber) GetNumericBatchNumber

func (b *BatchNumber) GetNumericBatchNumber(ctx context.Context, s StateInterface, e EthermanInterface, dbTx pgx.Tx) (uint64, Error)

GetNumericBatchNumber returns a numeric batch number based on the BatchNumber instance

func (*BatchNumber) StringOrHex added in v0.5.0

func (b *BatchNumber) StringOrHex() string

StringOrHex returns the batch number as a string or hex n == -5 = finalized n == -4 = safe n == -3 = pending n == -2 = latest n == -1 = earliest n >= 0 = hex(n)

func (*BatchNumber) UnmarshalJSON

func (b *BatchNumber) UnmarshalJSON(buffer []byte) error

UnmarshalJSON automatically decodes the user input for the block number, when a JSON RPC method is called

type Block

type Block struct {
	ParentHash      common.Hash         `json:"parentHash"`
	Sha3Uncles      common.Hash         `json:"sha3Uncles"`
	Miner           *common.Address     `json:"miner"`
	StateRoot       common.Hash         `json:"stateRoot"`
	TxRoot          common.Hash         `json:"transactionsRoot"`
	ReceiptsRoot    common.Hash         `json:"receiptsRoot"`
	LogsBloom       types.Bloom         `json:"logsBloom"`
	Difficulty      ArgUint64           `json:"difficulty"`
	TotalDifficulty *ArgUint64          `json:"totalDifficulty"`
	Size            ArgUint64           `json:"size"`
	Number          ArgUint64           `json:"number"`
	GasLimit        ArgUint64           `json:"gasLimit"`
	GasUsed         ArgUint64           `json:"gasUsed"`
	Timestamp       ArgUint64           `json:"timestamp"`
	ExtraData       ArgBytes            `json:"extraData"`
	MixHash         common.Hash         `json:"mixHash"`
	Nonce           *ArgBytes           `json:"nonce"`
	Hash            *common.Hash        `json:"hash"`
	Transactions    []TransactionOrHash `json:"transactions"`
	Uncles          []common.Hash       `json:"uncles"`
	GlobalExitRoot  *common.Hash        `json:"globalExitRoot,omitempty"`
	BlockInfoRoot   *common.Hash        `json:"blockInfoRoot,omitempty"`
}

Block structure

func NewBlock

func NewBlock(ctx context.Context, st StateInterface, hash *common.Hash, b *state.L2Block, receipts []types.Receipt, fullTx, includeReceipts bool, includeExtraInfo *bool, dbTx pgx.Tx) (*Block, error)

NewBlock creates a Block instance

type BlockNumber

type BlockNumber int64

BlockNumber is the number of a ethereum block

func StringToBlockNumber

func StringToBlockNumber(str string) (BlockNumber, error)

StringToBlockNumber converts a string like "latest" or "0x1" to a BlockNumber instance

func (*BlockNumber) GetNumericBlockNumber

func (b *BlockNumber) GetNumericBlockNumber(ctx context.Context, s StateInterface, e EthermanInterface, dbTx pgx.Tx) (uint64, Error)

GetNumericBlockNumber returns a numeric block number based on the BlockNumber instance

func (*BlockNumber) StringOrHex

func (b *BlockNumber) StringOrHex() string

StringOrHex returns the block number as a string or hex n == -5 = finalized n == -4 = safe n == -3 = pending n == -2 = latest n == -1 = earliest n >= 0 = hex(n)

func (*BlockNumber) UnmarshalJSON

func (b *BlockNumber) UnmarshalJSON(buffer []byte) error

UnmarshalJSON automatically decodes the user input for the block number, when a JSON RPC method is called

type BlockNumberOrHash

type BlockNumberOrHash struct {
	// contains filtered or unexported fields
}

BlockNumberOrHash allows a string value to be parsed into a block number or a hash, it's used by methods like eth_call that allows the block to be specified either by the block number or the block hash

func (*BlockNumberOrHash) Hash

func (b *BlockNumberOrHash) Hash() *ArgHash

Hash returns the hash

func (*BlockNumberOrHash) IsHash

func (b *BlockNumberOrHash) IsHash() bool

IsHash checks if the hash has value

func (*BlockNumberOrHash) IsNumber

func (b *BlockNumberOrHash) IsNumber() bool

IsNumber checks if the number has value

func (*BlockNumberOrHash) Number

func (b *BlockNumberOrHash) Number() *BlockNumber

Number returns the number

func (*BlockNumberOrHash) SetHash

func (b *BlockNumberOrHash) SetHash(hash ArgHash, requireCanonical bool)

SetHash sets the hash and nullify the number

func (*BlockNumberOrHash) SetNumber

func (b *BlockNumberOrHash) SetNumber(number BlockNumber)

SetNumber sets the number and nullify the hash

func (*BlockNumberOrHash) UnmarshalJSON

func (b *BlockNumberOrHash) UnmarshalJSON(buffer []byte) error

UnmarshalJSON automatically decodes the user input for the block number, when a JSON RPC method is called

type BlockOrHash added in v0.0.990

type BlockOrHash struct {
	Hash  *common.Hash
	Block *Block
}

BlockOrHash for union type of block and types.Hash

func (BlockOrHash) MarshalJSON added in v0.0.990

func (bh BlockOrHash) MarshalJSON() ([]byte, error)

MarshalJSON marshals into json

func (*BlockOrHash) UnmarshalJSON added in v0.0.990

func (bh *BlockOrHash) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from json

type Error

type Error interface {
	Error() string
	ErrorCode() int
	ErrorData() []byte
}

Error interface

type ErrorObject

type ErrorObject struct {
	Code    int       `json:"code"`
	Message string    `json:"message"`
	Data    *ArgBytes `json:"data,omitempty"`
}

ErrorObject is a jsonrpc error

func (*ErrorObject) RPCError added in v0.5.0

func (e *ErrorObject) RPCError() RPCError

RPCError returns an instance of RPCError from the data available in the ErrorObject instance

type EthermanInterface added in v0.0.990

type EthermanInterface interface {
	GetSafeBlockNumber(ctx context.Context) (uint64, error)
	GetFinalizedBlockNumber(ctx context.Context) (uint64, error)
}

EthermanInterface provides integration with L1

type ExitRoots added in v0.5.0

type ExitRoots struct {
	BlockNumber     ArgUint64   `json:"blockNumber"`
	Timestamp       ArgUint64   `json:"timestamp"`
	MainnetExitRoot common.Hash `json:"mainnetExitRoot"`
	RollupExitRoot  common.Hash `json:"rollupExitRoot"`
}

ExitRoots structure

type Index

type Index int64

Index of a item

func (*Index) UnmarshalJSON

func (i *Index) UnmarshalJSON(buffer []byte) error

UnmarshalJSON automatically decodes the user input for the block number, when a JSON RPC method is called

type Log

type Log struct {
	Address     common.Address `json:"address"`
	Topics      []common.Hash  `json:"topics"`
	Data        ArgBytes       `json:"data"`
	BlockNumber ArgUint64      `json:"blockNumber"`
	TxHash      common.Hash    `json:"transactionHash"`
	TxIndex     ArgUint64      `json:"transactionIndex"`
	BlockHash   common.Hash    `json:"blockHash"`
	LogIndex    ArgUint64      `json:"logIndex"`
	Removed     bool           `json:"removed"`
}

Log structure

func NewLog

func NewLog(l types.Log) Log

NewLog creates a new instance of Log

type LogFilterRequest

type LogFilterRequest struct {
	BlockHash *common.Hash  `json:"blockHash,omitempty"`
	FromBlock *string       `json:"fromBlock,omitempty"`
	ToBlock   *string       `json:"toBlock,omitempty"`
	Address   interface{}   `json:"address,omitempty"`
	Topics    []interface{} `json:"topics,omitempty"`
}

LogFilterRequest represents a log filter request.

type PoolInterface

type PoolInterface interface {
	AddTx(ctx context.Context, tx types.Transaction, ip string) error
	GetGasPrices(ctx context.Context) (pool.GasPrices, error)
	GetNonce(ctx context.Context, address common.Address) (uint64, error)
	GetPendingTxHashesSince(ctx context.Context, since time.Time) ([]common.Hash, error)
	GetPendingTxs(ctx context.Context, limit uint64) ([]pool.Transaction, error)
	CountPendingTransactions(ctx context.Context) (uint64, error)
	GetTransactionByHash(ctx context.Context, hash common.Hash) (*pool.Transaction, error)
	GetTransactionByL2Hash(ctx context.Context, hash common.Hash) (*pool.Transaction, error)
	CalculateEffectiveGasPrice(rawTx []byte, txGasPrice *big.Int, txGasUsed uint64, l1GasPrice uint64, l2GasPrice uint64) (*big.Int, error)
	EffectiveGasPriceEnabled() bool
}

PoolInterface contains the methods required to interact with the tx pool.

type RPCError

type RPCError struct {
	// contains filtered or unexported fields
}

RPCError represents an error returned by a JSON RPC endpoint.

func NewRPCError

func NewRPCError(code int, err string, args ...interface{}) *RPCError

NewRPCError creates a new error instance to be returned by the RPC endpoints

func NewRPCErrorWithData

func NewRPCErrorWithData(code int, err string, data []byte, args ...interface{}) *RPCError

NewRPCErrorWithData creates a new error instance with data to be returned by the RPC endpoints

func (RPCError) Error

func (e RPCError) Error() string

Error returns the error message.

func (*RPCError) ErrorCode

func (e *RPCError) ErrorCode() int

ErrorCode returns the error code.

func (*RPCError) ErrorData

func (e *RPCError) ErrorData() []byte

ErrorData returns the error data.

type Receipt

type Receipt struct {
	Root              *common.Hash    `json:"root,omitempty"`
	CumulativeGasUsed ArgUint64       `json:"cumulativeGasUsed"`
	LogsBloom         types.Bloom     `json:"logsBloom"`
	Logs              []*types.Log    `json:"logs"`
	Status            ArgUint64       `json:"status"`
	TxHash            common.Hash     `json:"transactionHash"`
	TxIndex           ArgUint64       `json:"transactionIndex"`
	BlockHash         common.Hash     `json:"blockHash"`
	BlockNumber       ArgUint64       `json:"blockNumber"`
	GasUsed           ArgUint64       `json:"gasUsed"`
	FromAddr          common.Address  `json:"from"`
	ToAddr            *common.Address `json:"to"`
	ContractAddress   *common.Address `json:"contractAddress"`
	Type              ArgUint64       `json:"type"`
	EffectiveGasPrice *ArgBig         `json:"effectiveGasPrice,omitempty"`
	TxL2Hash          *common.Hash    `json:"transactionL2Hash,omitempty"`
}

Receipt structure

func NewReceipt

func NewReceipt(tx types.Transaction, r *types.Receipt, l2Hash *common.Hash) (Receipt, error)

NewReceipt creates a new Receipt instance

type Request

type Request struct {
	JSONRPC string          `json:"jsonrpc"`
	ID      interface{}     `json:"id"`
	Method  string          `json:"method"`
	Params  json.RawMessage `json:"params,omitempty"`
}

Request is a jsonrpc request

type Response

type Response struct {
	JSONRPC string
	ID      interface{}
	Result  json.RawMessage
	Error   *ErrorObject
}

Response is a jsonrpc success response

func NewResponse

func NewResponse(req Request, reply []byte, err Error) Response

NewResponse returns Success/Error response object

func (Response) Bytes

func (s Response) Bytes() ([]byte, error)

Bytes return the serialized response

func (Response) MarshalJSON

func (r Response) MarshalJSON() ([]byte, error)

MarshalJSON customizes the JSON representation of the response.

type RevertInfo added in v0.5.13

type RevertInfo struct {
	Message string    `json:"message"`
	Data    *ArgBytes `json:"data,omitempty"`
}

RevertInfo contains the reverted message and data when a tx is reverted during the zk counter estimation

type StateInterface

type StateInterface interface {
	StartToMonitorNewL2Blocks()
	BeginStateTransaction(ctx context.Context) (pgx.Tx, error)
	DebugTransaction(ctx context.Context, transactionHash common.Hash, traceConfig state.TraceConfig, dbTx pgx.Tx) (*runtime.ExecutionResult, error)
	EstimateGas(transaction *types.Transaction, senderAddress common.Address, l2BlockNumber *uint64, dbTx pgx.Tx) (uint64, []byte, error)
	GetBalance(ctx context.Context, address common.Address, root common.Hash) (*big.Int, error)
	GetCode(ctx context.Context, address common.Address, root common.Hash) ([]byte, error)
	GetL2BlockByHash(ctx context.Context, hash common.Hash, dbTx pgx.Tx) (*state.L2Block, error)
	GetL2BlockByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.L2Block, error)
	BatchNumberByL2BlockNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (uint64, error)
	GetL2BlockHashesSince(ctx context.Context, since time.Time, dbTx pgx.Tx) ([]common.Hash, error)
	GetL2BlockHeaderByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.L2Header, error)
	GetL2BlockTransactionCountByHash(ctx context.Context, hash common.Hash, dbTx pgx.Tx) (uint64, error)
	GetL2BlockTransactionCountByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (uint64, error)
	GetLastVirtualizedL2BlockNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)
	GetLastConsolidatedL2BlockNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)
	GetLastL2Block(ctx context.Context, dbTx pgx.Tx) (*state.L2Block, error)
	GetLastL2BlockNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)
	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)
	GetNonce(ctx context.Context, address common.Address, root common.Hash) (uint64, error)
	GetStorageAt(ctx context.Context, address common.Address, position *big.Int, root common.Hash) (*big.Int, error)
	GetSyncingInfo(ctx context.Context, dbTx pgx.Tx) (state.SyncingInfo, error)
	GetTransactionByHash(ctx context.Context, transactionHash common.Hash, dbTx pgx.Tx) (*types.Transaction, error)
	GetTransactionByL2Hash(ctx context.Context, transactionHash common.Hash, dbTx pgx.Tx) (*types.Transaction, error)
	GetTransactionByL2BlockHashAndIndex(ctx context.Context, blockHash common.Hash, index uint64, dbTx pgx.Tx) (*types.Transaction, error)
	GetTransactionByL2BlockNumberAndIndex(ctx context.Context, blockNumber uint64, index uint64, dbTx pgx.Tx) (*types.Transaction, error)
	GetTransactionReceipt(ctx context.Context, transactionHash common.Hash, dbTx pgx.Tx) (*types.Receipt, error)
	IsL2BlockConsolidated(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (bool, error)
	IsL2BlockVirtualized(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (bool, error)
	ProcessUnsignedTransaction(ctx context.Context, tx *types.Transaction, senderAddress common.Address, l2BlockNumber *uint64, noZKEVMCounters bool, dbTx pgx.Tx) (*runtime.ExecutionResult, error)
	RegisterNewL2BlockEventHandler(h state.NewL2BlockEventHandler)
	GetLastVirtualBatchNum(ctx context.Context, dbTx pgx.Tx) (uint64, error)
	GetLastVerifiedBatch(ctx context.Context, dbTx pgx.Tx) (*state.VerifiedBatch, error)
	GetLastBatchNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)
	GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error)
	GetTransactionsByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (txs []types.Transaction, effectivePercentages []uint8, err error)
	GetVirtualBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.VirtualBatch, error)
	GetVerifiedBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.VerifiedBatch, error)
	GetExitRootByGlobalExitRoot(ctx context.Context, ger common.Hash, dbTx pgx.Tx) (*state.GlobalExitRoot, error)
	GetL2BlocksByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) ([]state.L2Block, error)
	GetNativeBlockHashesInRange(ctx context.Context, fromBlockNumber uint64, toBlockNumber uint64, dbTx pgx.Tx) ([]common.Hash, error)
	GetLastClosedBatchNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)
	GetLastVerifiedL2BlockNumberUntilL1Block(ctx context.Context, l1FinalizedBlockNumber uint64, dbTx pgx.Tx) (uint64, error)
	GetLastVerifiedBatchNumberUntilL1Block(ctx context.Context, l1BlockNumber uint64, dbTx pgx.Tx) (uint64, error)
	GetBatchTimestamp(ctx context.Context, batchNumber uint64, forcedForkId *uint64, dbTx pgx.Tx) (*time.Time, error)
	GetLatestBatchGlobalExitRoot(ctx context.Context, dbTx pgx.Tx) (common.Hash, error)
	GetL2TxHashByTxHash(ctx context.Context, hash common.Hash, dbTx pgx.Tx) (*common.Hash, error)
	PreProcessUnsignedTransaction(ctx context.Context, tx *types.Transaction, sender common.Address, l2BlockNumber *uint64, dbTx pgx.Tx) (*state.ProcessBatchResponse, error)
}

StateInterface gathers the methods required to interact with the state.

type SubscriptionResponse

type SubscriptionResponse struct {
	JSONRPC string                     `json:"jsonrpc"`
	Method  string                     `json:"method"`
	Params  SubscriptionResponseParams `json:"params"`
}

SubscriptionResponse used to push response for filters that have an active web socket connection

func (SubscriptionResponse) Bytes

func (s SubscriptionResponse) Bytes() ([]byte, error)

Bytes return the serialized response

type SubscriptionResponseParams

type SubscriptionResponseParams struct {
	Subscription string          `json:"subscription"`
	Result       json.RawMessage `json:"result"`
}

SubscriptionResponseParams parameters for subscription responses

type Transaction

type Transaction struct {
	Nonce       ArgUint64       `json:"nonce"`
	GasPrice    ArgBig          `json:"gasPrice"`
	Gas         ArgUint64       `json:"gas"`
	To          *common.Address `json:"to"`
	Value       ArgBig          `json:"value"`
	Input       ArgBytes        `json:"input"`
	V           ArgBig          `json:"v"`
	R           ArgBig          `json:"r"`
	S           ArgBig          `json:"s"`
	Hash        common.Hash     `json:"hash"`
	From        common.Address  `json:"from"`
	BlockHash   *common.Hash    `json:"blockHash"`
	BlockNumber *ArgUint64      `json:"blockNumber"`
	TxIndex     *ArgUint64      `json:"transactionIndex"`
	ChainID     ArgBig          `json:"chainId"`
	Type        ArgUint64       `json:"type"`
	Receipt     *Receipt        `json:"receipt,omitempty"`
	L2Hash      *common.Hash    `json:"l2Hash,omitempty"`
}

Transaction structure

func NewTransaction

func NewTransaction(
	tx types.Transaction,
	receipt *types.Receipt,
	includeReceipt bool, l2Hash *common.Hash,
) (*Transaction, error)

NewTransaction creates a transaction instance

func (Transaction) CoreTx

func (t Transaction) CoreTx() *types.Transaction

CoreTx returns a geth core type Transaction

type TransactionOrHash

type TransactionOrHash struct {
	Hash *common.Hash
	Tx   *Transaction
}

TransactionOrHash for union type of transaction and types.Hash

func (TransactionOrHash) MarshalJSON

func (th TransactionOrHash) MarshalJSON() ([]byte, error)

MarshalJSON marshals into json

func (*TransactionOrHash) UnmarshalJSON

func (th *TransactionOrHash) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from json

type TxArgs

type TxArgs struct {
	From     *common.Address
	To       *common.Address
	Gas      *ArgUint64
	GasPrice *ArgBytes
	Value    *ArgBytes
	Data     *ArgBytes
	Input    *ArgBytes
	Nonce    *ArgUint64
}

TxArgs is the transaction argument for the rpc endpoints

func (*TxArgs) ToTransaction

func (args *TxArgs) ToTransaction(ctx context.Context, st StateInterface, maxCumulativeGasUsed uint64, root common.Hash, defaultSenderAddress common.Address, dbTx pgx.Tx) (common.Address, *types.Transaction, error)

ToTransaction transforms txnArgs into a Transaction

type ZKCounters added in v0.5.13

type ZKCounters struct {
	GasUsed              ArgUint64 `json:"gasUsed"`
	UsedKeccakHashes     ArgUint64 `json:"usedKeccakHashes"`
	UsedPoseidonHashes   ArgUint64 `json:"usedPoseidonHashes"`
	UsedPoseidonPaddings ArgUint64 `json:"usedPoseidonPaddings"`
	UsedMemAligns        ArgUint64 `json:"usedMemAligns"`
	UsedArithmetics      ArgUint64 `json:"usedArithmetics"`
	UsedBinaries         ArgUint64 `json:"usedBinaries"`
	UsedSteps            ArgUint64 `json:"usedSteps"`
	UsedSHA256Hashes     ArgUint64 `json:"usedSHA256Hashes"`
}

ZKCounters counters for the tx

type ZKCountersLimits added in v0.5.13

type ZKCountersLimits struct {
	MaxGasUsed          ArgUint64 `json:"maxGasUsed"`
	MaxKeccakHashes     ArgUint64 `json:"maxKeccakHashes"`
	MaxPoseidonHashes   ArgUint64 `json:"maxPoseidonHashes"`
	MaxPoseidonPaddings ArgUint64 `json:"maxPoseidonPaddings"`
	MaxMemAligns        ArgUint64 `json:"maxMemAligns"`
	MaxArithmetics      ArgUint64 `json:"maxArithmetics"`
	MaxBinaries         ArgUint64 `json:"maxBinaries"`
	MaxSteps            ArgUint64 `json:"maxSteps"`
	MaxSHA256Hashes     ArgUint64 `json:"maxSHA256Hashes"`
}

ZKCountersLimits used to return the zk counter limits to the user

type ZKCountersResponse added in v0.5.13

type ZKCountersResponse struct {
	CountersUsed   ZKCounters       `json:"countersUsed"`
	CountersLimits ZKCountersLimits `json:"countersLimit"`
	Revert         *RevertInfo      `json:"revert,omitempty"`
	OOCError       *string          `json:"oocError,omitempty"`
}

ZKCountersResponse returned when counters are estimated

func NewZKCountersResponse added in v0.5.13

func NewZKCountersResponse(zkCounters state.ZKCounters, limits ZKCountersLimits, revert *RevertInfo, oocErr error) ZKCountersResponse

NewZKCountersResponse creates an instance of ZKCounters to be returned by the RPC to the caller

Jump to

Keyboard shortcuts

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