mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 13:21:37 +00:00
Merge 5966f20f8a into 7c9032dff6
This commit is contained in:
commit
41bdd94578
4 changed files with 36 additions and 10 deletions
|
|
@ -948,7 +948,7 @@ func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, bloc
|
|||
}
|
||||
var (
|
||||
msg = args.ToMessage(blockContext.BaseFee, true)
|
||||
tx = args.ToTransaction(types.DynamicFeeTxType)
|
||||
tx, _ = args.ToTransaction(types.DynamicFeeTxType)
|
||||
traceConfig *TraceConfig
|
||||
)
|
||||
// Lower the basefee to 0 to avoid breaking EVM
|
||||
|
|
|
|||
|
|
@ -1422,7 +1422,12 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH
|
|||
res, err := core.ApplyMessage(evm, msg, nil)
|
||||
evm.Release()
|
||||
if err != nil {
|
||||
return nil, 0, nil, fmt.Errorf("failed to apply transaction: %v err: %v", args.ToTransaction(types.LegacyTxType).Hash(), err)
|
||||
var hash common.Hash
|
||||
tx, err := args.ToTransaction(types.LegacyTxType)
|
||||
if err == nil {
|
||||
hash = tx.Hash()
|
||||
}
|
||||
return nil, 0, nil, fmt.Errorf("failed to apply transaction: %v err: %v", hash, err)
|
||||
}
|
||||
if tracer.Equal(prevTracer) {
|
||||
return accessList, res.UsedGas, res.Err, nil
|
||||
|
|
@ -1695,7 +1700,10 @@ func (api *TransactionAPI) SendTransaction(ctx context.Context, args Transaction
|
|||
return common.Hash{}, err
|
||||
}
|
||||
// Assemble the transaction and sign with the wallet
|
||||
tx := args.ToTransaction(types.DynamicFeeTxType)
|
||||
tx, err := args.ToTransaction(types.DynamicFeeTxType)
|
||||
if err != nil {
|
||||
return common.Hash{}, err
|
||||
}
|
||||
|
||||
signed, err := wallet.SignTx(account, tx, api.b.ChainConfig().ChainID)
|
||||
if err != nil {
|
||||
|
|
@ -1717,7 +1725,10 @@ func (api *TransactionAPI) FillTransaction(ctx context.Context, args Transaction
|
|||
return nil, err
|
||||
}
|
||||
// Assemble the transaction and obtain rlp
|
||||
tx := args.ToTransaction(types.DynamicFeeTxType)
|
||||
tx, err := args.ToTransaction(types.DynamicFeeTxType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
data, err := tx.MarshalBinary()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -1913,7 +1924,10 @@ func (api *TransactionAPI) SignTransaction(ctx context.Context, args Transaction
|
|||
return nil, err
|
||||
}
|
||||
// Before actually sign the transaction, ensure the transaction fee is reasonable.
|
||||
tx := args.ToTransaction(types.DynamicFeeTxType)
|
||||
tx, err := args.ToTransaction(types.DynamicFeeTxType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := checkTxFee(tx.GasPrice(), tx.Gas(), api.b.RPCTxFeeCap()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -1969,7 +1983,10 @@ func (api *TransactionAPI) Resend(ctx context.Context, sendArgs TransactionArgs,
|
|||
if err := sendArgs.setDefaults(ctx, api.b, sidecarConfig{}); err != nil {
|
||||
return common.Hash{}, err
|
||||
}
|
||||
matchTx := sendArgs.ToTransaction(types.DynamicFeeTxType)
|
||||
matchTx, err := sendArgs.ToTransaction(types.DynamicFeeTxType)
|
||||
if err != nil {
|
||||
return common.Hash{}, err
|
||||
}
|
||||
|
||||
// Before replacing the old transaction, ensure the _new_ transaction fee is reasonable.
|
||||
price := matchTx.GasPrice()
|
||||
|
|
@ -1999,7 +2016,11 @@ func (api *TransactionAPI) Resend(ctx context.Context, sendArgs TransactionArgs,
|
|||
if gasLimit != nil && *gasLimit != 0 {
|
||||
sendArgs.Gas = gasLimit
|
||||
}
|
||||
signedTx, err := api.sign(sendArgs.from(), sendArgs.ToTransaction(types.DynamicFeeTxType))
|
||||
tx, err := sendArgs.ToTransaction(types.DynamicFeeTxType)
|
||||
if err != nil {
|
||||
return common.Hash{}, err
|
||||
}
|
||||
signedTx, err := api.sign(sendArgs.from(), tx)
|
||||
if err != nil {
|
||||
return common.Hash{}, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -335,7 +335,7 @@ func (sim *simulator) processBlock(ctx context.Context, block *simBlock, header,
|
|||
return nil, nil, nil, err
|
||||
}
|
||||
var (
|
||||
tx = call.ToTransaction(types.DynamicFeeTxType)
|
||||
tx, _ = call.ToTransaction(types.DynamicFeeTxType)
|
||||
txHash = tx.Hash()
|
||||
)
|
||||
txes[i] = tx
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@ import (
|
|||
// TransactionArgs represents the arguments to construct a new transaction
|
||||
// or a message call.
|
||||
type TransactionArgs struct {
|
||||
Type *hexutil.Uint64 `json:"type,omitempty"`
|
||||
|
||||
From *common.Address `json:"from"`
|
||||
To *common.Address `json:"to"`
|
||||
Gas *hexutil.Uint64 `json:"gas"`
|
||||
|
|
@ -503,7 +505,7 @@ func (args *TransactionArgs) ToMessage(baseFee *big.Int, skipNonceCheck bool) *c
|
|||
|
||||
// ToTransaction converts the arguments to a transaction.
|
||||
// This assumes that setDefaults has been called.
|
||||
func (args *TransactionArgs) ToTransaction(defaultType int) *types.Transaction {
|
||||
func (args *TransactionArgs) ToTransaction(defaultType int) (*types.Transaction, error) {
|
||||
usedType := types.LegacyTxType
|
||||
switch {
|
||||
case args.AuthorizationList != nil || defaultType == types.SetCodeTxType:
|
||||
|
|
@ -519,6 +521,9 @@ func (args *TransactionArgs) ToTransaction(defaultType int) *types.Transaction {
|
|||
if args.GasPrice != nil {
|
||||
usedType = types.LegacyTxType
|
||||
}
|
||||
if usedType != int(*args.Type) {
|
||||
return nil, fmt.Errorf("wrong tx type used, requested: %v, used: %v", args.Type, usedType)
|
||||
}
|
||||
var data types.TxData
|
||||
switch usedType {
|
||||
case types.SetCodeTxType:
|
||||
|
|
@ -608,7 +613,7 @@ func (args *TransactionArgs) ToTransaction(defaultType int) *types.Transaction {
|
|||
Data: args.data(),
|
||||
}
|
||||
}
|
||||
return types.NewTx(data)
|
||||
return types.NewTx(data), nil
|
||||
}
|
||||
|
||||
// IsEIP4844 returns an indicator if the args contains EIP4844 fields.
|
||||
|
|
|
|||
Loading…
Reference in a new issue