Skip to content

Commit

Permalink
Add determinism arg to upload TX (#870)
Browse files Browse the repository at this point in the history
* add determinism arg to upload tx

* apply clippy suggestions
  • Loading branch information
German authored Dec 19, 2022
1 parent 9c75784 commit 278ff4b
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 9 deletions.
6 changes: 3 additions & 3 deletions crates/build/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ fn build_code_only(manifest_path: &ManifestPath) -> Result<()> {

// we specified that debug symbols should be removed
// original code should have some but the optimized version should have them removed
assert!(!has_debug_symbols(&res.dest_wasm.unwrap()));
assert!(!has_debug_symbols(res.dest_wasm.unwrap()));

Ok(())
}
Expand Down Expand Up @@ -341,7 +341,7 @@ fn keep_debug_symbols_in_debug_mode(manifest_path: &ManifestPath) -> Result<()>
let res = super::execute(args).expect("build failed");

// we specified that debug symbols should be kept
assert!(has_debug_symbols(&res.dest_wasm.unwrap()));
assert!(has_debug_symbols(res.dest_wasm.unwrap()));

Ok(())
}
Expand All @@ -359,7 +359,7 @@ fn keep_debug_symbols_in_release_mode(manifest_path: &ManifestPath) -> Result<()
let res = super::execute(args).expect("build failed");

// we specified that debug symbols should be kept
assert!(has_debug_symbols(&res.dest_wasm.unwrap()));
assert!(has_debug_symbols(res.dest_wasm.unwrap()));

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion crates/build/src/util/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub fn create_executable(path: &Path, content: &str) -> MockGuard {
}
pathes
};
env::set_var("PATH", env::join_paths(&env_paths).unwrap());
env::set_var("PATH", env::join_paths(env_paths).unwrap());
guard
}

Expand Down
Binary file not shown.
12 changes: 9 additions & 3 deletions crates/cargo-contract/src/cmd/extrinsics/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ use subxt::{
OnlineClient,
};

use super::runtime_api::api::runtime_types::pallet_contracts::wasm::Determinism;

#[derive(Debug, clap::Args)]
#[clap(name = "upload", about = "Upload a contract's code")]
pub struct UploadCommand {
Expand Down Expand Up @@ -161,6 +163,7 @@ impl UploadCommand {
origin: signer.account_id().clone(),
code,
storage_deposit_limit,
determinism: Determinism::Deterministic,
};
state_call(&url, "ContractsApi_upload_code", call_request).await
}
Expand All @@ -175,9 +178,11 @@ impl UploadCommand {
let token_metadata = TokenMetadata::query(client).await?;
let storage_deposit_limit =
self.extrinsic_opts.storage_deposit_limit(&token_metadata)?;
let call = super::runtime_api::api::tx()
.contracts()
.upload_code(code, storage_deposit_limit);
let call = super::runtime_api::api::tx().contracts().upload_code(
code,
storage_deposit_limit,
Determinism::Deterministic,
);

let result = submit_extrinsic(client, &call, signer).await?;
let display_events =
Expand All @@ -202,6 +207,7 @@ pub struct CodeUploadRequest {
origin: <DefaultConfig as Config>::AccountId,
code: Vec<u8>,
storage_deposit_limit: Option<Balance>,
determinism: Determinism,
}

#[derive(serde::Serialize)]
Expand Down
2 changes: 1 addition & 1 deletion crates/cargo-contract/tests/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ fn decode_works() {
let project_dir = tmp_dir.path().to_path_buf().join("switcher");

let lib = project_dir.join("lib.rs");
std::fs::write(&lib, contract).expect("Failed to write contract lib.rs");
std::fs::write(lib, contract).expect("Failed to write contract lib.rs");

tracing::debug!("Building contract in {}", project_dir.to_string_lossy());
cargo_contract(&project_dir).arg("build").assert().success();
Expand Down
2 changes: 1 addition & 1 deletion crates/transcode/src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl<'a> Decoder<'a> {
})?;

let mut elems = Vec::new();
while elems.len() < len as usize {
while elems.len() < len {
let elem = self.decode_type(type_id, ty, input)?;
elems.push(elem)
}
Expand Down

0 comments on commit 278ff4b

Please sign in to comment.