Skip to content

Commit

Permalink
add check for propose view/time
Browse files Browse the repository at this point in the history
  • Loading branch information
imabdulbasit committed Jul 12, 2024
1 parent 324719b commit b9c123d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions sequencer/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ mod upgrade_serialization {
))
}
(None, Some(v)) => {
if v.start_proposing_view < v.stop_proposing_view {
return Err(de::Error::custom(
"start_proposing_view is less than stop_proposing_view",
));
}

map.insert(
version,
Upgrade {
Expand All @@ -149,6 +155,14 @@ mod upgrade_serialization {
);
}
(Some(t), None) => {
if t.start_proposing_time.unix_timestamp()
< t.stop_proposing_time.unix_timestamp()
{
return Err(de::Error::custom(
"start_proposing_time is less than stop_proposing_time",
));
}

map.insert(
version,
Upgrade {
Expand Down
2 changes: 1 addition & 1 deletion types/src/v0/v0_1/instance_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl Upgrade {
config.start_proposing_time = t.start_proposing_time.unix_timestamp();
config.stop_proposing_time = t.stop_proposing_time.unix_timestamp();
config.start_voting_time = t.start_voting_time.unwrap_or_default().unix_timestamp();
// this should not panmic because Timestamp::max() constructs the maximum possible Unix timestamp
// this should not panic because Timestamp::max() constructs the maximum possible Unix timestamp
// using i64::MAX
config.stop_voting_time = t
.stop_voting_time
Expand Down

0 comments on commit b9c123d

Please sign in to comment.