check gas, nonce form ApplyRip7560ValidationPhases (#16)

move validations into the validation phase.
note that it breaks some tests which rely on wrong nonce.
This commit is contained in:
Dror Tirosh 2024-07-23 14:51:10 +03:00 committed by GitHub
parent 9bb4fb0328
commit 4dc333d54f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -95,19 +95,9 @@ func handleRip7560Transactions(transactions []*types.Transaction, index int, sta
break break
} }
aatx := tx.Rip7560TransactionData()
statedb.SetTxContext(tx.Hash(), index+i) statedb.SetTxContext(tx.Hash(), index+i)
err := CheckNonceRip7560(aatx, statedb)
if err != nil {
return nil, nil, nil, err
}
err = BuyGasRip7560Transaction(aatx, statedb)
if err != nil {
return nil, nil, nil, err
}
var vpr *ValidationPhaseResult vpr, err := ApplyRip7560ValidationPhases(chainConfig, bc, coinbase, gp, statedb, header, tx, cfg)
vpr, err = ApplyRip7560ValidationPhases(chainConfig, bc, coinbase, gp, statedb, header, tx, cfg)
if err != nil { if err != nil {
return nil, nil, nil, err return nil, nil, nil, err
} }
@ -175,6 +165,16 @@ func CheckNonceRip7560(tx *types.Rip7560AccountAbstractionTx, st *state.StateDB)
} }
func ApplyRip7560ValidationPhases(chainConfig *params.ChainConfig, bc ChainContext, author *common.Address, gp *GasPool, statedb *state.StateDB, header *types.Header, tx *types.Transaction, cfg vm.Config) (*ValidationPhaseResult, error) { func ApplyRip7560ValidationPhases(chainConfig *params.ChainConfig, bc ChainContext, author *common.Address, gp *GasPool, statedb *state.StateDB, header *types.Header, tx *types.Transaction, cfg vm.Config) (*ValidationPhaseResult, error) {
aatx := tx.Rip7560TransactionData()
err := CheckNonceRip7560(aatx, statedb)
if err != nil {
return nil, err
}
err = BuyGasRip7560Transaction(aatx, statedb)
if err != nil {
return nil, err
}
blockContext := NewEVMBlockContext(header, bc, author) blockContext := NewEVMBlockContext(header, bc, author)
sender := tx.Rip7560TransactionData().Sender sender := tx.Rip7560TransactionData().Sender
txContext := vm.TxContext{ txContext := vm.TxContext{