From b1fe1f6073b53ff48224deece24e3c75d4e8d740 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan-=C8=98tefan=20Neac=C8=99u?= Date: Tue, 20 Jul 2021 16:31:55 +0300 Subject: [PATCH 1/7] Update the version to 0.11.0 for non-upgradable crates --- Cargo.lock | 6 +++--- clients/client-core/Cargo.toml | 4 ++-- clients/webassembly/Cargo.toml | 2 +- service-providers/network-requester/Cargo.toml | 2 +- validator-api/Cargo.lock | 2 +- validator-api/Cargo.toml | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8716cf63c9..9ed2e8181a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -349,7 +349,7 @@ dependencies = [ [[package]] name = "client-core" -version = "0.11.0-rc1" +version = "0.11.0" dependencies = [ "config", "crypto", @@ -1703,7 +1703,7 @@ dependencies = [ [[package]] name = "nym-client-wasm" -version = "0.11.0-rc1" +version = "0.11.0" dependencies = [ "console_error_panic_hook", "crypto", @@ -1786,7 +1786,7 @@ dependencies = [ [[package]] name = "nym-network-requester" -version = "0.11.0-rc1" +version = "0.11.0" dependencies = [ "clap", "dirs", diff --git a/clients/client-core/Cargo.toml b/clients/client-core/Cargo.toml index 2efc844575..aadf4318fe 100644 --- a/clients/client-core/Cargo.toml +++ b/clients/client-core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "client-core" -version = "0.11.0-rc1" +version = "0.11.0" authors = ["Dave Hrycyszyn "] edition = "2018" @@ -28,4 +28,4 @@ topology = { path = "../../common/topology" } validator-client = { path = "../../common/client-libs/validator-client" } [dev-dependencies] -tempfile = "3.1.0" \ No newline at end of file +tempfile = "3.1.0" diff --git a/clients/webassembly/Cargo.toml b/clients/webassembly/Cargo.toml index 91def83246..b46c39fb63 100644 --- a/clients/webassembly/Cargo.toml +++ b/clients/webassembly/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "nym-client-wasm" authors = ["Dave Hrycyszyn ", "Jedrzej Stuczynski "] -version = "0.11.0-rc1" +version = "0.11.0" edition = "2018" keywords = ["nym", "sphinx", "wasm", "webassembly", "privacy", "client"] license = "Apache-2.0" diff --git a/service-providers/network-requester/Cargo.toml b/service-providers/network-requester/Cargo.toml index 0342173e4a..b2199a8565 100644 --- a/service-providers/network-requester/Cargo.toml +++ b/service-providers/network-requester/Cargo.toml @@ -3,7 +3,7 @@ [package] name = "nym-network-requester" -version = "0.11.0-rc1" +version = "0.11.0" authors = ["Dave Hrycyszyn ", "Jędrzej Stuczyński "] edition = "2018" diff --git a/validator-api/Cargo.lock b/validator-api/Cargo.lock index ccf826a987..b4947cc83c 100644 --- a/validator-api/Cargo.lock +++ b/validator-api/Cargo.lock @@ -1627,7 +1627,7 @@ dependencies = [ [[package]] name = "nym-validator-api" -version = "0.11.0-rc1" +version = "0.11.0" dependencies = [ "anyhow", "clap", diff --git a/validator-api/Cargo.toml b/validator-api/Cargo.toml index 235e8d3ae1..c58f12fe73 100644 --- a/validator-api/Cargo.toml +++ b/validator-api/Cargo.toml @@ -3,7 +3,7 @@ [package] name = "nym-validator-api" -version = "0.11.0-rc1" +version = "0.11.0" authors = [ "Dave Hrycyszyn ", "Jędrzej Stuczyński ", From fc74b723fa209b8e1719a80cac4edc1cb98c49b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan-=C8=98tefan=20Neac=C8=99u?= Date: Tue, 20 Jul 2021 16:41:49 +0300 Subject: [PATCH 2/7] Fix target version for the current upgrade functions --- clients/native/src/commands/upgrade.rs | 4 ++-- clients/socks5/src/commands/upgrade.rs | 4 ++-- gateway/src/commands/upgrade.rs | 6 ++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/clients/native/src/commands/upgrade.rs b/clients/native/src/commands/upgrade.rs index 4cbcf46a7e..598611ecda 100644 --- a/clients/native/src/commands/upgrade.rs +++ b/clients/native/src/commands/upgrade.rs @@ -253,8 +253,8 @@ fn do_upgrade(mut config: Config, matches: &ArgMatches, package_version: Version config = match config_version.major { 0 => match config_version.minor { - 9 => minor_010_upgrade(config, matches, &config_version, &package_version), - 10 => patch_010_upgrade(config, matches, &config_version, &package_version), + 9 => minor_010_upgrade(config, matches, &config_version, &Version::new(0, 10, 0)), + 10 => patch_010_upgrade(config, matches, &config_version, &Version::new(0, 10, 1)), _ => unsupported_upgrade(config_version, package_version), }, _ => unsupported_upgrade(config_version, package_version), diff --git a/clients/socks5/src/commands/upgrade.rs b/clients/socks5/src/commands/upgrade.rs index c5924953ce..d9a278a0b4 100644 --- a/clients/socks5/src/commands/upgrade.rs +++ b/clients/socks5/src/commands/upgrade.rs @@ -253,8 +253,8 @@ fn do_upgrade(mut config: Config, matches: &ArgMatches, package_version: Version config = match config_version.major { 0 => match config_version.minor { - 9 => minor_010_upgrade(config, matches, &config_version, &package_version), - 10 => patch_010_upgrade(config, matches, &config_version, &package_version), + 9 => minor_010_upgrade(config, matches, &config_version, &Version::new(0, 10, 0)), + 10 => patch_010_upgrade(config, matches, &config_version, &Version::new(0, 10, 1)), _ => unsupported_upgrade(config_version, package_version), }, _ => unsupported_upgrade(config_version, package_version), diff --git a/gateway/src/commands/upgrade.rs b/gateway/src/commands/upgrade.rs index 4968272e1b..91ffa06442 100644 --- a/gateway/src/commands/upgrade.rs +++ b/gateway/src/commands/upgrade.rs @@ -300,9 +300,11 @@ fn do_upgrade(mut config: Config, matches: &ArgMatches, package_version: Version config = match config_version.major { 0 => match config_version.minor { - 9 => minor_010_upgrade(config, matches, &config_version, &package_version), + 9 => minor_010_upgrade(config, matches, &config_version, &Version::new(0, 10, 0)), 10 => match config_version.patch { - 0 => patch_010_upgrade(config, matches, &config_version, &package_version), + 0 => { + patch_010_upgrade(config, matches, &config_version, &Version::new(0, 10, 1)) + } _ => undetermined_version_upgrade( config, matches, From b6a026da830b287373af7ce43422de77a6fb649a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan-=C8=98tefan=20Neac=C8=99u?= Date: Tue, 20 Jul 2021 17:39:05 +0300 Subject: [PATCH 3/7] Upgrade native client --- Cargo.lock | 2 +- clients/native/Cargo.toml | 4 +- clients/native/src/commands/upgrade.rs | 53 +++++++++++++++++++++++++- 3 files changed, 55 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9ed2e8181a..65039918be 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1673,7 +1673,7 @@ dependencies = [ [[package]] name = "nym-client" -version = "0.11.0-rc1" +version = "0.11.0" dependencies = [ "clap", "client-core", diff --git a/clients/native/Cargo.toml b/clients/native/Cargo.toml index 73e0ce6001..8540ae7bcb 100644 --- a/clients/native/Cargo.toml +++ b/clients/native/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nym-client" -version = "0.11.0-rc1" +version = "0.11.0" authors = ["Dave Hrycyszyn ", "Jędrzej Stuczyński "] edition = "2018" @@ -43,4 +43,4 @@ validator-client = { path = "../../common/client-libs/validator-client" } version-checker = { path = "../../common/version-checker" } [dev-dependencies] -serde_json = "1.0" # for the "textsend" example \ No newline at end of file +serde_json = "1.0" # for the "textsend" example diff --git a/clients/native/src/commands/upgrade.rs b/clients/native/src/commands/upgrade.rs index 598611ecda..99966838fa 100644 --- a/clients/native/src/commands/upgrade.rs +++ b/clients/native/src/commands/upgrade.rs @@ -242,6 +242,50 @@ fn patch_010_upgrade( config } +fn minor_011_upgrade( + mut config: Config, + _matches: &ArgMatches, + config_version: &Version, + package_version: &Version, +) -> Config { + let to_version = package_version; + + print_start_upgrade(&config_version, &to_version); + + println!( + "Setting mixnet contract address to {}", + DEFAULT_MIXNET_CONTRACT_ADDRESS + ); + + config + .get_base_mut() + .set_mixnet_contract(DEFAULT_MIXNET_CONTRACT_ADDRESS); + + // The default validator endpoint changed + println!( + "Setting validator REST endpoint to {:?}", + default_validator_rest_endpoints() + ); + + config + .get_base_mut() + .set_custom_validators(default_validator_rest_endpoints()); + + config + .get_base_mut() + .set_custom_version(to_version.to_string().as_ref()); + + config.save_to_file(None).unwrap_or_else(|err| { + eprintln!("failed to overwrite config file! - {:?}", err); + print_failed_upgrade(&config_version, &to_version); + process::exit(1); + }); + + print_successful_upgrade(config_version, to_version); + + config +} + fn do_upgrade(mut config: Config, matches: &ArgMatches, package_version: Version) { loop { let config_version = parse_config_version(&config); @@ -254,7 +298,14 @@ fn do_upgrade(mut config: Config, matches: &ArgMatches, package_version: Version config = match config_version.major { 0 => match config_version.minor { 9 => minor_010_upgrade(config, matches, &config_version, &Version::new(0, 10, 0)), - 10 => patch_010_upgrade(config, matches, &config_version, &Version::new(0, 10, 1)), + 10 => match config_version.patch { + 0 => { + patch_010_upgrade(config, matches, &config_version, &Version::new(0, 10, 1)) + } + _ => { + minor_011_upgrade(config, matches, &config_version, &Version::new(0, 11, 0)) + } + }, _ => unsupported_upgrade(config_version, package_version), }, _ => unsupported_upgrade(config_version, package_version), From afbed0e43847d2714a4775f749d95c67ed1219f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan-=C8=98tefan=20Neac=C8=99u?= Date: Tue, 20 Jul 2021 17:59:59 +0300 Subject: [PATCH 4/7] Upgrade socks5 client --- Cargo.lock | 2 +- clients/socks5/Cargo.toml | 2 +- clients/socks5/src/commands/upgrade.rs | 53 +++++++++++++++++++++++++- 3 files changed, 54 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 65039918be..9202c228c8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1807,7 +1807,7 @@ dependencies = [ [[package]] name = "nym-socks5-client" -version = "0.11.0-rc1" +version = "0.11.0" dependencies = [ "clap", "client-core", diff --git a/clients/socks5/Cargo.toml b/clients/socks5/Cargo.toml index 9eb32f50aa..df6f26f71b 100644 --- a/clients/socks5/Cargo.toml +++ b/clients/socks5/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nym-socks5-client" -version = "0.11.0-rc1" +version = "0.11.0" authors = ["Dave Hrycyszyn "] edition = "2018" diff --git a/clients/socks5/src/commands/upgrade.rs b/clients/socks5/src/commands/upgrade.rs index d9a278a0b4..83fd82b521 100644 --- a/clients/socks5/src/commands/upgrade.rs +++ b/clients/socks5/src/commands/upgrade.rs @@ -242,6 +242,50 @@ fn patch_010_upgrade( config } +fn minor_011_upgrade( + mut config: Config, + _matches: &ArgMatches, + config_version: &Version, + package_version: &Version, +) -> Config { + let to_version = package_version; + + print_start_upgrade(&config_version, &to_version); + + println!( + "Setting mixnet contract address to {}", + DEFAULT_MIXNET_CONTRACT_ADDRESS + ); + + config + .get_base_mut() + .set_mixnet_contract(DEFAULT_MIXNET_CONTRACT_ADDRESS); + + // The default validator endpoint changed + println!( + "Setting validator REST endpoint to {:?}", + default_validator_rest_endpoints() + ); + + config + .get_base_mut() + .set_custom_validators(default_validator_rest_endpoints()); + + config + .get_base_mut() + .set_custom_version(to_version.to_string().as_ref()); + + config.save_to_file(None).unwrap_or_else(|err| { + eprintln!("failed to overwrite config file! - {:?}", err); + print_failed_upgrade(&config_version, &to_version); + process::exit(1); + }); + + print_successful_upgrade(config_version, to_version); + + config +} + fn do_upgrade(mut config: Config, matches: &ArgMatches, package_version: Version) { loop { let config_version = parse_config_version(&config); @@ -254,7 +298,14 @@ fn do_upgrade(mut config: Config, matches: &ArgMatches, package_version: Version config = match config_version.major { 0 => match config_version.minor { 9 => minor_010_upgrade(config, matches, &config_version, &Version::new(0, 10, 0)), - 10 => patch_010_upgrade(config, matches, &config_version, &Version::new(0, 10, 1)), + 10 => match config_version.patch { + 0 => { + patch_010_upgrade(config, matches, &config_version, &Version::new(0, 10, 1)) + } + _ => { + minor_011_upgrade(config, matches, &config_version, &Version::new(0, 11, 0)) + } + }, _ => unsupported_upgrade(config_version, package_version), }, _ => unsupported_upgrade(config_version, package_version), From 87270384433ba3d004f43e8a5c786aceb01137f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan-=C8=98tefan=20Neac=C8=99u?= Date: Wed, 21 Jul 2021 11:07:43 +0300 Subject: [PATCH 5/7] Upgrade mixnode --- Cargo.lock | 2 +- mixnode/Cargo.toml | 2 +- mixnode/src/commands/upgrade.rs | 43 +++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9202c228c8..7c300a56e1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1754,7 +1754,7 @@ dependencies = [ [[package]] name = "nym-mixnode" -version = "0.11.0-rc1" +version = "0.11.0" dependencies = [ "bs58 0.4.0", "clap", diff --git a/mixnode/Cargo.toml b/mixnode/Cargo.toml index 1539ce6b93..3f12e93ce1 100644 --- a/mixnode/Cargo.toml +++ b/mixnode/Cargo.toml @@ -3,7 +3,7 @@ [package] name = "nym-mixnode" -version = "0.11.0-rc1" +version = "0.11.0" authors = [ "Dave Hrycyszyn ", "Jędrzej Stuczyński ", diff --git a/mixnode/src/commands/upgrade.rs b/mixnode/src/commands/upgrade.rs index 4174dd038a..bb6751e7a6 100644 --- a/mixnode/src/commands/upgrade.rs +++ b/mixnode/src/commands/upgrade.rs @@ -263,6 +263,43 @@ fn patch_0_10_1_upgrade( Ok(upgraded_config) } +fn minor_0_11_upgrade( + config: Config, + _matches: &ArgMatches, + config_version: &Version, + package_version: &Version, +) -> Result { + let to_version = package_version; + + print_start_upgrade(&config_version, &to_version); + + println!( + "Setting validator REST endpoint to {:?}", + default_validator_rest_endpoints() + ); + + println!( + "Setting mixnet contract address to {}", + DEFAULT_MIXNET_CONTRACT_ADDRESS + ); + + let upgraded_config = config + .with_custom_version(to_version.to_string().as_ref()) + .with_custom_validators(default_validator_rest_endpoints()) + .with_custom_mixnet_contract(DEFAULT_MIXNET_CONTRACT_ADDRESS); + + upgraded_config.save_to_file(None).map_err(|err| { + ( + to_version.clone(), + format!("failed to overwrite config file! - {:?}", err), + ) + })?; + + print_successful_upgrade(config_version, to_version); + + Ok(upgraded_config) +} + // TODO: to be renamed once the release version is decided (so presumably either 0.10.2 or 0.11.0) fn undetermined_version_upgrade( config: Config, @@ -382,6 +419,12 @@ fn do_upgrade(mut config: Config, matches: &ArgMatches, package_version: Version &config_version, &Version::new(0, 10, 1), ), + 1 => minor_0_11_upgrade( + config, + matches, + &config_version, + &Version::new(0, 11, 0), + ), _ => undetermined_version_upgrade( config, matches, From ce038bf56ab4cd44e5729595e2523460785758e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan-=C8=98tefan=20Neac=C8=99u?= Date: Wed, 21 Jul 2021 12:35:45 +0300 Subject: [PATCH 6/7] Upgrade gateway --- Cargo.lock | 2 +- gateway/Cargo.toml | 2 +- gateway/src/commands/upgrade.rs | 38 +++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7c300a56e1..30b973c71d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1724,7 +1724,7 @@ dependencies = [ [[package]] name = "nym-gateway" -version = "0.11.0-rc1" +version = "0.11.0" dependencies = [ "clap", "config", diff --git a/gateway/Cargo.toml b/gateway/Cargo.toml index a143dee420..621372c085 100644 --- a/gateway/Cargo.toml +++ b/gateway/Cargo.toml @@ -3,7 +3,7 @@ [package] name = "nym-gateway" -version = "0.11.0-rc1" +version = "0.11.0" authors = ["Dave Hrycyszyn ", "Jędrzej Stuczyński "] edition = "2018" diff --git a/gateway/src/commands/upgrade.rs b/gateway/src/commands/upgrade.rs index 91ffa06442..259b498dc7 100644 --- a/gateway/src/commands/upgrade.rs +++ b/gateway/src/commands/upgrade.rs @@ -238,6 +238,41 @@ fn patch_010_upgrade( upgraded_config } +fn minor_011_upgrade( + config: Config, + _matches: &ArgMatches, + config_version: &Version, + package_version: &Version, +) -> Config { + let to_version = package_version; + + print_start_upgrade(&config_version, &to_version); + + println!( + "Setting validator REST endpoint to {:?}", + default_validator_rest_endpoints() + ); + + println!( + "Setting mixnet contract address to {}", + DEFAULT_MIXNET_CONTRACT_ADDRESS + ); + + let upgraded_config = config + .with_custom_version(to_version.to_string().as_ref()) + .with_custom_validators(default_validator_rest_endpoints()) + .with_custom_mixnet_contract(DEFAULT_MIXNET_CONTRACT_ADDRESS); + + upgraded_config.save_to_file(None).unwrap_or_else(|err| { + eprintln!("failed to overwrite config file! - {:?}", err); + fail_upgrade(&config_version, &to_version) + }); + + print_successful_upgrade(config_version, to_version); + + upgraded_config +} + // TODO: to be renamed once the release version is decided (so presumably either 0.10.2 or 0.11.0) fn undetermined_version_upgrade( config: Config, @@ -305,6 +340,9 @@ fn do_upgrade(mut config: Config, matches: &ArgMatches, package_version: Version 0 => { patch_010_upgrade(config, matches, &config_version, &Version::new(0, 10, 1)) } + 1 => { + minor_011_upgrade(config, matches, &config_version, &Version::new(0, 11, 0)) + } _ => undetermined_version_upgrade( config, matches, From 1c335d3172cbda870b8898e1d5f37ff6c633fb14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Wed, 21 Jul 2021 14:16:36 +0100 Subject: [PATCH 7/7] Merged upgrade commands --- gateway/src/commands/upgrade.rs | 70 ++++++++-------------------- mixnode/src/commands/upgrade.rs | 81 ++++++++++----------------------- 2 files changed, 43 insertions(+), 108 deletions(-) diff --git a/gateway/src/commands/upgrade.rs b/gateway/src/commands/upgrade.rs index 259b498dc7..f6777cd201 100644 --- a/gateway/src/commands/upgrade.rs +++ b/gateway/src/commands/upgrade.rs @@ -239,54 +239,16 @@ fn patch_010_upgrade( } fn minor_011_upgrade( - config: Config, - _matches: &ArgMatches, - config_version: &Version, - package_version: &Version, -) -> Config { - let to_version = package_version; - - print_start_upgrade(&config_version, &to_version); - - println!( - "Setting validator REST endpoint to {:?}", - default_validator_rest_endpoints() - ); - - println!( - "Setting mixnet contract address to {}", - DEFAULT_MIXNET_CONTRACT_ADDRESS - ); - - let upgraded_config = config - .with_custom_version(to_version.to_string().as_ref()) - .with_custom_validators(default_validator_rest_endpoints()) - .with_custom_mixnet_contract(DEFAULT_MIXNET_CONTRACT_ADDRESS); - - upgraded_config.save_to_file(None).unwrap_or_else(|err| { - eprintln!("failed to overwrite config file! - {:?}", err); - fail_upgrade(&config_version, &to_version) - }); - - print_successful_upgrade(config_version, to_version); - - upgraded_config -} - -// TODO: to be renamed once the release version is decided (so presumably either 0.10.2 or 0.11.0) -fn undetermined_version_upgrade( config: Config, matches: &ArgMatches, config_version: &Version, package_version: &Version, ) -> Config { - // If we decide this version should be tagged with 0.11.0, then the following code will be used instead: - // let to_version = if package_version.major == 0 && package_version.minor == 11 { - // package_version.clone() - // } else { - // Version::new(0, 11, 0) - // }; - let to_version = package_version; + let to_version = if package_version.major == 0 && package_version.minor == 11 { + package_version.clone() + } else { + Version::new(0, 11, 0) + }; print_start_upgrade(&config_version, &to_version); @@ -309,10 +271,22 @@ fn undetermined_version_upgrade( listening_address.to_string() }; + println!( + "Setting validator REST endpoint to {:?}", + default_validator_rest_endpoints() + ); + + println!( + "Setting mixnet contract address to {}", + DEFAULT_MIXNET_CONTRACT_ADDRESS + ); + let upgraded_config = config .with_custom_version(to_version.to_string().as_ref()) .with_listening_address(listening_address) - .with_announce_address(announce_address); + .with_announce_address(announce_address) + .with_custom_validators(default_validator_rest_endpoints()) + .with_custom_mixnet_contract(DEFAULT_MIXNET_CONTRACT_ADDRESS); upgraded_config.save_to_file(None).unwrap_or_else(|err| { eprintln!("failed to overwrite config file! - {:?}", err); @@ -340,15 +314,9 @@ fn do_upgrade(mut config: Config, matches: &ArgMatches, package_version: Version 0 => { patch_010_upgrade(config, matches, &config_version, &Version::new(0, 10, 1)) } - 1 => { + _ => { minor_011_upgrade(config, matches, &config_version, &Version::new(0, 11, 0)) } - _ => undetermined_version_upgrade( - config, - matches, - &config_version, - &package_version, - ), }, _ => unsupported_upgrade(config_version, package_version), }, diff --git a/mixnode/src/commands/upgrade.rs b/mixnode/src/commands/upgrade.rs index bb6751e7a6..359d486a42 100644 --- a/mixnode/src/commands/upgrade.rs +++ b/mixnode/src/commands/upgrade.rs @@ -269,51 +269,12 @@ fn minor_0_11_upgrade( config_version: &Version, package_version: &Version, ) -> Result { - let to_version = package_version; + let to_version = if package_version.major == 0 && package_version.minor == 11 { + package_version.clone() + } else { + Version::new(0, 11, 0) + }; - print_start_upgrade(&config_version, &to_version); - - println!( - "Setting validator REST endpoint to {:?}", - default_validator_rest_endpoints() - ); - - println!( - "Setting mixnet contract address to {}", - DEFAULT_MIXNET_CONTRACT_ADDRESS - ); - - let upgraded_config = config - .with_custom_version(to_version.to_string().as_ref()) - .with_custom_validators(default_validator_rest_endpoints()) - .with_custom_mixnet_contract(DEFAULT_MIXNET_CONTRACT_ADDRESS); - - upgraded_config.save_to_file(None).map_err(|err| { - ( - to_version.clone(), - format!("failed to overwrite config file! - {:?}", err), - ) - })?; - - print_successful_upgrade(config_version, to_version); - - Ok(upgraded_config) -} - -// TODO: to be renamed once the release version is decided (so presumably either 0.10.2 or 0.11.0) -fn undetermined_version_upgrade( - config: Config, - _matches: &ArgMatches, - config_version: &Version, - package_version: &Version, -) -> Result { - // If we decide this version should be tagged with 0.11.0, then the following code will be used instead: - // let to_version = if package_version.major == 0 && package_version.minor == 11 { - // package_version.clone() - // } else { - // Version::new(0, 11, 0) - // }; - let to_version = package_version; let id = config.get_id(); let config_path = Config::default_config_directory(Some(&id)); @@ -326,6 +287,7 @@ fn undetermined_version_upgrade( print_start_upgrade(&config_version, &to_version); + // description action let description_file_path: PathBuf = [config_path.to_str().unwrap(), DESCRIPTION_FILE] .iter() .collect(); @@ -363,7 +325,7 @@ fn undetermined_version_upgrade( let announce_split = current_annnounce_addr.split(':').collect::>(); if announce_split.len() != 2 { return Err(( - to_version.clone(), + to_version, "failed to correctly parse current announce host".to_string(), )); } @@ -374,10 +336,22 @@ fn undetermined_version_upgrade( } }; + println!( + "Setting validator REST endpoint to {:?}", + default_validator_rest_endpoints() + ); + + println!( + "Setting mixnet contract address to {}", + DEFAULT_MIXNET_CONTRACT_ADDRESS + ); + let upgraded_config = config .with_custom_version(to_version.to_string().as_ref()) .with_announce_address(announce_address) - .with_mix_port(custom_mix_port); + .with_mix_port(custom_mix_port) + .with_custom_validators(default_validator_rest_endpoints()) + .with_custom_mixnet_contract(DEFAULT_MIXNET_CONTRACT_ADDRESS); if let Some(new_description) = new_description { NodeDescription::save_to_file(&new_description, description_file_path).map_err(|err| { @@ -419,18 +393,12 @@ fn do_upgrade(mut config: Config, matches: &ArgMatches, package_version: Version &config_version, &Version::new(0, 10, 1), ), - 1 => minor_0_11_upgrade( + _ => minor_0_11_upgrade( config, matches, &config_version, &Version::new(0, 11, 0), ), - _ => undetermined_version_upgrade( - config, - matches, - &config_version, - &package_version, - ), }, _ => unsupported_upgrade(config_version, package_version), }, @@ -489,9 +457,8 @@ mod upgrade_tests { let matches = ArgMatches::default(); let old_version = Version::new(0, 10, 1); let new_version = Version::new(0, 10, 2); - let new_config = - undetermined_version_upgrade(config, &matches, &old_version, &new_version).unwrap(); - assert_eq!(new_config.get_version(), "0.10.2"); + let new_config = minor_0_11_upgrade(config, &matches, &old_version, &new_version).unwrap(); + assert_eq!(new_config.get_version(), "0.11.0"); } #[test] @@ -510,7 +477,7 @@ mod upgrade_tests { let mut new_perms = initial_perms.clone(); new_perms.set_readonly(true); fs::set_permissions(config_file.clone(), new_perms).unwrap(); - let ret = undetermined_version_upgrade(config, &matches, &old_version, &new_version); + let ret = minor_0_11_upgrade(config, &matches, &old_version, &new_version); fs::set_permissions(config_file, initial_perms).unwrap(); assert!(ret.is_err()); }