t9n: refactor instrinsic and floordatagas checks

This commit is contained in:
lightclient 2025-01-29 15:06:52 -07:00
parent 965f2bf785
commit 3ff6bad7dd
No known key found for this signature in database
GPG key ID: 657913021EF45A6A

View file

@ -133,32 +133,33 @@ func Transaction(ctx *cli.Context) error {
r.Address = sender r.Address = sender
} }
// Check intrinsic gas // Check intrinsic gas
if gas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.SetCodeAuthorizations(), tx.To() == nil, rules := chainConfig.Rules(common.Big0, true, 0)
chainConfig.IsHomestead(new(big.Int)), chainConfig.IsIstanbul(new(big.Int)), chainConfig.IsShanghai(new(big.Int), 0)); err != nil { gas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.SetCodeAuthorizations(), tx.To() == nil, rules.IsHomestead, rules.IsIstanbul, rules.IsShanghai)
if err != nil {
r.Error = err r.Error = err
results = append(results, r) results = append(results, r)
continue continue
} else { }
r.IntrinsicGas = gas r.IntrinsicGas = gas
if tx.Gas() < gas { if tx.Gas() < gas {
r.Error = fmt.Errorf("%w: have %d, want %d", core.ErrIntrinsicGas, tx.Gas(), gas) r.Error = fmt.Errorf("%w: have %d, want %d", core.ErrIntrinsicGas, tx.Gas(), gas)
results = append(results, r) results = append(results, r)
continue continue
} }
if chainConfig.IsPrague(new(big.Int), 0) { // For Prague txs, validate the floor data gas.
if floorDataGas, err := core.FloorDataGas(tx.Data()); err != nil { if rules.IsPrague {
floorDataGas, err := core.FloorDataGas(tx.Data())
if err != nil {
r.Error = err r.Error = err
results = append(results, r) results = append(results, r)
continue continue
} else { }
if tx.Gas() < floorDataGas { if tx.Gas() < floorDataGas {
r.Error = fmt.Errorf("%w: have %d, want %d", core.ErrFloorDataGas, tx.Gas(), floorDataGas) r.Error = fmt.Errorf("%w: have %d, want %d", core.ErrFloorDataGas, tx.Gas(), floorDataGas)
results = append(results, r) results = append(results, r)
continue continue
} }
} }
}
}
// Validate <256bit fields // Validate <256bit fields
switch { switch {
case tx.Nonce()+1 < tx.Nonce(): case tx.Nonce()+1 < tx.Nonce():