Except for checking for double spends, if there's a transaction in a block that's already in the node's mempool, it can theoretically skip its validation. Does it actually happen, or the nodes validate each transaction twice?
The most expensive part of checking a transaction, ECDSA validation, is cached.
Zero confirmed transaction are unsafe. Simillarly, it is not safe to validate using them as benchmark. See this example:
- You have a transaction T1 that spends txouts of transaction T in mempool
- Another transaction T2 in mempool spends outputs of T1
- In Block B
- We have tranaction T1' that is double spend of T1 with different output. This is possible since miner can directly include T1' in the block and it is valid.
- We also have T2 in B but it is invalid. Now validating T2 based on mempool would be wrong. We have to consider all previous outputs and outputs in the current block.
Also note that bitcoind has to validate blocks which on different forks/chains. Mempool only has unconfirmed transaction on the longest chain