AvianNetwork / Avian

Avian Network is a proof-of-work secured blockchain designed for efficient and interoperable asset management.
https://avn.network
MIT License
54 stars 25 forks source link

validation: Do not check PoW when downloading headers during IBD #157

Closed alamshafil closed 2 years ago

alamshafil commented 2 years ago

This PR skips check header (PoW), only when downloading headers.

This reduces a bottleneck when downloading block headers during the initial block download. Tested on mainnet with IBD speed increase of ~22%

What is being skipped?

Skipped CheckProofOfWork() in pow.cpp when accepting headers (during IDB).

Is this safe?

CheckProofOfWork() is already checked in several places.

CheckProofOfWork() is called by CheckBlock() which is called multiple times.

In CheckBlock()

    // Check that the header is valid (particularly PoW).  This is mostly
    // redundant with the call in AcceptBlockHeader.
    if (!CheckBlockHeader(block, state, consensusParams, fCheckPOW))
        return false;
alamshafil commented 2 years ago

Merging now, tested full resync from scratch.