Does every full node verify every transaction TWO separate times?



I am building my Bitcoin expertise, and want to verify my understanding on a specific point: at what point(s) do all full nodes verifies a new transaction?

Here is my understanding in a nutshell, please confirm or correct:

[1] Upon receiving each new transaction, every full node fully verifies it before adding the transaction to the its own mempool

[2] Upon receiving each new block, every full node fully verifies each transaction in the block before accepting the block

If the above understanding is correct, then every full node verifies each new transaction TWO TIMES: once when the shiny-new transaction is unconfirmed, and again a few minutes later when the transaction is included in a block.

I recognize the above is somewhat of an abstraction ... is it an ACCURATE abstraction?

Thanks in advance.


Posted 2016-01-23T16:14:10.273

Reputation: 351



It is an accurate abstraction.

However, the most computationally expensive part of transaction verification is ECDSA signature verification. And the results of verification are cached and reused when they're done a second time. We don't cache the rest of transaction verification as it is subject to many parameters (new softfork rules can have been activated, height, locktime, ...), and it's relatively cheap anyway. We do however cache transaction verification failures.

Pieter Wuille

Posted 2016-01-23T16:14:10.273

Reputation: 64 874

Thanks much for the quick reply. You mention that "the results of verification are cached and reused when they're done a second time". Two clarifying questions:[1] that second time is when the full node receives a new block and is running through all of the transactions in that block? [2] every full node maintains its own "verification cache"? – Pressed250 – 2016-01-23T17:56:50.727

[1] Yes. [2] Yes. – Pieter Wuille – 2016-01-23T18:46:24.530