Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Verify transaction against its block during import (#10954)
Browse files Browse the repository at this point in the history
* Verify transaction against its block during import

* Client method for transaction verification added

* Verification methods united

* Verification sequence for transaction verifier returned
  • Loading branch information
grbIzl authored and s3krit committed Sep 5, 2019
1 parent a8920c8 commit baf3e54
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ethcore/src/miner/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ impl Miner {
let sender = transaction.sender();

// Re-verify transaction again vs current state.
let result = client.verify_signed(&transaction)
let result = client.verify_for_pending_block(&transaction, &open_block.header)
.map_err(|e| e.into())
.and_then(|_| {
open_block.push_transaction(transaction, None)
Expand Down
11 changes: 6 additions & 5 deletions ethcore/src/miner/pool_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,13 @@ impl<'a, C: 'a> PoolClient<'a, C> where
}
}

/// Verifies if signed transaction is executable.
/// Verifies transaction against its block (before its import into this block)
/// Also Verifies if signed transaction is executable.
///
/// This should perform any verifications that rely on chain status.
pub fn verify_signed(&self, tx: &SignedTransaction) -> Result<(), transaction::Error> {
self.engine.machine().verify_transaction(&tx, &self.best_block_header, self.chain)
pub fn verify_for_pending_block(&self, tx: &SignedTransaction, header: &Header) -> Result<(), transaction::Error> {
self.engine.machine().verify_transaction_basic(tx, header)?;
self.engine.machine().verify_transaction(tx, &self.best_block_header, self.chain)
}
}

Expand All @@ -138,8 +140,7 @@ impl<'a, C: 'a> pool::client::Client for PoolClient<'a, C> where
self.engine.verify_transaction_basic(&tx, &self.best_block_header)?;
let tx = self.engine.verify_transaction_unordered(tx, &self.best_block_header)?;

self.verify_signed(&tx)?;

self.engine.machine().verify_transaction(&tx, &self.best_block_header, self.chain)?;
Ok(tx)
}

Expand Down

0 comments on commit baf3e54

Please sign in to comment.