Skip to content

Commit 2589a50

Browse files
jamescowensclaude
andcommitted
consensus: remove ClaimValidator and shadow validation infrastructure (gridcoin-community#2880)
BlockRewardRules has been validated as the sole consensus rules implementation via full mainnet and testnet sync-from-genesis with zero mismatches. Remove the now-redundant ClaimValidator class (~750 lines), the shadow validation dispatch logic, and associated startup flags (-consensusrulesimpl, -consensusrulesshadow, -consensusshadowlog). GridcoinConnectBlock now calls BlockRewardRules::Check() directly. Update documentation references in block_rewards.h/cpp, tally.cpp, and design_notes.md to reflect the removal. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0ce3886 commit 2589a50

File tree

9 files changed

+17
-1111
lines changed

9 files changed

+17
-1111
lines changed

src/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ add_library(gridcoin_util STATIC
139139
gridcoin/crypto/rsaverify.cpp
140140
gridcoin/claim.cpp
141141
gridcoin/consensus/block_rewards.cpp
142-
gridcoin/consensus/shadow_validator.cpp
143142
gridcoin/contract/contract.cpp
144143
gridcoin/contract/message.cpp
145144
gridcoin/contract/registry.cpp

src/gridcoin/consensus/block_rewards.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,7 @@ bool BlockRewardRules::ValidateMandatorySidestakeOutputs(
214214
//
215215
// Why >= instead of ==:
216216
//
217-
// The >= preserves compatibility with the original ClaimValidator and
218-
// provides tolerance for the following edge case:
217+
// The >= provides tolerance for the following edge case:
219218
//
220219
// Remainder true-up: When mandatory allocations sum to exactly 100%
221220
// (theoretically possible if MaxMandatorySideStakeTotalAlloc is
@@ -305,7 +304,7 @@ bool BlockRewardRules::ValidateMandatorySidestakeOutputs(
305304
}
306305

307306
// =============================================================================
308-
// Full claim validation (replaces ClaimValidator::Check())
307+
// Full claim validation
309308
// =============================================================================
310309

311310
bool BlockRewardRules::Check(std::string& error_out) const

src/gridcoin/consensus/block_rewards.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ class BlockRewardRules
5252
int block_version,
5353
int64_t block_time);
5454

55-
//! Full validation mode — mirrors ClaimValidator constructor.
56-
//! Enables Check() for complete claim validation.
55+
//! Full validation mode. Enables Check() for complete claim validation.
5756
BlockRewardRules(
5857
const CBlock& block,
5958
const CBlockIndex* pindex,
@@ -62,15 +61,15 @@ class BlockRewardRules
6261
CAmount fees,
6362
uint64_t coin_age);
6463

65-
// --- Full claim validation (replaces ClaimValidator::Check()) ------------
64+
// --- Full claim validation ------------------------------------------------
6665

6766
//! Run the complete claim validation suite: research/non-research
6867
//! branching, reward envelope, MRC outputs, beacon signature, mandatory
6968
//! sidestakes, and all legacy version-specific checks.
7069
//!
7170
//! Returns true if the claim is valid. On failure, error_out contains a
72-
//! descriptive error message. Unlike ClaimValidator, this method does NOT
73-
//! call CBlock::DoS() — the caller decides on DoS scoring.
71+
//! descriptive error message. This method does NOT call CBlock::DoS() —
72+
//! the caller decides on DoS scoring.
7473
//!
7574
//! Requires the full validation constructor.
7675
//!

src/gridcoin/consensus/design_notes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ consume it.
3333

3434
### Validation-only logic stays validation-only
3535

36-
The `Check()` path (formerly `ClaimValidator`) is pure validation with no miner
36+
The `Check()` path (which replaced the former `ClaimValidator` class) is pure validation with no miner
3737
counterpart. MRC output matching, beacon signature checking, reward envelope
3838
checks, legacy fallbacks — none of these have a construction dual. Forcing them
3939
into a unified framework would be over-abstraction for no structural benefit.
@@ -51,7 +51,7 @@ Each step should:
5151

5252
### Comment preservation
5353

54-
The original `ClaimValidator` contained extensive inline comments explaining
54+
The original `ClaimValidator` class (now removed) contained extensive inline comments explaining
5555
*why* validation steps exist — historical context (beaconalt bug, newbie
5656
snapshot fix), structural invariants (mrc_start_index arithmetic, dust
5757
elimination ordering relative to shuffle), and subtle distinctions

src/gridcoin/consensus/shadow_validator.cpp

Lines changed: 0 additions & 179 deletions
This file was deleted.

src/gridcoin/consensus/shadow_validator.h

Lines changed: 0 additions & 77 deletions
This file was deleted.

src/gridcoin/tally.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,7 @@ CAmount Tally::AccrualNearLimit(
11071107
CAmount Tally::GetNewbieSuperblockAccrualCorrection(const Cpid& cpid, const SuperblockPtr& current_superblock)
11081108
{
11091109
// This function was moved from the anonymous namespace and private, to public and made static, because it has
1110-
// to be called from ClaimValidator::CheckResearchReward() directly too. Why?
1110+
// to be called from BlockRewardRules::Check() directly too. Why?
11111111

11121112
// The broken original newbie fix was CONDITIONAL. The initialization in Tally::Initialize was broken and would
11131113
// never activate, yet the alternate path through AcceptBlock AddToBlockIndex could actually set the original
@@ -1131,7 +1131,7 @@ CAmount Tally::GetNewbieSuperblockAccrualCorrection(const Cpid& cpid, const Supe
11311131
// included. This is activated at GetNewbieSnapshotFixHeight(), and will cause this function to be used to apply
11321132
// the corrections to any CPID's that do not have an accrual account at that height.
11331133
//
1134-
// 2. It is used in ConnectBlock (the ClaimValidator::CheckResearchReward()) to conditionally apply the accrual
1134+
// 2. It is used in ConnectBlock (via BlockRewardRules::Check()) to conditionally apply the accrual
11351135
// correction if the claimed value by the block fails the original CheckReward. If the original computed reward
11361136
// plus the correction equals the claimed reward, then the block is passed with a warning. This enables any
11371137
// node to conditionally validate a block that was staked with the accrual correction active, even if the

src/init.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "init.h"
1818
#include "node/ui_interface.h"
1919
#include "scheduler.h"
20-
#include "gridcoin/consensus/shadow_validator.h"
2120
#include "gridcoin/gridcoin.h"
2221
#include "gridcoin/upgrade.h"
2322
#include "gridcoin/contract/registry.h"
@@ -176,7 +175,6 @@ void Shutdown(void* parg)
176175
// This is necessary here to prevent a snapshot download from failing at the cleanup
177176
// step because of a write lock on accrual/registry.dat.
178177
GRC::CloseResearcherRegistryFile();
179-
GRC::ShutdownShadowValidator();
180178

181179
fs::remove(GetPidFile(gArgs));
182180
UnregisterWallet(pwalletMain);
@@ -300,15 +298,6 @@ void AddLoggingArgs(ArgsManager& argsman)
300298
argsman.AddArg("-org=<string>", "Set organization name for identification (default: not set). Required for use "
301299
"on testnet. Do not set this for a wallet on mainnet.",
302300
ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
303-
argsman.AddArg("-consensusrulesimpl=<old|new>",
304-
"Select consensus rules implementation (default: old; dev only)",
305-
ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
306-
argsman.AddArg("-consensusrulesshadow",
307-
"Run shadow implementation alongside authoritative for comparison (default: 0; dev only)",
308-
ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
309-
argsman.AddArg("-consensusshadowlog=<path>",
310-
"Write structured JSON-lines shadow comparison log to file (dev only)",
311-
ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
312301
}
313302

314303
void SetupServerArgs()
@@ -1494,8 +1483,6 @@ bool AppInit2(ThreadHandlerPtr threads)
14941483
// ProcessBlock works properly. If the GRC code fails to initialize, return false (bail).
14951484
if (!GRC::Initialize(threads, pindexBest)) return false;
14961485

1497-
GRC::InitShadowValidator();
1498-
14991486
// ********************************************************* Step 10: import blocks
15001487

15011488
fs::path pathBootstrap = GetDataDir() / "bootstrap.dat";

0 commit comments

Comments
 (0)