From e56ef592af534ad72d0490a8be8db22429860080 Mon Sep 17 00:00:00 2001 From: Eric Voskuil Date: Wed, 28 Oct 2026 00:25:00 -0400 Subject: [PATCH 1/2] Run tx check guards before store population. --- src/chasers/chaser_transaction.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/chasers/chaser_transaction.cpp b/src/chasers/chaser_transaction.cpp index ff7eb0b1..6d084cb2 100644 --- a/src/chasers/chaser_transaction.cpp +++ b/src/chasers/chaser_transaction.cpp @@ -575,15 +575,16 @@ code chaser_transaction::validate(const chain::transaction& tx) NOEXCEPT code ec{}; // Ensure tx does not violate tx consensus rules. + // Guards ensure tx does not violate presumed block consensus rules. + // These are DoS guards when validating a tx outside of a block. if (!ec) ec = tx.check(); if (!ec) ec = tx.check(pool_); - if (!ec) archive().populate_with_metadata(tx, true, true); - if (!ec) ec = tx.accept(pool_); - - // Ensure tx does not violate presumed block consensus rules. - // This is a DoS guard when validating a tx outside of a block. if (!ec) ec = tx.check_guard(); if (!ec) ec = tx.check_guard(pool_); + + // Store population follows all checks that do not require it. + if (!ec) archive().populate_with_metadata(tx, true, true); + if (!ec) ec = tx.accept(pool_); if (!ec) ec = tx.accept_guard(pool_); if (!ec) ec = tx.confirm_guard(pool_); From d7c719b1d75fd05089e703582571062a207a26cf Mon Sep 17 00:00:00 2001 From: Eric Voskuil Date: Wed, 28 Oct 2026 00:24:59 -0400 Subject: [PATCH 2/2] Rename block identify to check_guard. --- src/protocols/protocol_block_in_31800.cpp | 4 ++-- src/protocols/protocol_header_in_70014.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/protocols/protocol_block_in_31800.cpp b/src/protocols/protocol_block_in_31800.cpp index b06ecd59..440ef20d 100644 --- a/src/protocols/protocol_block_in_31800.cpp +++ b/src/protocols/protocol_block_in_31800.cpp @@ -370,14 +370,14 @@ bool protocol_block_in_31800::handle_receive_block(const code& ec, code protocol_block_in_31800::identify(const chain::view::block& block, const chain::context& ctx, bool bypass) const NOEXCEPT { - if (const auto ec = block.identify()) + if (const auto ec = block.check_guard()) return ec; // Bypass witness commitment check for stripped blocks. if (bypass && node_pruned_) return error::success; - if (const auto ec = block.identify(ctx)) + if (const auto ec = block.check_guard(ctx)) return ec; return error::success; diff --git a/src/protocols/protocol_header_in_70014.cpp b/src/protocols/protocol_header_in_70014.cpp index 7cf33d55..d6b59831 100644 --- a/src/protocols/protocol_header_in_70014.cpp +++ b/src/protocols/protocol_header_in_70014.cpp @@ -408,8 +408,8 @@ void protocol_header_in_70014::identify(const gate_t::ptr& gate) NOEXCEPT wtxids.cbegin()); const auto witness_root = sha256::merkle_root(std::move(wtxids)); - if ((ec = chain::block::identify(root, txids, is_malleated64(block))) || - (ec = chain::block::identify(ctx, first, witness_root, segregated))) + if ((ec = chain::block::check_guard(root, txids, is_malleated64(block))) || + (ec = chain::block::check_guard(ctx, first, witness_root, segregated))) { LOGR("Compact block [" << encode_hash(block.hash) << "] from [" << opposite() << "] " << ec.message());