mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
fix tx gaslimit and type default
This commit is contained in:
parent
3df0fec8e2
commit
760f5e5b24
3 changed files with 19 additions and 19 deletions
|
|
@ -449,7 +449,7 @@ func (s *PersonalAccountAPI) signTransaction(ctx context.Context, args *Transact
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// Assemble the transaction and sign with the wallet
|
// Assemble the transaction and sign with the wallet
|
||||||
tx := args.toTransaction()
|
tx := args.toTransaction(false)
|
||||||
|
|
||||||
return wallet.SignTxWithPassphrase(account, passwd, tx, s.b.ChainConfig().ChainID)
|
return wallet.SignTxWithPassphrase(account, passwd, tx, s.b.ChainConfig().ChainID)
|
||||||
}
|
}
|
||||||
|
|
@ -492,7 +492,7 @@ func (s *PersonalAccountAPI) SignTransaction(ctx context.Context, args Transacti
|
||||||
return nil, errors.New("nonce not specified")
|
return nil, errors.New("nonce not specified")
|
||||||
}
|
}
|
||||||
// Before actually signing the transaction, ensure the transaction fee is reasonable.
|
// Before actually signing the transaction, ensure the transaction fee is reasonable.
|
||||||
tx := args.toTransaction()
|
tx := args.toTransaction(false)
|
||||||
if err := checkTxFee(tx.GasPrice(), tx.Gas(), s.b.RPCTxFeeCap()); err != nil {
|
if err := checkTxFee(tx.GasPrice(), tx.Gas(), s.b.RPCTxFeeCap()); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -1299,7 +1299,7 @@ func (s *BlockChainAPI) MulticallV1(ctx context.Context, opts multicallOpts, blo
|
||||||
if blockContext.Random != nil {
|
if blockContext.Random != nil {
|
||||||
results[bi].PrevRandao = *blockContext.Random
|
results[bi].PrevRandao = *blockContext.Random
|
||||||
}
|
}
|
||||||
gasUsed := uint64(0)
|
var gasUsed uint64
|
||||||
for i, call := range block.Calls {
|
for i, call := range block.Calls {
|
||||||
// setDefaults will consult txpool's nonce tracker. Work around that.
|
// setDefaults will consult txpool's nonce tracker. Work around that.
|
||||||
if call.Nonce == nil {
|
if call.Nonce == nil {
|
||||||
|
|
@ -1308,8 +1308,8 @@ func (s *BlockChainAPI) MulticallV1(ctx context.Context, opts multicallOpts, blo
|
||||||
}
|
}
|
||||||
// Let the call run wild unless explicitly specified.
|
// Let the call run wild unless explicitly specified.
|
||||||
if call.Gas == nil {
|
if call.Gas == nil {
|
||||||
leftGas := gp.Gas()
|
remaining := blockContext.GasLimit - gasUsed
|
||||||
call.Gas = (*hexutil.Uint64)(&leftGas)
|
call.Gas = (*hexutil.Uint64)(&remaining)
|
||||||
}
|
}
|
||||||
if call.GasPrice == nil && call.MaxFeePerGas == nil && call.MaxPriorityFeePerGas == nil {
|
if call.GasPrice == nil && call.MaxFeePerGas == nil && call.MaxPriorityFeePerGas == nil {
|
||||||
call.GasPrice = (*hexutil.Big)(big.NewInt(0))
|
call.GasPrice = (*hexutil.Big)(big.NewInt(0))
|
||||||
|
|
@ -1318,7 +1318,7 @@ func (s *BlockChainAPI) MulticallV1(ctx context.Context, opts multicallOpts, blo
|
||||||
if err := call.setDefaults(ctx, s.b); err != nil {
|
if err := call.setDefaults(ctx, s.b); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
tx := call.ToTransaction()
|
tx := call.ToTransaction(true)
|
||||||
vmConfig := &vm.Config{
|
vmConfig := &vm.Config{
|
||||||
NoBaseFee: true,
|
NoBaseFee: true,
|
||||||
Tracer: newTracer(opts.TraceTransfers, blockContext.BlockNumber.Uint64(), hash, tx.Hash(), uint(i)),
|
Tracer: newTracer(opts.TraceTransfers, blockContext.BlockNumber.Uint64(), hash, tx.Hash(), uint(i)),
|
||||||
|
|
@ -1853,7 +1853,7 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH
|
||||||
vmenv, _ := b.GetEVM(ctx, msg, statedb, header, &config, nil)
|
vmenv, _ := b.GetEVM(ctx, msg, statedb, header, &config, nil)
|
||||||
res, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.GasLimit))
|
res, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.GasLimit))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, nil, fmt.Errorf("failed to apply transaction: %v err: %v", args.toTransaction().Hash(), err)
|
return nil, 0, nil, fmt.Errorf("failed to apply transaction: %v err: %v", args.toTransaction(false).Hash(), err)
|
||||||
}
|
}
|
||||||
if tracer.Equal(prevTracer) {
|
if tracer.Equal(prevTracer) {
|
||||||
return accessList, res.UsedGas, res.Err, nil
|
return accessList, res.UsedGas, res.Err, nil
|
||||||
|
|
@ -2121,7 +2121,7 @@ func (s *TransactionAPI) SendTransaction(ctx context.Context, args TransactionAr
|
||||||
return common.Hash{}, err
|
return common.Hash{}, err
|
||||||
}
|
}
|
||||||
// Assemble the transaction and sign with the wallet
|
// Assemble the transaction and sign with the wallet
|
||||||
tx := args.toTransaction()
|
tx := args.toTransaction(false)
|
||||||
|
|
||||||
signed, err := wallet.SignTx(account, tx, s.b.ChainConfig().ChainID)
|
signed, err := wallet.SignTx(account, tx, s.b.ChainConfig().ChainID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -2139,7 +2139,7 @@ func (s *TransactionAPI) FillTransaction(ctx context.Context, args TransactionAr
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// Assemble the transaction and obtain rlp
|
// Assemble the transaction and obtain rlp
|
||||||
tx := args.toTransaction()
|
tx := args.toTransaction(false)
|
||||||
data, err := tx.MarshalBinary()
|
data, err := tx.MarshalBinary()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -2205,7 +2205,7 @@ func (s *TransactionAPI) SignTransaction(ctx context.Context, args TransactionAr
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// Before actually sign the transaction, ensure the transaction fee is reasonable.
|
// Before actually sign the transaction, ensure the transaction fee is reasonable.
|
||||||
tx := args.toTransaction()
|
tx := args.toTransaction(false)
|
||||||
if err := checkTxFee(tx.GasPrice(), tx.Gas(), s.b.RPCTxFeeCap()); err != nil {
|
if err := checkTxFee(tx.GasPrice(), tx.Gas(), s.b.RPCTxFeeCap()); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -2253,7 +2253,7 @@ func (s *TransactionAPI) Resend(ctx context.Context, sendArgs TransactionArgs, g
|
||||||
if err := sendArgs.setDefaults(ctx, s.b); err != nil {
|
if err := sendArgs.setDefaults(ctx, s.b); err != nil {
|
||||||
return common.Hash{}, err
|
return common.Hash{}, err
|
||||||
}
|
}
|
||||||
matchTx := sendArgs.toTransaction()
|
matchTx := sendArgs.toTransaction(false)
|
||||||
|
|
||||||
// Before replacing the old transaction, ensure the _new_ transaction fee is reasonable.
|
// Before replacing the old transaction, ensure the _new_ transaction fee is reasonable.
|
||||||
var price = matchTx.GasPrice()
|
var price = matchTx.GasPrice()
|
||||||
|
|
@ -2283,7 +2283,7 @@ func (s *TransactionAPI) Resend(ctx context.Context, sendArgs TransactionArgs, g
|
||||||
if gasLimit != nil && *gasLimit != 0 {
|
if gasLimit != nil && *gasLimit != 0 {
|
||||||
sendArgs.Gas = gasLimit
|
sendArgs.Gas = gasLimit
|
||||||
}
|
}
|
||||||
signedTx, err := s.sign(sendArgs.from(), sendArgs.toTransaction())
|
signedTx, err := s.sign(sendArgs.from(), sendArgs.toTransaction(false))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return common.Hash{}, err
|
return common.Hash{}, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -992,7 +992,7 @@ func TestMulticallV1(t *testing.T) {
|
||||||
Index hexutil.Uint `json:"logIndex"`
|
Index hexutil.Uint `json:"logIndex"`
|
||||||
}
|
}
|
||||||
type callRes struct {
|
type callRes struct {
|
||||||
ReturnValue string `json:"return"`
|
ReturnValue string `json:"returnData"`
|
||||||
Error string
|
Error string
|
||||||
Logs []log
|
Logs []log
|
||||||
GasUsed string
|
GasUsed string
|
||||||
|
|
@ -1123,7 +1123,7 @@ func TestMulticallV1(t *testing.T) {
|
||||||
GasUsed: "0x0",
|
GasUsed: "0x0",
|
||||||
Logs: []log{},
|
Logs: []log{},
|
||||||
Status: "0x0",
|
Status: "0x0",
|
||||||
Error: fmt.Sprintf("err: insufficient funds for gas * price + value: address %s have 0 want 1000 (supplied gas 9937000)", randomAccounts[3].addr.String()),
|
Error: fmt.Sprintf("err: insufficient funds for gas * price + value: address %s have 0 want 1000 (supplied gas 4691388)", randomAccounts[3].addr.String()),
|
||||||
}},
|
}},
|
||||||
}},
|
}},
|
||||||
}, {
|
}, {
|
||||||
|
|
@ -1574,7 +1574,7 @@ func TestMulticallV1(t *testing.T) {
|
||||||
GasUsed: "0x0",
|
GasUsed: "0x0",
|
||||||
Logs: []log{},
|
Logs: []log{},
|
||||||
Status: "0x0",
|
Status: "0x0",
|
||||||
Error: fmt.Sprintf("err: nonce too high: address %s, tx: 2 state: 0 (supplied gas 10000000)", accounts[2].addr),
|
Error: fmt.Sprintf("err: nonce too high: address %s, tx: 2 state: 0 (supplied gas 4712388)", accounts[2].addr),
|
||||||
}},
|
}},
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -286,10 +286,10 @@ func (args *TransactionArgs) ToMessage(globalGasCap uint64, baseFee *big.Int, sk
|
||||||
|
|
||||||
// toTransaction converts the arguments to a transaction.
|
// toTransaction converts the arguments to a transaction.
|
||||||
// This assumes that setDefaults has been called.
|
// This assumes that setDefaults has been called.
|
||||||
func (args *TransactionArgs) toTransaction() *types.Transaction {
|
func (args *TransactionArgs) toTransaction(type2 bool) *types.Transaction {
|
||||||
var data types.TxData
|
var data types.TxData
|
||||||
switch {
|
switch {
|
||||||
case args.MaxFeePerGas != nil:
|
case args.MaxFeePerGas != nil || type2:
|
||||||
al := types.AccessList{}
|
al := types.AccessList{}
|
||||||
if args.AccessList != nil {
|
if args.AccessList != nil {
|
||||||
al = *args.AccessList
|
al = *args.AccessList
|
||||||
|
|
@ -331,6 +331,6 @@ func (args *TransactionArgs) toTransaction() *types.Transaction {
|
||||||
|
|
||||||
// ToTransaction converts the arguments to a transaction.
|
// ToTransaction converts the arguments to a transaction.
|
||||||
// This assumes that setDefaults has been called.
|
// This assumes that setDefaults has been called.
|
||||||
func (args *TransactionArgs) ToTransaction() *types.Transaction {
|
func (args *TransactionArgs) ToTransaction(type2 bool) *types.Transaction {
|
||||||
return args.toTransaction()
|
return args.toTransaction(type2)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue