Page MenuHomePhabricator

chain: add and set ASSUMED_VALID_FLAG for assumeutxo
ClosedPublic

Authored by PiRK on Oct 17 2022, 15:06.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC84b17a35a312: chain: add and set ASSUMED_VALID_FLAG for assumeutxo
Summary

chain: add and set ASSUMED_VALID_FLAG for assumeutxo

Instead of (ab)using the existing BlockValidity flags to mark CBlockIndex entries which
we haven't yet fully validated (but assume validity for use with UTXO snapshot
loading), introduce a status flag that specifically marks an assumed-valid state.

This state is then removed in RaiseValidity() when the block has actually been
validated.

This distinction will allow us to make the necessary changes to various parts of the
system to facilitate assumeutxo/background chainstate validation but without leaking
details like snapshot height, as we had done previously.

validation: set ASSUMED_VALID_FLAG during snapshot load

Mark the block index entries that are beneath the snapshot base block as
assumed-valid. Subsequent commits will make use of this flag in other
parts of the system.

This is a backport of core#21526 [5 & 6/12]
https://github.com/bitcoin/bitcoin/pull/21526/commits/42b2520db93fd9feb3df4101654391fa7d3e2140
https://github.com/bitcoin/bitcoin/pull/21526/commits/01a9b8fe719efab2c268dc738bc93cfbdf92edb7

Depends on D12278

Test Plan

ninja all check-all bitcoin-fuzzers

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

PiRK requested review of this revision.Oct 17 2022, 15:06
PiRK retitled this revision from chain: add ASSUMED_VALID_FLAG for use with assumeutxo to chain: add and set ASSUMED_VALID_FLAG for assumeutxo.
PiRK edited the summary of this revision. (Show Details)

squash with next commit to use the flag immediately

Fabien requested changes to this revision.Oct 18 2022, 09:37
Fabien added a subscriber: Fabien.

This is missing tests and fuzzing

src/blockindex.h
226 ↗(On Diff #35760)

And there is no test

src/blockstatus.h
46 ↗(On Diff #35760)

Missing the end of the comment

This revision now requires changes to proceed.Oct 18 2022, 09:37

add missing comment line, add a unit test for CBlockIndex::IsAssumedValid and CBlockIndex::RaiseValidity

remove unnecessary loop level

Fabien requested changes to this revision.Oct 18 2022, 14:05

Please complete the chain.cpp fuzzer as well

This revision now requires changes to proceed.Oct 18 2022, 14:05
PiRK edited the test plan for this revision. (Show Details)

add fuzzing and run ninja bitcoin-fuzzers

This revision is now accepted and ready to land.Oct 18 2022, 15:08