From 890ee8a64c0fd74a9a129a3f637f5e3e5096b543 Mon Sep 17 00:00:00 2001 From: Byron Hambly Date: Wed, 26 Jan 2022 23:10:26 +0200 Subject: [PATCH 1/9] feat: compile on stable rust --- .github/workflows/ci.yml | 4 ++-- applications/tari_collectibles/src-tauri/src/main.rs | 1 - base_layer/key_manager/Cargo.toml | 3 ++- base_layer/key_manager/src/lib.rs | 1 + comms/dht/src/lib.rs | 1 - comms/dht/src/store_forward/local_state.rs | 8 ++++---- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ef6183d199..7e710ed55c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ name: CI env: CARGO_HTTP_MULTIPLEXING: false PROTOC: protoc - toolchain: nightly-2021-11-20 + toolchain: stable jobs: clippy: @@ -61,7 +61,7 @@ jobs: - name: Compile NPM run: | cd applications/launchpad/gui-vue - npm install + npm ci npm run build - name: toolchain uses: actions-rs/toolchain@v1 diff --git a/applications/tari_collectibles/src-tauri/src/main.rs b/applications/tari_collectibles/src-tauri/src/main.rs index 974a325e0e..92ec3623a2 100644 --- a/applications/tari_collectibles/src-tauri/src/main.rs +++ b/applications/tari_collectibles/src-tauri/src/main.rs @@ -1,4 +1,3 @@ -#![feature(array_methods)] #![cfg_attr( all(not(debug_assertions), target_os = "windows"), windows_subsystem = "windows" diff --git a/base_layer/key_manager/Cargo.toml b/base_layer/key_manager/Cargo.toml index 253c40e902..1c16517dea 100644 --- a/base_layer/key_manager/Cargo.toml +++ b/base_layer/key_manager/Cargo.toml @@ -32,7 +32,7 @@ serde_json = "1.0.39" thiserror = "1.0.26" strum_macros = "0.22" strum = { version = "0.22", features = ["derive"] } -wasm-bindgen = { version = "0.2", features = ["serde-serialize", "nightly"] } +wasm-bindgen = { version = "0.2", features = ["serde-serialize", "nightly"], optional = true } wasm-bindgen-test = "0.3.28" [dev-dependencies] @@ -41,3 +41,4 @@ sha2 = "0.9.8" [features] avx2 = ["tari_crypto/avx2"] js = ["getrandom/js", "js-sys"] +wasm = ["wasm-bindgen"] diff --git a/base_layer/key_manager/src/lib.rs b/base_layer/key_manager/src/lib.rs index e9985c70de..ef4b1825e0 100644 --- a/base_layer/key_manager/src/lib.rs +++ b/base_layer/key_manager/src/lib.rs @@ -13,4 +13,5 @@ pub mod mnemonic; pub mod mnemonic_wordlists; // https://github.com/rustwasm/wasm-bindgen/issues/2774 #[allow(clippy::unused_unit)] +#[cfg(feature = "wasm")] pub mod wasm; diff --git a/comms/dht/src/lib.rs b/comms/dht/src/lib.rs index cb75344910..d2cd185154 100644 --- a/comms/dht/src/lib.rs +++ b/comms/dht/src/lib.rs @@ -1,4 +1,3 @@ -#![feature(map_entry_replace)] #![doc(html_root_url = "https://docs.rs/tower-filter/0.3.0-alpha.2")] #![cfg_attr(not(debug_assertions), deny(unused_variables))] #![cfg_attr(not(debug_assertions), deny(unused_imports))] diff --git a/comms/dht/src/store_forward/local_state.rs b/comms/dht/src/store_forward/local_state.rs index 50965dbdad..3dc064b80c 100644 --- a/comms/dht/src/store_forward/local_state.rs +++ b/comms/dht/src/store_forward/local_state.rs @@ -41,9 +41,9 @@ impl SafLocalState { pub fn register_inflight_request(&mut self, peer: NodeId) { match self.inflight_saf_requests.entry(peer) { - Entry::Occupied(entry) => { + Entry::Occupied(mut entry) => { let (count, _) = *entry.get(); - entry.replace_entry((count + 1, Instant::now())); + *entry.get_mut() = (count + 1, Instant::now()); }, Entry::Vacant(entry) => { entry.insert((1, Instant::now())); @@ -53,11 +53,11 @@ impl SafLocalState { pub fn mark_infight_response_received(&mut self, peer: NodeId) -> Option { match self.inflight_saf_requests.entry(peer) { - Entry::Occupied(entry) => { + Entry::Occupied(mut entry) => { let (count, ts) = *entry.get(); let reduced_count = count - 1; if reduced_count > 0 { - entry.replace_entry((reduced_count, ts)); + *entry.get_mut() = (reduced_count, ts); } else { entry.remove(); } From c6d706a2ea5ef3ef2e00572527885df5c70ba8bf Mon Sep 17 00:00:00 2001 From: Byron Hambly Date: Wed, 26 Jan 2022 23:27:57 +0200 Subject: [PATCH 2/9] wasm --- base_layer/key_manager/Cargo.toml | 2 +- base_layer/key_manager/Makefile | 20 +++++++++----------- base_layer/key_manager/src/wasm.rs | 6 ++++-- rust-toolchain.toml | 13 ------------- 4 files changed, 14 insertions(+), 27 deletions(-) delete mode 100644 rust-toolchain.toml diff --git a/base_layer/key_manager/Cargo.toml b/base_layer/key_manager/Cargo.toml index 1c16517dea..9677078db5 100644 --- a/base_layer/key_manager/Cargo.toml +++ b/base_layer/key_manager/Cargo.toml @@ -41,4 +41,4 @@ sha2 = "0.9.8" [features] avx2 = ["tari_crypto/avx2"] js = ["getrandom/js", "js-sys"] -wasm = ["wasm-bindgen"] +wasm = ["wasm-bindgen", "js"] diff --git a/base_layer/key_manager/Makefile b/base_layer/key_manager/Makefile index efa926462c..41689d327c 100644 --- a/base_layer/key_manager/Makefile +++ b/base_layer/key_manager/Makefile @@ -1,19 +1,17 @@ -.PHONY: test +toolchain=nightly-2021-11-20 +.phony: test test: - wasm-pack test --node --features js - -.PHONY: build + rustup run $(toolchain) wasm-pack test --node --features wasm +.phony: build build: - wasm-pack build --target bundler . -- --features js - -.PHONY: install + rustup run $(toolchain) wasm-pack build --target bundler . -- --features wasm +.phony: install install: - wasm-pack build --out-dir=../../applications/tari_web_extension/src/key_manager/ --target bundler . -- --features js - -.PHONY: web + rustup run $(toolchain) wasm-pack build --out-dir=../../applications/tari_web_extension/src/key_manager/ --target bundler . -- --features wasm +.phony: web web: - wasm-pack build --target web . -- --features js \ No newline at end of file + rustup run $(toolchain) wasm-pack build --target web . -- --features wasm \ No newline at end of file diff --git a/base_layer/key_manager/src/wasm.rs b/base_layer/key_manager/src/wasm.rs index aed0835ddb..2b8729ad73 100644 --- a/base_layer/key_manager/src/wasm.rs +++ b/base_layer/key_manager/src/wasm.rs @@ -148,7 +148,9 @@ pub fn derive_key(key_manager: &JsValue, key_index: u64) -> JsValue { /// Parse a T from a JsValue fn parse(js: &JsValue) -> Result -where T: for<'a> Deserialize<'a> { +where + T: for<'a> Deserialize<'a>, +{ match JsValue::into_serde::(js) { Ok(t) => Ok(t), Err(e) => { @@ -190,7 +192,7 @@ mod test { let next_key = response.key_manager.next_key().unwrap(); assert_eq!( next_key.k.to_hex(), - "5a14f1205cfeb10d53af46e82b70e8832a544206f524b404e7a346148532910a".to_string() + "5c06999ed20e18bbb76245826141f8ae8700a648d87ec4da5a2a7507ce4b5f0e".to_string() ) } diff --git a/rust-toolchain.toml b/rust-toolchain.toml deleted file mode 100644 index 493a995cd4..0000000000 --- a/rust-toolchain.toml +++ /dev/null @@ -1,13 +0,0 @@ -# So, you want to update the Rust toolchain... - -# Besides making sure the code compiles (duh) and the tests/clippy pass (obviously) -# Please note that you'll have to update all the toolchain references in the codebase! -# AND build new docker images for: -# - rust_tari-build-with-deps -# - rust-ndk -# AND update the action-buildlibs dockerfile. - - -# Hours spent updating the Rust Toolchain = 4 -[toolchain] -channel = "nightly-2021-11-20" From edbbadbd083364ebf7c5b4a905179cb43c7b87b2 Mon Sep 17 00:00:00 2001 From: Byron Hambly Date: Sun, 30 Jan 2022 13:20:07 +0200 Subject: [PATCH 3/9] keep toolchain --- rust-toolchain.toml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 rust-toolchain.toml diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000000..493a995cd4 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,13 @@ +# So, you want to update the Rust toolchain... + +# Besides making sure the code compiles (duh) and the tests/clippy pass (obviously) +# Please note that you'll have to update all the toolchain references in the codebase! +# AND build new docker images for: +# - rust_tari-build-with-deps +# - rust-ndk +# AND update the action-buildlibs dockerfile. + + +# Hours spent updating the Rust Toolchain = 4 +[toolchain] +channel = "nightly-2021-11-20" From 6a086426a551ac0464c5b614b5d88dfaf3a05c9e Mon Sep 17 00:00:00 2001 From: Byron Hambly Date: Sun, 30 Jan 2022 13:27:16 +0200 Subject: [PATCH 4/9] ci --- .github/workflows/ci.yml | 57 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7e710ed55c..0cfc33f098 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ name: CI env: CARGO_HTTP_MULTIPLEXING: false PROTOC: protoc - toolchain: stable + toolchain: nightly-2021-11-20 jobs: clippy: @@ -114,7 +114,7 @@ jobs: - name: Compile NPM run: | cd applications/launchpad/gui-vue - npm install + npm ci npm run build - name: toolchain uses: actions-rs/toolchain@v1 @@ -122,10 +122,59 @@ jobs: toolchain: ${{ env.toolchain }} components: clippy, rustfmt override: true + # Why not cargo check? Some diagnostics and errors are only emitted during code generation. + - name: cargo build + uses: actions-rs/cargo@v1 + with: + command: build + args: --release --all-targets + build-stable: + name: build stable + runs-on: ubuntu-18.04 + steps: + - name: checkout + uses: actions/checkout@v2 + - name: caching + uses: actions/cache@v2 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-${{ runner.cpu-model }}-stable-build-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-${{ runner.cpu-model }}-stable-build- + ${{ runner.os }}-${{ runner.cpu-model }}-stable- + - name: ubuntu dependencies + run: | + sudo apt-get update && \ + sudo apt-get -y install \ + build-essential \ + libgtk-3-dev \ + libwebkit2gtk-4.0-dev \ + libsoup2.4-dev \ + curl \ + wget \ + libappindicator3-dev \ + patchelf \ + librsvg2-dev \ + libprotobuf-dev \ + protobuf-compiler + - name: Compile NPM + run: | + cd applications/launchpad/gui-vue + npm ci + npm run build + - name: toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + override: true - name: cargo build uses: actions-rs/cargo@v1 with: - command: check + command: build args: --release --all-targets test: name: test @@ -163,7 +212,7 @@ jobs: - name: Compile NPM run: | cd applications/launchpad/gui-vue - npm install + npm ci npm run build - name: toolchain uses: actions-rs/toolchain@v1 From c80d577a5857a102e023a108362d81f6de261eed Mon Sep 17 00:00:00 2001 From: Byron Hambly Date: Sun, 30 Jan 2022 13:32:01 +0200 Subject: [PATCH 5/9] check is fine since test will build --- .github/workflows/ci.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0cfc33f098..4667406a99 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -80,7 +80,7 @@ jobs: command: clippy args: --all-targets -- -D warnings build: - name: build + name: check nightly runs-on: ubuntu-18.04 steps: - name: checkout @@ -122,14 +122,13 @@ jobs: toolchain: ${{ env.toolchain }} components: clippy, rustfmt override: true - # Why not cargo check? Some diagnostics and errors are only emitted during code generation. - - name: cargo build + - name: cargo check uses: actions-rs/cargo@v1 with: - command: build + command: check args: --release --all-targets build-stable: - name: build stable + name: check stable runs-on: ubuntu-18.04 steps: - name: checkout From 0dfc1121294d0b04185664c7db3e7e526159e4f3 Mon Sep 17 00:00:00 2001 From: Byron Hambly Date: Sun, 30 Jan 2022 13:33:21 +0200 Subject: [PATCH 6/9] fmt --- base_layer/key_manager/src/wasm.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/base_layer/key_manager/src/wasm.rs b/base_layer/key_manager/src/wasm.rs index 2b8729ad73..9534ed1722 100644 --- a/base_layer/key_manager/src/wasm.rs +++ b/base_layer/key_manager/src/wasm.rs @@ -148,9 +148,7 @@ pub fn derive_key(key_manager: &JsValue, key_index: u64) -> JsValue { /// Parse a T from a JsValue fn parse(js: &JsValue) -> Result -where - T: for<'a> Deserialize<'a>, -{ +where T: for<'a> Deserialize<'a> { match JsValue::into_serde::(js) { Ok(t) => Ok(t), Err(e) => { From 79ee9baa14f19c4f5f0ea3e6a79458924fbe4b0c Mon Sep 17 00:00:00 2001 From: Byron Hambly Date: Sun, 30 Jan 2022 13:48:43 +0200 Subject: [PATCH 7/9] check --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4667406a99..f6b4e0d6f8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -173,7 +173,7 @@ jobs: - name: cargo build uses: actions-rs/cargo@v1 with: - command: build + command: check args: --release --all-targets test: name: test @@ -221,4 +221,4 @@ jobs: uses: actions-rs/cargo@v1 with: command: test - args: --release + args: --release --all-targets From c778fbbafb1ff4be6171d087bddd085f2e2ccd48 Mon Sep 17 00:00:00 2001 From: Byron Hambly Date: Sun, 30 Jan 2022 20:58:16 +0200 Subject: [PATCH 8/9] rustup show --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f6b4e0d6f8..56d5a2bd43 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -170,6 +170,9 @@ jobs: toolchain: stable profile: minimal override: true + - name: rustup show + run: | + rustup show - name: cargo build uses: actions-rs/cargo@v1 with: From e858b0e0008afe4317464005ca9820806b2d89a3 Mon Sep 17 00:00:00 2001 From: Byron Hambly Date: Tue, 1 Feb 2022 21:32:46 +0200 Subject: [PATCH 9/9] clippy --- applications/tari_collectibles/src-tauri/src/app_state.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/applications/tari_collectibles/src-tauri/src/app_state.rs b/applications/tari_collectibles/src-tauri/src/app_state.rs index 8f2fa32163..b13a8bf9d3 100644 --- a/applications/tari_collectibles/src-tauri/src/app_state.rs +++ b/applications/tari_collectibles/src-tauri/src/app_state.rs @@ -74,11 +74,8 @@ impl ConcurrentAppState { pub async fn connect_base_node_client(&self) -> Result { let lock = self.inner.read().await; - let client = BaseNodeClient::connect(format!( - "http://{}", - lock.config.base_node_grpc_address.to_string() - )) - .await?; + let client = + BaseNodeClient::connect(format!("http://{}", lock.config.base_node_grpc_address)).await?; Ok(client) }