From 83df216e4f227359e2e861c0a8a6671352e60de4 Mon Sep 17 00:00:00 2001 From: Kaya Gokalp Date: Thu, 6 Jul 2023 15:26:30 +0300 Subject: [PATCH 1/2] feat: make random salt default for forc-deploy, remove --random-salt flag and add --default-salt flag for ci --- forc-plugins/forc-client/src/cmd/deploy.rs | 6 +++--- forc-plugins/forc-client/src/op/deploy.rs | 8 ++++---- test/src/e2e_vm_tests/harness.rs | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/forc-plugins/forc-client/src/cmd/deploy.rs b/forc-plugins/forc-client/src/cmd/deploy.rs index 65835fa0e6e..64e25025a2c 100644 --- a/forc-plugins/forc-client/src/cmd/deploy.rs +++ b/forc-plugins/forc-client/src/cmd/deploy.rs @@ -29,10 +29,10 @@ pub struct Command { /// --salt contract_b:0x0000000000000000000000000000000000000000000000000000000000000002 #[clap(long)] pub salt: Option>, - /// Generate a random salt for the contract. - /// Useful for testing or deploying examples to a shared network. + /// Generate a defualt salt (0x0000000000000000000000000000000000000000000000000000000000000000) for the contract. + /// Useful for CI, to create reproducable deployments. #[clap(long)] - pub random_salt: bool, + pub default_salt: bool, #[clap(flatten)] pub build_output: BuildOutput, #[clap(flatten)] diff --git a/forc-plugins/forc-client/src/op/deploy.rs b/forc-plugins/forc-client/src/op/deploy.rs index 4c30446ce24..bbf6cd64e00 100644 --- a/forc-plugins/forc-client/src/op/deploy.rs +++ b/forc-plugins/forc-client/src/op/deploy.rs @@ -131,7 +131,7 @@ pub async fn deploy(command: cmd::Deploy) -> Result> { .check_program_type(vec![TreeType::Contract]) .is_ok() { - let salt = match (&contract_salt_map, command.random_salt) { + let salt = match (&contract_salt_map, command.default_salt) { (Some(map), false) => { if let Some(salt) = map.get(pkg.descriptor.manifest_file.project_name()) { *salt @@ -139,10 +139,10 @@ pub async fn deploy(command: cmd::Deploy) -> Result> { Default::default() } } - (None, true) => rand::random(), - (None, false) => Default::default(), + (None, true) => Default::default(), + (None, false) => rand::random(), (Some(_), true) => { - bail!("Both `--salt` and `--random-salt` were specified: must choose one") + bail!("Both `--salt` and `--default-salt` were specified: must choose one") } }; let contract_id = diff --git a/test/src/e2e_vm_tests/harness.rs b/test/src/e2e_vm_tests/harness.rs index c4e796cf48c..8dd14020ff1 100644 --- a/test/src/e2e_vm_tests/harness.rs +++ b/test/src/e2e_vm_tests/harness.rs @@ -72,6 +72,7 @@ pub(crate) async fn deploy_contract(file_name: &str, run_config: &RunConfig) -> ..Default::default() }, signing_key: Some(SecretKey::from_str(SECRET_KEY).unwrap()), + default_salt: true, ..Default::default() }) .await From 3f61feefa97f9bc834c27caee36f8ee182075203 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kaya=20G=C3=B6kalp?= Date: Thu, 6 Jul 2023 16:55:37 +0300 Subject: [PATCH 2/2] Update forc-plugins/forc-client/src/cmd/deploy.rs Co-authored-by: Joshua Batty --- forc-plugins/forc-client/src/cmd/deploy.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forc-plugins/forc-client/src/cmd/deploy.rs b/forc-plugins/forc-client/src/cmd/deploy.rs index 64e25025a2c..8313b466675 100644 --- a/forc-plugins/forc-client/src/cmd/deploy.rs +++ b/forc-plugins/forc-client/src/cmd/deploy.rs @@ -29,7 +29,7 @@ pub struct Command { /// --salt contract_b:0x0000000000000000000000000000000000000000000000000000000000000002 #[clap(long)] pub salt: Option>, - /// Generate a defualt salt (0x0000000000000000000000000000000000000000000000000000000000000000) for the contract. + /// Generate a default salt (0x0000000000000000000000000000000000000000000000000000000000000000) for the contract. /// Useful for CI, to create reproducable deployments. #[clap(long)] pub default_salt: bool,