Documentation ¶
Index ¶
- Constants
- Variables
- func ToBatchNumArg(number *big.Int) string
- type ArgAddress
- type ArgBig
- type ArgBytes
- type ArgHash
- type ArgUint64
- type Batch
- type BatchNumber
- type Block
- type BlockNumber
- type BlockNumberOrHash
- func (b *BlockNumberOrHash) Hash() *ArgHash
- func (b *BlockNumberOrHash) IsHash() bool
- func (b *BlockNumberOrHash) IsNumber() bool
- func (b *BlockNumberOrHash) Number() *BlockNumber
- func (b *BlockNumberOrHash) SetHash(hash ArgHash, requireCanonical bool)
- func (b *BlockNumberOrHash) SetNumber(number BlockNumber)
- func (b *BlockNumberOrHash) UnmarshalJSON(buffer []byte) error
- type BlockOrHash
- type Error
- type ErrorObject
- type EthermanInterface
- type Index
- type Log
- type LogFilterRequest
- type PoolInterface
- type RPCError
- type Receipt
- type Request
- type Response
- type StateInterface
- type SubscriptionResponse
- type SubscriptionResponseParams
- type Transaction
- type TransactionOrHash
- type TxArgs
Constants ¶
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" )
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 ¶
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 ¶
func ToBatchNumArg ¶
ToBatchNumArg converts a big.Int into a batch number rpc parameter
Types ¶
type ArgAddress ¶
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 ¶
ArgBig helps to marshal big number values provided in the RPC requests
func (ArgBig) MarshalText ¶
MarshalText marshals an array of bytes into an instance of ArgBig
func (*ArgBig) UnmarshalText ¶
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 ¶
ArgBytesPtr helps to marshal byte array values provided in the RPC requests
func (ArgBytes) MarshalText ¶
MarshalText marshals into text
func (*ArgBytes) UnmarshalText ¶
UnmarshalText unmarshals from text
type ArgHash ¶
ArgHash represents a common.Hash that accepts strings shorter than 64 bytes, like 0x00
func (*ArgHash) UnmarshalText ¶
UnmarshalText unmarshals from text
type ArgUint64 ¶
type ArgUint64 uint64
ArgUint64 helps to marshal uint64 values provided in the RPC requests
func ArgUint64Ptr ¶
ArgUint64Ptr returns the pointer of the provided ArgUint64
func (ArgUint64) MarshalText ¶
MarshalText marshals into text
func (*ArgUint64) UnmarshalText ¶
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
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) 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"` }
Block structure
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) 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
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 ErrorObject ¶
type ErrorObject struct { Code int `json:"code"` Message string `json:"message"` Data *ArgBytes `json:"data,omitempty"` }
ErrorObject is a jsonrpc error
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 Index ¶
type Index int64
Index of a item
func (*Index) UnmarshalJSON ¶
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
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) GetTxByHash(ctx context.Context, hash common.Hash) (*pool.Transaction, error) }
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 ¶
NewRPCError creates a new error instance to be returned by the RPC endpoints
func NewRPCErrorWithData ¶
NewRPCErrorWithData creates a new error instance with data to be returned by the RPC endpoints
type Receipt ¶
type Receipt struct { Root common.Hash `json:"root"` 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"` }
Receipt structure
func NewReceipt ¶
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 ¶
NewResponse returns Success/Error response object
func (Response) MarshalJSON ¶
MarshalJSON customizes the JSON representation of the response.
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) (*types.Block, error) GetL2BlockByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*types.Block, 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) (*types.Header, 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) (*types.Block, 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) 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) ([]types.Block, 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) }
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"` }
Transaction structure
func NewTransaction ¶
func NewTransaction( tx types.Transaction, receipt *types.Receipt, includeReceipt bool, ) (*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