Skip to content

feat(elections): support persistent ADNL address across elections#105

Merged
Keshoid merged 4 commits into
release/nodectl/v0.4.0from
feature/sma-81-support-persistent-adnl-address-across-elections-static-adnl
Apr 20, 2026
Merged

feat(elections): support persistent ADNL address across elections#105
Keshoid merged 4 commits into
release/nodectl/v0.4.0from
feature/sma-81-support-persistent-adnl-address-across-elections-static-adnl

Conversation

@Keshoid
Copy link
Copy Markdown
Contributor

@Keshoid Keshoid commented Apr 20, 2026

Summary

  • Add elections.static_adnls config map to store pre-generated ADNL addresses per node (base64)
  • Add generate_adnl_addr() and register_adnl_addr() to ElectionsProvider trait
  • Runner reuses stored ADNL address via register_adnl_addr() instead of generating a new one each cycle
  • New POST /v1/elections/static-adnl endpoint: generates ADNL key on the validator node and saves it to config
  • New CLI command: nodectl config elections static-adnl --node <name>

Copilot AI review requested due to automatic review settings April 20, 2026 14:18
@linear
Copy link
Copy Markdown

linear Bot commented Apr 20, 2026

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

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_adnls to elections config and load it into the elections runner to re-register a configured ADNL instead of generating a new one.
  • Extend ElectionsProvider with generate_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;
@Keshoid Keshoid merged commit d5cb9c1 into release/nodectl/v0.4.0 Apr 20, 2026
5 of 6 checks passed
@Keshoid Keshoid deleted the feature/sma-81-support-persistent-adnl-address-across-elections-static-adnl branch April 20, 2026 15:42
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.

3 participants