From 224f268b6758a9adc9b27a34fc3a6fade574a0d9 Mon Sep 17 00:00:00 2001 From: lyfsn Date: Mon, 11 Mar 2024 22:43:00 +0800 Subject: [PATCH] fix: correctly interpret BaseFeePerGas as big-endian --- ethstore.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/ethstore.go b/ethstore.go index 1d9adad..a3e9b6f 100644 --- a/ethstore.go +++ b/ethstore.go @@ -488,13 +488,7 @@ func Calculate(ctx context.Context, bnAddress, elAddress, dayStr string, concurr totalTxFee.Add(totalTxFee, txFee) } - // base fee per gas is stored little-endian but we need it - // big-endian for big.Int. - var baseFeePerGasBEBytes [32]byte - for i := 0; i < 32; i++ { - baseFeePerGasBEBytes[i] = blockData.BaseFeePerGas[32-1-i] - } - baseFeePerGas := new(big.Int).SetBytes(baseFeePerGasBEBytes[:]) + baseFeePerGas := new(big.Int).SetBytes(blockData.BaseFeePerGas[:]) burntFee := new(big.Int).Mul(baseFeePerGas, new(big.Int).SetUint64(blockData.GasUsed)) totalTxFee.Sub(totalTxFee, burntFee)