cmd/evm: stricter transaction validation (#23694)
* cmd/evm: t9n: validate transaction intrinsic gas * cmd/evm: t9n: stricter tx validation
This commit is contained in:
committed by
GitHub
parent
8a430fbd1c
commit
64da037e99
@ -26,6 +26,7 @@ import (
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
@ -123,12 +124,22 @@ func Transaction(ctx *cli.Context) error {
|
||||
results = append(results, result{Error: err})
|
||||
continue
|
||||
}
|
||||
sender, err := types.Sender(signer, &tx)
|
||||
if err != nil {
|
||||
results = append(results, result{Error: err})
|
||||
r := result{Hash: tx.Hash()}
|
||||
if sender, err := types.Sender(signer, &tx); err != nil {
|
||||
r.Error = err
|
||||
results = append(results, r)
|
||||
continue
|
||||
} else {
|
||||
r.Address = sender
|
||||
}
|
||||
results = append(results, result{Address: sender, Hash: tx.Hash()})
|
||||
|
||||
if gas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil,
|
||||
chainConfig.IsHomestead(new(big.Int)), chainConfig.IsIstanbul(new(big.Int))); err != nil {
|
||||
r.Error = err
|
||||
} else if tx.Gas() < gas {
|
||||
r.Error = fmt.Errorf("%w: have %d, want %d", core.ErrIntrinsicGas, tx.Gas(), gas)
|
||||
}
|
||||
results = append(results, r)
|
||||
}
|
||||
out, err := json.MarshalIndent(results, "", " ")
|
||||
fmt.Println(string(out))
|
||||
|
Reference in New Issue
Block a user