feat(elections): support persistent ADNL address across elections#105
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for persisting a per-node ADNL address across election cycles by introducing a elections.static_adnls config map, new provider APIs to generate/register ADNL keys, and exposing management via HTTP + CLI.
Changes:
- Add
static_adnlsto elections config and load it into the elections runner to re-register a configured ADNL instead of generating a new one. - Extend
ElectionsProviderwithgenerate_adnl_addr()/register_adnl_addr()and implement them in the default provider. - Add an operator HTTP endpoint and CLI command to generate and persist a static ADNL key per node.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/node-control/service/src/http/http_server_task.rs |
Wires new /v1/elections/static-adnl route and OpenAPI schema entries. |
src/node-control/service/src/http/config_handlers.rs |
Adds request/response DTOs and handler that generates + stores static ADNL in runtime config. |
src/node-control/elections/src/runner.rs |
Loads static_adnls from config and registers static ADNL when creating a new validator key. |
src/node-control/elections/src/runner_tests.rs |
Extends provider mock + adds test verifying register_adnl_addr() is used for static ADNL. |
src/node-control/elections/src/providers/traits.rs |
Extends the provider trait with generate_adnl_addr() and register_adnl_addr(). |
src/node-control/elections/src/providers/default.rs |
Implements generate_adnl_addr() and register_adnl_addr() using the control client. |
src/node-control/common/src/app_config.rs |
Adds static_adnls field to ElectionsConfig with serde defaults. |
src/node-control/commands/src/commands/nodectl/config_elections_cmd.rs |
Adds nodectl config elections static-adnl --node <name> command to call the new endpoint. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1715
to
+1719
| pub async fn v1_elections_static_adnl_handler( | ||
| state: axum::extract::State<AppState>, | ||
| req: axum::Json<StaticAdnlRequest>, | ||
| ) -> Result<axum::Json<StaticAdnlResponse>, AppError> { | ||
| let node_name = req.0.node; |
Comment on lines
+305
to
+309
| base64::Engine::decode(&base64::engine::general_purpose::STANDARD, b64) | ||
| .map_err(|e| { | ||
| tracing::error!("node [{}] invalid static_adnl base64: {}", node_id, e); | ||
| }) | ||
| .ok() |
Comment on lines
+541
to
+545
| /// Pre-generated ADNL addresses, keyed by node name (base64-encoded). | ||
| /// When a node has an entry here, the runner attaches this existing ADNL address | ||
| /// to the validator key each election instead of generating a fresh one. | ||
| #[serde(default, skip_serializing_if = "HashMap::is_empty")] | ||
| pub static_adnls: HashMap<String, String>, |
| .generate_adnl_addr() | ||
| .await | ||
| .map_err(|e| AppError::internal(format!("generate_adnl_addr: {e}")))?; | ||
| let _ = provider.shutdown().await; |
Lapo4kaKek
approved these changes
Apr 20, 2026
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.
Summary
elections.static_adnlsconfig map to store pre-generated ADNL addresses per node (base64)generate_adnl_addr()andregister_adnl_addr()toElectionsProvidertraitregister_adnl_addr()instead of generating a new one each cyclePOST /v1/elections/static-adnlendpoint: generates ADNL key on the validator node and saves it to confignodectl config elections static-adnl --node <name>