ConnectBlock: don't serialize block hash twice
Summary:
In the validation:block_connected tracepoint, we call block->GetHash(), which ends up calling CBlockHeader::GetHash(), executing around 8000 serialization instructions. We don't need to do this extra work, because block->GetHash() is already called further up in the function. Let's save that value as a local variable and re-use it in our tracepoint so there is no unnecessary tracepoint overhead. Shave off an extra 100 or so instructions from the validation:block_connected tracepoint by reusing a nearby GetTimeMicros(). This brings the tracepoint down to 54 instructions. Still high, but much better than the previous ~154 and 8000 instructions which it was originally.
Backport of core#23819.
Depends on D12674.
Test Plan:
sudo bpftrace ../contrib/tracing/connectblock_benchmark.bt 0 0 25
Reviewers: #bitcoin_abc, PiRK, sdulfari
Reviewed By: #bitcoin_abc, PiRK, sdulfari
Differential Revision: https://reviews.bitcoinabc.org/D12705