Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Latest State TransactionValidator implementation #1289

Closed
mattsse opened this issue Feb 11, 2023 · 5 comments · Fixed by #1498
Closed

Add Latest State TransactionValidator implementation #1289

mattsse opened this issue Feb 11, 2023 · 5 comments · Fixed by #1498
Assignees
Labels
A-tx-pool Related to the transaction mempool C-enhancement New feature or request D-good-first-issue Nice and easy! A great choice to get started

Comments

@mattsse
Copy link
Collaborator

mattsse commented Feb 11, 2023

Describe the feature

the transaction pool requires a TransactionValidator

pub trait TransactionValidator: Send + Sync {

which is supposed to validate the transaction against protocol specs and the latest state.

It returns an outcome that includes the latest nonce and balance

Valid {
/// Balance of the sender at the current point.
balance: U256,
/// Current nonce of the sender.
state_nonce: u64,

TODO

  • Add an implementation of this that takes an AccountProvider and implements basic transaction checks

Additional context

No response

@mattsse mattsse added C-enhancement New feature or request D-good-first-issue Nice and easy! A great choice to get started A-tx-pool Related to the transaction mempool labels Feb 11, 2023
@chirag-bgh
Copy link
Contributor

I can take this.

@seroze
Copy link
Contributor

seroze commented Feb 12, 2023

@mattsse just to cross check my understanding.

which is supposed to validate the transaction against protocol specs and the latest state.

we have to fetch the latest state of the sender account and verify if the current_balance >= transaction_amount and if txn_nonce matches with last_txn_nonce+1. Are there any more checks that Iam missing ?

Add an implementation of this that takes an AccountProvider and implements basic transaction checks

How do we fetch the latest state of Account. I couldn't find any class with name AccountProvider ? Is the expectation to implement this class as well ?

@mattsse
Copy link
Collaborator Author

mattsse commented Feb 12, 2023

couldn't find any class with name AccountProvider

this is not fully implemented yet, but we abstract everything over the traits so all impls should be generic over the traits.

we have to fetch the latest state of the sender account and verify if the current_balance >= transaction_amount and if txn_nonce matches with last_txn_nonce+1.

not necessarily, we need to fetch current balance and nonce which is then used by the pool to update internals.
but we need to ensure nonce > last_txn_nonce because nonce < last_txn_nonce would be invalid.

@chirag-bgh
Copy link
Contributor

@mattsse for what type should be the trait TransactionValidator implemented?

@mattsse
Copy link
Collaborator Author

mattsse commented Feb 16, 2023

It should be something like

pub struct EthTransactionValidator<Client: AccountPorivider> {
   /// This type fetches account info from the db
   client: Client,
   /// whether shanghai is enabled.
   shanghai: bool,
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tx-pool Related to the transaction mempool C-enhancement New feature or request D-good-first-issue Nice and easy! A great choice to get started
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants