From 308159b926489c4d6e81edad2d1e75a230686e43 Mon Sep 17 00:00:00 2001 From: Kevin Halliday Date: Mon, 4 Nov 2024 12:13:49 -0500 Subject: [PATCH] op prefix --- go.mod | 3 +- lib/ethclient/ethclient.go | 8 +- lib/ethclient/ethclient_gen.go | 2 +- lib/ethclient/gen_receipt_json.go | 154 +++++++++++++------------- lib/ethclient/genwrap/genwrap.go | 2 +- lib/ethclient/mock/mock_interfaces.go | 30 ++--- lib/ethclient/receipt.go | 52 ++++----- lib/txmgr/txmgr.go | 2 +- lib/txmgr/txmgr_internal_test.go | 4 +- relayer/app/pnl.go | 6 +- 10 files changed, 125 insertions(+), 138 deletions(-) diff --git a/go.mod b/go.mod index e3f99684e..01025e214 100644 --- a/go.mod +++ b/go.mod @@ -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 @@ -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 diff --git a/lib/ethclient/ethclient.go b/lib/ethclient/ethclient.go index c42dbbfc7..4e837b7d4 100644 --- a/lib/ethclient/ethclient.go +++ b/lib/ethclient/ethclient.go @@ -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)) diff --git a/lib/ethclient/ethclient_gen.go b/lib/ethclient/ethclient_gen.go index 94bf9f07f..798f193df 100644 --- a/lib/ethclient/ethclient_gen.go +++ b/lib/ethclient/ethclient_gen.go @@ -27,7 +27,7 @@ type Client interface { ethereum.PendingStateReader ethereum.TransactionReader ethereum.TransactionSender - OPTransactionReceipt(ctx context.Context, hash common.Hash) (*Receipt, error) + TxReceipt(ctx context.Context, hash common.Hash) (*Receipt, error) HeaderByType(ctx context.Context, typ HeadType) (*types.Header, error) EtherBalanceAt(ctx context.Context, addr common.Address) (float64, error) PeerCount(ctx context.Context) (uint64, error) diff --git a/lib/ethclient/gen_receipt_json.go b/lib/ethclient/gen_receipt_json.go index 5684b55b4..0a6bbce83 100644 --- a/lib/ethclient/gen_receipt_json.go +++ b/lib/ethclient/gen_receipt_json.go @@ -17,30 +17,30 @@ var _ = (*receiptMarshaling)(nil) // MarshalJSON marshals as JSON. func (r Receipt) MarshalJSON() ([]byte, error) { type Receipt struct { - Type hexutil.Uint64 `json:"type,omitempty"` - PostState hexutil.Bytes `json:"root"` - Status hexutil.Uint64 `json:"status"` - CumulativeGasUsed hexutil.Uint64 `gencodec:"required" json:"cumulativeGasUsed"` - Bloom types.Bloom `gencodec:"required" json:"logsBloom"` - Logs []*types.Log `gencodec:"required" json:"logs"` - TxHash common.Hash `gencodec:"required" json:"transactionHash"` - ContractAddress common.Address `json:"contractAddress"` - GasUsed hexutil.Uint64 `gencodec:"required" json:"gasUsed"` - EffectiveGasPrice *hexutil.Big `json:"effectiveGasPrice"` - BlobGasUsed hexutil.Uint64 `json:"blobGasUsed,omitempty"` - BlobGasPrice *hexutil.Big `json:"blobGasPrice,omitempty"` - DepositNonce *hexutil.Uint64 `json:"depositNonce,omitempty"` - DepositReceiptVersion *hexutil.Uint64 `json:"depositReceiptVersion,omitempty"` - BlockHash common.Hash `json:"blockHash,omitempty"` - BlockNumber *hexutil.Big `json:"blockNumber,omitempty"` - TransactionIndex hexutil.Uint `json:"transactionIndex"` - L1GasPrice *hexutil.Big `json:"l1GasPrice,omitempty"` - L1BlobBaseFee *hexutil.Big `json:"l1BlobBaseFee,omitempty"` - L1GasUsed *hexutil.Big `json:"l1GasUsed,omitempty"` - L1Fee *hexutil.Big `json:"l1Fee,omitempty"` - FeeScalar *big.Float `json:"l1FeeScalar,omitempty"` - L1BaseFeeScalar *hexutil.Uint64 `json:"l1BaseFeeScalar,omitempty"` - L1BlobBaseFeeScalar *hexutil.Uint64 `json:"l1BlobBaseFeeScalar,omitempty"` + Type hexutil.Uint64 `json:"type,omitempty"` + PostState hexutil.Bytes `json:"root"` + Status hexutil.Uint64 `json:"status"` + CumulativeGasUsed hexutil.Uint64 `gencodec:"required" json:"cumulativeGasUsed"` + Bloom types.Bloom `gencodec:"required" json:"logsBloom"` + Logs []*types.Log `gencodec:"required" json:"logs"` + TxHash common.Hash `gencodec:"required" json:"transactionHash"` + ContractAddress common.Address `json:"contractAddress"` + GasUsed hexutil.Uint64 `gencodec:"required" json:"gasUsed"` + EffectiveGasPrice *hexutil.Big `json:"effectiveGasPrice"` + BlobGasUsed hexutil.Uint64 `json:"blobGasUsed,omitempty"` + BlobGasPrice *hexutil.Big `json:"blobGasPrice,omitempty"` + BlockHash common.Hash `json:"blockHash,omitempty"` + BlockNumber *hexutil.Big `json:"blockNumber,omitempty"` + TransactionIndex hexutil.Uint `json:"transactionIndex"` + OPDepositNonce *hexutil.Uint64 `json:"depositNonce,omitempty"` + OPDepositReceiptVersion *hexutil.Uint64 `json:"depositReceiptVersion,omitempty"` + OPL1GasPrice *hexutil.Big `json:"l1GasPrice,omitempty"` + OPL1BlobBaseFee *hexutil.Big `json:"l1BlobBaseFee,omitempty"` + OPL1GasUsed *hexutil.Big `json:"l1GasUsed,omitempty"` + OPL1Fee *hexutil.Big `json:"l1Fee,omitempty"` + OPL1FeeScalar *big.Float `json:"l1FeeScalar,omitempty"` + OPL1BaseFeeScalar *hexutil.Uint64 `json:"l1BaseFeeScalar,omitempty"` + OPL1BlobBaseFeeScalar *hexutil.Uint64 `json:"l1BlobBaseFeeScalar,omitempty"` } var enc Receipt enc.Type = hexutil.Uint64(r.Type) @@ -55,48 +55,48 @@ func (r Receipt) MarshalJSON() ([]byte, error) { enc.EffectiveGasPrice = (*hexutil.Big)(r.EffectiveGasPrice) enc.BlobGasUsed = hexutil.Uint64(r.BlobGasUsed) enc.BlobGasPrice = (*hexutil.Big)(r.BlobGasPrice) - enc.DepositNonce = (*hexutil.Uint64)(r.DepositNonce) - enc.DepositReceiptVersion = (*hexutil.Uint64)(r.DepositReceiptVersion) enc.BlockHash = r.BlockHash enc.BlockNumber = (*hexutil.Big)(r.BlockNumber) enc.TransactionIndex = hexutil.Uint(r.TransactionIndex) - enc.L1GasPrice = (*hexutil.Big)(r.L1GasPrice) - enc.L1BlobBaseFee = (*hexutil.Big)(r.L1BlobBaseFee) - enc.L1GasUsed = (*hexutil.Big)(r.L1GasUsed) - enc.L1Fee = (*hexutil.Big)(r.L1Fee) - enc.FeeScalar = r.FeeScalar - enc.L1BaseFeeScalar = (*hexutil.Uint64)(r.L1BaseFeeScalar) - enc.L1BlobBaseFeeScalar = (*hexutil.Uint64)(r.L1BlobBaseFeeScalar) + enc.OPDepositNonce = (*hexutil.Uint64)(r.OPDepositNonce) + enc.OPDepositReceiptVersion = (*hexutil.Uint64)(r.OPDepositReceiptVersion) + enc.OPL1GasPrice = (*hexutil.Big)(r.OPL1GasPrice) + enc.OPL1BlobBaseFee = (*hexutil.Big)(r.OPL1BlobBaseFee) + enc.OPL1GasUsed = (*hexutil.Big)(r.OPL1GasUsed) + enc.OPL1Fee = (*hexutil.Big)(r.OPL1Fee) + enc.OPL1FeeScalar = r.OPL1FeeScalar + enc.OPL1BaseFeeScalar = (*hexutil.Uint64)(r.OPL1BaseFeeScalar) + enc.OPL1BlobBaseFeeScalar = (*hexutil.Uint64)(r.OPL1BlobBaseFeeScalar) return json.Marshal(&enc) } // UnmarshalJSON unmarshals from JSON. func (r *Receipt) UnmarshalJSON(input []byte) error { type Receipt struct { - Type *hexutil.Uint64 `json:"type,omitempty"` - PostState *hexutil.Bytes `json:"root"` - Status *hexutil.Uint64 `json:"status"` - CumulativeGasUsed *hexutil.Uint64 `gencodec:"required" json:"cumulativeGasUsed"` - Bloom *types.Bloom `gencodec:"required" json:"logsBloom"` - Logs []*types.Log `gencodec:"required" json:"logs"` - TxHash *common.Hash `gencodec:"required" json:"transactionHash"` - ContractAddress *common.Address `json:"contractAddress"` - GasUsed *hexutil.Uint64 `gencodec:"required" json:"gasUsed"` - EffectiveGasPrice *hexutil.Big `json:"effectiveGasPrice"` - BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed,omitempty"` - BlobGasPrice *hexutil.Big `json:"blobGasPrice,omitempty"` - DepositNonce *hexutil.Uint64 `json:"depositNonce,omitempty"` - DepositReceiptVersion *hexutil.Uint64 `json:"depositReceiptVersion,omitempty"` - BlockHash *common.Hash `json:"blockHash,omitempty"` - BlockNumber *hexutil.Big `json:"blockNumber,omitempty"` - TransactionIndex *hexutil.Uint `json:"transactionIndex"` - L1GasPrice *hexutil.Big `json:"l1GasPrice,omitempty"` - L1BlobBaseFee *hexutil.Big `json:"l1BlobBaseFee,omitempty"` - L1GasUsed *hexutil.Big `json:"l1GasUsed,omitempty"` - L1Fee *hexutil.Big `json:"l1Fee,omitempty"` - FeeScalar *big.Float `json:"l1FeeScalar,omitempty"` - L1BaseFeeScalar *hexutil.Uint64 `json:"l1BaseFeeScalar,omitempty"` - L1BlobBaseFeeScalar *hexutil.Uint64 `json:"l1BlobBaseFeeScalar,omitempty"` + Type *hexutil.Uint64 `json:"type,omitempty"` + PostState *hexutil.Bytes `json:"root"` + Status *hexutil.Uint64 `json:"status"` + CumulativeGasUsed *hexutil.Uint64 `gencodec:"required" json:"cumulativeGasUsed"` + Bloom *types.Bloom `gencodec:"required" json:"logsBloom"` + Logs []*types.Log `gencodec:"required" json:"logs"` + TxHash *common.Hash `gencodec:"required" json:"transactionHash"` + ContractAddress *common.Address `json:"contractAddress"` + GasUsed *hexutil.Uint64 `gencodec:"required" json:"gasUsed"` + EffectiveGasPrice *hexutil.Big `json:"effectiveGasPrice"` + BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed,omitempty"` + BlobGasPrice *hexutil.Big `json:"blobGasPrice,omitempty"` + BlockHash *common.Hash `json:"blockHash,omitempty"` + BlockNumber *hexutil.Big `json:"blockNumber,omitempty"` + TransactionIndex *hexutil.Uint `json:"transactionIndex"` + OPDepositNonce *hexutil.Uint64 `json:"depositNonce,omitempty"` + OPDepositReceiptVersion *hexutil.Uint64 `json:"depositReceiptVersion,omitempty"` + OPL1GasPrice *hexutil.Big `json:"l1GasPrice,omitempty"` + OPL1BlobBaseFee *hexutil.Big `json:"l1BlobBaseFee,omitempty"` + OPL1GasUsed *hexutil.Big `json:"l1GasUsed,omitempty"` + OPL1Fee *hexutil.Big `json:"l1Fee,omitempty"` + OPL1FeeScalar *big.Float `json:"l1FeeScalar,omitempty"` + OPL1BaseFeeScalar *hexutil.Uint64 `json:"l1BaseFeeScalar,omitempty"` + OPL1BlobBaseFeeScalar *hexutil.Uint64 `json:"l1BlobBaseFeeScalar,omitempty"` } var dec Receipt if err := json.Unmarshal(input, &dec); err != nil { @@ -143,12 +143,6 @@ func (r *Receipt) UnmarshalJSON(input []byte) error { if dec.BlobGasPrice != nil { r.BlobGasPrice = (*big.Int)(dec.BlobGasPrice) } - if dec.DepositNonce != nil { - r.DepositNonce = (*uint64)(dec.DepositNonce) - } - if dec.DepositReceiptVersion != nil { - r.DepositReceiptVersion = (*uint64)(dec.DepositReceiptVersion) - } if dec.BlockHash != nil { r.BlockHash = *dec.BlockHash } @@ -158,26 +152,32 @@ func (r *Receipt) UnmarshalJSON(input []byte) error { if dec.TransactionIndex != nil { r.TransactionIndex = uint(*dec.TransactionIndex) } - if dec.L1GasPrice != nil { - r.L1GasPrice = (*big.Int)(dec.L1GasPrice) + if dec.OPDepositNonce != nil { + r.OPDepositNonce = (*uint64)(dec.OPDepositNonce) + } + if dec.OPDepositReceiptVersion != nil { + r.OPDepositReceiptVersion = (*uint64)(dec.OPDepositReceiptVersion) + } + if dec.OPL1GasPrice != nil { + r.OPL1GasPrice = (*big.Int)(dec.OPL1GasPrice) } - if dec.L1BlobBaseFee != nil { - r.L1BlobBaseFee = (*big.Int)(dec.L1BlobBaseFee) + if dec.OPL1BlobBaseFee != nil { + r.OPL1BlobBaseFee = (*big.Int)(dec.OPL1BlobBaseFee) } - if dec.L1GasUsed != nil { - r.L1GasUsed = (*big.Int)(dec.L1GasUsed) + if dec.OPL1GasUsed != nil { + r.OPL1GasUsed = (*big.Int)(dec.OPL1GasUsed) } - if dec.L1Fee != nil { - r.L1Fee = (*big.Int)(dec.L1Fee) + if dec.OPL1Fee != nil { + r.OPL1Fee = (*big.Int)(dec.OPL1Fee) } - if dec.FeeScalar != nil { - r.FeeScalar = dec.FeeScalar + if dec.OPL1FeeScalar != nil { + r.OPL1FeeScalar = dec.OPL1FeeScalar } - if dec.L1BaseFeeScalar != nil { - r.L1BaseFeeScalar = (*uint64)(dec.L1BaseFeeScalar) + if dec.OPL1BaseFeeScalar != nil { + r.OPL1BaseFeeScalar = (*uint64)(dec.OPL1BaseFeeScalar) } - if dec.L1BlobBaseFeeScalar != nil { - r.L1BlobBaseFeeScalar = (*uint64)(dec.L1BlobBaseFeeScalar) + if dec.OPL1BlobBaseFeeScalar != nil { + r.OPL1BlobBaseFeeScalar = (*uint64)(dec.OPL1BlobBaseFeeScalar) } return nil } diff --git a/lib/ethclient/genwrap/genwrap.go b/lib/ethclient/genwrap/genwrap.go index 095d6ced0..cde90d09a 100644 --- a/lib/ethclient/genwrap/genwrap.go +++ b/lib/ethclient/genwrap/genwrap.go @@ -44,7 +44,7 @@ import ( type Client interface { {{range .Providers}} ethereum.{{.}} {{end -}} - OPTransactionReceipt(ctx context.Context, hash common.Hash) (*Receipt, error) + TxReceipt(ctx context.Context, hash common.Hash) (*Receipt, error) HeaderByType(ctx context.Context, typ HeadType) (*types.Header, error) EtherBalanceAt(ctx context.Context, addr common.Address) (float64, error) PeerCount(ctx context.Context) (uint64, error) diff --git a/lib/ethclient/mock/mock_interfaces.go b/lib/ethclient/mock/mock_interfaces.go index 6f296e2c1..b52bd360f 100644 --- a/lib/ethclient/mock/mock_interfaces.go +++ b/lib/ethclient/mock/mock_interfaces.go @@ -281,21 +281,6 @@ func (mr *MockClientMockRecorder) NonceAt(ctx, account, blockNumber any) *gomock return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NonceAt", reflect.TypeOf((*MockClient)(nil).NonceAt), ctx, account, blockNumber) } -// OPTransactionReceipt mocks base method. -func (m *MockClient) OPTransactionReceipt(ctx context.Context, hash common.Hash) (*ethclient.Receipt, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OPTransactionReceipt", ctx, hash) - ret0, _ := ret[0].(*ethclient.Receipt) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// OPTransactionReceipt indicates an expected call of OPTransactionReceipt. -func (mr *MockClientMockRecorder) OPTransactionReceipt(ctx, hash any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OPTransactionReceipt", reflect.TypeOf((*MockClient)(nil).OPTransactionReceipt), ctx, hash) -} - // PeerCount mocks base method. func (m *MockClient) PeerCount(ctx context.Context) (uint64, error) { m.ctrl.T.Helper() @@ -565,3 +550,18 @@ func (mr *MockClientMockRecorder) TransactionReceipt(ctx, txHash any) *gomock.Ca mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TransactionReceipt", reflect.TypeOf((*MockClient)(nil).TransactionReceipt), ctx, txHash) } + +// TxReceipt mocks base method. +func (m *MockClient) TxReceipt(ctx context.Context, hash common.Hash) (*ethclient.Receipt, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "TxReceipt", ctx, hash) + ret0, _ := ret[0].(*ethclient.Receipt) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// TxReceipt indicates an expected call of TxReceipt. +func (mr *MockClientMockRecorder) TxReceipt(ctx, hash any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TxReceipt", reflect.TypeOf((*MockClient)(nil).TxReceipt), ctx, hash) +} diff --git a/lib/ethclient/receipt.go b/lib/ethclient/receipt.go index 24632732c..57e3aa2f8 100644 --- a/lib/ethclient/receipt.go +++ b/lib/ethclient/receipt.go @@ -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 @@ -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 { @@ -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 } diff --git a/lib/txmgr/txmgr.go b/lib/txmgr/txmgr.go index 8febf43ef..7c60071e7 100644 --- a/lib/txmgr/txmgr.go +++ b/lib/txmgr/txmgr.go @@ -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 diff --git a/lib/txmgr/txmgr_internal_test.go b/lib/txmgr/txmgr_internal_test.go index a6fde9563..2ce1d39ce 100644 --- a/lib/txmgr/txmgr_internal_test.go +++ b/lib/txmgr/txmgr_internal_test.go @@ -302,7 +302,7 @@ func (b *mockBackend) TransactionReceipt(ctx context.Context, txHash common.Hash }, nil } -func (b *mockBackend) OPTransactionReceipt(ctx context.Context, txHash common.Hash) (*ethclient.Receipt, error) { +func (b *mockBackend) TxReceipt(ctx context.Context, txHash common.Hash) (*ethclient.Receipt, error) { rec, err := b.TransactionReceipt(ctx, txHash) if err != nil { return nil, err @@ -792,7 +792,7 @@ func (b *failingBackend) TransactionReceipt( }, nil } -func (b *failingBackend) OPTransactionReceipt(_ context.Context, txHash common.Hash) (*ethclient.Receipt, error) { +func (b *failingBackend) TxReceipt(_ context.Context, txHash common.Hash) (*ethclient.Receipt, error) { rec, err := b.TransactionReceipt(context.Background(), txHash) if err != nil { return nil, err diff --git a/relayer/app/pnl.go b/relayer/app/pnl.go index 01bc3f8eb..4a1b708ff 100644 --- a/relayer/app/pnl.go +++ b/relayer/app/pnl.go @@ -206,8 +206,10 @@ func spendByDenom( func totalSpendGwei(tx *ethtypes.Transaction, rec *ethclient.Receipt) float64 { spend := new(big.Int).Mul(rec.EffectiveGasPrice, umath.NewBigInt(rec.GasUsed)) - // add optypes::Receipt.L1Fee. will be zero for non-OP chains - spend = new(big.Int).Add(spend, rec.L1Fee) + // add op l1 fee, if any + if rec.OPL1Fee != nil { + spend = new(big.Int).Add(spend, rec.OPL1Fee) + } // add tx value spend = new(big.Int).Add(spend, tx.Value())