mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-24 18:23:26 -03:00
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.
This commit is contained in:
parent
36dbebafb9
commit
e62a8abd7d
2 changed files with 1 additions and 4 deletions
|
@ -1024,9 +1024,6 @@ static RPCHelpMan submitblock()
|
|||
if (pindex->IsValid(BLOCK_VALID_SCRIPTS)) {
|
||||
return "duplicate";
|
||||
}
|
||||
if (pindex->nStatus & BLOCK_FAILED_MASK) {
|
||||
return "duplicate-invalid";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4285,7 +4285,7 @@ bool ChainstateManager::AcceptBlockHeader(const CBlockHeader& block, BlockValida
|
|||
*ppindex = pindex;
|
||||
if (pindex->nStatus & BLOCK_FAILED_MASK) {
|
||||
LogDebug(BCLog::VALIDATION, "%s: block %s is marked invalid\n", __func__, hash.ToString());
|
||||
return state.Invalid(BlockValidationResult::BLOCK_CACHED_INVALID, "duplicate");
|
||||
return state.Invalid(BlockValidationResult::BLOCK_CACHED_INVALID, "duplicate-invalid");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue