Skip to content

Refactor bootstrap into context + strategy pattern#5040

Merged
pwojcikdev merged 6 commits intonanocurrency:developfrom
pwojcikdev:bootstrap-strategies-3
Mar 11, 2026
Merged

Refactor bootstrap into context + strategy pattern#5040
pwojcikdev merged 6 commits intonanocurrency:developfrom
pwojcikdev:bootstrap-strategies-3

Conversation

@pwojcikdev
Copy link
Copy Markdown
Contributor

  • Extract bootstrap_context from bootstrap_service to own all shared state and internal logic, making bootstrap_service a thin facade
  • Extract 4 bootstrap strategies (priority, database, dependency, frontier) into separate classes
  • Move sync_dependencies into a dedicated thread in dependency_strategy
  • Rename cleanup_and_sync → cleanup, run_timeouts → run_cleanup for consistency

Move the lock.unlock() call after processing the response payload
to ensure atomic tag erasure and state updates. This eliminates
redundant inner lock acquisitions in process() overloads.
Strategies now depend on bootstrap_context instead of the full service.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the node’s ascending bootstrap implementation by extracting shared bootstrap state into a bootstrap_context and splitting the bootstrap workflow into separate strategy classes, while also updating related RPC output and config/test naming.

Changes:

  • Introduces bootstrap_context (shared state + core logic) and adds 4 strategy classes (priority/database/dependency/frontier) each running in its own thread(s).
  • Updates the bootstrap_priorities RPC response shape to nest output under bootstrap.* and adjusts RPC tests accordingly.
  • Renames/reshapes several bootstrap components (e.g., *_scan*_scan_index, account_setsaccount_sets_index) and updates build files + tests; also renames bootstrap server max_queuechannel_limit.

Reviewed changes

Copilot reviewed 34 out of 34 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
nano/rpc_test/rpc.cpp Updates RPC test expectations for nested bootstrap.* response fields.
nano/node/json_handler.cpp Adjusts bootstrap_priorities RPC to return nested bootstrap tree.
nano/node/fwd.hpp Adds forward declaration for nano::bootstrap::bootstrap_context.
nano/node/bootstrap/priority_strategy.hpp Adds priority bootstrap strategy interface.
nano/node/bootstrap/priority_strategy.cpp Implements priority bootstrap strategy loop + request logic.
nano/node/bootstrap/frontier_strategy.hpp Adds frontier scan bootstrap strategy interface.
nano/node/bootstrap/frontier_strategy.cpp Implements frontier scan strategy and frontier processing logic.
nano/node/bootstrap/frontier_scan_index.hpp Renames frontier scan tracker type to frontier_scan_index.
nano/node/bootstrap/frontier_scan_index.cpp Updates implementation for renamed frontier_scan_index.
nano/node/bootstrap/dependency_strategy.hpp Adds dependency walker/sync strategy interface.
nano/node/bootstrap/dependency_strategy.cpp Implements dependency walker and sync thread.
nano/node/bootstrap/database_strategy.hpp Adds database scan bootstrap strategy interface.
nano/node/bootstrap/database_strategy.cpp Implements database scan strategy loop + request logic.
nano/node/bootstrap/database_scan_index.hpp Renames database scan tracker type to database_scan_index.
nano/node/bootstrap/database_scan_index.cpp Updates implementation for renamed database_scan_index.
nano/node/bootstrap/common.hpp Introduces query_type/query_source enums and stat conversion declarations.
nano/node/bootstrap/common.cpp Implements enum-name-based conversion to nano::stat::detail.
nano/node/bootstrap/bootstrap_service.hpp Makes bootstrap_service a thin facade and changes info() to return a ptree.
nano/node/bootstrap/bootstrap_service.cpp Delegates bootstrap lifecycle + processing to bootstrap_context.
nano/node/bootstrap/bootstrap_server.hpp Renames bootstrap server per-channel queue setting to channel_limit.
nano/node/bootstrap/bootstrap_server.cpp Applies channel_limit rename in runtime logic and TOML ser/de.
nano/node/bootstrap/bootstrap_context.hpp Adds new shared bootstrap context API/state and strategy ownership.
nano/node/bootstrap/bootstrap_context.cpp Moves core bootstrap logic from service into context and wires strategies.
nano/node/bootstrap/account_sets_index.hpp Renames account sets to account_sets_index, updates sync_dependencies() return type.
nano/node/bootstrap/account_sets_index.cpp Updates implementation for renamed account_sets_index and returns synced count.
nano/node/CMakeLists.txt Registers new bootstrap sources and removes old renamed ones.
nano/lib/thread_roles.hpp Adds bootstrap_dependency_sync thread role.
nano/lib/thread_roles.cpp Adds string mapping for bootstrap_dependency_sync.
nano/lib/stats_enums.hpp Adds database/dependencies stat details for query source mapping.
nano/core_test/toml.cpp Updates tests for channel_limit rename in bootstrap server config.
nano/core_test/bootstrap_frontier_scan.cpp Updates include and type name for frontier_scan_index.
nano/core_test/bootstrap_account_sets.cpp Adds dedicated tests for account_sets_index.
nano/core_test/bootstrap.cpp Removes duplicated account sets tests and updates includes.
nano/core_test/CMakeLists.txt Adds new bootstrap_account_sets test target source.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pwojcikdev pwojcikdev merged commit 35a0b6f into nanocurrency:develop Mar 11, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants