Skip to content

Commit 0df7e0b

Browse files
Refactor Optimism Transaction Validator: Extract OP-Specific Checks & Enable Batch Processing (paradigmxyz#14929)
Co-authored-by: Matthias Seitz <[email protected]>
1 parent f96f426 commit 0df7e0b

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

crates/optimism/txpool/src/validator.rs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,30 @@ where
147147

148148
let outcome = self.inner.validate_one(origin, transaction);
149149

150+
self.apply_op_checks(outcome)
151+
}
152+
153+
/// Validates all given transactions.
154+
///
155+
/// Returns all outcomes for the given transactions in the same order.
156+
///
157+
/// See also [`Self::validate_one`]
158+
pub fn validate_all(
159+
&self,
160+
transactions: Vec<(TransactionOrigin, Tx)>,
161+
) -> Vec<TransactionValidationOutcome<Tx>> {
162+
transactions.into_iter().map(|(origin, tx)| self.validate_one(origin, tx)).collect()
163+
}
164+
165+
/// Performs the necessary opstack specific checks based on top of the regular eth outcome.
166+
fn apply_op_checks(
167+
&self,
168+
outcome: TransactionValidationOutcome<Tx>,
169+
) -> TransactionValidationOutcome<Tx> {
150170
if !self.requires_l1_data_gas_fee() {
151171
// no need to check L1 gas fee
152172
return outcome
153173
}
154-
155174
// ensure that the account has enough balance to cover the L1 gas cost
156175
if let TransactionValidationOutcome::Valid {
157176
balance,
@@ -198,21 +217,8 @@ where
198217
propagate,
199218
}
200219
}
201-
202220
outcome
203221
}
204-
205-
/// Validates all given transactions.
206-
///
207-
/// Returns all outcomes for the given transactions in the same order.
208-
///
209-
/// See also [`Self::validate_one`]
210-
pub fn validate_all(
211-
&self,
212-
transactions: Vec<(TransactionOrigin, Tx)>,
213-
) -> Vec<TransactionValidationOutcome<Tx>> {
214-
transactions.into_iter().map(|(origin, tx)| self.validate_one(origin, tx)).collect()
215-
}
216222
}
217223

218224
impl<Client, Tx> TransactionValidator for OpTransactionValidator<Client, Tx>

0 commit comments

Comments
 (0)