Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change download window to chase downloaded vs. validated. #629

Merged
merged 5 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ src_libbitcoin_node_la_SOURCES = \
src/chasers/chaser_check.cpp \
src/chasers/chaser_confirm.cpp \
src/chasers/chaser_header.cpp \
src/chasers/chaser_preconfirm.cpp \
src/chasers/chaser_snapshot.cpp \
src/chasers/chaser_storage.cpp \
src/chasers/chaser_template.cpp \
src/chasers/chaser_transaction.cpp \
src/chasers/chaser_validate.cpp \
src/protocols/protocol.cpp \
src/protocols/protocol_block_in.cpp \
src/protocols/protocol_block_in_31800.cpp \
Expand Down Expand Up @@ -89,9 +89,9 @@ test_libbitcoin_node_test_SOURCES = \
test/chasers/chaser_check.cpp \
test/chasers/chaser_confirm.cpp \
test/chasers/chaser_header.cpp \
test/chasers/chaser_preconfirm.cpp \
test/chasers/chaser_template.cpp \
test/chasers/chaser_transaction.cpp \
test/chasers/chaser_validate.cpp \
test/protocols/protocol.cpp \
test/sessions/session.cpp

Expand Down Expand Up @@ -140,11 +140,11 @@ include_bitcoin_node_chasers_HEADERS = \
include/bitcoin/node/chasers/chaser_confirm.hpp \
include/bitcoin/node/chasers/chaser_header.hpp \
include/bitcoin/node/chasers/chaser_organize.hpp \
include/bitcoin/node/chasers/chaser_preconfirm.hpp \
include/bitcoin/node/chasers/chaser_snapshot.hpp \
include/bitcoin/node/chasers/chaser_storage.hpp \
include/bitcoin/node/chasers/chaser_template.hpp \
include/bitcoin/node/chasers/chaser_transaction.hpp \
include/bitcoin/node/chasers/chaser_validate.hpp \
include/bitcoin/node/chasers/chasers.hpp

include_bitcoin_node_impl_chasersdir = ${includedir}/bitcoin/node/impl/chasers
Expand Down
4 changes: 2 additions & 2 deletions builds/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,11 @@ add_library( ${CANONICAL_LIB_NAME}
"../../src/chasers/chaser_check.cpp"
"../../src/chasers/chaser_confirm.cpp"
"../../src/chasers/chaser_header.cpp"
"../../src/chasers/chaser_preconfirm.cpp"
"../../src/chasers/chaser_snapshot.cpp"
"../../src/chasers/chaser_storage.cpp"
"../../src/chasers/chaser_template.cpp"
"../../src/chasers/chaser_transaction.cpp"
"../../src/chasers/chaser_validate.cpp"
"../../src/protocols/protocol.cpp"
"../../src/protocols/protocol_block_in.cpp"
"../../src/protocols/protocol_block_in_31800.cpp"
Expand Down Expand Up @@ -329,9 +329,9 @@ if (with-tests)
"../../test/chasers/chaser_check.cpp"
"../../test/chasers/chaser_confirm.cpp"
"../../test/chasers/chaser_header.cpp"
"../../test/chasers/chaser_preconfirm.cpp"
"../../test/chasers/chaser_template.cpp"
"../../test/chasers/chaser_transaction.cpp"
"../../test/chasers/chaser_validate.cpp"
"../../test/protocols/protocol.cpp"
"../../test/sessions/session.cpp" )

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@
<ClCompile Include="..\..\..\..\test\chasers\chaser_check.cpp" />
<ClCompile Include="..\..\..\..\test\chasers\chaser_confirm.cpp" />
<ClCompile Include="..\..\..\..\test\chasers\chaser_header.cpp" />
<ClCompile Include="..\..\..\..\test\chasers\chaser_preconfirm.cpp" />
<ClCompile Include="..\..\..\..\test\chasers\chaser_template.cpp" />
<ClCompile Include="..\..\..\..\test\chasers\chaser_transaction.cpp" />
<ClCompile Include="..\..\..\..\test\chasers\chaser_validate.cpp" />
<ClCompile Include="..\..\..\..\test\configuration.cpp" />
<ClCompile Include="..\..\..\..\test\error.cpp" />
<ClCompile Include="..\..\..\..\test\main.cpp" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@
<ClCompile Include="..\..\..\..\test\chasers\chaser_header.cpp">
<Filter>src\chasers</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\test\chasers\chaser_preconfirm.cpp">
<Filter>src\chasers</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\test\chasers\chaser_template.cpp">
<Filter>src\chasers</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\test\chasers\chaser_transaction.cpp">
<Filter>src\chasers</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\test\chasers\chaser_validate.cpp">
<Filter>src\chasers</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\test\configuration.cpp">
<Filter>src</Filter>
</ClCompile>
Expand Down
4 changes: 2 additions & 2 deletions builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@
<ClCompile Include="..\..\..\..\src\chasers\chaser_check.cpp" />
<ClCompile Include="..\..\..\..\src\chasers\chaser_confirm.cpp" />
<ClCompile Include="..\..\..\..\src\chasers\chaser_header.cpp" />
<ClCompile Include="..\..\..\..\src\chasers\chaser_preconfirm.cpp" />
<ClCompile Include="..\..\..\..\src\chasers\chaser_snapshot.cpp" />
<ClCompile Include="..\..\..\..\src\chasers\chaser_storage.cpp" />
<ClCompile Include="..\..\..\..\src\chasers\chaser_template.cpp" />
<ClCompile Include="..\..\..\..\src\chasers\chaser_transaction.cpp" />
<ClCompile Include="..\..\..\..\src\chasers\chaser_validate.cpp" />
<ClCompile Include="..\..\..\..\src\configuration.cpp" />
<ClCompile Include="..\..\..\..\src\error.cpp" />
<ClCompile Include="..\..\..\..\src\full_node.cpp" />
Expand Down Expand Up @@ -114,11 +114,11 @@
<ClInclude Include="..\..\..\..\include\bitcoin\node\chasers\chaser_confirm.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\chasers\chaser_header.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\chasers\chaser_organize.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\chasers\chaser_preconfirm.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\chasers\chaser_snapshot.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\chasers\chaser_storage.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\chasers\chaser_template.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\chasers\chaser_transaction.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\chasers\chaser_validate.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\chasers\chasers.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\configuration.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\define.hpp" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@
<ClCompile Include="..\..\..\..\src\chasers\chaser_header.cpp">
<Filter>src\chasers</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\src\chasers\chaser_preconfirm.cpp">
<Filter>src\chasers</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\src\chasers\chaser_snapshot.cpp">
<Filter>src\chasers</Filter>
</ClCompile>
Expand All @@ -78,6 +75,9 @@
<ClCompile Include="..\..\..\..\src\chasers\chaser_transaction.cpp">
<Filter>src\chasers</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\src\chasers\chaser_validate.cpp">
<Filter>src\chasers</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\src\configuration.cpp">
<Filter>src</Filter>
</ClCompile>
Expand Down Expand Up @@ -167,9 +167,6 @@
<ClInclude Include="..\..\..\..\include\bitcoin\node\chasers\chaser_organize.hpp">
<Filter>include\bitcoin\node\chasers</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\node\chasers\chaser_preconfirm.hpp">
<Filter>include\bitcoin\node\chasers</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\node\chasers\chaser_snapshot.hpp">
<Filter>include\bitcoin\node\chasers</Filter>
</ClInclude>
Expand All @@ -182,6 +179,9 @@
<ClInclude Include="..\..\..\..\include\bitcoin\node\chasers\chaser_transaction.hpp">
<Filter>include\bitcoin\node\chasers</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\node\chasers\chaser_validate.hpp">
<Filter>include\bitcoin\node\chasers</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\node\chasers\chasers.hpp">
<Filter>include\bitcoin\node\chasers</Filter>
</ClInclude>
Expand Down
16 changes: 3 additions & 13 deletions console/executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,6 @@
#include <boost/format.hpp>
#include <bitcoin/node.hpp>

// for do_hardware
#ifdef HAVE_XCPU
constexpr auto with_xcpu = true;
#else
constexpr auto with_xcpu = false;
#endif
#ifdef HAVE_ARM
constexpr auto with_arm = true;
#else
constexpr auto with_arm = false;
#endif

namespace libbitcoin {
namespace node {

Expand Down Expand Up @@ -1526,6 +1514,7 @@ void executor::read_test() const
constexpr auto hash523354 = base16_hash(
"0000000000000000002e0e763e60bde40c58aa23f295ef1919b352f3303e06a6");

const auto start = logger::now();
const auto link = query_.to_header(hash523354);
if (link.is_terminal())
{
Expand Down Expand Up @@ -1591,7 +1580,8 @@ void executor::read_test() const
return;
}

logger("Validated block 523354.");
const auto span = duration_cast<milliseconds>(logger::now() - start);
logger(format("Validated block 523354 in %1% msec.") % span.count());
}

// arbitrary testing (non-const).
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
#include <bitcoin/node/chasers/chaser_confirm.hpp>
#include <bitcoin/node/chasers/chaser_header.hpp>
#include <bitcoin/node/chasers/chaser_organize.hpp>
#include <bitcoin/node/chasers/chaser_preconfirm.hpp>
#include <bitcoin/node/chasers/chaser_snapshot.hpp>
#include <bitcoin/node/chasers/chaser_storage.hpp>
#include <bitcoin/node/chasers/chaser_template.hpp>
#include <bitcoin/node/chasers/chaser_transaction.hpp>
#include <bitcoin/node/chasers/chaser_validate.hpp>
#include <bitcoin/node/chasers/chasers.hpp>
#include <bitcoin/node/protocols/protocol.hpp>
#include <bitcoin/node/protocols/protocol_block_in.hpp>
Expand Down
22 changes: 11 additions & 11 deletions include/bitcoin/node/chase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ enum class chase
/// -----------------------------------------------------------------------

/// Chasers directed to start operating (height_t).
/// Issued by 'full_node' and handled by 'preconfirm'.
/// Issued by 'full_node' and handled by 'validate'.
start,

/// Disk space is limited (count_t).
/// Issued by full_node and handled by 'snapshot' and 'storage'.
space,

/// Chaser is directed to start when there are no downloads (height_t).
/// Issued by 'organize' and handled by 'preconfirm'.
/// Issued by 'organize' and handled by 'validate'.
bump,

/// Channels (all) directed to stop (channel_t).
Expand Down Expand Up @@ -87,12 +87,12 @@ enum class chase
/// Late-stage Invalidity.
/// -----------------------------------------------------------------------

/// unchecked, unpreconfirmable or unconfirmable was handled (height_t).
/// Issued by 'organize' and handled by 'preconfirm' (disorgs candidates).
/// unchecked, unvalid or unconfirmable was handled (height_t).
/// Issued by 'organize' and handled by 'validate' (disorgs candidates).
disorganized,

/// stored block was determined to be malleated (invalid) (header_t).
/// Issued by 'preconfirm' and 'confirm', handled by 'chaser' (redownload).
/// Issued by 'validate' and 'confirm', handled by 'chaser' (redownload).
malleated,

/// Validation.
Expand All @@ -106,13 +106,13 @@ enum class chase
/// Issued by 'block_in_31800' and handled by 'header'.
unchecked,

/// A branch has become preconfirmable (height_t).
/// Issued by 'preconfirm' and handled by 'confirm'.
preconfirmable,
/// A branch has become valid (height_t).
/// Issued by 'validate' and handled by 'confirm'.
valid,

/// A checked block has failed preconfirmability (header_t).
/// Issued by 'preconfirm' and handled by 'header'.
unpreconfirmable,
/// A checked block has failed validation (header_t).
/// Issued by 'validate' and handled by 'header'.
unvalid,

/// Confirmation.
/// -----------------------------------------------------------------------
Expand Down
9 changes: 9 additions & 0 deletions include/bitcoin/node/chasers/chaser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,16 @@ class BCN_API chaser
/// Height of checkpoint (or genesis) with maximum height.
size_t top_checkpoint() const NOEXCEPT;

/// Position keeping.
/// -----------------------------------------------------------------------

size_t& position() NOEXCEPT;
void set_position(size_t height) NOEXCEPT;

private:
// This is protected by strand.
size_t position_;

// These are thread safe (mostly).
full_node& node_;
network::asio::strand strand_;
Expand Down
7 changes: 3 additions & 4 deletions include/bitcoin/node/chasers/chaser_check.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class BCN_API chaser_check
public:
DELETE_COPY_MOVE_DESTRUCT(chaser_check);

/// Craete empty shared map.
/// Create empty shared map.
static map_ptr empty_map() NOEXCEPT;

/// Move half of map into returned map.
Expand All @@ -58,8 +58,9 @@ class BCN_API chaser_check
virtual bool handle_event(const code& ec, chase event_,
event_value value) NOEXCEPT;

virtual void do_bump(height_t branch_point) NOEXCEPT;
virtual void do_header(height_t branch_point) NOEXCEPT;
virtual void do_preconfirmable(height_t height) NOEXCEPT;
virtual void do_checked(height_t height) NOEXCEPT;
virtual void do_regressed(height_t branch_point) NOEXCEPT;
virtual void do_disorganized(height_t top) NOEXCEPT;
virtual void do_malleated(header_t link) NOEXCEPT;
Expand All @@ -70,7 +71,6 @@ class BCN_API chaser_check
private:
typedef std::deque<map_ptr> maps;

////size_t count_maps() const NOEXCEPT;
map_ptr get_map() NOEXCEPT;
size_t get_unassociated() NOEXCEPT;

Expand All @@ -82,7 +82,6 @@ class BCN_API chaser_check
// These are protected by strand.
size_t inventory_{};
size_t requested_{};
size_t validated_{};
maps maps_{};
};

Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/node/chasers/chaser_confirm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class BCN_API chaser_confirm
virtual bool handle_event(const code& ec, chase event_,
event_value value) NOEXCEPT;

virtual void do_preconfirmed(height_t height) NOEXCEPT;
virtual void do_validated(height_t height) NOEXCEPT;
virtual code confirm(const database::header_link& link,
size_t height) NOEXCEPT;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LIBBITCOIN_NODE_CHASERS_CHASER_PRECONFIRM_HPP
#define LIBBITCOIN_NODE_CHASERS_CHASER_PRECONFIRM_HPP
#ifndef LIBBITCOIN_NODE_CHASERS_CHASER_VALIDATE_HPP
#define LIBBITCOIN_NODE_CHASERS_CHASER_VALIDATE_HPP

#include <bitcoin/database.hpp>
#include <bitcoin/node/chasers/chaser.hpp>
Expand All @@ -29,13 +29,13 @@ namespace node {
class full_node;

/// Chase down blocks in the the candidate header chain for validation.
class BCN_API chaser_preconfirm
class BCN_API chaser_validate
: public chaser
{
public:
DELETE_COPY_MOVE_DESTRUCT(chaser_preconfirm);
DELETE_COPY_MOVE_DESTRUCT(chaser_validate);

chaser_preconfirm(full_node& node) NOEXCEPT;
chaser_validate(full_node& node) NOEXCEPT;

code start() NOEXCEPT override;

Expand All @@ -56,14 +56,13 @@ class BCN_API chaser_preconfirm
bool update_neutrino(const database::header_link& link) NOEXCEPT;
bool update_neutrino(const database::header_link& link,
const system::chain::block& block) NOEXCEPT;
void update_cache(size_t height) NOEXCEPT;
void update_position(size_t height) NOEXCEPT;

// These are thread safe.
const uint64_t initial_subsidy_;
const uint32_t subsidy_interval_blocks_;

// These are protected by strand.
size_t validated_{};
// This is protected by strand.
system::hash_digest neutrino_{};
};

Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/node/chasers/chasers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <bitcoin/node/chasers/chaser_confirm.hpp>
#include <bitcoin/node/chasers/chaser_header.hpp>
#include <bitcoin/node/chasers/chaser_organize.hpp>
#include <bitcoin/node/chasers/chaser_preconfirm.hpp>
#include <bitcoin/node/chasers/chaser_validate.hpp>
#include <bitcoin/node/chasers/chaser_snapshot.hpp>
#include <bitcoin/node/chasers/chaser_storage.hpp>
#include <bitcoin/node/chasers/chaser_template.hpp>
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/node/error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ enum error_t : uint8_t
set_confirmed,
block_confirmable,
set_txs_connected,
set_block_preconfirmable,
set_block_valid,

/// query composite
node_push,
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/node/full_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class BCN_API full_node
chaser_block chaser_block_;
chaser_header chaser_header_;
chaser_check chaser_check_;
chaser_preconfirm chaser_preconfirm_;
chaser_validate chaser_validate_;
chaser_confirm chaser_confirm_;
chaser_transaction chaser_transaction_;
chaser_template chaser_template_;
Expand Down
Loading
Loading