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

Verify transaction against its block during import #10954

Merged
merged 4 commits into from
Aug 15, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ethcore/src/miner/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,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
13 changes: 6 additions & 7 deletions ethcore/src/miner/pool_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,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 @@ -136,11 +138,8 @@ 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 = tx.verify_unordered()?;

self.verify_signed(&tx)?;

self.verify_for_pending_block(&tx, &self.best_block_header)?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, unfortunately we can't change the order here. basic needs to be performed before verify_unordered, otherwise we are risking a DoS attack vector.

Maybe just use engine.machine() methods here directly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok

Ok(tx)
}

Expand Down