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

Runtime network selection #1482

Merged
merged 83 commits into from
Jun 22, 2022
Merged

Runtime network selection #1482

merged 83 commits into from
Jun 22, 2022

Conversation

elmattic
Copy link
Contributor

@elmattic elmattic commented Mar 17, 2022

Summary of changes
Changes introduced in this pull request:

  • Add runtime selection for mainnet and calibnet
  • Add a new chain section in config toml file to drive chain parameters
  • Add a sub directory per chain for the blockstore

Reference issue to close (if applicable)

Closes #1402

Other information and links

@elmattic elmattic requested review from ec2 and noot as code owners March 17, 2022 14:30
connormullett and others added 4 commits June 8, 2022 11:02
* use NetworkVersion and implement de; scaffold ser

* test for serde functionality

* error on invalid network version; default to V1

* add missing test cases

* remove redundant type conversion

* fix bug in serialization; requested changes

* add bad test case

* use expect over unwrap
@lemmih lemmih changed the title Elmattic/network selection [WIP] Runtime network selection Jun 21, 2022
@lemmih
Copy link
Contributor

lemmih commented Jun 21, 2022

I can still sync to mainnet with this branch. Is it ready for review?

@elmattic
Copy link
Contributor Author

I can still sync to mainnet with this branch. Is it ready for review?

Yes, please do.

@elmattic elmattic marked this pull request as ready for review June 21, 2022 11:08
@lemmih lemmih changed the title [WIP] Runtime network selection Runtime network selection Jun 21, 2022
@@ -0,0 +1,87 @@
[package]
Copy link
Contributor

Choose a reason for hiding this comment

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

This file should be deleted.

Copy link
Contributor

@lemmih lemmih left a comment

Choose a reason for hiding this comment

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

Once you delete the conformance test file, it looks good to go.

blockchain/message_pool/src/msgpool/mod.rs Show resolved Hide resolved
blockchain/state_manager/src/lib.rs Show resolved Hide resolved
forest/src/daemon.rs Outdated Show resolved Hide resolved
} else {
mainnet::DRAND_SCHEDULE.iter()
};
let mut points = BeaconSchedule(Vec::with_capacity(ds_iter.len()));
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense to make it a creation method for BeaconSchedule? Messing with its internals in another module is a bit shady.

Copy link
Contributor

Choose a reason for hiding this comment

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

Done.

.iter()
.find(|info| height == info.height)
.map(|info| info.epoch)
.unwrap()
Copy link
Member

Choose a reason for hiding this comment

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

perhaps an expect with a nice description would be more gentle in a terrible case where it may fail (or perhaps it can't?)

Copy link
Contributor

Choose a reason for hiding this comment

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

Done. It would be nice to prove that it cannot happen.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @lemmih ! Hard to prove because it can depend of an input config file. But we could validate those calls upfront, ie at client init. This would avoid for unexpected panics later.

Copy link
Member

Choose a reason for hiding this comment

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

@elmattic how about adding a shiny, low-priority issue with a nice description to have this validation so someone could take a look in a separate PR?

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"mainnet" => Ok(Network::Mainnet),
_ => Ok(Network::Testnet),
Copy link
Member

Choose a reason for hiding this comment

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

Not sure about this, "cthulhu" shouldn't default to testnet - I'd expect an unrecognized network panic. Let's be pickier!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it should, all networks that don't are mainnet are testnet.

Copy link
Contributor

Choose a reason for hiding this comment

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

Done.

@lemmih lemmih merged commit 42313c8 into main Jun 22, 2022
@lemmih lemmih deleted the elmattic/network_selection branch June 22, 2022 11:00
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.

Network selection and protocol upgrades should be handled at runtime
4 participants