Skip to content

Commit

Permalink
Add stateDB usage for celo validation
Browse files Browse the repository at this point in the history
  • Loading branch information
hbandura committed Nov 14, 2023
1 parent 721c4a3 commit 4696960
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion core/txpool/blobpool/blobpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ func (p *BlobPool) validateTx(tx *types.Transaction) error {
MinTip: p.gasTip.ToBig(),
}
var fcv txpool.FeeCurrencyValidator = nil // TODO: create with proper value
if err := txpool.CeloValidateTransaction(tx, p.head, p.signer, baseOpts, fcv); err != nil {
if err := txpool.CeloValidateTransaction(tx, p.head, p.signer, baseOpts, p.state, fcv); err != nil {
return err
}
// Ensure the transaction adheres to the stateful pool filters (nonce, balance)
Expand Down
8 changes: 4 additions & 4 deletions core/txpool/celo_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ func (cvo *CeloValidationOptions) Accepts(txType uint8) bool {
// This check is public to allow different transaction pools to check the basic
// rules without duplicating code and running the risk of missed updates.
func CeloValidateTransaction(tx *types.Transaction, head *types.Header,
signer types.Signer, opts *CeloValidationOptions, fcv FeeCurrencyValidator) error {
signer types.Signer, opts *CeloValidationOptions, st *state.StateDB, fcv FeeCurrencyValidator) error {

if err := ValidateTransaction(tx, head, signer, opts); err != nil {
return err
}
if FeeCurrencyTx(tx) {
// if !fcv.IsWhitelisted(tx.FeeCurrency(), head.Number) { // TODO: change to celoContext
// return NonWhitelistedFeeCurrencyError
// }
if !fcv.IsWhitelisted(st, tx.FeeCurrency()) {
return NonWhitelistedFeeCurrencyError
}
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion core/txpool/legacypool/legacypool.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ func (pool *LegacyPool) validateTxBasics(tx *types.Transaction, local bool) erro
if local {
opts.MinTip = new(big.Int)
}
if err := txpool.CeloValidateTransaction(tx, pool.currentHead.Load(), pool.signer, opts, pool.feeCurrencyValidator); err != nil {
if err := txpool.CeloValidateTransaction(tx, pool.currentHead.Load(), pool.signer, opts, pool.currentState, pool.feeCurrencyValidator); err != nil {
return err
}
return nil
Expand Down

0 comments on commit 4696960

Please sign in to comment.