diff --git a/common/math/big.go b/common/math/big.go index c9d381d076..7f3bf98936 100644 --- a/common/math/big.go +++ b/common/math/big.go @@ -199,7 +199,7 @@ func BigMinUint256(x, y *uint256.Int) *uint256.Int { // todo: @anshalshukla - check implementation correctness func BigIntToUint256Int(x *big.Int) *uint256.Int { - return new(uint256.Int).SetUint64(x.Uint64()) + return new(uint256.Int).SetBytes(x.Bytes()) } // FirstBitSet returns the index of the first 1 bit in v, counting from LSB. diff --git a/core/state_processor.go b/core/state_processor.go index b4fd3ec659..94d1d731f1 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -22,6 +22,7 @@ import ( "math/big" "github.com/ethereum/go-ethereum/common" + cmath "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/consensus/misc" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/tracing" @@ -29,7 +30,6 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" - "github.com/holiman/uint256" ) // StateProcessor is a basic Processor, which takes care of transitioning @@ -160,11 +160,11 @@ func ApplyTransactionWithEVM(msg *Message, config *params.ChainConfig, gp *GasPo statedb.SetMVHashmap(nil) if evm.ChainConfig().IsLondon(blockNumber) { - statedb.AddBalance(result.BurntContractAddress, uint256.NewInt(result.FeeBurnt.Uint64()), tracing.BalanceChangeTransfer) + statedb.AddBalance(result.BurntContractAddress, cmath.BigIntToUint256Int(result.FeeBurnt), tracing.BalanceChangeTransfer) } // TODO(raneet10) Double check - statedb.AddBalance(evm.Context.Coinbase, uint256.NewInt(result.FeeTipped.Uint64()), tracing.BalanceChangeTransfer) + statedb.AddBalance(evm.Context.Coinbase, cmath.BigIntToUint256Int(result.FeeTipped), tracing.BalanceChangeTransfer) output1 := new(big.Int).SetBytes(result.SenderInitBalance.Bytes()) output2 := new(big.Int).SetBytes(coinbaseBalance.Bytes()) diff --git a/core/state_transition.go b/core/state_transition.go index 6ed13c880e..ec131e14ad 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -528,12 +528,12 @@ func (st *StateTransition) TransitionDb(interruptCtx context.Context) (*Executio burnAmount = new(big.Int).Mul(new(big.Int).SetUint64(st.gasUsed()), st.evm.Context.BaseFee) if !st.noFeeBurnAndTip { - st.state.AddBalance(burntContractAddress, uint256.NewInt(burnAmount.Uint64()), tracing.BalanceChangeTransfer) + st.state.AddBalance(burntContractAddress, cmath.BigIntToUint256Int(burnAmount), tracing.BalanceChangeTransfer) } } if !st.noFeeBurnAndTip { - st.state.AddBalance(st.evm.Context.Coinbase, uint256.NewInt(amount.Uint64()), tracing.BalanceIncreaseRewardTransactionFee) + st.state.AddBalance(st.evm.Context.Coinbase, cmath.BigIntToUint256Int(amount), tracing.BalanceIncreaseRewardTransactionFee) // add the coinbase to the witness iff the fee is greater than 0 if rules.IsEIP4762 && amount.Sign() != 0 {