Refactor bootstrap into context + strategy pattern#5040
Merged
pwojcikdev merged 6 commits intonanocurrency:developfrom Mar 11, 2026
Merged
Refactor bootstrap into context + strategy pattern#5040pwojcikdev merged 6 commits intonanocurrency:developfrom
pwojcikdev merged 6 commits intonanocurrency:developfrom
Conversation
Contributor
pwojcikdev
commented
Mar 10, 2026
- 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.
a8b251b to
e4a6b43
Compare
Contributor
There was a problem hiding this comment.
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_prioritiesRPC response shape to nest output underbootstrap.*and adjusts RPC tests accordingly. - Renames/reshapes several bootstrap components (e.g.,
*_scan→*_scan_index,account_sets→account_sets_index) and updates build files + tests; also renames bootstrap servermax_queue→channel_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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.