Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow nodes to fetch network config from peers #1711

Merged
merged 4 commits into from
Jul 15, 2024
Merged

Conversation

jbearer
Copy link
Member

@jbearer jbearer commented Jul 15, 2024

This allows nodes to fetch the network config from the config API of another node, instead of/in addition to local storage and the orchestrator. This could be useful when a node in an existing network is migrating to new storage, or when storage has been lost. In particular, Kudasai is currently not running their Cappuccino nodes because (for reasons still unknown) they lost their persisted network config, and now have no way of getting it back since the orchestrator is already shut down.

This PR:

  • Adds a PublicNetworkConfig which wraps a PublicHotShotConfig
  • Has the config/hotshot endpoint return the network config instead of just the HotShot config, which is strictly more information
  • Adds functions to convert a PublicNetworkConfig to a proper NetworkConfig based on a given set of private keys
  • Adds configuration logic to fetch the network config from a peer on startup

This PR does not:

  • Fix any issues with the network config being lost from persistent storage

Key places to review:

  • New config serialization in api/data_source.rs
  • Configuration logic in lib.rs

@jbearer jbearer requested a review from rob-maron July 15, 2024 14:55
@jbearer jbearer marked this pull request as ready for review July 15, 2024 15:02
Comment on lines +198 to +199
#[derivative(Debug(format_with = "fmt_opt_urls"))]
pub config_peers: Option<Vec<Url>>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any downside to changing this to Vec<Url> and then treating an empty vector as nothing? It may remove some complexity

Copy link
Member Author

Choose a reason for hiding this comment

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

I personally prefer Option<Vec> when empty is qualitatively different from non-empty because the compiler forces you to handle the None case explicitly whenever you want to use the vector. Whereas with just Vec<Url>, it's pretty easy to forget to check is_empty which is bad when there's entirely separate logic you want to do in the empty case

@jbearer jbearer merged commit dbc04c1 into main Jul 15, 2024
14 checks passed
@jbearer jbearer deleted the jb/config-fetching branch July 15, 2024 15:24
rob-maron added a commit that referenced this pull request Jul 15, 2024
This allows nodes to fetch the network config from the `config` API of
another node, instead of/in addition to local storage and the
orchestrator. This could be useful when a node in an existing network is
migrating to new storage, or when storage has been lost. In particular,
Kudasai is currently not running their Cappuccino nodes because (for
reasons still unknown) they lost their persisted network config, and now
have no way of getting it back since the orchestrator is already shut
down.

* Adds a `PublicNetworkConfig` which wraps a `PublicHotShotConfig`
* Has the `config/hotshot` endpoint return the network config instead of
just the HotShot config, which is strictly more information
* Adds functions to convert a `PublicNetworkConfig` to a proper
`NetworkConfig` based on a given set of private keys
* Adds configuration logic to fetch the network config from a peer on
startup

* Fix any issues with the network config being lost from persistent
storage

* New config serialization in `api/data_source.rs`
* Configuration logic in `lib.rs`
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