rpc

package
v0.0.0-...-d7cfa30 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: LGPL-3.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Debug string
)

Functions

func DoCall

func DoCall(ctx context.Context, be backend.Backend, args TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides *StateOverride, blockOverrides *BlockOverrides, timeout time.Duration, globalGasCap uint64) (*core.ExecutionResult, error)

func DoEstimateGas

func DoEstimateGas(ctx context.Context, be backend.Backend, args TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides *StateOverride, gasCap uint64) (hexutil.Uint64, error)

func Estimate

func Estimate(ctx context.Context, call *core.Message, opts *estimateOptions, gasCap uint64) (uint64, []byte, error)

Estimate returns the lowest possible gas limit that allows the transaction to run successfully with the provided context options. It returns an error if the transaction would always revert, or if there are unexpected failures.

func RPCMarshalBlock

func RPCMarshalBlock(block *types.Block, inclTx bool, fullTx bool, config *params.ChainConfig) map[string]interface{}

func RPCMarshalHeader

func RPCMarshalHeader(head *types.Header) map[string]interface{}

Types

type AdminAPI

type AdminAPI struct {
	Pause              func() error
	Unpause            func() error
	DestructStateChild func(height uint64, root common.Hash, child common.Hash) error
	ForceProcessBlock  func(ctx context.Context, hash common.Hash) error
}

func NewClient

func NewClient(ctx context.Context, port int) (AdminAPI, jsonrpc.ClientCloser, error)

type BlockOverrides

type BlockOverrides struct {
	Number      *hexutil.Big
	Difficulty  *hexutil.Big
	Time        *hexutil.Uint64
	GasLimit    *hexutil.Uint64
	Coinbase    *common.Address
	Random      *common.Hash
	BaseFee     *hexutil.Big
	BlobBaseFee *hexutil.Big
}

BlockOverrides is a set of header fields to override.

func (*BlockOverrides) Apply

func (diff *BlockOverrides) Apply(blockCtx *vm.BlockContext)

Apply overrides the given header fields into the given block context.

type Opts

type Opts struct {
	// The RPC Host
	Host string

	// The RPC Port
	Port uint64

	// The RPC Gas cap
	RPCGasCap uint64

	// The RPC EVM Timeout
	RPCEVMTimeout time.Duration
}

Opts is the options for rpc.

type OverrideAccount

type OverrideAccount struct {
	Nonce     *hexutil.Uint64             `json:"nonce"`
	Code      *hexutil.Bytes              `json:"code"`
	Balance   *hexutil.Big                `json:"balance"`
	State     map[common.Hash]common.Hash `json:"state"`
	StateDiff map[common.Hash]common.Hash `json:"stateDiff"`
}

OverrideAccount indicates the overriding fields of account during the execution of a message call. Note, state and stateDiff can't be specified at the same time. If state is set, message execution will only use the data in the given state. Otherwise if stateDiff is set, all diff will be applied first and then execute the call message.

type RPCTransaction

type RPCTransaction struct {
	BlockHash           *common.Hash      `json:"blockHash"`
	BlockNumber         *hexutil.Big      `json:"blockNumber"`
	From                common.Address    `json:"from"`
	Gas                 hexutil.Uint64    `json:"gas"`
	GasPrice            *hexutil.Big      `json:"gasPrice"`
	GasFeeCap           *hexutil.Big      `json:"maxFeePerGas,omitempty"`
	GasTipCap           *hexutil.Big      `json:"maxPriorityFeePerGas,omitempty"`
	MaxFeePerBlobGas    *hexutil.Big      `json:"maxFeePerBlobGas,omitempty"`
	Hash                common.Hash       `json:"hash"`
	Input               hexutil.Bytes     `json:"input"`
	Nonce               hexutil.Uint64    `json:"nonce"`
	To                  *common.Address   `json:"to"`
	TransactionIndex    *hexutil.Uint64   `json:"transactionIndex"`
	Value               *hexutil.Big      `json:"value"`
	Type                hexutil.Uint64    `json:"type"`
	Accesses            *types.AccessList `json:"accessList,omitempty"`
	ChainID             *hexutil.Big      `json:"chainId,omitempty"`
	BlobVersionedHashes []common.Hash     `json:"blobVersionedHashes,omitempty"`
	V                   *hexutil.Big      `json:"v"`
	R                   *hexutil.Big      `json:"r"`
	S                   *hexutil.Big      `json:"s"`
	YParity             *hexutil.Uint64   `json:"yParity,omitempty"`
}

RPCTransaction represents a transaction that will serialize to the RPC representation of a transaction

type Server

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

func NewServer

func NewServer(opts Opts, node *node.Node) (*Server, error)

NewServer creates a new rpc server.

func (*Server) Shutdown

func (s *Server) Shutdown()

Close graceful close the component.

type StateOverride

type StateOverride map[common.Address]OverrideAccount

StateOverride is the collection of overridden accounts.

func (*StateOverride) Apply

func (diff *StateOverride) Apply(statedb worldstate.MutableWorldState) error

Apply overrides the fields of specified accounts into the given state.

type TraceCallConfig

type TraceCallConfig struct {
	tracers.TraceConfig
	StateOverrides *StateOverride
	BlockOverrides *BlockOverrides
	TxIndex        *hexutil.Uint
}

TraceCallConfig is the config for traceCall API. It holds one more field to override the state for tracing.

type TransactionArgs

type TransactionArgs struct {
	From                 *common.Address `json:"from"`
	To                   *common.Address `json:"to"`
	Gas                  *hexutil.Uint64 `json:"gas"`
	GasPrice             *hexutil.Big    `json:"gasPrice"`
	MaxFeePerGas         *hexutil.Big    `json:"maxFeePerGas"`
	MaxPriorityFeePerGas *hexutil.Big    `json:"maxPriorityFeePerGas"`
	Value                *hexutil.Big    `json:"value"`
	Nonce                *hexutil.Uint64 `json:"nonce"`

	Data  *hexutil.Bytes `json:"data"`
	Input *hexutil.Bytes `json:"input"`

	// Introduced by AccessListTxType transaction.
	AccessList *types.AccessList `json:"accessList,omitempty"`
	ChainID    *hexutil.Big      `json:"chainId,omitempty"`

	// For BlobTxType
	BlobFeeCap *hexutil.Big  `json:"maxFeePerBlobGas"`
	BlobHashes []common.Hash `json:"blobVersionedHashes,omitempty"`

	// For BlobTxType transactions with blob sidecar
	Blobs       []kzg4844.Blob       `json:"blobs"`
	Commitments []kzg4844.Commitment `json:"commitments"`
	Proofs      []kzg4844.Proof      `json:"proofs"`
}

TransactionArgs represents the arguments to construct a new transaction or a message call.

func (*TransactionArgs) CallDefaults

func (args *TransactionArgs) CallDefaults(globalGasCap uint64, baseFee *big.Int, chainID *big.Int) error

CallDefaults sanitizes the transaction arguments, often filling in zero values, for the purpose of eth_call class of RPC methods.

func (*TransactionArgs) ToMessage

func (args *TransactionArgs) ToMessage(baseFee *big.Int) *core.Message

ToMessage converts the transaction arguments to the Message type used by the core evm. This method is used in calls and traces that do not require a real live transaction. Assumes that fields are not nil, i.e. setDefaults or CallDefaults has been called.

func (*TransactionArgs) ToTransaction

func (args *TransactionArgs) ToTransaction() *types.Transaction

ToTransaction converts the arguments to a transaction. This assumes that setDefaults has been called.

type TxIndexingError

type TxIndexingError struct{}

TxIndexingError is an API error that indicates the transaction indexing is not fully finished yet with JSON error code and a binary data blob.

func NewTxIndexingError

func NewTxIndexingError() *TxIndexingError

NewTxIndexingError creates a TxIndexingError instance.

func (*TxIndexingError) Error

func (e *TxIndexingError) Error() string

Error implement error interface, returning the error message.

func (*TxIndexingError) ErrorCode

func (e *TxIndexingError) ErrorCode() int

ErrorCode returns the JSON error code for a revert. See: https://github.com/ethereum/wiki/wiki/JSON-RPC-Error-Codes-Improvement-Proposal

func (*TxIndexingError) ErrorData

func (e *TxIndexingError) ErrorData() interface{}

ErrorData returns the hex encoded revert reason.

Jump to

Keyboard shortcuts

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