-
Notifications
You must be signed in to change notification settings - Fork 159
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
Validate the ChainConfig struct at construction time #1845
Conversation
@tyshko5 You can write a |
I've already added a compile-time check |
Right but you can't use |
types/networks/src/lib.rs
Outdated
pub const HEIGHT_VEC: [Height; 17] = [ | ||
Height::Breeze, | ||
Height::Smoke, | ||
Height::Ignition, | ||
Height::ActorsV2, | ||
Height::Tape, | ||
Height::Liftoff, | ||
Height::Kumquat, | ||
Height::Calico, | ||
Height::Persian, | ||
Height::Orange, | ||
Height::Trust, | ||
Height::Norwegian, | ||
Height::Turbo, | ||
Height::Hyperdrive, | ||
Height::Chocolate, | ||
Height::OhSnap, | ||
Height::Skyr, | ||
]; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unused.
types/networks/src/lib.rs
Outdated
Height::Breeze => NetworkVersion::V0, | ||
Height::Smoke => NetworkVersion::V1, | ||
Height::Ignition => NetworkVersion::V2, | ||
Height::ActorsV2 => NetworkVersion::V3, | ||
Height::Tape => NetworkVersion::V4, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bump everything such that Breeze
is V1
and Tape
is V5
. See the deleted UPGRADE_INFOS
for ground truth.
types/networks/src/lib.rs
Outdated
pub fn sort_by_epoch(mut height_info_vec: Vec<HeightInfo>) -> Vec<HeightInfo> { | ||
height_info_vec.sort_by(|a, b| a.epoch.cmp(&b.epoch)); | ||
height_info_vec | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this function takes a slice of HeightInfo
(and turns it into a Vec) then the rest of the code will become simpler.
types/networks/src/lib.rs
Outdated
let height_infos = sort_by_epoch(&self.height_infos); | ||
let height = height_infos |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let height_infos = sort_by_epoch(&self.height_infos); | |
let height = height_infos | |
let height = sort_by_epoch(&self.height_infos) |
types/networks/src/lib.rs
Outdated
let height_infos = sort_by_epoch(&self.height_infos); | ||
height_infos |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let height_infos = sort_by_epoch(&self.height_infos); | |
height_infos | |
sort_by_epoch(&self.height_infos) |
types/networks/src/lib.rs
Outdated
self.name == other.name | ||
&& self.bootstrap_peers == other.bootstrap_peers | ||
&& self.block_delay_secs == other.block_delay_secs | ||
&& self.version_schedule == other.version_schedule | ||
&& self.height_infos == other.height_infos | ||
&& height_infos == other_height_infos |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&& height_infos == other_height_infos | |
&& sort_by_epoch(&self.height_infos) == sort_by_epoch(&other.height_infos) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good. Only a few style suggestions.
@tyshko5 Could you update the delegate consensus code that is still using |
Done |
* most changes * requested change * fix fmt * new ways: delete claus, version_schedule, sort * fix lint * requested changes * compile time check * from implementation * requested changes * requested changes * requested changes * requested changes * requested changes * delete Claus from deleg cns config
* most changes * requested change * fix fmt * new ways: delete claus, version_schedule, sort * fix lint * requested changes * compile time check * from implementation * requested changes * requested changes * requested changes * requested changes * requested changes * delete Claus from deleg cns config
* most changes * requested change * fix fmt * new ways: delete claus, version_schedule, sort * fix lint * requested changes * compile time check * from implementation * requested changes * requested changes * requested changes * requested changes * requested changes * delete Claus from deleg cns config
Summary of changes
Changes introduced in this pull request:
Reference issue to close (if applicable)
Closes #1579
Other information and links