diff --git a/db/migrations/00013_create_cid_indexes.sql b/db/migrations/00013_create_cid_indexes.sql index 2038c867..f178de66 100644 --- a/db/migrations/00013_create_cid_indexes.sql +++ b/db/migrations/00013_create_cid_indexes.sql @@ -47,8 +47,6 @@ CREATE INDEX state_mh_index ON eth.state_cids USING btree (mh_key); CREATE INDEX state_path_index ON eth.state_cids USING btree (state_path); -CREATE INDEX state_node_type_index ON eth.state_cids USING btree (node_type); - -- storage node indexes CREATE INDEX storage_state_id_index ON eth.storage_cids USING btree (state_id); @@ -60,8 +58,6 @@ CREATE INDEX storage_mh_index ON eth.storage_cids USING btree (mh_key); CREATE INDEX storage_path_index ON eth.storage_cids USING btree (storage_path); -CREATE INDEX storage_node_type_index ON eth.storage_cids USING btree (node_type); - -- state accounts indexes CREATE INDEX account_state_id_index ON eth.state_accounts USING btree (state_id); @@ -73,7 +69,6 @@ DROP INDEX eth.storage_root_index; DROP INDEX eth.account_state_id_index; -- storage node indexes -DROP INDEX eth.storage_node_type_index; DROP INDEX eth.storage_path_index; DROP INDEX eth.storage_mh_index; DROP INDEX eth.storage_cid_index; @@ -81,7 +76,6 @@ DROP INDEX eth.storage_leaf_key_index; DROP INDEX eth.storage_state_id_index; -- state node indexes -DROP INDEX eth.state_node_type_index; DROP INDEX eth.state_path_index; DROP INDEX eth.state_mh_index; DROP INDEX eth.state_cid_index; diff --git a/pkg/eth/api.go b/pkg/eth/api.go index e9e9c922..f905034b 100644 --- a/pkg/eth/api.go +++ b/pkg/eth/api.go @@ -506,7 +506,7 @@ func (pea *PublicEthAPI) localGetTransactionReceipt(ctx context.Context, hash co var signer types.Signer = types.FrontierSigner{} if tx.Protected() { - signer = types.NewEIP155Signer(tx.ChainId()) + signer = types.LatestSignerForChainID(tx.ChainId()) } from, _ := types.Sender(signer, tx) @@ -537,6 +537,15 @@ func (pea *PublicEthAPI) localGetTransactionReceipt(ctx context.Context, hash co if receipt.ContractAddress != (common.Address{}) { fields["contractAddress"] = receipt.ContractAddress } + + if !pea.B.Config.ChainConfig.IsLondon(block.Number()) { + fields["effectiveGasPrice"] = hexutil.Uint64(tx.GasPrice().Uint64()) + } else { + baseFee := block.BaseFee() + effectiveGasTip, _ := tx.EffectiveGasTip(baseFee) + gasPrice := new(big.Int).Add(block.BaseFee(), effectiveGasTip) + fields["effectiveGasPrice"] = hexutil.Uint64(gasPrice.Uint64()) + } return fields, nil } diff --git a/pkg/eth/api_test.go b/pkg/eth/api_test.go index 57866cab..71ca98b9 100644 --- a/pkg/eth/api_test.go +++ b/pkg/eth/api_test.go @@ -43,15 +43,16 @@ import ( ) var ( - randomAddr = common.HexToAddress("0x1C3ab14BBaD3D99F4203bd7a11aCB94882050E6f") - randomHash = crypto.Keccak256Hash(randomAddr.Bytes()) - number = rpc.BlockNumber(test_helpers.BlockNumber.Int64()) - londonBlockNum = rpc.BlockNumber(test_helpers.LondonBlockNum.Int64()) - wrongNumber = number + 1 - blockHash = test_helpers.MockBlock.Header().Hash() - baseFee = test_helpers.MockLondonBlock.BaseFee() - ctx = context.Background() - expectedBlock = map[string]interface{}{ + randomAddr = common.HexToAddress("0x1C3ab14BBaD3D99F4203bd7a11aCB94882050E6f") + randomHash = crypto.Keccak256Hash(randomAddr.Bytes()) + number = rpc.BlockNumber(test_helpers.BlockNumber.Int64()) + londonBlockNum = rpc.BlockNumber(test_helpers.LondonBlockNum.Int64()) + wrongNumber = number + 1 + blockHash = test_helpers.MockBlock.Header().Hash() + baseFee = test_helpers.MockLondonBlock.BaseFee() + ctx = context.Background() + londonBlockHash = test_helpers.MockLondonBlock.Header().Hash() + expectedBlock = map[string]interface{}{ "number": (*hexutil.Big)(test_helpers.MockBlock.Number()), "hash": test_helpers.MockBlock.Hash(), "parentHash": test_helpers.MockBlock.ParentHash(), @@ -151,6 +152,7 @@ var ( "logs": test_helpers.MockReceipts[0].Logs, "logsBloom": test_helpers.MockReceipts[0].Bloom, "status": hexutil.Uint(test_helpers.MockReceipts[0].Status), + "effectiveGasPrice": hexutil.Uint64(test_helpers.MockTransactions[0].GasPrice().Uint64()), } expectedReceipt2 = map[string]interface{}{ "blockHash": blockHash, @@ -165,6 +167,7 @@ var ( "logs": test_helpers.MockReceipts[1].Logs, "logsBloom": test_helpers.MockReceipts[1].Bloom, "root": hexutil.Bytes(test_helpers.MockReceipts[1].PostState), + "effectiveGasPrice": hexutil.Uint64(test_helpers.MockTransactions[1].GasPrice().Uint64()), } expectedReceipt3 = map[string]interface{}{ "blockHash": blockHash, @@ -179,6 +182,24 @@ var ( "logs": test_helpers.MockReceipts[2].Logs, "logsBloom": test_helpers.MockReceipts[2].Bloom, "root": hexutil.Bytes(test_helpers.MockReceipts[2].PostState), + "effectiveGasPrice": hexutil.Uint64(test_helpers.MockTransactions[2].GasPrice().Uint64()), + } + + effectiveGasTip, _ = test_helpers.MockLondonTransactions[0].EffectiveGasTip(baseFee) + expectedLondonReceipt = map[string]interface{}{ + "blockHash": londonBlockHash, + "blockNumber": hexutil.Uint64(uint64(londonBlockNum.Int64())), + "transactionHash": expectedLondonTransaction.Hash, + "transactionIndex": hexutil.Uint64(0), + "from": expectedLondonTransaction.From, + "to": expectedLondonTransaction.To, + "gasUsed": hexutil.Uint64(test_helpers.MockLondonReceipts[0].GasUsed), + "cumulativeGasUsed": hexutil.Uint64(test_helpers.MockLondonReceipts[0].CumulativeGasUsed), + "contractAddress": nil, + "logs": test_helpers.MockLondonReceipts[0].Logs, + "logsBloom": test_helpers.MockLondonReceipts[0].Bloom, + "root": hexutil.Bytes(test_helpers.MockLondonReceipts[0].PostState), + "effectiveGasPrice": hexutil.Uint64((new(big.Int).Add(baseFee, effectiveGasTip)).Uint64()), } ) @@ -513,6 +534,12 @@ var _ = Describe("API", func() { Expect(tx.GasTipCap).To(Equal((*hexutil.Big)(test_helpers.MockLondonTransactions[0].GasTipCap()))) Expect(tx).To(Equal(expectedLondonTransaction)) }) + It("Retrieves the GasPrice for dynamic transaction from the london block hash", func() { + tx := api.GetTransactionByBlockNumberAndIndex(ctx, londonBlockNum, 0) + Expect(tx).ToNot(BeNil()) + Expect(tx.GasPrice).To(Equal((*hexutil.Big)(test_helpers.MockLondonTransactions[0].GasPrice()))) + Expect(tx).To(Equal(expectedLondonTransaction)) + }) }) Describe("eth_getTransactionByBlockHashAndIndex", func() { @@ -639,6 +666,11 @@ var _ = Describe("API", func() { rct, err = api.GetTransactionReceipt(ctx, hash) Expect(err).ToNot(HaveOccurred()) Expect(rct).To(Equal(expectedReceipt3)) + + hash = test_helpers.MockLondonTransactions[0].Hash() + rct, err = api.GetTransactionReceipt(ctx, hash) + Expect(err).ToNot(HaveOccurred()) + Expect(rct).To(Equal(expectedLondonReceipt)) }) It("Throws an error if it cannot find a receipt for the provided tx hash", func() { _, err := api.GetTransactionReceipt(ctx, randomHash) diff --git a/pkg/eth/test_helpers/test_data.go b/pkg/eth/test_helpers/test_data.go index f769315c..93c057d5 100644 --- a/pkg/eth/test_helpers/test_data.go +++ b/pkg/eth/test_helpers/test_data.go @@ -631,6 +631,8 @@ func createDynamicTransactionsAndReceipts(blockNumber *big.Int) (types.Transacti TxHash: signedTrx1.Hash(), } + mockReceipt1.GasUsed = mockReceipt1.CumulativeGasUsed + return types.Transactions{signedTrx1}, types.Receipts{mockReceipt1}, senderAddr } diff --git a/version/version.go b/version/version.go index 29ac8ff1..f8f952c5 100644 --- a/version/version.go +++ b/version/version.go @@ -21,7 +21,7 @@ import "fmt" const ( Major = 0 // Major version component of the current release Minor = 3 // Minor version component of the current release - Patch = 6 // Patch version component of the current release + Patch = 5 // Patch version component of the current release Meta = "alpha" // Version metadata to append to the version string )