Skip to content

Conversation

@lowhung
Copy link
Collaborator

@lowhung lowhung commented Nov 26, 2025

Description

Introduces a [global] configuration section that gets merged as a base layer for every module's config. This allows shared settings to be defined once rather than duplicated across multiple [module.*] sections.

Module-specific values take precedence over global values when keys collide. This requires the Caryatid PR to be merged for the new versions to be picked up.

[global.startup]
method = "snapshot"

[module.mithril-snapshot-fetcher]
# can access startup.method from global

[module.snapshot-bootstrapper]
# can also access startup.method from global

Both modules can now call config.get("startup.method") to decide whether to proceed or exit early—without duplicating the setting in each module's section.

Related Issue(s)

#220 & #395

How was this tested?

  • Running the node using both "mithril" and "snapshot" as the startup.method

Checklist

  • My code builds and passes local tests
  • I added/updated tests for my changes, where applicable
  • I updated documentation (if applicable)
  • CI is green for this PR

Impact / Side effects

  • No breaking changes: Existing module configs are unaffected

Comment on lines 400 to 403
// Check if this module is the selected startup method
let startup_method = config
.get::<StartupMethod>(CONFIG_KEY_START_UP_METHOD)
.unwrap_or(StartupMethod::Mithril);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it would make sense for a helper function which did this to live in common, specifically so that we automatically get the same default value everywhere. But I don't think that's critical enough to block the PR

Copy link
Collaborator Author

@lowhung lowhung Dec 1, 2025

Choose a reason for hiding this comment

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

I like that, something like this perhaps?

use config::Config;

pub const CONFIG_KEY_STARTUP_METHOD: &str = "startup.method";

impl StartupMethod {
    pub fn from_config(config: &Config) -> Self {
        config
            .get::<StartupMethod>(CONFIG_KEY_STARTUP_METHOD)
            .unwrap_or(StartupMethod::Mithril)
    }
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done here ede0b1c

Copy link
Collaborator

@whankinsiv whankinsiv left a comment

Choose a reason for hiding this comment

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

My only feedback is to move the key definition to common and also include the default value. const CONFIG_KEY_START_UP_METHOD: (&str, &str) = ("startup.method", StartupMethod::Mithril);

@lowhung lowhung linked an issue Dec 1, 2025 that may be closed by this pull request
14 tasks
@lowhung lowhung merged commit 122a2fc into main Dec 1, 2025
2 checks passed
@lowhung lowhung deleted the lowhung/add-global-config branch December 1, 2025 19:05
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.

Bootstrap Orchestration

4 participants