Skip to content

Commit

Permalink
op prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinhalliday committed Nov 5, 2024
1 parent 267bdd1 commit 308159b
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 138 deletions.
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ require (
github.com/cosmos/gogoproto v1.7.0
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0
github.com/ethereum/go-ethereum v1.14.11
github.com/fjl/gencodec v0.0.0-20230517082657-f9840df7b83e
github.com/golang-jwt/jwt/v5 v5.2.1
github.com/google/go-cmp v0.6.0
github.com/google/gofuzz v1.2.0
Expand Down Expand Up @@ -294,8 +295,6 @@ require (
sigs.k8s.io/yaml v1.4.0 // indirect
)

require github.com/fjl/gencodec v0.0.0-20230517082657-f9840df7b83e

require (
buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.35.1-20241023225133-42bdb4b67625.1 // indirect
buf.build/gen/go/pluginrpc/pluginrpc/protocolbuffers/go v1.35.1-20241007202033-cf42259fcbfc.1 // indirect
Expand Down
8 changes: 4 additions & 4 deletions lib/ethclient/ethclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@ func (w Wrapper) EtherBalanceAt(ctx context.Context, addr common.Address) (float
return bf / params.Ether, nil
}

// OPTransactionReceipt returns the OP trasnaction receipt for the given hash.
// OP receipts included additional fields for L1 fee info.
func (w Wrapper) OPTransactionReceipt(ctx context.Context, txHash common.Hash) (*Receipt, error) {
const endpoint = "op_transaction_receipt"
// TxReceipt returns the transaction receipt for the given transaction hash.
// It includes additional fields not present in the geth ethclient, such as OP L1 fee info.
func (w Wrapper) TxReceipt(ctx context.Context, txHash common.Hash) (*Receipt, error) {
const endpoint = "tx_receipt"
defer latency(w.chain, endpoint)()

ctx, span := tracer.Start(ctx, spanName(endpoint))
Expand Down
2 changes: 1 addition & 1 deletion lib/ethclient/ethclient_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

154 changes: 77 additions & 77 deletions lib/ethclient/gen_receipt_json.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/ethclient/genwrap/genwrap.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 15 additions & 15 deletions lib/ethclient/mock/mock_interfaces.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 19 additions & 33 deletions lib/ethclient/receipt.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ import (

//go:generate go run github.com/fjl/gencodec -type Receipt -field-override receiptMarshaling -out gen_receipt_json.go

const (
// ReceiptStatusFailed is the status code of a transaction if execution failed.
ReceiptStatusFailed = uint64(0)

// ReceiptStatusSuccessful is the status code of a transaction if execution succeeded.
ReceiptStatusSuccessful = uint64(1)
)

// Receipt represents the results of a transaction.
type Receipt struct {
// Consensus fields: These fields are defined by the Yellow Paper
Expand All @@ -40,28 +32,22 @@ type Receipt struct {
BlobGasUsed uint64 `json:"blobGasUsed,omitempty"`
BlobGasPrice *big.Int `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 *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 *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 *big.Int `json:"blockNumber,omitempty"`
TransactionIndex uint `json:"transactionIndex"`

// Optimism: extend receipts with L1 fee info
L1GasPrice *big.Int `json:"l1GasPrice,omitempty"` // Present from pre-bedrock. L1 Basefee after Bedrock
L1BlobBaseFee *big.Int `json:"l1BlobBaseFee,omitempty"` // Always nil prior to the Ecotone hardfork
L1GasUsed *big.Int `json:"l1GasUsed,omitempty"` // Present from pre-bedrock, deprecated as of Fjord
L1Fee *big.Int `json:"l1Fee,omitempty"` // Present from pre-bedrock
FeeScalar *big.Float `json:"l1FeeScalar,omitempty"` // Present from pre-bedrock to Ecotone. Nil after Ecotone
L1BaseFeeScalar *uint64 `json:"l1BaseFeeScalar,omitempty"` // Always nil prior to the Ecotone hardfork
L1BlobBaseFeeScalar *uint64 `json:"l1BlobBaseFeeScalar,omitempty"` // Always nil prior to the Ecotone hardfork
// Optimism fields: extend receipts with L1 fee info
OPDepositNonce *uint64 `json:"depositNonce,omitempty"`
OPDepositReceiptVersion *uint64 `json:"depositReceiptVersion,omitempty"`
OPL1GasPrice *big.Int `json:"l1GasPrice,omitempty"` // Present from pre-bedrock. L1 Basefee after Bedrock
OPL1BlobBaseFee *big.Int `json:"l1BlobBaseFee,omitempty"` // Always nil prior to the Ecotone hardfork
OPL1GasUsed *big.Int `json:"l1GasUsed,omitempty"` // Present from pre-bedrock, deprecated as of Fjord
OPL1Fee *big.Int `json:"l1Fee,omitempty"` // Present from pre-bedrock
OPL1FeeScalar *big.Float `json:"l1FeeScalar,omitempty"` // Present from pre-bedrock to Ecotone. Nil after Ecotone
OPL1BaseFeeScalar *uint64 `json:"l1BaseFeeScalar,omitempty"` // Always nil prior to the Ecotone hardfork
OPL1BlobBaseFeeScalar *uint64 `json:"l1BlobBaseFeeScalar,omitempty"` // Always nil prior to the Ecotone hardfork
}

type receiptMarshaling struct {
Expand All @@ -77,13 +63,13 @@ type receiptMarshaling struct {
TransactionIndex hexutil.Uint

// Optimism
L1GasPrice *hexutil.Big
L1BlobBaseFee *hexutil.Big
L1GasUsed *hexutil.Big
L1Fee *hexutil.Big
FeeScalar *big.Float
L1BaseFeeScalar *hexutil.Uint64
L1BlobBaseFeeScalar *hexutil.Uint64
DepositNonce *hexutil.Uint64
DepositReceiptVersion *hexutil.Uint64
OPL1GasPrice *hexutil.Big
OPL1BlobBaseFee *hexutil.Big
OPL1GasUsed *hexutil.Big
OPL1Fee *hexutil.Big
OPL1FeeScalar *big.Float
OPL1BaseFeeScalar *hexutil.Uint64
OPL1BlobBaseFeeScalar *hexutil.Uint64
OPDepositNonce *hexutil.Uint64
OPDepositReceiptVersion *hexutil.Uint64
}
2 changes: 1 addition & 1 deletion lib/txmgr/txmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ func (m *simple) queryReceipt(ctx context.Context, txHash common.Hash,
sendState *SendState) (*ethclient.Receipt, bool, error) {
ctx, cancel := context.WithTimeout(ctx, m.cfg.NetworkTimeout)
defer cancel()
receipt, err := m.backend.OPTransactionReceipt(ctx, txHash)
receipt, err := m.backend.TxReceipt(ctx, txHash)
if err != nil {
if strings.Contains(err.Error(), "transaction indexing is in progress") {
return nil, false, nil // Just back off here
Expand Down
Loading

0 comments on commit 308159b

Please sign in to comment.