Skip to content

Commit

Permalink
chore: remove unrequired settings migration (#4193)
Browse files Browse the repository at this point in the history
  • Loading branch information
kylezs authored Nov 2, 2023
1 parent 06f3184 commit c34f6f7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 216 deletions.
1 change: 0 additions & 1 deletion engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ pub mod multisig;
pub mod p2p;
pub mod retrier;
pub mod settings;
pub mod settings_migrate;
pub mod state_chain_observer;
pub mod stream_utils;
pub mod witness;
Expand Down
49 changes: 4 additions & 45 deletions engine/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use chainflip_engine::{
eth::retry_rpc::EthersRetryRpcClient,
health, p2p,
settings::{CommandLineOptions, Settings, DEFAULT_SETTINGS_DIR},
settings_migrate::migrate_settings0_9_3_to_0_10_0,
state_chain_observer::{
self,
client::{
Expand All @@ -22,7 +21,6 @@ use clap::Parser;
use futures::FutureExt;
use multisig::{self, bitcoin::BtcSigning, eth::EthSigning, polkadot::PolkadotSigning};
use std::{
path::PathBuf,
sync::{atomic::AtomicBool, Arc},
time::Duration,
};
Expand Down Expand Up @@ -108,29 +106,18 @@ async fn main() -> anyhow::Result<()> {

let opts = CommandLineOptions::parse();

let config_root_path = PathBuf::from(&opts.config_root);

// the settings directory from opts.config_root that we'll use to read the settings file
let migrated_settings_dir = migrate_settings0_9_3_to_0_10_0(opts.config_root.clone())?;

let settings = Settings::new_with_settings_dir(
migrated_settings_dir.unwrap_or(DEFAULT_SETTINGS_DIR),
opts,
)
.context("Error reading settings")?;
let settings = Settings::new_with_settings_dir(DEFAULT_SETTINGS_DIR, opts)
.context("Error reading settings")?;

// Note: the greeting should only be printed in normal mode (i.e. not for short-lived commands
// like `--version`), so we execute it only after the settings have been parsed.
utilities::print_start_and_end!(async run_main(settings, config_root_path, migrated_settings_dir));
utilities::print_start_and_end!(async run_main(settings));

Ok(())
}

async fn run_main(
settings: Settings,
config_root_path: PathBuf,
migrated_settings_dir: Option<&str>,
) -> anyhow::Result<()> {
async fn run_main(settings: Settings) -> anyhow::Result<()> {
task_scope(|scope| {
async move {
let mut start_logger_server_fn =
Expand Down Expand Up @@ -158,34 +145,6 @@ async fn run_main(
// Wait until SCC has started, to ensure old engine has stopped
start_logger_server_fn.take().expect("only called once")(scope);

if *CFE_VERSION == (SemVer { major: 0, minor: 10, patch: 0 })
{
if let Some(migrated_settings_dir) = migrated_settings_dir {
// Back up the old settings.
std::fs::copy(
config_root_path.join(DEFAULT_SETTINGS_DIR).join("Settings.toml"),
config_root_path.join(DEFAULT_SETTINGS_DIR).join("Settings.backup-0.9.3.toml"),
)
.context("Unable to back up old settings. Please ensure the chainflip-engine has write permissions in the config directories.")?;

// Replace with the migrated settings.
std::fs::rename(
config_root_path.join(migrated_settings_dir).join("Settings.toml"),
config_root_path.join(DEFAULT_SETTINGS_DIR).join("Settings.toml"),
)
.context("Unable to replace old settings with migrated settings. Please ensure the chainflip-engine has write permissions in the config directories.")?;

// Remove the migration dir.
std::fs::remove_dir_all(config_root_path.join(migrated_settings_dir))
.unwrap_or_else(|e| {
tracing::warn!(
"Unable to remove migration dir: {e:?}. Please remove it manually.",
e = e
)
});
}
}

if let Some(health_check_settings) = &settings.health_check {
health::start(scope, health_check_settings, has_completed_initialising.clone())
.await?;
Expand Down
170 changes: 0 additions & 170 deletions engine/src/settings_migrate.rs

This file was deleted.

0 comments on commit c34f6f7

Please sign in to comment.