optimism

package
v0.0.0-...-565925e Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MintOpType is a [RosettaTypes.Operation] type for an Optimism Deposit or "mint" transaction.
	MintOpType = "MINT"
	// An erroneous STOP Type not defined in rosetta-geth-sdk
	StopOpType = "STOP"
)

Op Types

View Source
const (
	NumTopicsERC20Transfer = 3
	UnknownERC20Symbol     = "ERC20_UNKNOWN"
	UnknownERC20Decimals   = 0

	UnknownERC721Symbol   = "ERC721_UNKNOWN"
	UnknownERC721Decimals = 0
)

ERC20 Log Consts

View Source
const (
	// NodeVersion is the version of geth we are using.
	NodeVersion = "1.9.24"

	// Blockchain is Optimism.
	Blockchain string = "Optimism"

	// MainnetNetwork is the value of the network
	// in MainnetNetworkIdentifier.
	MainnetNetwork string = "Mainnet"

	// TestnetNetwork is the value of the network
	// in TestnetNetworkIdentifier.
	TestnetNetwork string = "Testnet"

	// SepoliaNetwork is the value of the sepolia network.
	SepoliaNetwork string = "Sepolia"

	// GoerliNetwork is the value of the network
	// in GoerliNetworkNetworkIdentifier.
	GoerliNetwork string = "Goerli"

	// Symbol is the symbol value
	// used in Currency.
	Symbol = "ETH"

	TokenSymbol = "OP"

	// Decimals is the decimals value
	// used in Currency.
	Decimals = 18

	TokenDecimals = 18

	// FeeOpType is used to represent fee operations.
	FeeOpType = "FEE"

	// PaymentOpType is used to represent token transfer operations
	PaymentOpType = "PAYMENT"

	// ERC20MintOpType is used to represent token mint operations
	ERC20MintOpType = "ERC20_MINT"

	// ERC20BurnOpType is used to represent token burn operations
	ERC20BurnOpType = "ERC20_BURN"

	// ERC20TransferOpType is used to represent token transfer operations
	ERC20TransferOpType = "ERC20_TRANSFER"

	// CallOpType is used to represent CALL trace operations.
	CallOpType = "CALL"

	// CreateOpType is used to represent CREATE trace operations.
	CreateOpType = "CREATE"

	// Create2OpType is used to represent CREATE2 trace operations.
	Create2OpType = "CREATE2"

	// SelfDestructOpType is used to represent SELFDESTRUCT trace operations.
	SelfDestructOpType = "SELFDESTRUCT"

	// CallCodeOpType is used to represent CALLCODE trace operations.
	CallCodeOpType = "CALLCODE"

	// DelegateCallOpType is used to represent DELEGATECALL trace operations.
	DelegateCallOpType = "DELEGATECALL"

	// StaticCallOpType is used to represent STATICCALL trace operations.
	StaticCallOpType = "STATICCALL"

	// DestructOpType is a synthetic operation used to represent the
	// deletion of suicided accounts that still have funds at the end
	// of a transaction.
	DestructOpType = "DESTRUCT"

	// DelegateVotesOpType is used to represent OZ ERC20Votes votes delegation
	DelegateVotesOpType = "DELEGATE_VOTES"

	// SuccessStatus is the status of any
	// Ethereum operation considered successful.
	SuccessStatus = "SUCCESS"

	// FailureStatus is the status of any
	// Ethereum operation considered unsuccessful.
	FailureStatus = "FAILURE"

	// HistoricalBalanceSupported is whether
	// historical balance is supported.
	HistoricalBalanceSupported = true

	// GenesisBlockIndex is the index of the
	// genesis block.
	GenesisBlockIndex = int64(0)

	// TransferGasLimit is the gas limit
	// of a transfer.
	TransferGasLimit = uint64(21000) //nolint:gomnd

	// MainnetGethArguments are the arguments to start a mainnet geth instance.
	MainnetGethArguments = `--config=/app/optimism/geth.toml --gcmode=archive --graphql`

	// IncludeMempoolCoins does not apply to rosetta-ethereum as it is not UTXO-based.
	IncludeMempoolCoins = false

	// ContractAddressKey is the key used to denote the contract address
	// for a token, provided via Currency metadata.
	ContractAddressKey string = "token_address"
)
View Source
const (
	// EthGetTransactionReceipt is the RPC method used to fetch a transaction receipt.
	EthGetTransactionReceipt = "eth_getTransactionReceipt"

	// EthGetBlockByNumber is the RPC method used to fetch a block by number.
	EthGetBlockByNumber = "eth_getBlockByNumber"

	// EthCall is the RPC method used to call a contract.
	EthCall = "eth_call"

	// EthEstimateGas is the RPC method used to estimate gas.
	EthEstimateGas = "eth_estimateGas"
)

RPC Methods

View Source
const ImplementationContractFilter = "0xc0d3c0d3c0d3c0d3c0d3c0d3c0d3c0d3c0d3"
View Source
const L1ToL2DepositType = 126 // (126)

L1ToL2DepositType is the transaction type for L1ToL2 deposits.

View Source
const ProxyContractFilter = "0x420000000000000000000000000000000000"
View Source
const TopicsInErc20Transfer = 3
View Source
const (
	// TransferEvent is emitted when an ERC20 token is transferred.
	//
	// TransferEvent is emitted in two bridging scenarios:
	// 1. When a native token is being sent to a non-native chain, from the sender to the bridge contract.
	//    Think: Transferring USDC on Ethereum Mainnet to the Optimism bridge contract,
	//    you will see a Transfer event from the sender (you) to the bridge contract.
	// 2. When a non-native token is being sent to a native chain, from the bridge to the sender contract.
	// 	  Think: "Withdrawing" USDC from Optimism to Ethereum Mainnet. You will see a Transfer event
	// 	  from the bridge contract to you (the sender) once the withdrawal is finalized on Mainnet.
	TransferEvent = "Transfer(address,address,uint256)"
)

Event Topics

Variables

View Source
var (
	ErrBlockOrphaned         = errors.New("block orphaned")
	ErrCallParametersInvalid = errors.New("call parameters invalid")
	ErrCallOutputMarshal     = errors.New("call output marshal")
	ErrCallMethodInvalid     = errors.New("call method invalid")
)

Client errors

View Source
var (
	// The BaseFeeVault predeploy receives the basefees on L2.
	// The basefee is not burnt on L2 like it is on L1.
	// Once the contract has received a certain amount of fees,
	// the ETH can be permissionlessly withdrawn to an immutable address on L1.
	BaseFeeVault = EthCommon.HexToAddress("0x4200000000000000000000000000000000000019")

	// The L1FeeVault predeploy receives the L1 portion of the transaction fees.
	// Once the contract has received a certain amount of fees,
	// the ETH can be permissionlessly withdrawn to an immutable address on L1.
	L1FeeVault = EthCommon.HexToAddress("0x420000000000000000000000000000000000001a")
)

Optimism Predeploy Addresses (represented as 0x-prefixed hex string) See PredeployedContracts for more information.

View Source
var (
	// TestnetGethArguments are the arguments to start a ropsten geth instance.
	TestnetGethArguments = fmt.Sprintf("%s --testnet", MainnetGethArguments)

	// RinkebyGethArguments are the arguments to start a rinkeby geth instance.
	RinkebyGethArguments = fmt.Sprintf("%s --rinkeby", MainnetGethArguments)

	// GoerliGethArguments are the arguments to start a ropsten geth instance.
	GoerliGethArguments = fmt.Sprintf("%s --goerli", MainnetGethArguments)

	// MainnetGenesisBlockIdentifier is the *types.BlockIdentifier
	// of the mainnet genesis block.
	MainnetGenesisBlockIdentifier = &types.BlockIdentifier{
		Hash:  "0x7ca38a1916c42007829c55e69d3e9a73265554b586a499015373241b8a3fa48b",
		Index: GenesisBlockIndex,
	}

	// TestnetGenesisBlockIdentifier is the *types.BlockIdentifier
	// of the testnet genesis block.
	TestnetGenesisBlockIdentifier = &types.BlockIdentifier{
		Hash:  "0x02adc9b449ff5f2467b8c674ece7ff9b21319d76c4ad62a67a70d552655927e5",
		Index: GenesisBlockIndex,
	}

	// GoerliGenesisBlockIdentifier is the *types.BlockIdentifier
	// of the Goerli genesis block.
	GoerliGenesisBlockIdentifier = &types.BlockIdentifier{
		Hash:  "0xb643d8aa991fb19f47b9178818886afb4eb54589eb500967beb444ea64f9761b",
		Index: GenesisBlockIndex,
	}

	SepoliaGenesisBlockIdentifier = &types.BlockIdentifier{
		Hash:  "0x102de6ffb001480cc9b8b548fd05c34cd4f46ae4aa91759393db90ea0409887d",
		Index: GenesisBlockIndex,
	}

	// Currency is the *types.Currency for all
	// Ethereum networks.
	Currency = &types.Currency{
		Symbol:   Symbol,
		Decimals: Decimals,
	}

	OPTokenCurrency = &types.Currency{
		Symbol:   TokenSymbol,
		Decimals: TokenDecimals,
	}

	// OperationTypes are all suppoorted operation types.
	OperationTypes = []string{
		FeeOpType,
		PaymentOpType,
		ERC20MintOpType,
		ERC20BurnOpType,
		CallOpType,
		CreateOpType,
		Create2OpType,
		SelfDestructOpType,
		CallCodeOpType,
		DelegateCallOpType,
		StaticCallOpType,
		DestructOpType,
		DelegateVotesOpType,
		ERC20TransferOpType,
	}

	// OperationStatuses are all supported operation statuses.
	OperationStatuses = []*types.OperationStatus{
		{
			Status:     SuccessStatus,
			Successful: true,
		},
		{
			Status:     FailureStatus,
			Successful: false,
		},
	}

	// CallMethods are all supported call methods.
	CallMethods = []string{
		EthGetBlockByNumber,
		EthGetTransactionReceipt,
		EthCall,
		EthEstimateGas,
	}
)
View Source
var ErrBadCurrency = errors.New("bad currency")
View Source
var ErrBlockFetch = fmt.Errorf("failed to fetch block")
View Source
var ErrBlockNotFound = fmt.Errorf("block not found")
View Source
var ErrBlockUnmarshal = fmt.Errorf("failed to unmarshal block")
View Source
var ErrClientBlockOrphaned = errors.New("block orphaned")
View Source
var ErrHeaderUnmarshal = fmt.Errorf("failed to unmarshal header")

Functions

func Account

func Amount

func Amount(value *big.Int, currency *RosettaTypes.Currency) *RosettaTypes.Amount

Amount returns a Rosetta Amount from a big.Int and currency.

func BedrockContainsTopic

func BedrockContainsTopic(log *EthTypes.Log, topic string) bool

BedrockContainsTopic checks if a bedrock log contains a topic

func CallType

func CallType(t string) bool

CallType returns a boolean indicating if the provided trace type is a call type.

func ChecksumAddress

func ChecksumAddress(address string) (string, bool)

ChecksumAddress ensures an Ethereum hex address is in Checksum Format. If the address cannot be converted, it returns !ok.

func ConvertEVMTopicHashToAddress

func ConvertEVMTopicHashToAddress(hash *EthCommon.Hash) *EthCommon.Address

ConvertEVMTopicHashToAddress uses the last 20 bytes of a common.Hash to create a common.Address

func CreateType

func CreateType(t string) bool

CreateType returns a boolean indicating if the provided trace type is a create type.

func EffectiveGasPrice

func EffectiveGasPrice(tx InnerBedrockTransaction, baseFee *big.Int) (*big.Int, error)

EffectiveGasPrice returns the price of gas charged to this Transaction to be included in the block.

func Erc20Amount

func Erc20Amount(
	bytes []byte,
	addr EthCommon.Address,
	currency RosettaTypes.Currency,
	sender bool,
) *RosettaTypes.Amount

func Erc20Ops

func Erc20Ops(
	transferLog *EthTypes.Log,
	currency *RosettaTypes.Currency,
	opsLen int64,
) []*RosettaTypes.Operation

Erc20Ops returns a list of erc20 operations parsed from the log from a transaction receipt

func ExtractL1Fee

func ExtractL1Fee(rosettaTxReceipt *RosettaTxReceipt) *big.Int

ExtractL1Fee attempts to unmarshal an [L1Fee] from the RawMessage field in a RosettaTxReceipt TODO: hoist this up to initial receipt unmarshalling in the bedrock block handler so we can error early

func ExtractStatus

func ExtractStatus(rosettaTxReceipt *RosettaTxReceipt) (uint64, error)

ExtractStatus unmarshals a receipt status from a json marshalled raw message

func FeeOps

func FeeOps(tx *bedrockTransaction) ([]*RosettaTypes.Operation, error)

FeeOps returns the fee operations for a given transaction.

func GenerateBootstrapFile

func GenerateBootstrapFile(genesisFile string, outputFile string) error

GenerateBootstrapFile creates the bootstrap balances file for a particular genesis file.

func GenerateOp

func GenerateOp(opIndex int64, relatedOps []*RosettaTypes.OperationIdentifier, opType string, opStatus string, address string, amount *RosettaTypes.Amount, metadata map[string]interface{}) *RosettaTypes.Operation

func LoadAndParseURL

func LoadAndParseURL(url string, output interface{}) error

func MarshalJSONMap

func MarshalJSONMap(i interface{}) (map[string]interface{}, error)

MarshalJSONMap converts an interface into a map[string]interface{}.

func MintOps

func MintOps(tx *bedrockTransaction, startIndex int) []*RosettaTypes.Operation

MintOps constructs a list of [RosettaTypes.Operation]s for an Optimism Deposit or "mint" transaction.

func MustChecksum

func MustChecksum(address string) string

MustChecksum ensures an address can be converted into a valid checksum. If it does not, the program will exit.

func StartGeth

func StartGeth(ctx context.Context, arguments string, g *errgroup.Group) error

StartGeth starts a geth daemon in another goroutine and logs the results to the console.

func TraceOps

func TraceOps(calls []*FlatCall, startIndex int) []*RosettaTypes.Operation

TraceOps constructs [RosettaTypes.Operation]s from a list of [FlatCall]s.

Types

type BedrockRPCTransaction

type BedrockRPCTransaction struct {
	Tx InnerBedrockTransaction `json:"tx"`
	TxExtraInfo
}

BedrockRPCTransaction is a post-bedrock transaction.

func (*BedrockRPCTransaction) LoadTransaction

func (tx *BedrockRPCTransaction) LoadTransaction() *bedrockTransaction

LoadTransaction constructs a [bedrockTransaction] from a BedrockRPCTransaction.

func (*BedrockRPCTransaction) UnmarshalJSON

func (tx *BedrockRPCTransaction) UnmarshalJSON(msg []byte) error

UnmarshalJSON unmarshals an BedrockRPCTransaction from bytes.

type BlockError

type BlockError struct {
	Ty  error
	Err error
}

func NewBlockError

func NewBlockError(ty error, err error) *BlockError

func (*BlockError) IsBlockFetchError

func (e *BlockError) IsBlockFetchError() bool

type BlockParser

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

func NewBlockParser

func NewBlockParser(bedrockBlock *big.Int) *BlockParser

type Call

type Call struct {
	Type         string            `json:"type"`
	From         EthCommon.Address `json:"from"`
	To           EthCommon.Address `json:"to"`
	Value        *big.Int          `json:"value"`
	GasUsed      *big.Int          `json:"gasUsed"`
	Input        string            `json:"input"`
	Revert       bool
	ErrorMessage string  `json:"error"`
	Calls        []*Call `json:"calls"`
}

Call is an Ethereum debug trace.

func (*Call) UnmarshalJSON

func (t *Call) UnmarshalJSON(input []byte) error

UnmarshalJSON is a custom unmarshaler for Call.

type Client

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

Client allows for querying a set of specific Ethereum endpoints in an idempotent manner. Client relies on the eth_*, debug_*, and admin_* methods and on the graphql endpoint.

Client borrows HEAVILY from https://github.com/ethereum/go-ethereum/tree/master/ethclient.

func NewClient

func NewClient(url string, params *params.ChainConfig, opts ClientOptions) (*Client, error)

NewClient creates a Client that from the provided url and params.

func (*Client) Balance

Balance returns the balance of a *RosettaTypes.AccountIdentifier at a *RosettaTypes.PartialBlockIdentifier. The OP Token and ETH balances will be returned if currencies is unspecified

func (*Client) BaseFee

func (ec *Client) BaseFee(ctx context.Context) (*big.Int, error)

BaseFee returns the current base fee per gas

func (*Client) Block

func (ec *Client) Block(
	ctx context.Context,
	blockIdentifier *RosettaTypes.PartialBlockIdentifier,
) (*RosettaTypes.Block, error)

Block returns a populated block at the *RosettaTypes.PartialBlockIdentifier. If neither the hash or index is populated in the *RosettaTypes.PartialBlockIdentifier, the current (aka latest) block is returned.

func (*Client) Call

Call handles calls to the /call endpoint.

func (*Client) CallContract

func (ec *Client) CallContract(ctx context.Context, call Eth.CallMsg, blockNumber *big.Int) ([]byte, error)

func (*Client) Close

func (ec *Client) Close()

Close shuts down the RPC client connection.

func (*Client) CodeAt

func (ec *Client) CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error)

Dummy implementations to ensure we can leverage bind.ContractBackend interface for reusing the TCP connection Error out for now, and we can implement in the future if it's necessary

func (*Client) EstimateGas

func (ec *Client) EstimateGas(ctx context.Context, msg ethereum.CallMsg) (uint64, error)

EstimateGas retrieves the currently gas limit

func (*Client) FilterLogs

func (ec *Client) FilterLogs(ctx context.Context, query Eth.FilterQuery) ([]EthTypes.Log, error)

func (*Client) HeaderByNumber

func (ec *Client) HeaderByNumber(ctx context.Context, number *big.Int) (*EthTypes.Header, error)

func (*Client) IsPreBedrock

func (c *Client) IsPreBedrock(b *big.Int) bool

IsPreBedrock returns if the given block number is before the bedrock block.

func (*Client) ParseOps

func (ec *Client) ParseOps(
	tx *bedrockTransaction,
) ([]*RosettaTypes.Operation, error)

ParseOps mimics the down-stream implementation of [rosetta-geth-sdk], exposing a hook for down-stream clients.

func (*Client) PendingCodeAt

func (ec *Client) PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error)

func (*Client) PendingNonceAt

func (ec *Client) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)

PendingNonceAt returns the account nonce of the given account in the pending state. This is the nonce that should be used for the next transaction.

func (*Client) SendTransaction

func (ec *Client) SendTransaction(ctx context.Context, tx *types2.Transaction) error

SendTransaction injects a signed transaction into the pending pool for execution.

If the transaction was a contract creation use the TransactionReceipt method to get the contract address after the transaction has been mined.

func (*Client) Status

Status returns geth status information for determining node healthiness.

func (*Client) SubscribeFilterLogs

func (ec *Client) SubscribeFilterLogs(ctx context.Context, query Eth.FilterQuery, ch chan<- EthTypes.Log) (Eth.Subscription, error)

func (*Client) SuggestGasPrice

func (ec *Client) SuggestGasPrice(ctx context.Context) (*big.Int, error)

SuggestGasPrice retrieves the currently suggested gas price to allow a timely execution of a transaction.

func (*Client) SuggestGasTipCap

func (ec *Client) SuggestGasTipCap(ctx context.Context) (*big.Int, error)

SuggestGasPrice retrieves the currently suggested gas price

func (*Client) TraceBlockByHash

func (ec *Client) TraceBlockByHash(
	ctx context.Context,
	blockHash EthCommon.Hash,
	txs []BedrockRPCTransaction,
) (map[string][]*FlatCall, error)

TraceBlockByHash returns the Transaction traces of all transactions in the block

func (*Client) TraceTransactions

func (ec *Client) TraceTransactions(
	ctx context.Context,
	blockHash EthCommon.Hash,
	txs []BedrockRPCTransaction,
) (map[string][]*FlatCall, error)

TraceTransactions returns traces for each of the given transactions. TraceTransactions uses `debug_traceTransaction` under the hood.

type ClientOptions

type ClientOptions struct {
	HTTPTimeout               time.Duration
	MaxTraceConcurrency       int64
	EnableTraceCache          bool
	EnableGethTracer          bool
	FilterTokens              bool
	SupportedTokens           map[string]bool
	BedrockBlock              *big.Int
	SuportsSyncing            bool
	SkipAdminCalls            bool
	SupportsPeering           bool
	EnableCustomBedrockTracer bool
	TraceByBlock              bool
	TraceCacheSize            int
}

type CurrencyFetcher

type CurrencyFetcher interface {
	FetchCurrency(ctx context.Context, blockNum uint64, contractAddress string) (*RosettaTypes.Currency, error)
}

CurrencyFetcher interface describes a struct that can fetch the details of an Ethereum-based token given its contract address.

type ERC20CurrencyFetcher

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

ERC20CurrencyFetcher type has a global currencyCache (lru) to cache results of fetching currency details, as well as a GraphQL client (required for getting currency details).

func (ERC20CurrencyFetcher) FetchCurrency

func (ecf ERC20CurrencyFetcher) FetchCurrency(
	ctx context.Context,
	blockNum uint64,
	contractAddress string,
) (*RosettaTypes.Currency, error)

FetchCurrency is a helper function that takes in a contract address (ERC20) and returns a Currency object with details such as the symbol and # of decimal places. This method uses RPC calls to fetch such data. Because the contractAddress param is checksummed prior to invocation, we assume it is valid. We make use of an LRU cache to prevent repeatedly fetching currency details.

There are a few failure cases that this logic accounts for. If any contract call returns an empty value ("0x"), we fall back on default values. Additionally, in the specific case of the symbol, if an empty symbol is returned, we again fall back on the default symbol value.

Note: any returned data payload with the prefix `0x4e487b71` are the first four bytes of keccak256(Panic(uint256)) If we encounter a failure while fetching currency details, we return a default value.

type FlatCall

type FlatCall struct {
	Type         string            `json:"type"`
	From         EthCommon.Address `json:"from"`
	To           EthCommon.Address `json:"to"`
	Value        *big.Int          `json:"value"`
	GasUsed      *big.Int          `json:"gasUsed"`
	Input        string            `json:"input"`
	Revert       bool
	ErrorMessage string `json:"error"`
}

FlatCall is a flattened Call object.

func FlattenTraces

func FlattenTraces(data *Call, flattened []*FlatCall) []*FlatCall

FlattenTraces recursively flattens all traces.

type GetBlockByNumberInput

type GetBlockByNumberInput struct {
	Index         *int64 `json:"index,omitempty"`
	ShowTxDetails bool   `json:"show_transaction_details"`
}

GetBlockByNumberInput is the input to the call method "eth_getBlockByNumber".

type GetCallInput

type GetCallInput struct {
	BlockIndex int64  `json:"index,omitempty"`
	BlockHash  string `json:"hash,omitempty"`
	From       string `json:"from"`
	To         string `json:"to"`
	Gas        int64  `json:"gas"`
	GasPrice   int64  `json:"gas_price"`
	Value      int64  `json:"value"`
	Data       string `json:"data"`
}

GetCallInput is the input to the call method "eth_call", "eth_estimateGas".

type GetTransactionReceiptInput

type GetTransactionReceiptInput struct {
	TxHash string `json:"tx_hash"`
}

GetTransactionReceiptInput is the input to the call method "eth_getTransactionReceipt".

type GraphQL

type GraphQL interface {
	Query(ctx context.Context, input string) (string, error)
}

GraphQL is the interface for accessing go-ethereum's GraphQL endpoint.

type GraphQLClient

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

GraphQLClient is a client used to make graphQL queries to geth's graphql endpoint.

func (*GraphQLClient) Query

func (g *GraphQLClient) Query(ctx context.Context, input string) (string, error)

Query makes a query to the graphQL endpoint.

type InnerBedrockTransaction

type InnerBedrockTransaction interface {
	Hash() EthCommon.Hash
	To() *EthCommon.Address
	Gas() uint64
	GasPrice() *big.Int
	GetType() uint64
	GetValue() *big.Int
	EffectiveGasTip(*big.Int) (*big.Int, error)
}

InnerBedrockTransaction is the JSON representation of a bedrock transaction.

type JSONRPC

type JSONRPC interface {
	CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error
	BatchCallContext(ctx context.Context, b []rpc.BatchElem) error
	Close()
}

JSONRPC is the interface for accessing go-ethereum's JSON RPC endpoint.

type L2Receipt

type L2Receipt struct {
	// Consensus fields: These fields are defined by the Yellow Paper
	Type              *hexutil.Uint64 `json:"type,omitempty"`
	PostState         []byte          `json:"root"`
	Status            *hexutil.Uint64 `json:"status"`
	CumulativeGasUsed *hexutil.Uint64 `json:"cumulativeGasUsed"`
	Bloom             ethTypes.Bloom  `json:"logsBloom"`
	Logs              []*ethTypes.Log `json:"logs"`

	// Implementation fields: These fields are added by geth when processing a transaction or retrieving a receipt.
	// gencodec annotated fields: these are stored in the chain database.
	TxHash            common.Hash     `json:"transactionHash"`
	ContractAddress   *common.Address `json:"contractAddress"`
	GasUsed           *hexutil.Uint64 `json:"gasUsed"`
	EffectiveGasPrice *hexutil.Uint64 `json:"effectiveGasPrice,omitempty"` // required, but tag omitted for backwards compatibility
	BlobGasUsed       *hexutil.Uint64 `json:"blobGasUsed,omitempty"`
	BlobGasPrice      *hexutil.Uint64 `json:"blobGasPrice,omitempty"`

	// DepositNonce was introduced in Regolith to store the actual nonce used by deposit transactions
	// The state transition process ensures this is only set for Regolith deposit transactions.
	DepositNonce *hexutil.Uint64 `json:"depositNonce,omitempty"`
	// DepositReceiptVersion was introduced in Canyon to indicate an update to how receipt hashes
	// should be computed when set. The state transition process ensures this is only set for
	// post-Canyon deposit transactions.
	DepositReceiptVersion *hexutil.Uint64 `json:"depositReceiptVersion,omitempty"`

	// Inclusion information: These fields provide information about the inclusion of the
	// transaction corresponding to this receipt.
	BlockHash        common.Hash     `json:"blockHash,omitempty"`
	BlockNumber      *hexutil.Uint64 `json:"blockNumber,omitempty"`
	TransactionIndex *hexutil.Uint64 `json:"transactionIndex"`

	// OVM legacy: extend receipts with their L1 price (if a rollup tx)
	L1GasPrice *hexutil.Uint64 `json:"l1GasPrice,omitempty"`
	L1GasUsed  *hexutil.Uint64 `json:"l1GasUsed,omitempty"`
	L1Fee      *hexutil.Uint64 `json:"l1Fee,omitempty"`
	FeeScalar  *big.Float      `json:"l1FeeScalar,omitempty"` // always nil after Ecotone hardfork
}

L2Receipt represents the results of a transaction.

type RosettaTxReceipt

type RosettaTxReceipt struct {
	Type           uint8 `json:"type,omitempty"`
	GasPrice       *big.Int
	GasUsed        *big.Int
	TransactionFee *big.Int
	Logs           []*EthTypes.Log
	RawMessage     json.RawMessage
}

RosettaTxReceipt is a Rosetta-compatible receipt type.

type TraceCache

type TraceCache interface {
	FetchTransaction(ctx context.Context, txhash common.Hash) (*Call, error)
}

func NewTraceCache

func NewTraceCache(client JSONRPC, opt tracerSpec, tracerTimeout time.Duration, cacheSize int) (TraceCache, error)

type TxExtraInfo

type TxExtraInfo struct {
	BlockNumber *string            `json:"blockNumber,omitempty"`
	BlockHash   *EthCommon.Hash    `json:"blockHash,omitempty"`
	From        *EthCommon.Address `json:"from,omitempty"`
	TxHash      *EthCommon.Hash    `json:"hash,omitempty"`
}

Directories

Path Synopsis
utilities

Jump to

Keyboard shortcuts

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