From 250209524e1ad2815189d4fa18a6b0e0d9fcf609 Mon Sep 17 00:00:00 2001 From: Jonathan Downing Date: Wed, 27 Nov 2024 11:20:48 -0600 Subject: [PATCH] Reset gasprice/basefee and minertip to zero in estimateGas and createAccessList --- core/core.go | 2 +- core/state_transition.go | 2 +- internal/quaiapi/api.go | 6 +++--- internal/quaiapi/quai_api.go | 2 +- internal/quaiapi/transaction_args.go | 6 ++---- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/core/core.go b/core/core.go index 8d98b424d3..6e37cfc5a9 100644 --- a/core/core.go +++ b/core/core.go @@ -1306,7 +1306,7 @@ func (c *Core) GetUTXOsByAddress(address common.Address) ([]*types.UtxoEntry, er for _, outpoint := range outpointsForAddress { entry := rawdb.GetUTXO(c.sl.sliceDb, outpoint.TxHash, outpoint.Index) if entry == nil { - return nil, errors.New("failed to get UTXO for address") + continue } utxos = append(utxos, entry) } diff --git a/core/state_transition.go b/core/state_transition.go index cb104e3b3d..b817e28d24 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -261,7 +261,7 @@ func (st *StateTransition) preCheck() error { } // Make sure that transaction gasPrice is greater than the baseFee // Skip the checks if gas fields are zero and baseFee was explicitly disabled (eth_call) - if !st.evm.Config.NoBaseFee || st.gasPrice.BitLen() > 0 || st.gasPrice.BitLen() > 0 { + if !st.evm.Config.NoBaseFee || st.gasPrice.BitLen() > 0 || st.minerTip.BitLen() > 0 { if l := st.gasPrice.BitLen(); l > 256 { return fmt.Errorf("%w: address %v, gasPrice bit length: %d", ErrFeeCapVeryHigh, st.msg.From().Hex(), l) diff --git a/internal/quaiapi/api.go b/internal/quaiapi/api.go index 0ed938d425..e015a9200c 100644 --- a/internal/quaiapi/api.go +++ b/internal/quaiapi/api.go @@ -704,14 +704,14 @@ func DoEstimateGas(ctx context.Context, b Backend, args TransactionArgs, blockNr hi = uint64(*args.Gas) } else { // Retrieve the block to act as the gas ceiling - block, err := b.BlockByNumberOrHash(ctx, blockNrOrHash) + header, err := b.HeaderByNumberOrHash(ctx, blockNrOrHash) if err != nil { return 0, err } - if block == nil { + if header == nil { return 0, errors.New("block not found") } - hi = block.GasLimit() + hi = header.GasLimit() if hi == 0 { hi = params.GasCeil } diff --git a/internal/quaiapi/quai_api.go b/internal/quaiapi/quai_api.go index 81855594fc..6cf31b5862 100644 --- a/internal/quaiapi/quai_api.go +++ b/internal/quaiapi/quai_api.go @@ -820,7 +820,7 @@ func (s *PublicBlockChainQuaiAPI) EstimateGas(ctx context.Context, args Transact bNrOrHash = *blockNrOrHash } - if args.from(s.b.NodeLocation()).IsInQuaiLedgerScope() && args.To.IsInQiLedgerScope() { + if args.from(s.b.NodeLocation()).IsInQuaiLedgerScope() && args.To != nil && args.To.IsInQiLedgerScope() { // Conversion transaction var header *types.WorkObject var err error diff --git a/internal/quaiapi/transaction_args.go b/internal/quaiapi/transaction_args.go index b2e61a9fed..1ee57a13cc 100644 --- a/internal/quaiapi/transaction_args.go +++ b/internal/quaiapi/transaction_args.go @@ -169,10 +169,7 @@ func (args *TransactionArgs) ToMessage(globalGasCap uint64, baseFee *big.Int, no minerTip *big.Int ) // User specified max fee (or none), use those - gasPrice = new(big.Int) - if args.GasPrice != nil { - gasPrice = args.GasPrice.ToInt() - } + gasPrice = new(big.Int).Set(common.Big0) minerTip = gasPrice value := new(big.Int) if args.Value != nil { @@ -183,6 +180,7 @@ func (args *TransactionArgs) ToMessage(globalGasCap uint64, baseFee *big.Int, no if args.AccessList != nil { accessList = *args.AccessList } + msg := types.NewMessage(addr, args.To, uint64(*args.Nonce), value, gas, gasPrice, minerTip, data, accessList, false) return msg, nil }