remove verify_transaction_unordered from engine (#10891)

This commit is contained in:
Marek Kotewicz 2019-07-21 21:15:08 +02:00 committed by GitHub
parent acb1243214
commit d1b28bf57e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 9 additions and 21 deletions

View File

@ -55,7 +55,7 @@ use types::{
machine::{AuxiliaryData, AuxiliaryRequest},
},
errors::{EthcoreError as Error, EngineError},
transaction::{self, UnverifiedTransaction, SignedTransaction},
transaction::{self, UnverifiedTransaction},
};
use snapshot::SnapshotComponents;
use client::EngineClient;
@ -400,18 +400,6 @@ pub trait Engine: Sync + Send {
self.machine().signing_chain_id(env_info)
}
/// Verify a particular transaction is valid.
///
/// Unordered verification doesn't rely on the transaction execution order,
/// i.e. it should only verify stuff that doesn't assume any previous transactions
/// has already been verified and executed.
///
/// NOTE This function consumes an `UnverifiedTransaction` and produces `SignedTransaction`
/// which implies that a heavy check of the signature is performed here.
fn verify_transaction_unordered(&self, t: UnverifiedTransaction, header: &Header) -> Result<SignedTransaction, transaction::Error> {
self.machine().verify_transaction_unordered(t, header)
}
/// Perform basic/cheap transaction verification.
///
/// This should include all cheap checks that can be done before

View File

@ -76,7 +76,7 @@ fn do_json_test<H: FnMut(&str, HookType)>(json_data: &[u8], start_stop_hook: &mu
}.into());
}
spec.engine.verify_transaction_basic(&t, &header)?;
Ok(spec.engine.verify_transaction_unordered(t, &header)?)
Ok(t.verify_unordered()?)
});
match (res, result.hash, result.sender) {

View File

@ -324,11 +324,6 @@ impl Machine {
}
}
/// Verify a particular transaction is valid, regardless of order.
pub fn verify_transaction_unordered(&self, t: UnverifiedTransaction, _header: &Header) -> Result<SignedTransaction, transaction::Error> {
Ok(SignedTransaction::new(t)?)
}
/// Does basic verification of the transaction.
pub fn verify_transaction_basic(&self, t: &UnverifiedTransaction, header: &Header) -> Result<(), transaction::Error> {
let check_low_s = match self.ethash_extensions {

View File

@ -137,7 +137,7 @@ impl<'a, C: 'a> pool::client::Client for PoolClient<'a, C> where
fn verify_transaction(&self, tx: UnverifiedTransaction)-> Result<SignedTransaction, transaction::Error> {
self.engine.verify_transaction_basic(&tx, &self.best_block_header)?;
let tx = self.engine.verify_transaction_unordered(tx, &self.best_block_header)?;
let tx = tx.verify_unordered()?;
self.verify_signed(&tx)?;

View File

@ -88,7 +88,7 @@ pub fn verify_block_unordered(block: Unverified, engine: &dyn Engine, check_seal
let transactions = block.transactions
.into_iter()
.map(|t| {
let t = engine.verify_transaction_unordered(t, &header)?;
let t = t.verify_unordered()?;
if let Some(max_nonce) = nonce_cap {
if t.nonce >= max_nonce {
return Err(BlockError::TooManyTransactions(t.sender()).into());

View File

@ -401,6 +401,11 @@ impl UnverifiedTransaction {
};
Ok(())
}
/// Try to verify transaction and recover sender.
pub fn verify_unordered(self) -> Result<SignedTransaction, ethkey::Error> {
SignedTransaction::new(self)
}
}
/// A `UnverifiedTransaction` with successfully recovered `sender`.