remove verify_transaction_unordered from engine (#10891)
This commit is contained in:
parent
acb1243214
commit
d1b28bf57e
@ -55,7 +55,7 @@ use types::{
|
|||||||
machine::{AuxiliaryData, AuxiliaryRequest},
|
machine::{AuxiliaryData, AuxiliaryRequest},
|
||||||
},
|
},
|
||||||
errors::{EthcoreError as Error, EngineError},
|
errors::{EthcoreError as Error, EngineError},
|
||||||
transaction::{self, UnverifiedTransaction, SignedTransaction},
|
transaction::{self, UnverifiedTransaction},
|
||||||
};
|
};
|
||||||
use snapshot::SnapshotComponents;
|
use snapshot::SnapshotComponents;
|
||||||
use client::EngineClient;
|
use client::EngineClient;
|
||||||
@ -400,18 +400,6 @@ pub trait Engine: Sync + Send {
|
|||||||
self.machine().signing_chain_id(env_info)
|
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.
|
/// Perform basic/cheap transaction verification.
|
||||||
///
|
///
|
||||||
/// This should include all cheap checks that can be done before
|
/// This should include all cheap checks that can be done before
|
||||||
|
@ -76,7 +76,7 @@ fn do_json_test<H: FnMut(&str, HookType)>(json_data: &[u8], start_stop_hook: &mu
|
|||||||
}.into());
|
}.into());
|
||||||
}
|
}
|
||||||
spec.engine.verify_transaction_basic(&t, &header)?;
|
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) {
|
match (res, result.hash, result.sender) {
|
||||||
|
@ -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.
|
/// Does basic verification of the transaction.
|
||||||
pub fn verify_transaction_basic(&self, t: &UnverifiedTransaction, header: &Header) -> Result<(), transaction::Error> {
|
pub fn verify_transaction_basic(&self, t: &UnverifiedTransaction, header: &Header) -> Result<(), transaction::Error> {
|
||||||
let check_low_s = match self.ethash_extensions {
|
let check_low_s = match self.ethash_extensions {
|
||||||
|
@ -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> {
|
fn verify_transaction(&self, tx: UnverifiedTransaction)-> Result<SignedTransaction, transaction::Error> {
|
||||||
self.engine.verify_transaction_basic(&tx, &self.best_block_header)?;
|
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)?;
|
self.verify_signed(&tx)?;
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ pub fn verify_block_unordered(block: Unverified, engine: &dyn Engine, check_seal
|
|||||||
let transactions = block.transactions
|
let transactions = block.transactions
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|t| {
|
.map(|t| {
|
||||||
let t = engine.verify_transaction_unordered(t, &header)?;
|
let t = t.verify_unordered()?;
|
||||||
if let Some(max_nonce) = nonce_cap {
|
if let Some(max_nonce) = nonce_cap {
|
||||||
if t.nonce >= max_nonce {
|
if t.nonce >= max_nonce {
|
||||||
return Err(BlockError::TooManyTransactions(t.sender()).into());
|
return Err(BlockError::TooManyTransactions(t.sender()).into());
|
||||||
|
@ -401,6 +401,11 @@ impl UnverifiedTransaction {
|
|||||||
};
|
};
|
||||||
Ok(())
|
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`.
|
/// A `UnverifiedTransaction` with successfully recovered `sender`.
|
||||||
|
Loading…
Reference in New Issue
Block a user