Skip to content

Commit e62a8ab

Browse files
committed
rpc: Remove submitblock invalid-duplicate precheck
ProcessNewBlock fails if an invalid duplicate block is passed in through its call to AcceptBlock and AcceptBlockHeader. The failure in AcceptBlockHeader makes AcceptBlock return early. This makes the pre-check in submitblock redundant. --- With the introduction of a mining ipc interface and the potential future introduction of a kernel library API it becomes increasingly important to offer common behaviour between them. An example of this is ProcessNewBlock, which is used by ipc, rpc, net_processing and (potentially) the kernel library. Having divergent behaviour on suggested pre-checks and checks for these functions is confusing to both developers and users and is a maintenance burden. The rpc interface for ProcessNewBlock (submitblock) currently pre-checks if the block has a coinbase transaction and whether it has been processed before. While the current example binary for how to use the kernel library, bitcoin-chainstate, imitates these checks, the other interfaces do not.
1 parent 36dbeba commit e62a8ab

File tree

2 files changed

+1
-4
lines changed

2 files changed

+1
-4
lines changed

src/rpc/mining.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,9 +1024,6 @@ static RPCHelpMan submitblock()
10241024
if (pindex->IsValid(BLOCK_VALID_SCRIPTS)) {
10251025
return "duplicate";
10261026
}
1027-
if (pindex->nStatus & BLOCK_FAILED_MASK) {
1028-
return "duplicate-invalid";
1029-
}
10301027
}
10311028
}
10321029

src/validation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4285,7 +4285,7 @@ bool ChainstateManager::AcceptBlockHeader(const CBlockHeader& block, BlockValida
42854285
*ppindex = pindex;
42864286
if (pindex->nStatus & BLOCK_FAILED_MASK) {
42874287
LogDebug(BCLog::VALIDATION, "%s: block %s is marked invalid\n", __func__, hash.ToString());
4288-
return state.Invalid(BlockValidationResult::BLOCK_CACHED_INVALID, "duplicate");
4288+
return state.Invalid(BlockValidationResult::BLOCK_CACHED_INVALID, "duplicate-invalid");
42894289
}
42904290
return true;
42914291
}

0 commit comments

Comments
 (0)