Skip to content

Commit

Permalink
Reset gasprice/basefee and minertip to zero in estimateGas and create…
Browse files Browse the repository at this point in the history
…AccessList
  • Loading branch information
jdowning100 committed Dec 1, 2024
1 parent 141ec54 commit 2502095
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions internal/quaiapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion internal/quaiapi/quai_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions internal/quaiapi/transaction_args.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down

0 comments on commit 2502095

Please sign in to comment.