From b1a3e77b060c9b0d9268e3564efdff55b4d05a37 Mon Sep 17 00:00:00 2001 From: frozen <355847+Frozen@users.noreply.github.com> Date: Mon, 9 Sep 2024 15:49:33 -0400 Subject: [PATCH 01/10] Effective gas price. WIP --- core/types/receipt.go | 66 +++++++++++++++++++++++++++++++++++++-- core/types/transaction.go | 4 +++ 2 files changed, 67 insertions(+), 3 deletions(-) diff --git a/core/types/receipt.go b/core/types/receipt.go index d0a6c6dc76..b61abeab5e 100644 --- a/core/types/receipt.go +++ b/core/types/receipt.go @@ -20,13 +20,17 @@ import ( "bytes" "fmt" "io" + "math/big" "unsafe" "github.com/ethereum/go-ethereum/common" ethcommon "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/rlp" + "github.com/harmony-one/harmony/internal/params" + "github.com/pkg/errors" ) // no go:generate gencodec -type Receipt -field-override receiptMarshaling -out gen_receipt_json.go @@ -54,9 +58,10 @@ type Receipt struct { Logs []*Log `json:"logs" gencodec:"required"` // Implementation fields (don't reorder!) - TxHash common.Hash `json:"transactionHash" gencodec:"required"` - ContractAddress common.Address `json:"contractAddress"` - GasUsed uint64 `json:"gasUsed" gencodec:"required"` + TxHash common.Hash `json:"transactionHash" gencodec:"required"` + ContractAddress common.Address `json:"contractAddress"` + GasUsed uint64 `json:"gasUsed" gencodec:"required"` + EffectiveGasPrice *big.Int `json:"effectiveGasPrice"` // required, but tag omitted for backwards compatibility } type receiptMarshaling struct { @@ -235,3 +240,58 @@ func FindLogsWithTopic( } return logs } + +// DeriveFields fills the receipts with their computed fields based on consensus +// data and contextual infos like containing block and transactions. +func (rs Receipts) DeriveFields(config *params.ChainConfig, hash common.Hash, number uint64, time uint64, baseFee *big.Int, blobGasPrice *big.Int, txs []*Transaction) error { + signer := MakeSigner(config, new(big.Int).SetUint64(number)) + + logIndex := uint(0) + if len(txs) != len(rs) { + return errors.New("transaction and receipt count mismatch") + } + for i := 0; i < len(rs); i++ { + // The transaction type and hash can be retrieved from the transaction itself + rs[i].Type = txs[i].Type() + rs[i].TxHash = txs[i].Hash() + rs[i].EffectiveGasPrice = txs[i].data.effectiveGasPrice(new(big.Int), baseFee) + + // EIP-4844 blob transaction fields + if txs[i].Type() == BlobTxType { + rs[i].BlobGasUsed = txs[i].BlobGas() + rs[i].BlobGasPrice = blobGasPrice + } + + // block location fields + rs[i].BlockHash = hash + rs[i].BlockNumber = new(big.Int).SetUint64(number) + rs[i].TransactionIndex = uint(i) + + // The contract address can be derived from the transaction itself + if txs[i].To() == nil { + // Deriving the signer is expensive, only do if it's actually needed + from, _ := Sender(signer, txs[i]) + rs[i].ContractAddress = crypto.CreateAddress(from, txs[i].Nonce()) + } else { + rs[i].ContractAddress = common.Address{} + } + + // The used gas can be calculated based on previous r + if i == 0 { + rs[i].GasUsed = rs[i].CumulativeGasUsed + } else { + rs[i].GasUsed = rs[i].CumulativeGasUsed - rs[i-1].CumulativeGasUsed + } + + // The derived log fields can simply be set from the block and transaction + for j := 0; j < len(rs[i].Logs); j++ { + rs[i].Logs[j].BlockNumber = number + rs[i].Logs[j].BlockHash = hash + rs[i].Logs[j].TxHash = rs[i].TxHash + rs[i].Logs[j].TxIndex = uint(i) + rs[i].Logs[j].Index = logIndex + logIndex++ + } + } + return nil +} diff --git a/core/types/transaction.go b/core/types/transaction.go index bee69a393f..4461b86506 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -178,6 +178,10 @@ func (d *txdata) CopyFrom(d2 *txdata) { d.Hash = copyHash(d2.Hash) } +func (d *txdata) effectiveGasPrice(dst *big.Int, baseFee *big.Int) *big.Int { + return dst.Set(d.Price) +} + type txdataMarshaling struct { AccountNonce hexutil.Uint64 Price *hexutil.Big From 95c2a5889b33a4e7e39734c156b0f59c9f1c815f Mon Sep 17 00:00:00 2001 From: frozen <355847+Frozen@users.noreply.github.com> Date: Tue, 17 Sep 2024 15:36:05 -0400 Subject: [PATCH 02/10] Effective gas price. --- core/types/receipt.go | 21 ++++++++++++--------- rpc/harmony/v2/types.go | 1 + 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/core/types/receipt.go b/core/types/receipt.go index b61abeab5e..e8d9d47b44 100644 --- a/core/types/receipt.go +++ b/core/types/receipt.go @@ -27,10 +27,7 @@ import ( ethcommon "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" ethtypes "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/rlp" - "github.com/harmony-one/harmony/internal/params" - "github.com/pkg/errors" ) // no go:generate gencodec -type Receipt -field-override receiptMarshaling -out gen_receipt_json.go @@ -87,6 +84,7 @@ type receiptStorageRLP struct { ContractAddress common.Address Logs []*LogForStorage GasUsed uint64 + effectiveGasPrice *big.Int } // NewReceipt creates a barebone transaction receipt, copying the init fields. @@ -171,6 +169,7 @@ func (r *ReceiptForStorage) EncodeRLP(w io.Writer) error { ContractAddress: r.ContractAddress, Logs: make([]*LogForStorage, len(r.Logs)), GasUsed: r.GasUsed, + effectiveGasPrice: r.EffectiveGasPrice, } for i, log := range r.Logs { enc.Logs[i] = (*LogForStorage)(log) @@ -241,6 +240,7 @@ func FindLogsWithTopic( return logs } +/* // DeriveFields fills the receipts with their computed fields based on consensus // data and contextual infos like containing block and transactions. func (rs Receipts) DeriveFields(config *params.ChainConfig, hash common.Hash, number uint64, time uint64, baseFee *big.Int, blobGasPrice *big.Int, txs []*Transaction) error { @@ -252,15 +252,17 @@ func (rs Receipts) DeriveFields(config *params.ChainConfig, hash common.Hash, nu } for i := 0; i < len(rs); i++ { // The transaction type and hash can be retrieved from the transaction itself - rs[i].Type = txs[i].Type() + //rs[i].Type = txs[i].Type() rs[i].TxHash = txs[i].Hash() rs[i].EffectiveGasPrice = txs[i].data.effectiveGasPrice(new(big.Int), baseFee) - // EIP-4844 blob transaction fields - if txs[i].Type() == BlobTxType { - rs[i].BlobGasUsed = txs[i].BlobGas() - rs[i].BlobGasPrice = blobGasPrice - } + + // EIP-4844 blob transaction fields + if txs[i].Type() == BlobTxType { + rs[i].BlobGasUsed = txs[i].BlobGas() + rs[i].BlobGasPrice = blobGasPrice + } + // block location fields rs[i].BlockHash = hash @@ -295,3 +297,4 @@ func (rs Receipts) DeriveFields(config *params.ChainConfig, hash common.Hash, nu } return nil } +*/ diff --git a/rpc/harmony/v2/types.go b/rpc/harmony/v2/types.go index c9abbead05..d2c70b4cf5 100644 --- a/rpc/harmony/v2/types.go +++ b/rpc/harmony/v2/types.go @@ -235,6 +235,7 @@ type StakingTxReceipt struct { Type staking.Directive `json:"type"` Root hexutil.Bytes `json:"root"` Status uint `json:"status"` + EffectiveGasPrice *big.Int `json:"effectiveGasPrice"` } // CxReceipt represents a CxReceipt that will serialize to the RPC representation of a CxReceipt From fe4210923beb912f00debfccf4c5e8fdcd76b2d8 Mon Sep 17 00:00:00 2001 From: frozen <355847+Frozen@users.noreply.github.com> Date: Tue, 17 Sep 2024 15:51:04 -0400 Subject: [PATCH 03/10] Added test is effective gas price is optional. --- core/types/receipt_test.go | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/core/types/receipt_test.go b/core/types/receipt_test.go index 5a8891cf44..c1b692162e 100644 --- a/core/types/receipt_test.go +++ b/core/types/receipt_test.go @@ -5,7 +5,6 @@ import ( "testing" ethcommon "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" "github.com/harmony-one/harmony/staking" ) @@ -112,3 +111,28 @@ func TestFindLogsWithTopic(t *testing.T) { } } } + +// Test we can still parse receipt without EffectiveGasPrice for backwards compatibility, even +// though it is required per the spec. +func TestEffectiveGasPriceNotRequired(t *testing.T) { + r := &Receipt{ + Status: ReceiptStatusFailed, + CumulativeGasUsed: 1, + Logs: []*Log{}, + // derived fields: + TxHash: ethcommon.BytesToHash([]byte{0x03, 0x14}), + ContractAddress: ethcommon.HexToAddress("0x5a443704dd4b594b382c22a083e2bd3090a6fef3"), + GasUsed: 1, + } + + r.EffectiveGasPrice = nil + b, err := r.MarshalJSON() + if err != nil { + t.Fatal("error marshaling receipt to json:", err) + } + r2 := Receipt{} + err = r2.UnmarshalJSON(b) + if err != nil { + t.Fatal("error unmarshalling receipt from json:", err) + } +} From 3951fcbca82ad9a7a9ff2776fb2b775f45cb729f Mon Sep 17 00:00:00 2001 From: frozen <355847+Frozen@users.noreply.github.com> Date: Tue, 17 Sep 2024 16:43:32 -0400 Subject: [PATCH 04/10] Added code to state processor. --- core/state_processor.go | 1 + core/types/transaction.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/core/state_processor.go b/core/state_processor.go index fb7290c077..9601357813 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -334,6 +334,7 @@ func ApplyTransaction(bc ChainContext, author *common.Address, gp *GasPool, stat receipt := types.NewReceipt(root, failedExe, *usedGas) receipt.TxHash = tx.Hash() receipt.GasUsed = result.UsedGas + receipt.EffectiveGasPrice = tx.EffectiveGasPrice(big.NewInt(0), nil) // if the transaction created a contract, store the creation address in the receipt. if msg.To() == nil { receipt.ContractAddress = crypto.CreateAddress(vmenv.Context.Origin, tx.Nonce()) diff --git a/core/types/transaction.go b/core/types/transaction.go index 4461b86506..590c99b8b8 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -536,6 +536,11 @@ func (tx *Transaction) SenderAddress() (common.Address, error) { return addr, nil } +// EffectiveGasPrice returns the effective gas price of the transaction. +func (tx *Transaction) EffectiveGasPrice(dst *big.Int, baseFee *big.Int) *big.Int { + return tx.data.effectiveGasPrice(dst, baseFee) +} + // TxByNonce implements the sort interface to allow sorting a list of transactions // by their nonces. This is usually only useful for sorting transactions from a // single account, otherwise a nonce comparison doesn't make much sense. From 08c8148b9975a32ac2e7250898456f88c13ffc04 Mon Sep 17 00:00:00 2001 From: frozen <355847+Frozen@users.noreply.github.com> Date: Tue, 17 Sep 2024 19:43:30 -0400 Subject: [PATCH 05/10] Added tests for rlp empty EffectiveGasPrice. --- core/types/receipt.go | 5 +++-- core/types/receipt_test.go | 42 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/core/types/receipt.go b/core/types/receipt.go index e8d9d47b44..c4648b9205 100644 --- a/core/types/receipt.go +++ b/core/types/receipt.go @@ -84,7 +84,7 @@ type receiptStorageRLP struct { ContractAddress common.Address Logs []*LogForStorage GasUsed uint64 - effectiveGasPrice *big.Int + EffectiveGasPrice *big.Int `rlp:"optional"` } // NewReceipt creates a barebone transaction receipt, copying the init fields. @@ -169,7 +169,7 @@ func (r *ReceiptForStorage) EncodeRLP(w io.Writer) error { ContractAddress: r.ContractAddress, Logs: make([]*LogForStorage, len(r.Logs)), GasUsed: r.GasUsed, - effectiveGasPrice: r.EffectiveGasPrice, + EffectiveGasPrice: r.EffectiveGasPrice, } for i, log := range r.Logs { enc.Logs[i] = (*LogForStorage)(log) @@ -195,6 +195,7 @@ func (r *ReceiptForStorage) DecodeRLP(s *rlp.Stream) error { } // Assign the implementation fields r.TxHash, r.ContractAddress, r.GasUsed = dec.TxHash, dec.ContractAddress, dec.GasUsed + r.EffectiveGasPrice = dec.EffectiveGasPrice return nil } diff --git a/core/types/receipt_test.go b/core/types/receipt_test.go index c1b692162e..514546e032 100644 --- a/core/types/receipt_test.go +++ b/core/types/receipt_test.go @@ -1,12 +1,15 @@ package types import ( + "math/big" "reflect" "testing" ethcommon "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/rlp" "github.com/harmony-one/harmony/staking" + "github.com/stretchr/testify/require" ) func TestFindLogsWithTopic(t *testing.T) { @@ -136,3 +139,42 @@ func TestEffectiveGasPriceNotRequired(t *testing.T) { t.Fatal("error unmarshalling receipt from json:", err) } } + +func TestReceiptEncDec(t *testing.T) { + r := ReceiptForStorage(Receipt{ + Status: ReceiptStatusFailed, + CumulativeGasUsed: 1, + Logs: []*Log{}, + // derived fields: + TxHash: ethcommon.BytesToHash([]byte{0x03, 0x14}), + ContractAddress: ethcommon.HexToAddress("0x5a443704dd4b594b382c22a083e2bd3090a6fef3"), + GasUsed: 1, + EffectiveGasPrice: big.NewInt(1), + }) + + bytes, err := rlp.EncodeToBytes(&r) + if err != nil { + t.Fatal("error encoding receipt to bytes:", err) + } + + r2 := ReceiptForStorage{} + err = rlp.DecodeBytes(bytes, &r2) + if err != nil { + t.Fatal("error decoding receipt from bytes:", err) + } + + require.Equal(t, r, r2) +} + +func TestReceiptDecodeEmptyEffectiveGasPrice(t *testing.T) { + r := ReceiptForStorage(Receipt{}) + + bytes, err := rlp.EncodeToBytes(&r) + require.NoError(t, err, "error encoding receipt to bytes") + + r2 := ReceiptForStorage{} + err = rlp.DecodeBytes(bytes, &r2) + require.NoError(t, err, "error decoding receipt from bytes") + + require.EqualValues(t, r.EffectiveGasPrice, r2.EffectiveGasPrice) +} From c1fd76060ec341a695b1bbaa60e33261bb037077 Mon Sep 17 00:00:00 2001 From: frozen <355847+Frozen@users.noreply.github.com> Date: Fri, 20 Sep 2024 13:40:17 -0400 Subject: [PATCH 06/10] Removed commented block code. --- core/types/receipt.go | 59 ------------------------------------------- 1 file changed, 59 deletions(-) diff --git a/core/types/receipt.go b/core/types/receipt.go index c4648b9205..6207332d4e 100644 --- a/core/types/receipt.go +++ b/core/types/receipt.go @@ -240,62 +240,3 @@ func FindLogsWithTopic( } return logs } - -/* -// DeriveFields fills the receipts with their computed fields based on consensus -// data and contextual infos like containing block and transactions. -func (rs Receipts) DeriveFields(config *params.ChainConfig, hash common.Hash, number uint64, time uint64, baseFee *big.Int, blobGasPrice *big.Int, txs []*Transaction) error { - signer := MakeSigner(config, new(big.Int).SetUint64(number)) - - logIndex := uint(0) - if len(txs) != len(rs) { - return errors.New("transaction and receipt count mismatch") - } - for i := 0; i < len(rs); i++ { - // The transaction type and hash can be retrieved from the transaction itself - //rs[i].Type = txs[i].Type() - rs[i].TxHash = txs[i].Hash() - rs[i].EffectiveGasPrice = txs[i].data.effectiveGasPrice(new(big.Int), baseFee) - - - // EIP-4844 blob transaction fields - if txs[i].Type() == BlobTxType { - rs[i].BlobGasUsed = txs[i].BlobGas() - rs[i].BlobGasPrice = blobGasPrice - } - - - // block location fields - rs[i].BlockHash = hash - rs[i].BlockNumber = new(big.Int).SetUint64(number) - rs[i].TransactionIndex = uint(i) - - // The contract address can be derived from the transaction itself - if txs[i].To() == nil { - // Deriving the signer is expensive, only do if it's actually needed - from, _ := Sender(signer, txs[i]) - rs[i].ContractAddress = crypto.CreateAddress(from, txs[i].Nonce()) - } else { - rs[i].ContractAddress = common.Address{} - } - - // The used gas can be calculated based on previous r - if i == 0 { - rs[i].GasUsed = rs[i].CumulativeGasUsed - } else { - rs[i].GasUsed = rs[i].CumulativeGasUsed - rs[i-1].CumulativeGasUsed - } - - // The derived log fields can simply be set from the block and transaction - for j := 0; j < len(rs[i].Logs); j++ { - rs[i].Logs[j].BlockNumber = number - rs[i].Logs[j].BlockHash = hash - rs[i].Logs[j].TxHash = rs[i].TxHash - rs[i].Logs[j].TxIndex = uint(i) - rs[i].Logs[j].Index = logIndex - logIndex++ - } - } - return nil -} -*/ From 0f41c5dd1556b208eb0b871f892722791cbadfcd Mon Sep 17 00:00:00 2001 From: frozen <355847+Frozen@users.noreply.github.com> Date: Wed, 25 Sep 2024 15:21:27 -0500 Subject: [PATCH 07/10] Run tests against branch feature/effective-gas-price --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index aa3c5ced23..d7b8580d8c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ install: # /home/travis/gopath/src/github.com/harmony-one/harmony # https://docs.travis-ci.com/user/languages/go/#go-import-path - echo $TRAVIS_PULL_REQUEST_BRANCH - - TEST_REPO_BRANCH="master" + - TEST_REPO_BRANCH="feature/effective-gas-price" - git clone https://github.com/harmony-one/mcl.git $GOPATH/src/github.com/harmony-one/mcl - git clone https://github.com/harmony-one/bls.git $GOPATH/src/github.com/harmony-one/bls - git clone --branch $TEST_REPO_BRANCH https://github.com/harmony-one/harmony-test.git $GOPATH/src/github.com/harmony-one/harmony-test From 150f2f5e87514dff2f95750caf7c9a522cf83e26 Mon Sep 17 00:00:00 2001 From: frozen <355847+Frozen@users.noreply.github.com> Date: Thu, 26 Sep 2024 09:47:48 -0500 Subject: [PATCH 08/10] Added effectiveGasPrice to TxReceipt. --- rpc/harmony/v1/types.go | 2 ++ rpc/harmony/v2/types.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/rpc/harmony/v1/types.go b/rpc/harmony/v1/types.go index c297cfbe7e..949ddfd028 100644 --- a/rpc/harmony/v1/types.go +++ b/rpc/harmony/v1/types.go @@ -188,6 +188,7 @@ type TxReceipt struct { To string `json:"to"` Root hexutil.Bytes `json:"root"` Status hexutil.Uint `json:"status"` + EffectiveGasPrice *big.Int `json:"effectiveGasPrice"` } // StakingTxReceipt represents a staking transaction receipt that will serialize to the RPC representation. @@ -359,6 +360,7 @@ func NewTxReceipt( To: receiver, Root: receipt.PostState, Status: hexutil.Uint(receipt.Status), + EffectiveGasPrice: new(big.Int).Set(receipt.EffectiveGasPrice), } // Set empty array for empty logs diff --git a/rpc/harmony/v2/types.go b/rpc/harmony/v2/types.go index d2c70b4cf5..3b67169546 100644 --- a/rpc/harmony/v2/types.go +++ b/rpc/harmony/v2/types.go @@ -218,6 +218,7 @@ type TxReceipt struct { To string `json:"to"` Root hexutil.Bytes `json:"root"` Status uint `json:"status"` + EffectiveGasPrice *big.Int `json:"effectiveGasPrice"` } // StakingTxReceipt represents a staking transaction receipt that will serialize to the RPC representation. @@ -389,6 +390,7 @@ func NewTxReceipt( To: receiver, Root: receipt.PostState, Status: uint(receipt.Status), + EffectiveGasPrice: new(big.Int).Set(receipt.EffectiveGasPrice), } // Set optionals From 14195db6ac2fc8a0f93182138cff749ac4c4d42d Mon Sep 17 00:00:00 2001 From: frozen <355847+Frozen@users.noreply.github.com> Date: Mon, 14 Oct 2024 19:15:10 -0400 Subject: [PATCH 09/10] Added `effectiveGasPrice` to eth epi. --- rpc/harmony/eth/types.go | 1 + 1 file changed, 1 insertion(+) diff --git a/rpc/harmony/eth/types.go b/rpc/harmony/eth/types.go index a319a8fc12..3d72f858bb 100644 --- a/rpc/harmony/eth/types.go +++ b/rpc/harmony/eth/types.go @@ -152,6 +152,7 @@ func NewReceipt(senderAddr common.Address, tx *types.EthTransaction, blockHash c "contractAddress": nil, "logs": receipt.Logs, "logsBloom": receipt.Bloom, + "effectiveGasPrice": new(big.Int).Set(receipt.EffectiveGasPrice), } // Assign receipt status or post state. From 302422e18b49192ce248980ebfbd6c503ec98c61 Mon Sep 17 00:00:00 2001 From: frozen <355847+Frozen@users.noreply.github.com> Date: Wed, 16 Oct 2024 19:05:46 -0400 Subject: [PATCH 10/10] effectiveGasPrice in hex --- rpc/harmony/eth/types.go | 2 +- rpc/harmony/v1/types.go | 4 ++-- rpc/harmony/v2/types.go | 5 ++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/rpc/harmony/eth/types.go b/rpc/harmony/eth/types.go index 3d72f858bb..120129f45d 100644 --- a/rpc/harmony/eth/types.go +++ b/rpc/harmony/eth/types.go @@ -152,7 +152,7 @@ func NewReceipt(senderAddr common.Address, tx *types.EthTransaction, blockHash c "contractAddress": nil, "logs": receipt.Logs, "logsBloom": receipt.Bloom, - "effectiveGasPrice": new(big.Int).Set(receipt.EffectiveGasPrice), + "effectiveGasPrice": hexutil.Big(*receipt.EffectiveGasPrice), } // Assign receipt status or post state. diff --git a/rpc/harmony/v1/types.go b/rpc/harmony/v1/types.go index 949ddfd028..0a8e02acfb 100644 --- a/rpc/harmony/v1/types.go +++ b/rpc/harmony/v1/types.go @@ -188,7 +188,7 @@ type TxReceipt struct { To string `json:"to"` Root hexutil.Bytes `json:"root"` Status hexutil.Uint `json:"status"` - EffectiveGasPrice *big.Int `json:"effectiveGasPrice"` + EffectiveGasPrice hexutil.Big `json:"effectiveGasPrice"` } // StakingTxReceipt represents a staking transaction receipt that will serialize to the RPC representation. @@ -360,7 +360,7 @@ func NewTxReceipt( To: receiver, Root: receipt.PostState, Status: hexutil.Uint(receipt.Status), - EffectiveGasPrice: new(big.Int).Set(receipt.EffectiveGasPrice), + EffectiveGasPrice: hexutil.Big(*receipt.EffectiveGasPrice), } // Set empty array for empty logs diff --git a/rpc/harmony/v2/types.go b/rpc/harmony/v2/types.go index 3b67169546..003a690861 100644 --- a/rpc/harmony/v2/types.go +++ b/rpc/harmony/v2/types.go @@ -218,7 +218,7 @@ type TxReceipt struct { To string `json:"to"` Root hexutil.Bytes `json:"root"` Status uint `json:"status"` - EffectiveGasPrice *big.Int `json:"effectiveGasPrice"` + EffectiveGasPrice hexutil.Big `json:"effectiveGasPrice"` } // StakingTxReceipt represents a staking transaction receipt that will serialize to the RPC representation. @@ -236,7 +236,6 @@ type StakingTxReceipt struct { Type staking.Directive `json:"type"` Root hexutil.Bytes `json:"root"` Status uint `json:"status"` - EffectiveGasPrice *big.Int `json:"effectiveGasPrice"` } // CxReceipt represents a CxReceipt that will serialize to the RPC representation of a CxReceipt @@ -390,7 +389,7 @@ func NewTxReceipt( To: receiver, Root: receipt.PostState, Status: uint(receipt.Status), - EffectiveGasPrice: new(big.Int).Set(receipt.EffectiveGasPrice), + EffectiveGasPrice: hexutil.Big(*receipt.EffectiveGasPrice), } // Set optionals