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

feat: Improve OP txpool batch validation #13918

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yohkaz
Copy link

@yohkaz yohkaz commented Jan 22, 2025

Closes #13902

(someone is already assigned, did it for the exercise :)

@emhane emhane added A-op-reth Related to Optimism and op-reth C-perf A change motivated by improving speed, memory usage or disk footprint A-tx-pool Related to the transaction mempool labels Jan 22, 2025

outcomes
.into_iter()
.map(|outcome| self.validate_gas_fee(self.validate_transaction_type(outcome)))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: i validate the transaction type after performing the transaction validation (validate_all), which is in a different order than done previously. if you think this is problematic, lmk.

Comment on lines +433 to +438
if transaction.is_eip4844() {
return TransactionValidationOutcome::Invalid(
transaction,
InvalidTransactionError::TxTypeNotSupported.into(),
);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can call the new method validate_transaction_type right?

}

return TransactionValidationOutcome::Valid {
balance,
state_nonce,
transaction: valid_tx,
propagate,
}
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls revert all these semicolons, and take care to use cargo +nightly fmt instead of cargo fmt in the future

Comment on lines +328 to +338
fn validate_batch(
&self,
origin: TransactionOrigin,
transaction: Tx,
transactions: Vec<(TransactionOrigin, Tx)>,
) -> Vec<TransactionValidationOutcome<Tx>> {
let outcomes = self.inner.validate_all(transactions);

outcomes
.into_iter()
.map(|outcome| self.validate_gas_fee(self.validate_transaction_type(outcome)))
.collect()
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it makes sense to do the tx type validation first! it is much cheaper in the case of an eip4844 transaction, as then it will bail on first check as opposed to if you do batch validation on inner EthTransactionValidator first, which would allow the eip4844 tx to pass through and then carry out all the other checks on it for no reason

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-op-reth Related to Optimism and op-reth A-tx-pool Related to the transaction mempool C-perf A change motivated by improving speed, memory usage or disk footprint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve OP txpool batch validation
2 participants