Skip to content

Commit 307c077

Browse files
authored
Merge branch 'main' into jeremy/proposer-priority
2 parents da7747f + ca756c0 commit 307c077

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

evmrpc/tests/tx_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,23 @@ func TestEVMTransactionIndexResponseCorrectnessAndConsistency(t *testing.T) {
130130
},
131131
)
132132
}
133+
134+
func TestGetTransactionGasPrice(t *testing.T) {
135+
txData := send(0)
136+
signedTx := signTxWithMnemonic(txData, mnemonic1)
137+
tx := encodeEvmTx(txData, signedTx)
138+
SetupTestServer([][][]byte{{tx}}, mnemonicInitializer(mnemonic1)).Run(
139+
func(port int) {
140+
res := sendRequestWithNamespace("eth", port, "getTransactionByHash", signedTx.Hash().Hex())
141+
result := res["result"].(map[string]any)
142+
143+
// Verify gasPrice field exists and has the expected value
144+
gasPrice, exists := result["gasPrice"]
145+
require.True(t, exists, "gasPrice field should exist in response")
146+
147+
// The gasPrice should match the GasFeeCap from the DynamicFeeTx
148+
expectedGasPrice := "0x3b9aca00" // 1000000000 in hex
149+
require.Equal(t, expectedGasPrice, gasPrice, "gasPrice should match the transaction's GasFeeCap")
150+
},
151+
)
152+
}

evmrpc/tx.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,12 @@ func (t *TransactionAPI) getTransactionWithBlock(block *coretypes.ResultBlock, i
316316
return nil, errors.New("not found")
317317
}
318318
height := int64(receipt.BlockNumber)
319-
baseFeePerGas := t.keeper.GetBaseFee(t.ctxProvider(height))
319+
var baseFeePerGas *big.Int
320+
if block.Block.Height > 1 {
321+
baseFeePerGas = t.keeper.GetNextBaseFeePerGas(t.ctxProvider(height - 1)).TruncateInt().BigInt()
322+
} else {
323+
baseFeePerGas = types.DefaultMinFeePerGas.TruncateInt().BigInt()
324+
}
320325
chainConfig := types.DefaultChainConfig().EthereumConfig(t.keeper.ChainID(t.ctxProvider(height)))
321326
blockHash := common.HexToHash(block.BlockID.Hash.String())
322327
blockNumber := uint64(block.Block.Height)

0 commit comments

Comments
 (0)