remove error enum #35693

pull yuvicc wants to merge 4 commits into bitcoin:master from yuvicc:2026-06-remove_enum_ie_2 changing 36 files +435 −404
  1. yuvicc commented at 12:47 PM on July 9, 2026: contributor

    No description provided.

  2. validation: route fatal errors through util::Expected<T, kernel::FatalError>
    Validation functions previously signalled fatal/internal errors by
    setting an `M_ERROR` mode on the BlockValidationState out-parameter,
    which tangled three outcomes (valid / invalid / fatal) in a single
    object and forced callers to unwrap them.
    
    Introduce `kernel::FatalError`, which can only be created through
    `FatalError::Raise()`. Raise() fires the fatalError notification and
    returns the error wrapped in `util::Unexpected`, so holding a FatalError
    proves the notification fired exactly once; propagation up the stack
    just moves the object.
    
    Convert the block processing chain to return `util::Expected<T,
    kernel::FatalError>`, where the error channel carries the fatal error
    and the value channel carries the `BlockValidationState`
    (valid/invalid) or void. `BlockManager::WriteBlock` and
    `FindNextBlockPos` now mint the error at the true origin instead of
    returning a null FlatFilePos after firing the notification.
    
    `Chainstate::DisconnectTip` and `Chainstate::InvalidateBlock` keep a
    plain string error channel because they mix outcomes: DisconnectTip
    failures are escalated to a fatal error by ActivateBestChainStep but
    surfaced as a plain error by InvalidateBlock (matching the previous
    AbortNode-at-caller behaviour), and InvalidateBlock mixes user errors
    with propagated fatal messages.
    
    The BlockChecked validation interface signal is now fired only for
    valid/invalid outcomes, never on a fatal error. Observable behaviour is
    otherwise unchanged: fatal errors keep mapping to the same RPC error
    codes as before, and the Mining interface's checkBlock/submitBlock
    surface the fatal message as the reject reason as before. The one
    exception is the internal-bug guard in ActivateBestChain
    (m_target_utxohash set), which now raises a fatal error instead of
    returning a plain string, since continuing to operate that chainstate
    would corrupt state.
    93cf87a9db
  3. rpc: surface fatal validation errors as RPC_INTERNAL_ERROR
    A fatal error (disk failure, block data corruption, ...) is a failure of
    the node itself, not a verdict on the RPC's inputs, and the node is
    already shutting down by the time it is reported. Previously these
    errors were conflated with block validation failures: submitblock and
    getblocktemplate reported them as RPC_VERIFY_ERROR; preciousblock,
    invalidateblock and reconsiderblock as RPC_DATABASE_ERROR; and
    generatetoaddress/generatetodescriptor flattened them into the generic
    "ProcessNewBlock, block not accepted" error.
    
    Add a ThrowFatalError() helper and use it at every RPC call site that
    receives a kernel::FatalError, so all of them consistently fail with
    RPC_INTERNAL_ERROR and the fatal error message.
    88e08d7bd5
  4. consensus: remove `Error()`/`IsError()` from ValidationState
    Now that fatal errors are propagated through util::Expected's error
    channel, no validation code sets or reads the `M_ERROR` mode. Drop
    `Error()`, `IsError()` and the `M_ERROR` enumerator so that a `ValidationState`
    can only be valid or invalid.
    fa5a55ebb8
  5. kernel: remove `INTERNAL_ERROR` from `btck_ValidationMode` 65d6f7eb6c
  6. yuvicc closed this on Jul 9, 2026

  7. DrahtBot commented at 12:47 PM on July 9, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35693.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process. A summary of reviews will appear here.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

    LLM Linter (✨ experimental)

    Possible places where named args for integral literals may be used (e.g. func(x, /*named_arg=*/0) in C++, and func(x, named_arg=0) in Python):

    • chainman.AcceptBlock(pblockone, &pindex, true, nullptr, &newblock, true) in src/test/validation_chainstate_tests.cpp
    • chainman.ProcessNewBlock(block, true, true, &new_block) in src/test/util/mining.cpp
    • Assert(m_node.chainman)->ProcessNewBlock(shared_pblock, true, true, nullptr) in src/test/util/setup_common.cpp
    • auto res{Assert(m_node.chainman)->ProcessNewBlock(std::make_shared<CBlock>(Params().GenesisBlock()), true, true, &ignored)} in src/test/validation_block_tests.cpp
    • (void)Assert(m_node.chainman)->ProcessNewBlock(block, true, true, &ignored) in src/test/validation_block_tests.cpp
    • auto res{Assert(m_node.chainman)->ProcessNewBlock(block, true, true, &ignored)} in src/test/validation_block_tests.cpp
    • chainman.AcceptBlock(new_block, &new_block_index, true, nullptr, nullptr, true) in src/test/coinstatsindex_tests.cpp
    • AcceptBlock(pblock, nullptr, true, dbp, nullptr, true) in src/validation.cpp
    • AcceptBlock(pblockrecursive, nullptr, true, &it->second, nullptr, true) in src/validation.cpp

    <sup>2026-07-09 12:48:09</sup>

Contributors

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-07-11 18:51 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me