diff --git a/.changelog/unreleased/improvements/3254-rust-1.78.md b/.changelog/unreleased/improvements/3254-rust-1.78.md new file mode 100644 index 0000000000..f08cb5c476 --- /dev/null +++ b/.changelog/unreleased/improvements/3254-rust-1.78.md @@ -0,0 +1,2 @@ +- Updated Rust toolchain to v1.78.0. + ([\#3254](https://github.com/anoma/namada/pull/3254)) \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index f0b1785345..9d46375a15 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5200,7 +5200,7 @@ dependencies = [ "namada_gas", "namada_macros", "namada_migrations", - "num-derive 0.3.3", + "num-derive 0.4.2", "num-traits 0.2.17", "proptest", "prost 0.12.3", diff --git a/Cargo.toml b/Cargo.toml index 088f455e41..7c8748d3af 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -129,7 +129,7 @@ masp_primitives = { git = "https://github.com/anoma/masp", rev = "6fc4692841a224 masp_proofs = { git = "https://github.com/anoma/masp", rev = "6fc4692841a2241633792c429cc66b42023e5bf3", default-features = false, features = ["local-prover"] } num256 = "0.3.5" num_cpus = "1.13.0" -num-derive = "0.3.3" +num-derive = "0.4" num-rational = "0.4.1" num-traits = "0.2.14" once_cell = "1.8.0" diff --git a/crates/core/src/storage.rs b/crates/core/src/storage.rs index 8516c11ff1..de12f19706 100644 --- a/crates/core/src/storage.rs +++ b/crates/core/src/storage.rs @@ -53,6 +53,8 @@ pub enum Error { {0}" )] DbColFamily(String), + #[error("{0}")] + TryFromInt(#[from] std::num::TryFromIntError), } /// Result for functions that may fail @@ -1086,14 +1088,17 @@ macro_rules! impl_int_key_seg { // get signed int from a unsigned int complemented with a min // value let complemented = <$unsigned>::parse(string)?; - let signed = (complemented as $signed) ^ <$signed>::MIN; + let signed = <$signed>::try_from(complemented)?; + let signed = signed ^ <$signed>::MIN; Ok(signed) } fn raw(&self) -> String { // signed int is converted to unsigned int that preserves the // order by complementing it with a min value - let complemented = (*self ^ <$signed>::MIN) as $unsigned; + let complemented = + <$unsigned>::try_from(*self ^ <$signed>::MIN) + .expect("Complemented signed int is zero or positive"); complemented.raw() } diff --git a/crates/core/src/uint.rs b/crates/core/src/uint.rs index 3e21dc204b..6990ea052a 100644 --- a/crates/core/src/uint.rs +++ b/crates/core/src/uint.rs @@ -184,7 +184,7 @@ impl Uint { q_hat } else { // here q_hat >= q_j >= q_hat - 1 - u64::max_value() + u64::MAX }; // ex. 20: diff --git a/crates/merkle_tree/src/lib.rs b/crates/merkle_tree/src/lib.rs index c6a4e147e5..3465dd15b0 100644 --- a/crates/merkle_tree/src/lib.rs +++ b/crates/merkle_tree/src/lib.rs @@ -1422,7 +1422,7 @@ mod test { &value, )); // for the verification of the base tree - value = sub_root.clone(); + value.clone_from(&sub_root); } // Check the base root assert_eq!(sub_root, tree.root().0); @@ -1486,7 +1486,7 @@ mod test { &value, )); // for the verification of the base tree - value = sub_root.clone(); + value.clone_from(&sub_root); } // Check the base root assert_eq!(sub_root, tree.root().0); diff --git a/crates/namada/src/ledger/mod.rs b/crates/namada/src/ledger/mod.rs index 3753ca9b77..f4465826ed 100644 --- a/crates/namada/src/ledger/mod.rs +++ b/crates/namada/src/ledger/mod.rs @@ -160,8 +160,10 @@ mod test { /// tx wasm compilation cache pub tx_wasm_cache: TxCache, /// VP wasm compilation cache directory + #[allow(dead_code)] // never read pub vp_cache_dir: TempDir, /// tx wasm compilation cache directory + #[allow(dead_code)] // never read pub tx_cache_dir: TempDir, } diff --git a/crates/node/src/bench_utils.rs b/crates/node/src/bench_utils.rs index 8053609298..19dccb4f70 100644 --- a/crates/node/src/bench_utils.rs +++ b/crates/node/src/bench_utils.rs @@ -672,8 +672,7 @@ pub struct BenchShieldedUtils { context_dir: WrapperTempDir, } -#[cfg_attr(feature = "async-send", async_trait::async_trait)] -#[cfg_attr(not(feature = "async-send"), async_trait::async_trait(?Send))] +#[async_trait::async_trait(?Send)] impl ShieldedUtils for BenchShieldedUtils { fn local_tx_prover(&self) -> LocalTxProver { if let Ok(params_dir) = std::env::var(masp::ENV_VAR_MASP_PARAMS_DIR) { @@ -768,8 +767,7 @@ impl ShieldedUtils for BenchShieldedUtils { } } -#[cfg_attr(feature = "async-send", async_trait::async_trait)] -#[cfg_attr(not(feature = "async-send"), async_trait::async_trait(?Send))] +#[async_trait::async_trait(?Send)] impl Client for BenchShell { type Error = std::io::Error; diff --git a/crates/node/src/shell/finalize_block.rs b/crates/node/src/shell/finalize_block.rs index be1fb8d531..45daa8a41a 100644 --- a/crates/node/src/shell/finalize_block.rs +++ b/crates/node/src/shell/finalize_block.rs @@ -5436,9 +5436,7 @@ mod test_finalize_block { ); // Assert that the last tx didn't run assert!( - inner_results - .get(&batch.commitments()[2].get_hash()) - .is_none() + !inner_results.contains_key(&batch.commitments()[2].get_hash()) ); // Check storage modifications are missing @@ -5554,9 +5552,7 @@ mod test_finalize_block { ); // Assert that the last tx didn't run assert!( - inner_results - .get(&batch.commitments()[2].get_hash()) - .is_none() + !inner_results.contains_key(&batch.commitments()[2].get_hash()) ); // Check storage modifications are missing @@ -5603,9 +5599,7 @@ mod test_finalize_block { ); // Assert that the last tx didn't run assert!( - inner_results - .get(&batch.commitments()[2].get_hash()) - .is_none() + !inner_results.contains_key(&batch.commitments()[2].get_hash()) ); // Check storage modifications diff --git a/crates/node/src/shell/mod.rs b/crates/node/src/shell/mod.rs index 99c98b3ff8..b119c47bcd 100644 --- a/crates/node/src/shell/mod.rs +++ b/crates/node/src/shell/mod.rs @@ -1059,7 +1059,7 @@ where response.code = ResultCode::InvalidTx.into(); response.log = "The wrapper gas limit overflowed gas \ representation" - .to_owned(); + .to_string(); return response; } }; diff --git a/crates/node/src/shell/queries.rs b/crates/node/src/shell/queries.rs index fe9c5d5935..ad9d9bebc2 100644 --- a/crates/node/src/shell/queries.rs +++ b/crates/node/src/shell/queries.rs @@ -67,6 +67,7 @@ where // NOTE: we are testing `namada::ledger::queries_ext`, // which is not possible from `namada` since we do not have // access to the `Shell` there +#[allow(clippy::cast_possible_truncation)] #[cfg(test)] mod test_queries { use namada::core::storage::Epoch; diff --git a/crates/node/src/shell/testing/node.rs b/crates/node/src/shell/testing/node.rs index be308531f9..22ad689d5d 100644 --- a/crates/node/src/shell/testing/node.rs +++ b/crates/node/src/shell/testing/node.rs @@ -675,8 +675,7 @@ impl MockNode { } } -#[cfg_attr(feature = "async-send", async_trait::async_trait)] -#[cfg_attr(not(feature = "async-send"), async_trait::async_trait(?Send))] +#[async_trait::async_trait(?Send)] impl<'a> Client for &'a MockNode { type Error = Report; diff --git a/crates/proof_of_stake/src/lib.rs b/crates/proof_of_stake/src/lib.rs index a6116d6fa9..92326128bc 100644 --- a/crates/proof_of_stake/src/lib.rs +++ b/crates/proof_of_stake/src/lib.rs @@ -378,14 +378,6 @@ where total_consensus_stake_handle().set(storage, total, epoch, 0) } -/// Used below in `fn unbond_tokens` to update the bond and unbond amounts -#[derive(Eq, Hash, PartialEq)] -struct BondAndUnbondUpdates { - bond_start: Epoch, - new_bond_value: token::Change, - unbond_value: token::Change, -} - /// Unbond tokens that are bonded between a validator and a source (self or /// delegator). /// diff --git a/crates/sdk/Cargo.toml b/crates/sdk/Cargo.toml index e9ebe6d6b3..d681124f8e 100644 --- a/crates/sdk/Cargo.toml +++ b/crates/sdk/Cargo.toml @@ -17,6 +17,8 @@ version.workspace = true [features] default = ["tendermint-rpc", "download-params", "std", "rand", "migrations"] +mainnet = ["namada_core/mainnet", "namada_events/mainnet"] + multicore = ["masp_proofs/multicore"] namada-sdk = ["tendermint-rpc", "masp_primitives/transparent-inputs"] diff --git a/crates/sdk/src/queries/router.rs b/crates/sdk/src/queries/router.rs index 5270a859f6..e9adfe622e 100644 --- a/crates/sdk/src/queries/router.rs +++ b/crates/sdk/src/queries/router.rs @@ -657,6 +657,14 @@ macro_rules! router_type { // paste the generated methods $( $methods )* } + + impl Default for $name { + fn default() -> Self { + Self { + prefix: String::new(), + } + } + } } }; diff --git a/crates/sdk/src/tx.rs b/crates/sdk/src/tx.rs index d2d4f5691b..d569c24887 100644 --- a/crates/sdk/src/tx.rs +++ b/crates/sdk/src/tx.rs @@ -272,10 +272,7 @@ pub async fn process_tx( pub async fn is_reveal_pk_needed( client: &C, address: &Address, -) -> Result -where - C: crate::queries::Client + Sync, -{ +) -> Result { // Check if PK revealed Ok(!has_revealed_pk(client, address).await?) } diff --git a/crates/tests/Cargo.toml b/crates/tests/Cargo.toml index 6b3f6e07bf..75a2fbc0c9 100644 --- a/crates/tests/Cargo.toml +++ b/crates/tests/Cargo.toml @@ -45,8 +45,10 @@ flate2.workspace = true hyper = {version = "0.14.20", features = ["full"]} ibc-testkit.workspace = true ics23.workspace = true +itertools.workspace = true lazy_static.workspace = true num-traits.workspace = true +proptest.workspace = true prost.workspace = true regex.workspace = true serde.workspace = true @@ -74,10 +76,8 @@ escargot = {workspace = true} # , features = ["print"]} expectrl.workspace = true eyre.workspace = true fs_extra.workspace = true -itertools.workspace = true once_cell.workspace = true pretty_assertions.workspace = true -proptest.workspace = true proptest-state-machine.workspace = true rand.workspace = true tendermint-light-client.workspace = true diff --git a/crates/tests/src/e2e.rs b/crates/tests/src/e2e.rs index 10a6f69d6e..b1cfb67a9d 100644 --- a/crates/tests/src/e2e.rs +++ b/crates/tests/src/e2e.rs @@ -11,8 +11,8 @@ //! To keep the temporary files created by a test, use env var //! `NAMADA_E2E_KEEP_TEMP=true`. -#[cfg(DISABLED_UNTIL_ERC20_WHITELISTS_IMPLEMENTED)] -pub mod eth_bridge_tests; +// Disabled until erc20 whitelists implemented +// pub mod eth_bridge_tests; pub mod helpers; pub mod ibc_tests; pub mod ledger_tests; diff --git a/crates/tests/src/native_vp/pos.rs b/crates/tests/src/native_vp/pos.rs index 57f04c706d..e0d970f11a 100644 --- a/crates/tests/src/native_vp/pos.rs +++ b/crates/tests/src/native_vp/pos.rs @@ -574,7 +574,6 @@ mod tests { } /// Testing helpers -#[cfg(any(test, feature = "testing"))] pub mod testing { use std::cell::RefCell; diff --git a/docker/namada-wasm/Dockerfile b/docker/namada-wasm/Dockerfile index 215f9bf231..0dec9b9ba5 100644 --- a/docker/namada-wasm/Dockerfile +++ b/docker/namada-wasm/Dockerfile @@ -6,7 +6,7 @@ FROM rust:1.78.0-bookworm WORKDIR /__w/namada/namada # The version should be matching the version set above -RUN rustup toolchain install 1.76.0 --profile minimal +RUN rustup toolchain install 1.78.0 --profile minimal RUN rustup target add wasm32-unknown-unknown RUN apt-get update && apt-get install -y \ diff --git a/docker/namada/Dockerfile b/docker/namada/Dockerfile index 2616be740b..2ed5b2e2ec 100644 --- a/docker/namada/Dockerfile +++ b/docker/namada/Dockerfile @@ -1,4 +1,4 @@ -FROM lukemathwalker/cargo-chef:latest-rust-1.78.0-bookwork AS chef +FROM lukemathwalker/cargo-chef:latest-rust-1.78.0-bookworm AS chef WORKDIR /app FROM chef AS planner diff --git a/rust-nightly-version b/rust-nightly-version index 2dbd8cea78..d7d44f19cb 100644 --- a/rust-nightly-version +++ b/rust-nightly-version @@ -1 +1 @@ -nightly-2024-02-10 +nightly-2024-05-15 diff --git a/rust-toolchain.toml b/rust-toolchain.toml index f537877896..30fa9c3717 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "1.76.0" +channel = "1.78.0" components = ["rustc", "cargo", "rust-std", "rust-docs", "rls", "rust-src", "rust-analysis"] targets = ['wasm32-unknown-unknown'] \ No newline at end of file diff --git a/wasm/Cargo.lock b/wasm/Cargo.lock index ed08dd9f93..e8d2fab2a2 100644 --- a/wasm/Cargo.lock +++ b/wasm/Cargo.lock @@ -4063,6 +4063,7 @@ dependencies = [ "hyper", "ibc-testkit", "ics23", + "itertools 0.12.1", "lazy_static", "namada", "namada_core", @@ -4071,6 +4072,7 @@ dependencies = [ "namada_tx_prelude", "namada_vp_prelude", "num-traits 0.2.17", + "proptest", "prost", "regex", "serde", @@ -4121,7 +4123,7 @@ dependencies = [ "namada_gas", "namada_macros", "namada_migrations", - "num-derive 0.3.3", + "num-derive 0.4.2", "num-traits 0.2.17", "proptest", "prost", diff --git a/wasm/rust-toolchain.toml b/wasm/rust-toolchain.toml index 16235b717f..ef9f0f467d 100644 --- a/wasm/rust-toolchain.toml +++ b/wasm/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.76.0" +channel = "1.78.0" components = ["rustc", "cargo", "rust-std", "rust-docs", "rls", "rust-analysis"] diff --git a/wasm_for_tests/Cargo.lock b/wasm_for_tests/Cargo.lock index d5d7377393..29ec324ea3 100644 --- a/wasm_for_tests/Cargo.lock +++ b/wasm_for_tests/Cargo.lock @@ -4012,6 +4012,7 @@ dependencies = [ "hyper", "ibc-testkit", "ics23", + "itertools 0.12.1", "lazy_static", "namada", "namada_core", @@ -4020,6 +4021,7 @@ dependencies = [ "namada_tx_prelude", "namada_vp_prelude", "num-traits 0.2.17", + "proptest", "prost", "regex", "serde", @@ -4068,7 +4070,7 @@ dependencies = [ "namada_events", "namada_gas", "namada_macros", - "num-derive 0.3.3", + "num-derive 0.4.2", "num-traits 0.2.17", "proptest", "prost",