From e770e42e1fe9dade9f2b4e1b1d23188bb83e4f78 Mon Sep 17 00:00:00 2001 From: Jeb Bearer Date: Tue, 22 Oct 2024 11:57:24 -0700 Subject: [PATCH] Add epoch_height config parameter --- sequencer/api/migrations/V41__epoch_height.sql | 8 ++++++++ sequencer/src/persistence/fs.rs | 6 ++++++ 2 files changed, 14 insertions(+) create mode 100644 sequencer/api/migrations/V41__epoch_height.sql diff --git a/sequencer/api/migrations/V41__epoch_height.sql b/sequencer/api/migrations/V41__epoch_height.sql new file mode 100644 index 0000000000..deb330036d --- /dev/null +++ b/sequencer/api/migrations/V41__epoch_height.sql @@ -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')); diff --git a/sequencer/src/persistence/fs.rs b/sequencer/src/persistence/fs.rs index 9a1a6025bd..452c45b512 100644 --- a/sequencer/src/persistence/fs.rs +++ b/sequencer/src/persistence/fs.rs @@ -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) }