Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f292058
fix(evo): stall instead of invalidating blocks on missing local Evo s…
PastaPastaPasta Oct 15, 2026
ae671dd
refactor(evo): add EvoDB view tokens and scopes
PastaPastaPasta Oct 15, 2026
a9a8ae5
feat(dbwrapper): report LevelDB iterator read errors
PastaPastaPasta Nov 13, 2026
5592b80
feat(evo): store snapshot-identity state in a generation namespace wi…
PastaPastaPasta Oct 15, 2026
d6be29b
fix(evo): partition Evo-derived caches by view
PastaPastaPasta Nov 20, 2026
87cb7c9
fix(evo): bind non-active paths and dispatcher boundaries explicitly
PastaPastaPasta Oct 15, 2026
d96835e
feat(evo): reject unbound Evo reads during dual operation
PastaPastaPasta Oct 15, 2026
6f5fc5b
fix(instantsend): keep a local quorum-selection error to its own islock
PastaPastaPasta Oct 31, 2026
3ae9024
fix(llmq): treat short scans of types not enabled up to the snapshot …
PastaPastaPasta Oct 31, 2026
ae0f6b4
fix(interfaces): raise the Evo-unavailable warning once per operation…
PastaPastaPasta Oct 31, 2026
437c9af
fix(node): keep an earlier invalid snapshot dir when finishing a reje…
PastaPastaPasta Oct 31, 2026
c88c696
fix(validation): stop reading a rejected snapshot when its rejection …
PastaPastaPasta Oct 31, 2026
4461144
feat(evo): v4 snapshot with derived rotation dependencies and bootstr…
PastaPastaPasta Oct 15, 2026
79ddcb0
feat(evo): carry and consume the credit-pool window
PastaPastaPasta Oct 15, 2026
3ba11ce
feat(evo): carry the header-proven base coinbase and use it for B+1 C…
PastaPastaPasta Oct 15, 2026
4f00e49
fix(evo): export the raw MNHF signal record at the base and derive th…
PastaPastaPasta Oct 16, 2026
d93223a
fix(llmq): exact work modifiers and no silent degradation under the s…
PastaPastaPasta Oct 15, 2026
4cd2fd6
feat(llmq): prove ChainLock and asset-unlock scan coverage
PastaPastaPasta Nov 20, 2026
8a41aed
feat(rpc): emit the v4 evo section in dumptxoutset
PastaPastaPasta Oct 15, 2026
e28bda8
feat(validation): require a matching evo pin; add regtest -assumeutxo…
PastaPastaPasta Oct 15, 2026
7e8de93
test: suppress a TSan lock-order false positive from a reused stack a…
PastaPastaPasta Nov 19, 2026
130669e
feat(validation): seed into an unpublished generation, dry-run, then …
PastaPastaPasta Oct 15, 2026
19b9cdb
feat(validation): rebuild and compare the full evo section at completion
PastaPastaPasta Nov 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions doc/release-notes-7593.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Updated RPCs
------------

- On a pruned node, `quorum info`, `quorum memberof` and `quorum selectquorum`
fail with `RPC_INTERNAL_ERROR` for a quorum whose members this node cannot
compute because the block that fixes them was pruned. They used to work with
members computed from a substitute value, which could be wrong. (#7593)

Other changes
-------------

- A pruned node no longer substitutes the block hash for the quorum score
modifier of a pruned work block. It keeps such a quorum's public key, from
its mined commitment, without members, so it still verifies signatures
by that quorum (for example on masternode hard-fork signals) and never
stalls on them. (#7593)
39 changes: 39 additions & 0 deletions doc/release-notes-7887.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Updated RPCs
------------

- An RPC that fails with an error because this node cannot read the
masternode, quorum or other Evo state it needs, for example because the
block data it is derived from was pruned, now returns error code
`RPC_INTERNAL_ERROR` (-32603) instead of `RPC_MISC_ERROR` (-1). The request
was not at fault. The package RPCs report such a failure as described
below. (#7887)

- `testmempoolaccept` with more than one transaction reports such a failure as
the `package-error` `evo-local-unavailable`, and `submitpackage` fails with
that reason. (#7887)

Other changes
-------------

- A block this node has stored but cannot read back while deriving the credit
pool or the EHF signals no longer makes the block being validated invalid.
The node shuts down with a "Failed to read block" error instead, as it does
when it cannot read a block it is connecting. (#7887)

- On a node without an assumeutxo snapshot, a warning about Evo state that
cannot be derived because block data was pruned now says so and suggests
restarting with `-reindex`. Startup still fails when the EHF signals at the
tip cannot be rebuilt. (#7887)

- On a pruned node, a block whose masternode, quorum or other Evo state
depends on block data that was pruned is no longer marked invalid, which
left the node on a local fork until `reconsiderblock`. The node now stops
advancing at that block, logs an error and shows a warning that block data
was pruned; restart with `-reindex` to download it again. (#7887)

- Developers: on regtest, every Evo database access must now be bound to a
chainstate's view (the hidden `-checkevobinding` option, on by default
there). A code path that reads Evo state without a binding fails with an
internal error, a dropped task or a stalled chainstate instead of reading
the default view. Local regtest networks run with it unless started with
`-checkevobinding=0`. (#7887)
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ add_library(bitcoin_node STATIC EXCLUDE_FROM_ALL
evo/simplifiedmns.cpp
evo/smldiff.cpp
evo/snapshot.cpp
evo/snapshot_chain.cpp
evo/snapshot_config.cpp
evo/specialtx.cpp
evo/specialtx_filter.cpp
evo/specialtxman.cpp
Expand Down
37 changes: 22 additions & 15 deletions src/chainlock/handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ ChainlockHandler::ChainlockHandler(chainlock::Chainlocks& chainlocks, Chainstate
std::make_unique<std::thread>(std::thread(util::TraceThread, "cl-schdlr", [&] { scheduler->serviceQueue(); }))},
seenChainLocks{SEEN_CHAINLOCKS_CUTOFF_SIZE, SEEN_CHAINLOCKS_MAX_SIZE}
{
// Tasks are scheduled only from Start(), after this is set.
scheduler->SetTaskWrapper(
[this](const CScheduler::Function& task) { RunActiveEvoRound(m_chainman.EvoDb(), "cl-schdlr", task); });
}

ChainlockHandler::~ChainlockHandler()
Expand Down Expand Up @@ -174,12 +177,11 @@ MessageProcessingResult ChainlockHandler::ProcessNewChainLock(const NodeId from,
if (!m_chainlocks.UpdateBestChainlock(hash, clsig, pindex)) return {};

if (pindex) {
scheduler->scheduleFromNow(
[&]() {
CheckActiveState();
EnforceBestChainLock();
},
std::chrono::seconds{0});
scheduler->scheduleFromNow(WithCapturedEvoView([&]() {
CheckActiveState();
EnforceBestChainLock();
}),
std::chrono::seconds{0});

LogPrint(BCLog::CHAINLOCKS, "ChainlockHandler::%s -- processed new CLSIG (%s), peer=%d\n", __func__,
clsig.ToString(), from);
Expand All @@ -201,14 +203,19 @@ void ChainlockHandler::UpdatedBlockTip(const CBlockIndex* pindexNew, const CBloc
// atomic[If tryLockChainTipScheduled is false, do (set it to true] and schedule signing).

if (bool expected = false; tryLockChainTipScheduled.compare_exchange_strong(expected, true)) {
scheduler->scheduleFromNow(
[&]() {
CheckActiveState();
EnforceBestChainLock();
Cleanup();
tryLockChainTipScheduled = false;
},
std::chrono::seconds{0});
const auto unschedule{[this] { tryLockChainTipScheduled = false; }};
scheduler->scheduleFromNow(WithCapturedEvoView(
[&, unschedule]() {
const struct Unschedule {
decltype(unschedule) f;
~Unschedule() { f(); }
} done{unschedule};
CheckActiveState();
EnforceBestChainLock();
Cleanup();
},
unschedule),
std::chrono::seconds{0});
}
}

Expand Down Expand Up @@ -300,7 +307,7 @@ void ChainlockHandler::EnforceBestChainLock()
LogPrint(BCLog::CHAINLOCKS, "ChainlockHandler::%s -- enforcing block %s via CLSIG (%s)\n", __func__,
currentBestChainLockBlockIndex->GetBlockHash().ToString(), clsig.ToString());
m_chainman.ActiveChainstate().EnforceBlock(dummy_state, currentBestChainLockBlockIndex);

if (dummy_state.IsError()) return;

if (/*activateNeeded =*/WITH_LOCK(::cs_main, return m_chainman.ActiveTip()->GetAncestor(
currentBestChainLockBlockIndex->nHeight)) !=
Expand Down
3 changes: 3 additions & 0 deletions src/chainlock/signing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ ChainLockSigner::ChainLockSigner(const ChainstateManager& chainman, const chainl
m_scheduler_thread{
std::make_unique<std::thread>(std::thread(util::TraceThread, "cls-schdlr", [&] { m_scheduler->serviceQueue(); }))}
{
// Tasks are scheduled only from Start(), after this is set.
m_scheduler->SetTaskWrapper(
[this](const CScheduler::Function& task) { RunActiveEvoRound(m_chainman.EvoDb(), "cls-schdlr", task); });
}

ChainLockSigner::~ChainLockSigner() { Stop(); }
Expand Down
27 changes: 27 additions & 0 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,31 @@ static void ReadRegTestLLMQInstantSendDIP0024Args(const ArgsManager& args, CChai
options.llmq_dip0024_instantsend = args.GetArg("-llmqtestinstantsenddip0024", "");
}

static void ReadRegTestAssumeutxoArgs(const ArgsManager& args, CChainParams::RegTestOptions& options)
{
for (const std::string& arg : args.GetArgs("-assumeutxodata")) {
const std::vector<std::string> fields{SplitString(arg, ':')};
const auto valid_hash = [](const std::string& value) {
return value.size() == uint256::size() * 2 && IsHex(value) && !uint256S(value).IsNull();
};
int32_t height;
uint32_t n_chain_tx;
if (fields.size() != 5 || !ParseInt32(fields[0], &height) || height <= 0 || !valid_hash(fields[1]) ||
!valid_hash(fields[2]) || !ParseUInt32(fields[3], &n_chain_tx) || n_chain_tx == 0 ||
!valid_hash(fields[4])) {
throw std::runtime_error(strprintf(
"Invalid value (%s) for -assumeutxodata=<height>:<hash_serialized>:<evo_hash>:<nchaintx>:<blockhash>",
arg));
}
options.assumeutxo_data.emplace_back(height, AssumeutxoData{
.hash_serialized = AssumeutxoHash{uint256S(fields[1])},
.evo_hash = EvoSnapshotHash{uint256S(fields[2])},
.nChainTx = n_chain_tx,
.blockhash = uint256S(fields[4]),
});
}
}

void ReadRegTestArgs(const ArgsManager& args, CChainParams::RegTestOptions& options)
{
if (auto value = args.GetBoolArg("-fastprune")) options.fastprune = *value;
Expand All @@ -210,6 +235,7 @@ void ReadRegTestArgs(const ArgsManager& args, CChainParams::RegTestOptions& opti
ReadRegTestLLMQTestArgs(args, options, Consensus::LLMQType::LLMQ_TEST_INSTANTSEND);
ReadRegTestLLMQTestArgs(args, options, Consensus::LLMQType::LLMQ_TEST_PLATFORM);
ReadRegTestLLMQInstantSendDIP0024Args(args, options);
ReadRegTestAssumeutxoArgs(args, options);
}

static void ReadDevNetSubsidyAndDiffArgs(const ArgsManager& args, CChainParams::DevNetOptions& options)
Expand Down Expand Up @@ -330,6 +356,7 @@ void SetupChainParamsOptions(ArgsManager& argsman)
{
SetupChainParamsBaseOptions(argsman);

argsman.AddArg("-assumeutxodata=<height>:<hash_serialized>:<evo_hash>:<nchaintx>:<blockhash>", "Add an exact AssumeUTXO snapshot authorization (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-budgetparams=<masternode>:<budget>:<superblock>", "Override masternode, budget and superblock start heights (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-dip3params=<activation>:<enforcement>", "Override DIP3 activation and enforcement heights (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-highsubsidyblocks=<n>", "The number of blocks with a higher than normal subsidy to mine at the start of a chain. Block after that height will have fixed subsidy base. (default: 0, devnet-only)", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
Expand Down
23 changes: 22 additions & 1 deletion src/consensus/validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,28 @@ class ValidationState
}
};

/** Why a block could not be processed against this node's own Evo state. This
* never describes the block itself, so it accompanies an error, not a
* BlockValidationResult. */
enum class LocalEvoStateResult {
NONE = 0, //!< not a local Evo state error
UNAVAILABLE, //!< state the block needs is not available to this chainstate
BINDING, //!< the operation was not bound to this chainstate's Evo view
MISMATCH, //!< state disagrees with the snapshot, which could not be rejected
};

class TxValidationState : public ValidationState<TxValidationResult> {};
class BlockValidationState : public ValidationState<BlockValidationResult> {};
class BlockValidationState : public ValidationState<BlockValidationResult>
{
LocalEvoStateResult m_local_evo_result{LocalEvoStateResult::NONE};

public:
bool LocalEvoStateError(LocalEvoStateResult result, const std::string& reject_reason)
{
if (IsValid()) m_local_evo_result = result;
return Error(reject_reason);
}
LocalEvoStateResult GetLocalEvoStateResult() const { return m_local_evo_result; }
};

#endif // BITCOIN_CONSENSUS_VALIDATION_H
1 change: 1 addition & 0 deletions src/dbwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ Span<const std::byte> CDBIterator::GetValueImpl() const

CDBIterator::~CDBIterator() = default;
bool CDBIterator::Valid() const { return m_impl_iter->iter->Valid(); }
bool CDBIterator::HasError() const { return !m_impl_iter->iter->status().ok(); }
void CDBIterator::SeekToFirst() { m_impl_iter->iter->SeekToFirst(); }
void CDBIterator::Next() { m_impl_iter->iter->Next(); }

Expand Down
2 changes: 2 additions & 0 deletions src/dbwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ class CDBIterator
~CDBIterator();

bool Valid() const;
//! True once a read failed, e.g. on a corrupt block. Entries may then have been skipped.
bool HasError() const;

void SeekToFirst();

Expand Down
59 changes: 49 additions & 10 deletions src/evo/cbtx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include <evo/cbtx.h>

#include <evo/evodb.h>
#include <evo/snapshot_types.h>
#include <evo/specialtx.h>
#include <llmq/blockprocessor.h>
#include <llmq/commitment.h>
Expand Down Expand Up @@ -193,6 +195,32 @@ std::string CCbTx::ToString() const
creditPoolBalance / COIN, creditPoolBalance % COIN, merkleRootAssetUnlocks.ToString());
}

std::optional<CCbTx> DecodeCbTxPayload(const CTransaction& tx)
{
if (!tx.IsCoinBase() || tx.nType != TRANSACTION_COINBASE) return std::nullopt;
CDataStream ds(tx.vExtraPayload, SER_NETWORK, PROTOCOL_VERSION);
CCbTx cbtx;
try {
ds >> cbtx.nVersion >> cbtx.nHeight >> cbtx.merkleRootMNList;
if (cbtx.nVersion >= CCbTx::Version::MERKLE_ROOT_QUORUMS) {
ds >> cbtx.merkleRootQuorums;
if (cbtx.nVersion >= CCbTx::Version::CLSIG_AND_BALANCE) {
ds >> COMPACTSIZE(cbtx.bestCLHeightDiff);
// Decoded eagerly: bytes valid in neither scheme reject the payload.
CBLSSignature signature;
ds >> signature;
cbtx.bestCLSignature.Set(signature);
ds >> cbtx.creditPoolBalance;
if (cbtx.nVersion >= CCbTx::Version::MERKLE_ROOT_ASSETUNLOCKS) ds >> cbtx.merkleRootAssetUnlocks;
}
}
} catch (const std::exception&) {
return std::nullopt;
}
if (!ds.empty()) return std::nullopt;
return cbtx;
}

std::optional<std::pair<CBLSSignature, uint32_t>> GetNonNullCoinbaseChainlock(const node::BlockManager& blockman, const CBlockIndex* pindex)
{
if (pindex == nullptr) {
Expand All @@ -204,22 +232,33 @@ std::optional<std::pair<CBLSSignature, uint32_t>> GetNonNullCoinbaseChainlock(co
return std::nullopt;
}

CBlock block;
if (!blockman.ReadBlockFromDisk(block, *pindex)) {
const auto [have_data, block_pos]{WITH_LOCK(::cs_main, return std::make_pair(
(pindex->nStatus & BLOCK_HAVE_DATA) != 0, pindex->GetBlockPos()))};
if (!have_data) {
// A snapshot view lacks the bodies at or below its base, where a
// coinbase ChainLock that cannot be read cannot be told from none.
if (const auto view{EvoViewScope::InnermostAny()};
view && view->identity == EvoDbIdentity::SNAPSHOT && pindex->nHeight <= view->base_height) {
throw BlockDataUnavailableError(
strprintf("coinbase of block %s at or below the snapshot base is not available",
pindex->GetBlockHash().ToString()));
}
return std::nullopt;
}
CBlock block;
if (blockman.ReadBlockFromDisk(block, block_pos) != pindex->GetBlockHash()) {
throw BlockDataReadError(strprintf("coinbase of block %s cannot be read", pindex->GetBlockHash().ToString()));
}

return GetNonNullCoinbaseChainlock(block, pindex->nHeight);
return GetNonNullCoinbaseChainlock(block, *pindex);
}

std::optional<std::pair<CBLSSignature, uint32_t>> GetNonNullCoinbaseChainlock(const CBlock& block, int32_t height)
std::optional<std::pair<CBLSSignature, uint32_t>> GetNonNullCoinbaseChainlock(const CBlock& block, const CBlockIndex& index)
{
if (block.vtx.empty() || !block.vtx[0]->IsCoinBase() || block.vtx[0]->nType != TRANSACTION_COINBASE) {
return std::nullopt;
}
const auto payload = GetTxPayload<CCbTx>(*block.vtx[0]);
if (!payload || payload->nVersion < CCbTx::Version::CLSIG_AND_BALANCE || payload->nHeight != height ||
!payload->bestCLSignature.Get().IsValid() || payload->bestCLHeightDiff >= static_cast<uint32_t>(height)) {
if (block.vtx.empty()) return std::nullopt;
const auto payload{DecodeCbTxPayload(*block.vtx[0])};
if (!payload || payload->nVersion < CCbTx::Version::CLSIG_AND_BALANCE || payload->nHeight != index.nHeight ||
!payload->bestCLSignature.Get().IsValid() || payload->bestCLHeightDiff >= static_cast<uint32_t>(index.nHeight)) {
return std::nullopt;
}
return std::make_pair(payload->bestCLSignature.Get(), payload->bestCLHeightDiff);
Expand Down
11 changes: 10 additions & 1 deletion src/evo/cbtx.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,16 @@ bool CalcCbTxMerkleRootQuorums(const CBlock& block, const CBlockIndex* pindexPre
BlockValidationState& state);
uint256 CalcCbTxMerkleRootAssetUnlocks(const CBlock& block);

/** Decode a coinbase's CbTx payload strictly: the ChainLock signature
* eagerly, and nothing may follow the payload. */
std::optional<CCbTx> DecodeCbTxPayload(const CTransaction& tx);
/** The non-null ChainLock in the coinbase of `pindex`'s block. A block this
* node has but cannot read raises BlockDataReadError; one it lacks reads as
* none, except at or below the base in a snapshot view, where it raises
* BlockDataUnavailableError. */
std::optional<std::pair<CBLSSignature, uint32_t>> GetNonNullCoinbaseChainlock(const node::BlockManager& blockman, const CBlockIndex* pindex);
std::optional<std::pair<CBLSSignature, uint32_t>> GetNonNullCoinbaseChainlock(const CBlock& block, int32_t height);
/** The non-null ChainLock in `block`'s coinbase, decoded strictly, where
* `index` is the block's own index. */
std::optional<std::pair<CBLSSignature, uint32_t>> GetNonNullCoinbaseChainlock(const CBlock& block, const CBlockIndex& index);

#endif // BITCOIN_EVO_CBTX_H
Loading
Loading