Page MenuHomePhabricator

[validation] make CheckSequenceLocks context-free
ClosedPublic

Authored by PiRK on Sep 30 2022, 08:31.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABCb7c4f4f739cf: [validation] make CheckSequenceLocks context-free
Summary

Allow CheckSequenceLocks to use heights and coins from any CoinsView and
CBlockIndex provided. This means that CheckSequenceLocks() doesn't need
to hold the mempool lock or cs_main. The caller is responsible for
ensuring the CoinsView and CBlockIndex are consistent before passing
them in. The typical usage is still to create a CCoinsViewMemPool from
the mempool and grab the CBlockIndex from the chainstate tip.

This is a backport of core#20833 [1/13]
https://github.com/bitcoin/bitcoin/pull/20833/commits/42cf8b25df07c45562b7210e0e15c3fd5edb2c11

Test Plan

With clang + debug + TSAN

ninja && ninja check check-functional

Diff Detail

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

Event Timeline

PiRK requested review of this revision.Sep 30 2022, 08:31
Fabien requested changes to this revision.Sep 30 2022, 08:43
Fabien added a subscriber: Fabien.
Fabien added inline comments.
src/validation.h
441 ↗(On Diff #35315)

tip should be const ?

This revision now requires changes to proceed.Sep 30 2022, 08:43
PiRK requested review of this revision.Sep 30 2022, 09:47
PiRK added inline comments.
src/validation.h
441 ↗(On Diff #35315)

That causes errors further down, because other non-const pointers will use the tip (even though it is never modified in the current codebase)

src/validation.cpp:183:19: error: assigning to 'CBlockIndex *' from 'const CBlockIndex *' discards qualifiers
     index.pprev = tip;
This revision is now accepted and ready to land.Sep 30 2022, 11:12