Skip to content

Commit

Permalink
Add epoch_height config parameter (#2200)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbearer authored Oct 22, 2024
1 parent 36cf092 commit 977baee
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
8 changes: 8 additions & 0 deletions sequencer/api/migrations/V41__epoch_height.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- HotShotConfig was upgraded to include an `epoch_height` parameter. This migration initializes it
-- with a default. We use the `||` operator to merge two JSON objects, one containing the default
-- value for the new config parameter and one containing the existing config. When keys are present
-- in both, the rightmost operand (the existing config) will take precedence.
UPDATE network_config SET
config = jsonb_set(config, '{config}', '{
"epoch_height": 0
}' || (config->'config'));
18 changes: 14 additions & 4 deletions sequencer/src/persistence/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,12 @@ fn migrate_network_config(
config.insert("stop_voting_time".into(), 0.into());
}

// HotShotConfig was upgraded to include an `epoch_height` parameter. Initialize with a default
// if missing.
if !config.contains_key("epoch_height") {
config.insert("epoch_height".into(), 0.into());
}

Ok(network_config)
}

Expand Down Expand Up @@ -870,7 +876,8 @@ mod test {
"start_proposing_time": 1,
"stop_proposing_time": 2,
"start_voting_time": 1,
"stop_voting_time": 2
"stop_voting_time": 2,
"epoch_height": 0
}
});

Expand All @@ -889,7 +896,8 @@ mod test {
"start_proposing_time": 1,
"stop_proposing_time": 2,
"start_voting_time": 1,
"stop_voting_time": 2
"stop_voting_time": 2,
"epoch_height": 0
}
});

Expand All @@ -913,7 +921,8 @@ mod test {
"start_proposing_time": 9007199254740991u64,
"stop_proposing_time": 0,
"start_voting_time": 9007199254740991u64,
"stop_voting_time": 0
"stop_voting_time": 0,
"epoch_height": 0
}
});

Expand All @@ -932,7 +941,8 @@ mod test {
"start_proposing_time": 1,
"stop_proposing_time": 2,
"start_voting_time": 1,
"stop_voting_time": 2
"stop_voting_time": 2,
"epoch_height": 0
}
});

Expand Down

0 comments on commit 977baee

Please sign in to comment.