diff --git a/.changelog/unreleased/improvements/4982-rust-1.91.md b/.changelog/unreleased/improvements/4982-rust-1.91.md new file mode 100644 index 00000000000..7a1f6d2a7cf --- /dev/null +++ b/.changelog/unreleased/improvements/4982-rust-1.91.md @@ -0,0 +1,2 @@ +- Updated Rust toolchain to v1.91.1. ([\#4982](https://github.com/namada- + net/namada/pull/4982)) \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 05b2fb46925..aa1ffa7174d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,7 @@ env: CACHE_BUCKET: github-runners-remote-cache-shared SCCACHE_BUCKET: github-runners-remote-cache-shared AWS_REGION: us-west-2 - NIGHTLY: nightly-2025-03-27 + NIGHTLY: nightly-2025-11-17 NAMADA_MASP_PARAMS_DIR: /masp/.masp-params LEDGER_APP_VERSION: "3.0.7" ROLE: arn:aws:iam::375643557360:role/github-runners-ci-shared @@ -57,7 +57,7 @@ jobs: rust-docs: container: - image: ghcr.io/heliaxdev/namada-ci:namada-v2.3.0 + image: ghcr.io/heliaxdev/namada-ci:namada-pr-34 runs-on: [self-hosted, 4vcpu-8ram-ubuntu22-namada-x86] timeout-minutes: 20 @@ -91,7 +91,7 @@ jobs: lints: container: - image: ghcr.io/heliaxdev/namada-ci:namada-v2.3.0 + image: ghcr.io/heliaxdev/namada-ci:namada-pr-34 runs-on: [self-hosted, 8vcpu-16ram-ubuntu22-namada-x86] timeout-minutes: 15 @@ -129,7 +129,7 @@ jobs: timeout-minutes: 10 runs-on: [self-hosted, 4vcpu-8ram-ubuntu22-namada-x86] container: - image: ghcr.io/heliaxdev/namada-ci:namada-v2.3.0 + image: ghcr.io/heliaxdev/namada-ci:namada-pr-34 strategy: fail-fast: true matrix: @@ -176,7 +176,7 @@ jobs: test-wasm: timeout-minutes: 30 container: - image: ghcr.io/heliaxdev/namada-ci:namada-v2.3.0 + image: ghcr.io/heliaxdev/namada-ci:namada-pr-34 runs-on: [self-hosted, 4vcpu-8ram-ubuntu22-namada-x86] needs: [build-wasm] @@ -223,7 +223,7 @@ jobs: test-unit: runs-on: [self-hosted, 8vcpu-16ram-ubuntu22-namada-x86] container: - image: ghcr.io/heliaxdev/namada-ci:namada-v2.3.0 + image: ghcr.io/heliaxdev/namada-ci:namada-pr-34 timeout-minutes: 30 needs: [build-wasm] @@ -276,7 +276,7 @@ jobs: check-packages: runs-on: [self-hosted, 8vcpu-16ram-ubuntu22-namada-x86] container: - image: ghcr.io/heliaxdev/namada-ci:namada-v2.3.0 + image: ghcr.io/heliaxdev/namada-ci:namada-pr-34 timeout-minutes: 15 steps: @@ -312,7 +312,7 @@ jobs: test-integration: runs-on: [self-hosted, 16vcpu-32ram-ubuntu22-namada-x86] container: - image: ghcr.io/heliaxdev/namada-ci:namada-v2.3.0 + image: ghcr.io/heliaxdev/namada-ci:namada-pr-34 timeout-minutes: 120 needs: [build-wasm] @@ -365,7 +365,7 @@ jobs: check-benchmarks: runs-on: [self-hosted, 16vcpu-32ram-ubuntu22-namada-x86] container: - image: ghcr.io/heliaxdev/namada-ci:namada-v2.3.0 + image: ghcr.io/heliaxdev/namada-ci:namada-pr-34 if: github.event.pull_request.draft == false || contains(github.head_ref, 'mergify/merge-queue') || contains(github.ref_name, 'mergify/merge-queue') timeout-minutes: 35 needs: [build-wasm] @@ -413,7 +413,7 @@ jobs: build-binaries: runs-on: [self-hosted, 16vcpu-32ram-ubuntu22-namada-x86] container: - image: ghcr.io/heliaxdev/namada-ci:namada-v2.3.0 + image: ghcr.io/heliaxdev/namada-ci:namada-pr-34 timeout-minutes: 25 steps: @@ -464,7 +464,7 @@ jobs: test-e2e: runs-on: [self-hosted, 4vcpu-8ram-ubuntu22-namada-x86] container: - image: ghcr.io/heliaxdev/namada-ci:namada-v2.3.0 + image: ghcr.io/heliaxdev/namada-ci:namada-pr-34 if: github.event.pull_request.draft == false || contains(github.head_ref, 'mergify/merge-queue') || contains(github.ref_name, 'mergify/merge-queue') needs: [build-wasm, build-binaries] timeout-minutes: 50 @@ -635,7 +635,7 @@ jobs: test-e2e-with-device-automation: runs-on: [self-hosted, 4vcpu-8ram-ubuntu22-namada-x86] container: - image: ghcr.io/heliaxdev/namada-ci:namada-v2.3.0 + image: ghcr.io/heliaxdev/namada-ci:namada-pr-34 if: github.event.pull_request.draft == false || contains(github.head_ref, 'mergify/merge-queue') || contains(github.ref_name, 'mergify/merge-queue') needs: [build-wasm, build-binaries] timeout-minutes: 50 @@ -729,7 +729,7 @@ jobs: check-sdk-licenses: runs-on: [self-hosted, 4vcpu-8ram-ubuntu22-namada-x86] container: - image: ghcr.io/heliaxdev/namada-ci:namada-v2.3.0 + image: ghcr.io/heliaxdev/namada-ci:namada-pr-34 timeout-minutes: 5 steps: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6ac43611e24..8221dcb71c1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,7 +26,7 @@ jobs: wasm: runs-on: [ubuntu-latest] container: - image: ghcr.io/heliaxdev/namada-ci:namada-v2.3.0 + image: ghcr.io/heliaxdev/namada-ci:namada-pr-34 steps: - name: Checkout repo uses: actions/checkout@v4 diff --git a/Cargo.lock b/Cargo.lock index 128a4436fd6..2f2f7144e7d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5661,6 +5661,175 @@ dependencies = [ "parity-wasm", ] +[[package]] +name = "nam-wasmer" +version = "4.4.0-nam.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3581e8dc0cfc304075640e6899014bc1b27455c2da93dcdfa6c758e6769f42cb" +dependencies = [ + "bytes", + "cfg-if", + "derivative", + "indexmap 1.9.3", + "js-sys", + "more-asserts", + "nam-wasmer-compiler", + "nam-wasmer-compiler-cranelift", + "nam-wasmer-derive", + "nam-wasmer-types", + "nam-wasmer-vm", + "rustc-demangle", + "serde", + "serde-wasm-bindgen", + "shared-buffer", + "target-lexicon", + "thiserror 1.0.69", + "tracing", + "wasm-bindgen", + "wat", + "windows-sys 0.59.0", +] + +[[package]] +name = "nam-wasmer-cache" +version = "4.4.0-nam.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59f09ed14f6a5ad8f29df51301b5a9a94a22a8cc35d3c9e2261ec1c996928f64" +dependencies = [ + "blake3", + "hex", + "nam-wasmer", + "thiserror 1.0.69", +] + +[[package]] +name = "nam-wasmer-compiler" +version = "4.4.0-nam.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a66cbcb0362b5fe96ca088540053072ca66e6acd5302998bcc817be5cc175afc" +dependencies = [ + "backtrace", + "bytes", + "cfg-if", + "enum-iterator", + "enumset", + "lazy_static", + "leb128", + "libc", + "memmap2 0.6.2", + "more-asserts", + "nam-wasmer-types", + "nam-wasmer-vm", + "region", + "rkyv", + "self_cell", + "shared-buffer", + "smallvec", + "thiserror 1.0.69", + "wasmparser", + "windows-sys 0.59.0", + "xxhash-rust", +] + +[[package]] +name = "nam-wasmer-compiler-cranelift" +version = "4.4.0-nam.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1b743a12f25f7e60a837a76399e3a522f34741305bd94a384c95c9a82e0570a" +dependencies = [ + "cranelift-codegen", + "cranelift-entity", + "cranelift-frontend", + "gimli 0.26.2", + "more-asserts", + "nam-wasmer-compiler", + "nam-wasmer-types", + "rayon", + "smallvec", + "target-lexicon", + "tracing", +] + +[[package]] +name = "nam-wasmer-compiler-singlepass" +version = "4.4.0-nam.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2de27e7e6fa858bc723426de49df964dc82146802bc6f3d319713218bc57ae76" +dependencies = [ + "byteorder", + "dynasm", + "dynasmrt", + "enumset", + "gimli 0.26.2", + "lazy_static", + "more-asserts", + "nam-wasmer-compiler", + "nam-wasmer-types", + "rayon", + "smallvec", +] + +[[package]] +name = "nam-wasmer-derive" +version = "4.4.0-nam.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84d709563c07f9020feb672cd9942d67a93dc611d73ddc6fff1ada13a562735b" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "nam-wasmer-types" +version = "4.4.0-nam.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891920ff63d1b271d4b174e553c8816e3378b4c2e2a23e21bd28c877af0efe13" +dependencies = [ + "bytecheck", + "enum-iterator", + "enumset", + "getrandom 0.2.15", + "hex", + "indexmap 1.9.3", + "more-asserts", + "rkyv", + "sha2 0.10.8", + "target-lexicon", + "thiserror 1.0.69", + "xxhash-rust", +] + +[[package]] +name = "nam-wasmer-vm" +version = "4.4.0-nam.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "766ce48171a49ac3994ec43fa69f25464112e3f79aa0766d699676bf3a2440d3" +dependencies = [ + "backtrace", + "cc", + "cfg-if", + "corosensei", + "crossbeam-queue", + "dashmap", + "derivative", + "enum-iterator", + "fnv", + "indexmap 1.9.3", + "lazy_static", + "libc", + "mach2", + "memoffset 0.9.1", + "more-asserts", + "nam-wasmer-types", + "region", + "rustversion", + "scopeguard", + "thiserror 1.0.69", + "windows-sys 0.59.0", +] + [[package]] name = "namada_account" version = "0.251.0" @@ -5766,6 +5935,8 @@ dependencies = [ "masp_primitives", "masp_proofs", "nam-wasm-instrument", + "nam-wasmer", + "nam-wasmer-compiler-singlepass", "namada_apps_lib", "namada_node", "namada_vm", @@ -5775,8 +5946,6 @@ dependencies = [ "rand_core", "sha2 0.10.8", "tempfile", - "wasmer", - "wasmer-compiler-singlepass", ] [[package]] @@ -6463,6 +6632,7 @@ dependencies = [ "ics23", "itertools 0.14.0", "masp_primitives", + "nam-wasmer", "namada_apps_lib", "namada_core", "namada_node", @@ -6490,7 +6660,6 @@ dependencies = [ "test-log", "tokio", "toml", - "wasmer", ] [[package]] @@ -6618,6 +6787,12 @@ dependencies = [ "git2", "itertools 0.14.0", "nam-wasm-instrument", + "nam-wasmer", + "nam-wasmer-cache", + "nam-wasmer-compiler", + "nam-wasmer-compiler-singlepass", + "nam-wasmer-types", + "nam-wasmer-vm", "namada_account", "namada_core", "namada_events", @@ -6636,12 +6811,6 @@ dependencies = [ "test-log", "thiserror 2.0.12", "tracing", - "wasmer", - "wasmer-cache", - "wasmer-compiler", - "wasmer-compiler-singlepass", - "wasmer-types", - "wasmer-vm", "wasmparser", ] @@ -10578,174 +10747,6 @@ dependencies = [ "leb128", ] -[[package]] -name = "wasmer" -version = "4.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d920d06243e9f456c336c428a34560357dedf59d9febaae14f1995ac120cff6" -dependencies = [ - "bytes", - "cfg-if", - "derivative", - "indexmap 1.9.3", - "js-sys", - "more-asserts", - "rustc-demangle", - "serde", - "serde-wasm-bindgen", - "shared-buffer", - "target-lexicon", - "thiserror 1.0.69", - "tracing", - "wasm-bindgen", - "wasmer-compiler", - "wasmer-compiler-cranelift", - "wasmer-derive", - "wasmer-types", - "wasmer-vm", - "wat", - "windows-sys 0.59.0", -] - -[[package]] -name = "wasmer-cache" -version = "4.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e2aa507d7ab1d7f6038f60ca107bc4629c5dbf3a0e18427091b7576b0ffbbd9" -dependencies = [ - "blake3", - "hex", - "thiserror 1.0.69", - "wasmer", -] - -[[package]] -name = "wasmer-compiler" -version = "4.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e01832173aa52345e480965f18c638a8a5a9e5e4d85a48675bdf1964147dc7f" -dependencies = [ - "backtrace", - "bytes", - "cfg-if", - "enum-iterator", - "enumset", - "lazy_static", - "leb128", - "libc", - "memmap2 0.6.2", - "more-asserts", - "region", - "rkyv", - "self_cell", - "shared-buffer", - "smallvec", - "thiserror 1.0.69", - "wasmer-types", - "wasmer-vm", - "wasmparser", - "windows-sys 0.59.0", - "xxhash-rust", -] - -[[package]] -name = "wasmer-compiler-cranelift" -version = "4.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c1618f53b492cf6649beeb372930e376e0f52d9842c0c5eb5aa2b548251dab6" -dependencies = [ - "cranelift-codegen", - "cranelift-entity", - "cranelift-frontend", - "gimli 0.26.2", - "more-asserts", - "rayon", - "smallvec", - "target-lexicon", - "tracing", - "wasmer-compiler", - "wasmer-types", -] - -[[package]] -name = "wasmer-compiler-singlepass" -version = "4.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2b111c55d0b8a30dba67afe8766c56b53f0055653f0bb14b1a337056263ae48" -dependencies = [ - "byteorder", - "dynasm", - "dynasmrt", - "enumset", - "gimli 0.26.2", - "lazy_static", - "more-asserts", - "rayon", - "smallvec", - "wasmer-compiler", - "wasmer-types", -] - -[[package]] -name = "wasmer-derive" -version = "4.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c5875633aea92153b6a561cb07363785ca9e07792ca6cd7c1cc371761001d8f" -dependencies = [ - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "wasmer-types" -version = "4.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fb32f0d231b591e4c8a65e81d4647fa3180496d71a123d4948dba8551bba9c2" -dependencies = [ - "bytecheck", - "enum-iterator", - "enumset", - "getrandom 0.2.15", - "hex", - "indexmap 1.9.3", - "more-asserts", - "rkyv", - "sha2 0.10.8", - "target-lexicon", - "thiserror 1.0.69", - "xxhash-rust", -] - -[[package]] -name = "wasmer-vm" -version = "4.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e38e9301f5bb9f18da9cda4002d74d2cb6ac1f36dcf919fd77f91fca321fb1e5" -dependencies = [ - "backtrace", - "cc", - "cfg-if", - "corosensei", - "crossbeam-queue", - "dashmap", - "derivative", - "enum-iterator", - "fnv", - "indexmap 1.9.3", - "lazy_static", - "libc", - "mach2", - "memoffset 0.9.1", - "more-asserts", - "region", - "scopeguard", - "thiserror 1.0.69", - "wasmer-types", - "windows-sys 0.59.0", -] - [[package]] name = "wasmparser" version = "0.121.2" diff --git a/Cargo.toml b/Cargo.toml index 7f598c8216a..e8c02db71fc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -265,12 +265,12 @@ uint = "0.10" warp = "0.3" wasmparser = "0.121" wasm-instrument = { package = "nam-wasm-instrument", version = "0.5.2", features = ["sign_ext"] } -wasmer = "4.3.5" -wasmer-cache = "4.3.5" -wasmer-compiler = "4.3.5" -wasmer-compiler-singlepass = "4.3.5" -wasmer-types = "4.3.5" -wasmer-vm = "4.3.5" +wasmer = { package = "nam-wasmer", version = "4.4.0-nam.0" } +wasmer-cache = { package = "nam-wasmer-cache", version = "4.4.0-nam.0" } +wasmer-compiler = { package = "nam-wasmer-compiler", version = "4.4.0-nam.0" } +wasmer-compiler-singlepass = { package = "nam-wasmer-compiler-singlepass", version = "4.4.0-nam.0" } +wasmer-types = { package = "nam-wasmer-types", version = "4.4.0-nam.0" } +wasmer-vm = { package = "nam-wasmer-vm", version = "4.4.0-nam.0" } wasmtimer = "0.4" winapi = "0.3" xorf = { version = "0.11", features = ["serde"] } diff --git a/Dockerfile b/Dockerfile index 7487afc7838..81815d4f83e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM lukemathwalker/cargo-chef:latest-rust-1.85.1-bookworm AS chef +FROM lukemathwalker/cargo-chef:latest-rust-1.91.1-bookworm AS chef WORKDIR /app FROM chef AS planner diff --git a/clippy.toml b/clippy.toml index 2fc50cebd16..0abad5d6377 100644 --- a/clippy.toml +++ b/clippy.toml @@ -4,7 +4,7 @@ disallowed-types = [ ] disallowed-methods = [ { path = "std::time::Instant::now", reason = "Do not use current date/time in code that must be deterministic" }, - { path = "chrono::DateTime::now", reason = "Do not use current date/time in code that must be deterministic" }, + { path = "chrono::Local::now", reason = "Do not use current date/time in code that must be deterministic" }, { path = "chrono::Utc::now", reason = "Do not use current date/time in code that must be deterministic" }, { path = "namada_core::time::DateTimeUtc::now", reason = "Do not use current date/time in code that must be deterministic" }, { path = "wasmtimer::std::Instant", reason = "Do not use current date/time in code that must be deterministic" }, diff --git a/crates/apps/src/bin/namada-node/cli.rs b/crates/apps/src/bin/namada-node/cli.rs index b8d6167a5bf..d35533d9ff2 100644 --- a/crates/apps/src/bin/namada-node/cli.rs +++ b/crates/apps/src/bin/namada-node/cli.rs @@ -156,15 +156,15 @@ fn sleep_until(time: Option) { if let Some(time) = time { #[allow(clippy::disallowed_methods)] let now = Utc::now(); - if let Ok(sleep_time) = time.0.signed_duration_since(now).to_std() { - if !sleep_time.is_zero() { - tracing::info!( - "Waiting ledger start time: {:?}, time left: {:?}", - time, - sleep_time - ); - std::thread::sleep(sleep_time) - } + if let Ok(sleep_time) = time.0.signed_duration_since(now).to_std() + && !sleep_time.is_zero() + { + tracing::info!( + "Waiting ledger start time: {:?}, time left: {:?}", + time, + sleep_time + ); + std::thread::sleep(sleep_time) } } } diff --git a/crates/apps_lib/src/cli.rs b/crates/apps_lib/src/cli.rs index 32ec3e07b05..48bda28ff69 100644 --- a/crates/apps_lib/src/cli.rs +++ b/crates/apps_lib/src/cli.rs @@ -725,7 +725,7 @@ pub mod cmds { fn parse(matches: &ArgMatches) -> Option { matches .subcommand_matches(Self::CMD) - .map(|matches| (Self(args::KeyAddressList::parse(matches)))) + .map(|matches| Self(args::KeyAddressList::parse(matches))) } fn def() -> App { @@ -778,7 +778,7 @@ pub mod cmds { fn parse(matches: &ArgMatches) -> Option { matches .subcommand_matches(Self::CMD) - .map(|matches| (Self(args::KeyExport::parse(matches)))) + .map(|matches| Self(args::KeyExport::parse(matches))) } fn def() -> App { @@ -801,7 +801,7 @@ pub mod cmds { fn parse(matches: &ArgMatches) -> Option { matches .subcommand_matches(Self::CMD) - .map(|matches| (Self(args::KeyConvert::parse(matches)))) + .map(|matches| Self(args::KeyConvert::parse(matches))) } fn def() -> App { @@ -824,7 +824,7 @@ pub mod cmds { fn parse(matches: &ArgMatches) -> Option { matches .subcommand_matches(Self::CMD) - .map(|matches| (Self(args::KeyImport::parse(matches)))) + .map(|matches| Self(args::KeyImport::parse(matches))) } fn def() -> App { @@ -847,7 +847,7 @@ pub mod cmds { fn parse(matches: &ArgMatches) -> Option { matches .subcommand_matches(Self::CMD) - .map(|matches| (Self(args::KeyAddressAdd::parse(matches)))) + .map(|matches| Self(args::KeyAddressAdd::parse(matches))) } fn def() -> App { diff --git a/crates/apps_lib/src/cli/wallet.rs b/crates/apps_lib/src/cli/wallet.rs index 19f4261d3a4..a6bb2865503 100644 --- a/crates/apps_lib/src/cli/wallet.rs +++ b/crates/apps_lib/src/cli/wallet.rs @@ -1076,15 +1076,15 @@ fn transparent_address_or_alias_find( alias ); } - } else if address.is_some() { - if let Some(alias) = wallet.find_alias(address.as_ref().unwrap()) { + } else if let Some(address) = address.as_ref() { + if let Some(alias) = wallet.find_alias(address) { display_line!(io, "Found alias {}", alias); } else { display_line!( io, "No address with alias {} found. Use the command `list \ --addr` to see all the known transparent addresses.", - address.unwrap() + address ); } } @@ -1116,17 +1116,15 @@ fn payment_address_or_alias_find( alias ); } - } else if payment_address.is_some() { - if let Some(alias) = - wallet.find_alias_by_payment_addr(payment_address.as_ref().unwrap()) - { + } else if let Some(address) = payment_address.as_ref() { + if let Some(alias) = wallet.find_alias_by_payment_addr(address) { display_line!(io, "Found alias {}", alias); } else { display_line!( io, "No address with alias {} found. Use the command `list \ --shielded --addr` to see all the known payment addresses.", - payment_address.unwrap() + address ); } } diff --git a/crates/apps_lib/src/config/genesis/chain.rs b/crates/apps_lib/src/config/genesis/chain.rs index f3604c3bbe2..137d67dde64 100644 --- a/crates/apps_lib/src/config/genesis/chain.rs +++ b/crates/apps_lib/src/config/genesis/chain.rs @@ -303,8 +303,9 @@ impl Finalized { &self, add_persistent_peers: bool, ) -> Vec { - add_persistent_peers.then(|| { - self.transactions + if add_persistent_peers { + { + self.transactions .validator_account .as_ref() .map(|txs| { @@ -313,8 +314,10 @@ impl Finalized { .collect() }) .unwrap_or_default() - }) - .unwrap_or_default() + } + } else { + Default::default() + } } /// Get the chain parameters set in genesis diff --git a/crates/apps_lib/src/logging.rs b/crates/apps_lib/src/logging.rs index f77b745c1df..a54ad8a031a 100644 --- a/crates/apps_lib/src/logging.rs +++ b/crates/apps_lib/src/logging.rs @@ -21,19 +21,14 @@ const ROLLING_ENV_KEY: &str = "NAMADA_LOG_ROLLING"; const LOG_FILE_NAME_PREFIX: &str = "namada.log"; -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Default)] enum Fmt { + #[default] Full, Json, Pretty, } -impl Default for Fmt { - fn default() -> Self { - Self::Full - } -} - /// When logging to a file is enabled, returns a guard that handles flushing of /// remaining logs on termination. /// diff --git a/crates/core/src/booleans.rs b/crates/core/src/booleans.rs index 8b96e2a2aa9..8485c648819 100644 --- a/crates/core/src/booleans.rs +++ b/crates/core/src/booleans.rs @@ -4,23 +4,23 @@ /// [`Result`] values of unit and some error type. pub trait BoolResultUnitExt { /// Return `Ok(())` if true, or `error` if false. - fn ok_or(self, error: E) -> Result<(), E>; + fn ext_ok_or(self, error: E) -> Result<(), E>; /// Return `Ok(())` if true, or the value returned by /// `handle_err` if false. - fn ok_or_else(self, handle_err: F) -> Result<(), E> + fn ext_ok_or_else(self, handle_err: F) -> Result<(), E> where F: FnOnce() -> E; } impl BoolResultUnitExt for bool { #[inline] - fn ok_or(self, error: E) -> Result<(), E> { + fn ext_ok_or(self, error: E) -> Result<(), E> { if self { Ok(()) } else { Err(error) } } #[inline] - fn ok_or_else(self, handle_err: F) -> Result<(), E> + fn ext_ok_or_else(self, handle_err: F) -> Result<(), E> where F: FnOnce() -> E, { @@ -33,11 +33,11 @@ impl BoolResultUnitExt for bool { pub trait ResultBoolExt { /// Return `Ok(())` if `Ok(true)`, `Err(error)` if `Ok(false)` /// or pass back the error if `Err(_)`. - fn true_or(self, error: E) -> Result<(), E>; + fn ext_true_or(self, error: E) -> Result<(), E>; /// Return `Ok(())` if `Ok(true)`, `Err(handle_err())` if `Ok(false)` /// or pass back the error if `Err(_)`. - fn true_or_else(self, handle_err: F) -> Result<(), E> + fn ext_true_or_else(self, handle_err: F) -> Result<(), E> where F: FnOnce() -> E; } @@ -46,17 +46,17 @@ impl ResultBoolExt for Result { /// Return `Ok(())` if `Ok(true)`, `Err(error)` if `Ok(false)` /// or pass back the error if `Err(_)`. #[inline] - fn true_or(self, error: E) -> Result<(), E> { - self.and_then(|ok| ok.ok_or(error)) + fn ext_true_or(self, error: E) -> Result<(), E> { + self.and_then(|ok| ok.ext_ok_or(error)) } /// Return `Ok(())` if `Ok(true)`, `Err(handle_err())` if `Ok(false)` /// or pass back the error if `Err(_)`. #[inline] - fn true_or_else(self, handle_err: F) -> Result<(), E> + fn ext_true_or_else(self, handle_err: F) -> Result<(), E> where F: FnOnce() -> E, { - self.and_then(|ok| ok.ok_or_else(handle_err)) + self.and_then(|ok| ok.ext_ok_or_else(handle_err)) } } diff --git a/crates/core/src/chain.rs b/crates/core/src/chain.rs index 41ae40c3326..260580b9a01 100644 --- a/crates/core/src/chain.rs +++ b/crates/core/src/chain.rs @@ -349,7 +349,7 @@ impl Epoch { /// length. Work-around for `Step` implementation pending on stabilization of . pub fn iter_range(self, len: u64) -> impl Iterator + Clone { let start_ix: u64 = self.into(); - let end_ix: u64 = start_ix.checked_add(len).unwrap_or(u64::MAX); + let end_ix: u64 = start_ix.saturating_add(len); (start_ix..end_ix).map(Epoch::from) } diff --git a/crates/core/src/token.rs b/crates/core/src/token.rs index de30d386a20..68e678ceb17 100644 --- a/crates/core/src/token.rs +++ b/crates/core/src/token.rs @@ -1488,7 +1488,7 @@ mod tests { fn test_token_amount_from_u128() { for val in [ u128::MIN, - u128::MIN + 1, + 1, u128::from(u64::MAX) - 1, u128::from(u64::MAX), u128::from(u64::MAX) + 1, diff --git a/crates/ethereum_bridge/src/protocol/transactions/ethereum_events/eth_msgs.rs b/crates/ethereum_bridge/src/protocol/transactions/ethereum_events/eth_msgs.rs index 24f66a45a09..0f35ae4aff2 100644 --- a/crates/ethereum_bridge/src/protocol/transactions/ethereum_events/eth_msgs.rs +++ b/crates/ethereum_bridge/src/protocol/transactions/ethereum_events/eth_msgs.rs @@ -1,11 +1,11 @@ -use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; +use borsh::{BorshDeserialize, BorshSerialize}; use namada_core::ethereum_events::EthereumEvent; use namada_macros::BorshDeserializer; #[cfg(feature = "migrations")] use namada_migrations::*; use namada_vote_ext::ethereum_events::MultiSignedEthEvent; -use crate::protocol::transactions::votes::{Tally, Votes, dedupe}; +use crate::protocol::transactions::votes::{Votes, dedupe}; /// Represents an Ethereum event being seen by some validators #[derive( @@ -40,24 +40,6 @@ impl From for EthMsgUpdate { } } -/// Represents an event stored under `eth_msgs` -#[derive( - Clone, - Debug, - PartialEq, - Eq, - BorshSerialize, - BorshDeserialize, - BorshDeserializer, - BorshSchema, -)] -pub struct EthMsg { - /// The event being stored - pub body: EthereumEvent, - /// Tallying of votes for this event - pub votes: Tally, -} - #[cfg(test)] mod tests { use std::collections::BTreeSet; diff --git a/crates/ethereum_bridge/src/vp/bridge_pool_vp.rs b/crates/ethereum_bridge/src/vp/bridge_pool_vp.rs index ffe10c8fde9..4fb8f74e25c 100644 --- a/crates/ethereum_bridge/src/vp/bridge_pool_vp.rs +++ b/crates/ethereum_bridge/src/vp/bridge_pool_vp.rs @@ -168,14 +168,14 @@ where &transfer, escrow_checks.token_check, )? - .ok_or_else(|| { + .ext_ok_or_else(|| { Error::new_const( "The wrapped NAM tokens were not escrowed properly", ) }) } else { Self::check_escrowed_toks(ctx, escrow_checks.token_check)? - .ok_or_else(|| { + .ext_ok_or_else(|| { Error::new_alloc(format!( "The {} tokens were not escrowed properly", transfer.transfer.asset diff --git a/crates/ethereum_bridge/src/vp/eth_bridge_vp.rs b/crates/ethereum_bridge/src/vp/eth_bridge_vp.rs index eff83cac5b4..bfb81c47e48 100644 --- a/crates/ethereum_bridge/src/vp/eth_bridge_vp.rs +++ b/crates/ethereum_bridge/src/vp/eth_bridge_vp.rs @@ -77,7 +77,7 @@ where let bridge_pool_is_verifier = verifiers.contains(&storage::bridge_pool::BRIDGE_POOL_ADDRESS); - bridge_pool_is_verifier.ok_or_else(|| { + bridge_pool_is_verifier.ext_ok_or_else(|| { Error::new_const( "Bridge pool VP was not marked as a verifier of the \ transaction", diff --git a/crates/ethereum_bridge/src/vp/nut_vp.rs b/crates/ethereum_bridge/src/vp/nut_vp.rs index 40f637acf68..c2fdbeb6cbd 100644 --- a/crates/ethereum_bridge/src/vp/nut_vp.rs +++ b/crates/ethereum_bridge/src/vp/nut_vp.rs @@ -39,7 +39,7 @@ where verifiers .contains(&Address::Internal(InternalAddress::Multitoken)) - .ok_or_else(|| { + .ext_ok_or_else(|| { let error = Error::new_const("Rejecting non-multitoken transfer tx"); tracing::debug!("{error}"); diff --git a/crates/events/src/tracer.rs b/crates/events/src/tracer.rs index 33fc9524ca9..8a72684d920 100644 --- a/crates/events/src/tracer.rs +++ b/crates/events/src/tracer.rs @@ -121,7 +121,7 @@ impl FromStr for EventTrace<'_> { } } - (init_state == bits::DONE).ok_or_else(|| { + (init_state == bits::DONE).ext_ok_or_else(|| { "Some fields were not initialized in the event trace".to_owned() })?; diff --git a/crates/governance/src/vp/mod.rs b/crates/governance/src/vp/mod.rs index 896edb95584..8465ae2d24d 100644 --- a/crates/governance/src/vp/mod.rs +++ b/crates/governance/src/vp/mod.rs @@ -320,7 +320,7 @@ where pre_voting_start_epoch, pre_voting_end_epoch, ) - .ok_or_else(|| { + .ext_ok_or_else(|| { Error::new_alloc(format!( "Validator {voter} voted outside of the voting period. \ Current epoch: {current_epoch}, pre voting start epoch: \ @@ -425,15 +425,15 @@ where let is_valid_total_pgf_actions = stewards.len() < MAX_PGF_ACTIONS; - return if is_valid_total_pgf_actions { + if is_valid_total_pgf_actions { Ok(()) } else { - return Err(Error::new_alloc(format!( + Err(Error::new_alloc(format!( "Maximum number of steward actions \ ({MAX_PGF_ACTIONS}) exceeded ({})", stewards.len() - ))); - }; + ))) + } } else if let Some(address) = stewards_added.first() { let author_key = gov_storage::get_author_key(proposal_id); let author = Self::force_read::
( @@ -470,9 +470,9 @@ where ))); } - return Ok(()); + Ok(()) } else { - return Err(Error::new_const("Invalid PGF proposal")); + Err(Error::new_const("Invalid PGF proposal")) } } ProposalType::PGFPayment(fundings) => { @@ -537,7 +537,7 @@ where .count() as u64 == 0; - are_targets_unique.ok_or_else(|| { + are_targets_unique.ext_ok_or_else(|| { Error::new_const( "One or more payment targets were added and removed \ in the same proposal", @@ -808,7 +808,7 @@ where let diff = checked!(end_epoch - start_epoch)?; let valid_voting_period = diff.0 >= min_period && diff.0 <= max_period; - valid_voting_period.ok_or_else(|| { + valid_voting_period.ext_ok_or_else(|| { Error::new_alloc(format!( "Proposal with id {proposal_id} must have a voting period \ with a minimum of {min_period} epochs, and a maximum of \ @@ -843,7 +843,7 @@ where || { let is_post_funds_greater_than_minimum = post_funds >= min_funds_parameter; - is_post_funds_greater_than_minimum.ok_or_else(|| { + is_post_funds_greater_than_minimum.ext_ok_or_else(|| { Error::new_alloc(format!( "Funds must be greater than the minimum funds of {}", min_funds_parameter.native_denominated() @@ -851,7 +851,7 @@ where })?; let post_balance_is_same = post_balance == post_funds; - post_balance_is_same.ok_or_else(|| { + post_balance_is_same.ext_ok_or_else(|| { Error::new_alloc(format!( "Funds and the balance of the governance account have \ diverged: funds {} != balance {}", @@ -864,7 +864,7 @@ where |pre_balance| { let is_post_funds_greater_than_minimum = post_funds >= min_funds_parameter; - is_post_funds_greater_than_minimum.ok_or_else(|| { + is_post_funds_greater_than_minimum.ext_ok_or_else(|| { Error::new_alloc(format!( "Funds {} must be greater than the minimum funds of {}", post_funds.native_denominated(), @@ -874,7 +874,7 @@ where let is_valid_funds = post_balance >= pre_balance && checked!(post_balance - pre_balance)? == post_funds; - is_valid_funds.ok_or_else(|| { + is_valid_funds.ext_ok_or_else(|| { Error::new_alloc(format!( "Invalid funds {} have been written to storage", post_funds.native_denominated() @@ -911,7 +911,7 @@ where post_balance >= pre_balance }; - is_valid_balance.ok_or_else(|| { + is_valid_balance.ext_ok_or_else(|| { Error::new_const("Invalid balance change for governance address") }) } @@ -933,14 +933,14 @@ where } let author = Self::force_read(ctx, &author_key, ReadType::Post)?; - namada_account::exists(&ctx.pre(), &author).true_or_else(|| { + namada_account::exists(&ctx.pre(), &author).ext_true_or_else(|| { Error::new_alloc(format!( "No author account {author} could be found for the proposal \ with id {proposal_id}" )) })?; - verifiers.contains(&author).ok_or_else(|| { + verifiers.contains(&author).ext_ok_or_else(|| { Error::new_alloc(format!( "The VP of the proposal with id {proposal_id}'s author \ {author} should have been triggered" @@ -959,7 +959,7 @@ where let expected_counter = checked!(pre_counter + set_count)?; let valid_counter = expected_counter == post_counter; - valid_counter.ok_or_else(|| { + valid_counter.ext_ok_or_else(|| { Error::new_alloc(format!( "Invalid proposal counter. Expected {expected_counter}, but \ got {post_counter} instead." @@ -980,7 +980,7 @@ where // register a committing key causing a bug let pre_counter_is_lower = pre_counter < post_counter; - pre_counter_is_lower.ok_or_else(|| { + pre_counter_is_lower.ext_ok_or_else(|| { Error::new_alloc(format!( "The value of the previous counter {pre_counter} must be \ lower than the value of the new counter {post_counter}." @@ -1002,7 +1002,7 @@ where )) }, |data| { - is_proposal_accepted(&ctx.pre(), data.as_ref())?.ok_or_else( + is_proposal_accepted(&ctx.pre(), data.as_ref())?.ext_ok_or_else( || { Error::new_const( "Governance parameter changes can only be \ diff --git a/crates/governance/src/vp/pgf.rs b/crates/governance/src/vp/pgf.rs index 43a75e6d7ff..75653091246 100644 --- a/crates/governance/src/vp/pgf.rs +++ b/crates/governance/src/vp/pgf.rs @@ -141,16 +141,16 @@ where .map_or_else( // if a steward resigns, check their signature || { - verifiers.contains(&steward_address).ok_or_else( - || { + verifiers + .contains(&steward_address) + .ext_ok_or_else(|| { Error::new_alloc(format!( "The VP of the steward \ {steward_address} should have \ been triggered to check their \ signature" )) - }, - ) + }) }, // if a steward updates the reward distribution (so // total_stewards_pre == total_stewards_post) check @@ -165,7 +165,7 @@ where } steward .is_valid_reward_distribution() - .ok_or_else(|| { + .ext_ok_or_else(|| { Error::new_const( "Steward commissions are invalid", ) @@ -202,7 +202,7 @@ where )) }, |data| { - is_proposal_accepted(&ctx.pre(), data.as_ref())?.ok_or_else( + is_proposal_accepted(&ctx.pre(), data.as_ref())?.ext_ok_or_else( || { Error::new_const( "PGF parameter changes can only be performed by a \ @@ -228,7 +228,7 @@ where let is_valid_balance = post_balance >= pre_balance; - is_valid_balance.ok_or_else(|| { + is_valid_balance.ext_ok_or_else(|| { Error::new_const("Only governance can debit from PGF account") }) } diff --git a/crates/node/src/protocol.rs b/crates/node/src/protocol.rs index 7865ea4078f..6ddfb087ca3 100644 --- a/crates/node/src/protocol.rs +++ b/crates/node/src/protocol.rs @@ -1441,7 +1441,7 @@ where .contains(&Address::Internal( InternalAddress::Multitoken, )) - .ok_or_else(|| { + .ext_ok_or_else(|| { Error::AccessForbidden( internal_addr.clone(), ) diff --git a/crates/parameters/src/vp.rs b/crates/parameters/src/vp.rs index dd6e28b9666..c8cda84066a 100644 --- a/crates/parameters/src/vp.rs +++ b/crates/parameters/src/vp.rs @@ -41,7 +41,7 @@ where match key_type { KeyType::PARAMETER | KeyType::UNKNOWN_PARAMETER => { let is_gov = Gov::is_proposal_accepted(&ctx.pre(), &data)? - .ok_or_else(|| { + .ext_ok_or_else(|| { Error::new_alloc(format!( "Attempted to change a protocol parameter \ from outside of a governance proposal, or \ diff --git a/crates/proof_of_stake/src/lib.rs b/crates/proof_of_stake/src/lib.rs index a9b0aa84300..705285ef6a4 100644 --- a/crates/proof_of_stake/src/lib.rs +++ b/crates/proof_of_stake/src/lib.rs @@ -2666,7 +2666,7 @@ where // Get the addresses of the validators who voted let vote_addresses = votes .iter() - .map(|vote| (&vote.validator_address)) + .map(|vote| &vote.validator_address) .collect::>(); let height_to_prune = diff --git a/crates/proof_of_stake/src/tests/state_machine.rs b/crates/proof_of_stake/src/tests/state_machine.rs index bb94cfa2516..a185f260549 100644 --- a/crates/proof_of_stake/src/tests/state_machine.rs +++ b/crates/proof_of_stake/src/tests/state_machine.rs @@ -2241,8 +2241,8 @@ impl ReferenceStateMachine for AbstractPosState { let consensus_set = state.consensus_set.entry(epoch).or_default(); let consensus_vals_len = consensus_set - .iter() - .map(|(_stake, validators)| validators.len() as u64) + .values() + .map(|validators| validators.len() as u64) .sum(); if tokens < state.params.validator_stake_threshold { diff --git a/crates/proof_of_stake/src/tests/state_machine_v2.rs b/crates/proof_of_stake/src/tests/state_machine_v2.rs index 89fa68d6867..caef1969c1a 100644 --- a/crates/proof_of_stake/src/tests/state_machine_v2.rs +++ b/crates/proof_of_stake/src/tests/state_machine_v2.rs @@ -3639,8 +3639,8 @@ impl ReferenceStateMachine for AbstractPosState { let consensus_set = state.consensus_set.entry(epoch).or_default(); let consensus_vals_len = consensus_set - .iter() - .map(|(_stake, validators)| validators.len() as u64) + .values() + .map(|validators| validators.len() as u64) .sum(); if tokens < state.params.validator_stake_threshold { diff --git a/crates/proof_of_stake/src/vp.rs b/crates/proof_of_stake/src/vp.rs index 095b451ea32..da840a1a2d3 100644 --- a/crates/proof_of_stake/src/vp.rs +++ b/crates/proof_of_stake/src/vp.rs @@ -376,7 +376,7 @@ where fn is_valid_parameter_change(ctx: &'ctx CTX) -> Result<()> { let validation_errors: Vec = read_owned_pos_params(&ctx.post())?.validate(); - validation_errors.is_empty().ok_or_else(|| { + validation_errors.is_empty().ext_ok_or_else(|| { let validation_errors_str = itertools::join(validation_errors, ", "); Error::new_alloc(format!( diff --git a/crates/sdk/src/lib.rs b/crates/sdk/src/lib.rs index 677f0bdffe3..96003dfd802 100644 --- a/crates/sdk/src/lib.rs +++ b/crates/sdk/src/lib.rs @@ -85,10 +85,6 @@ pub const DEFAULT_GAS_LIMIT: u64 = 50_000; /// An interface for high-level interaction with the Namada SDK #[cfg_attr(feature = "async-send", async_trait::async_trait)] #[cfg_attr(not(feature = "async-send"), async_trait::async_trait(?Send))] -#[rustversion::attr( - nightly, - allow(elided_named_lifetimes, reason = "Not actually named") -)] pub trait Namada: NamadaIo { /// Captures the interactive parts of the wallet's functioning type WalletUtils: WalletIo + WalletStorage + MaybeSend + MaybeSync; @@ -772,7 +768,7 @@ where #[cfg_attr(not(feature = "async-send"), async_trait::async_trait(?Send))] #[rustversion::attr( nightly, - allow(elided_named_lifetimes, reason = "Not actually named") + allow(mismatched_lifetime_syntaxes, reason = "Not actually named") )] impl Namada for NamadaImpl where diff --git a/crates/sdk/src/migrations.rs b/crates/sdk/src/migrations.rs index 9c973054589..c53e1af9b9b 100644 --- a/crates/sdk/src/migrations.rs +++ b/crates/sdk/src/migrations.rs @@ -560,7 +560,11 @@ impl Display for DbUpdateType { "Write to key in {} CF: <{}> with {}value: {}", cf.to_str(), key, - value.is_raw().then_some("raw ").unwrap_or_default(), + if value.is_raw() { + "raw " + } else { + Default::default() + }, formatted )) } @@ -580,7 +584,11 @@ impl Display for DbUpdateType { "Write to pattern in {} CF: <{}> with {}value: {}", cf.to_str(), pattern, - value.is_raw().then_some("raw ").unwrap_or_default(), + if value.is_raw() { + "raw " + } else { + Default::default() + }, formatted, )) } diff --git a/crates/sdk/src/queries/shell.rs b/crates/sdk/src/queries/shell.rs index 6ed17d266f2..33c4b514a0f 100644 --- a/crates/sdk/src/queries/shell.rs +++ b/crates/sdk/src/queries/shell.rs @@ -223,7 +223,7 @@ where .conversion_state .assets .iter() - .filter(|&(_, asset)| (asset.epoch == masp_epoch)) + .filter(|&(_, asset)| asset.epoch == masp_epoch) .map(|(&asset_type, asset)| { ( asset_type, diff --git a/crates/sdk/src/signing.rs b/crates/sdk/src/signing.rs index f8ca8722fb4..0923843f310 100644 --- a/crates/sdk/src/signing.rs +++ b/crates/sdk/src/signing.rs @@ -2522,10 +2522,6 @@ mod test_signing { } #[cfg_attr(feature = "async-send", async_trait::async_trait)] #[cfg_attr(not(feature = "async-send"), async_trait::async_trait(?Send))] - #[rustversion::attr( - nightly, - allow(elided_named_lifetimes, reason = "Not actually named") - )] impl Namada for TestNamadaImpl { type ShieldedUtils = FsShieldedUtils; type WalletUtils = TestWalletUtils; diff --git a/crates/shielded_token/src/vp.rs b/crates/shielded_token/src/vp.rs index ede932c1540..e262f6a7616 100644 --- a/crates/shielded_token/src/vp.rs +++ b/crates/shielded_token/src/vp.rs @@ -117,10 +117,10 @@ where // The MASP transfer keys can only be changed by a valid Transaction Self::is_valid_masp_transfer(ctx, tx_data, keys_changed, verifiers) } else { - return Err(Error::new_const( + Err(Error::new_const( "A governance proposal is required to modify MASP \ non-transfer keys", - )); + )) } } @@ -157,7 +157,7 @@ where // value for this key anyway) ctx.read_bytes_post(&nullifier_key)? .is_some_and(|value| value.is_empty()) - .ok_or_else(|| { + .ext_ok_or_else(|| { Error::new_const( "The nullifier should have been committed with no \ associated data", @@ -943,7 +943,7 @@ fn verify_sapling_balancing_value( balance", ); tracing::debug!("{error}"); - return Err(error); + Err(error) } else { Ok(()) } diff --git a/crates/storage/src/error.rs b/crates/storage/src/error.rs index 50115ce012c..472c3a58a3d 100644 --- a/crates/storage/src/error.rs +++ b/crates/storage/src/error.rs @@ -137,8 +137,7 @@ impl std::fmt::Display for CustomError { /// static string (handy for WASM). pub trait OptionExt { /// Transforms the [`Option`] into a [`Result`], mapping - /// [`Some(v)`] to [`Ok(v)`] and [`None`] to the given static error - /// message. + /// `Some(v)` to `Ok(v)` and `None` to the given static error message. fn ok_or_err_msg(self, msg: &'static str) -> Result; } diff --git a/crates/tests/src/lib.rs b/crates/tests/src/lib.rs index 7797f7bf30d..c66471c521d 100644 --- a/crates/tests/src/lib.rs +++ b/crates/tests/src/lib.rs @@ -32,6 +32,7 @@ pub use namada_sdk::*; /// A type corresponding to cometbft `FilePVLastSignState` in `privval/file.go` /// stored in `cometbft/data/priv_validator_state.json` #[derive(Debug, serde::Serialize, serde::Deserialize)] +#[cfg(test)] struct LastSignState { // i64 encoded as a string pub height: String, diff --git a/crates/tests/src/vm_host_env/tx.rs b/crates/tests/src/vm_host_env/tx.rs index 36430728e8f..04767bc60aa 100644 --- a/crates/tests/src/vm_host_env/tx.rs +++ b/crates/tests/src/vm_host_env/tx.rs @@ -853,8 +853,8 @@ mod tests { fn arb_u64() -> impl Strategy { prop_oneof![ 5 => Just(u64::MIN), - 5 => Just(u64::MIN + 1), - 5 => u64::MIN + 2..=u32::MAX as u64, + 5 => Just(1), + 5 => 2..=u32::MAX as u64, 1 => Just(u64::MAX), 1 => Just(u64::MAX - 1), 1 => u32::MAX as u64 + 1..u64::MAX - 1, diff --git a/crates/trans_token/src/vp.rs b/crates/trans_token/src/vp.rs index 36eb7a0f33c..683905a6830 100644 --- a/crates/trans_token/src/vp.rs +++ b/crates/trans_token/src/vp.rs @@ -232,7 +232,7 @@ where == dec_mint.checked_sub(inc_mint) }; - token_changes_are_balanced.ok_or_else(|| { + token_changes_are_balanced.ext_ok_or_else(|| { Error::new_const( "The transaction's token changes are unbalanced", ) @@ -255,7 +255,7 @@ where if minter == Address::Internal(InternalAddress::Ibc) => { - verifiers.contains(&minter).ok_or_else(|| { + verifiers.contains(&minter).ext_ok_or_else(|| { Error::new_const("The IBC VP was not triggered") }) } @@ -283,7 +283,7 @@ where }, |data| { Gov::is_proposal_accepted(&ctx.pre(), data.as_ref())? - .ok_or_else(|| { + .ext_ok_or_else(|| { Error::new_const( "Token parameter changes can only be performed by \ a governance proposal that has been accepted", diff --git a/crates/tx/src/types.rs b/crates/tx/src/types.rs index 7a3539642f5..769f4279d1f 100644 --- a/crates/tx/src/types.rs +++ b/crates/tx/src/types.rs @@ -1154,7 +1154,7 @@ impl BatchedTx { #[cfg(test)] mod test { use std::collections::BTreeMap; - use std::fs; + use std::{fs, slice}; use assert_matches::assert_matches; use data_encoding::HEXLOWER; @@ -1418,8 +1418,11 @@ mod test { // Sign the tx with one key only - sk1 { let mut tx = tx.clone(); - let signatures = - tx.compute_section_signature(&[sk1.clone()], &pks_map, None); + let signatures = tx.compute_section_signature( + slice::from_ref(&sk1), + &pks_map, + None, + ); assert_eq!(signatures.len(), 1); tx.add_signatures(signatures); @@ -1491,7 +1494,7 @@ mod test { let pks_map_wrong = AccountPublicKeysMap::from_iter(vec![pk1.clone()]); let signatures = tx.compute_section_signature( - &[sk1.clone()], + slice::from_ref(&sk1), &pks_map_wrong, None, ); @@ -1523,7 +1526,7 @@ mod test { let pks_map_wrong = AccountPublicKeysMap::from_iter(vec![pk1.clone()]); let signatures = tx.compute_section_signature( - &[sk1.clone()], + slice::from_ref(&sk1), &pks_map_wrong, None, ); @@ -1561,7 +1564,7 @@ mod test { let pks_map_wrong = AccountPublicKeysMap::from_iter(vec![pk1.clone()]); let signatures = tx.compute_section_signature( - &[sk1.clone()], + slice::from_ref(&sk1), &pks_map_wrong, None, ); diff --git a/crates/vote_ext/src/ethereum_events.rs b/crates/vote_ext/src/ethereum_events.rs index 56db6606ed3..4786ae8e24b 100644 --- a/crates/vote_ext/src/ethereum_events.rs +++ b/crates/vote_ext/src/ethereum_events.rs @@ -256,7 +256,7 @@ mod tests { ext }); - let ext = vec![ext_1, ext_2, ext_3]; + let ext = [ext_1, ext_2, ext_3]; // we have the `Signed` instances we need, // let us now compress them into a single `VextDigest` diff --git a/rust-nightly-version b/rust-nightly-version index fb518dc2b71..a1decf6a031 100644 --- a/rust-nightly-version +++ b/rust-nightly-version @@ -1 +1 @@ -nightly-2025-03-27 +nightly-2025-11-17 diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 7ecae5d0431..5f69a9c4b67 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "1.85.1" -components = ["rustc", "cargo", "rust-std", "rust-docs", "rls", "rust-src", "rust-analysis"] +channel = "1.91.1" +components = ["rustc", "cargo", "rust-std", "rust-docs", "rust-src", "rust-analyzer"] targets = ['wasm32-unknown-unknown'] diff --git a/wasm/Cargo.lock b/wasm/Cargo.lock index 662af707b7d..8e586af3a10 100644 --- a/wasm/Cargo.lock +++ b/wasm/Cargo.lock @@ -4606,6 +4606,175 @@ dependencies = [ "parity-wasm", ] +[[package]] +name = "nam-wasmer" +version = "4.4.0-nam.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3581e8dc0cfc304075640e6899014bc1b27455c2da93dcdfa6c758e6769f42cb" +dependencies = [ + "bytes", + "cfg-if", + "derivative", + "indexmap 1.9.3", + "js-sys", + "more-asserts", + "nam-wasmer-compiler", + "nam-wasmer-compiler-cranelift", + "nam-wasmer-derive", + "nam-wasmer-types", + "nam-wasmer-vm", + "rustc-demangle", + "serde", + "serde-wasm-bindgen", + "shared-buffer", + "target-lexicon", + "thiserror 1.0.69", + "tracing", + "wasm-bindgen", + "wat", + "windows-sys 0.59.0", +] + +[[package]] +name = "nam-wasmer-cache" +version = "4.4.0-nam.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59f09ed14f6a5ad8f29df51301b5a9a94a22a8cc35d3c9e2261ec1c996928f64" +dependencies = [ + "blake3", + "hex", + "nam-wasmer", + "thiserror 1.0.69", +] + +[[package]] +name = "nam-wasmer-compiler" +version = "4.4.0-nam.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a66cbcb0362b5fe96ca088540053072ca66e6acd5302998bcc817be5cc175afc" +dependencies = [ + "backtrace", + "bytes", + "cfg-if", + "enum-iterator", + "enumset", + "lazy_static", + "leb128", + "libc", + "memmap2 0.6.2", + "more-asserts", + "nam-wasmer-types", + "nam-wasmer-vm", + "region", + "rkyv", + "self_cell", + "shared-buffer", + "smallvec", + "thiserror 1.0.69", + "wasmparser", + "windows-sys 0.59.0", + "xxhash-rust", +] + +[[package]] +name = "nam-wasmer-compiler-cranelift" +version = "4.4.0-nam.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1b743a12f25f7e60a837a76399e3a522f34741305bd94a384c95c9a82e0570a" +dependencies = [ + "cranelift-codegen", + "cranelift-entity", + "cranelift-frontend", + "gimli 0.26.2", + "more-asserts", + "nam-wasmer-compiler", + "nam-wasmer-types", + "rayon", + "smallvec", + "target-lexicon", + "tracing", +] + +[[package]] +name = "nam-wasmer-compiler-singlepass" +version = "4.4.0-nam.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2de27e7e6fa858bc723426de49df964dc82146802bc6f3d319713218bc57ae76" +dependencies = [ + "byteorder", + "dynasm", + "dynasmrt", + "enumset", + "gimli 0.26.2", + "lazy_static", + "more-asserts", + "nam-wasmer-compiler", + "nam-wasmer-types", + "rayon", + "smallvec", +] + +[[package]] +name = "nam-wasmer-derive" +version = "4.4.0-nam.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84d709563c07f9020feb672cd9942d67a93dc611d73ddc6fff1ada13a562735b" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "nam-wasmer-types" +version = "4.4.0-nam.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891920ff63d1b271d4b174e553c8816e3378b4c2e2a23e21bd28c877af0efe13" +dependencies = [ + "bytecheck", + "enum-iterator", + "enumset", + "getrandom 0.2.15", + "hex", + "indexmap 1.9.3", + "more-asserts", + "rkyv", + "sha2 0.10.8", + "target-lexicon", + "thiserror 1.0.69", + "xxhash-rust", +] + +[[package]] +name = "nam-wasmer-vm" +version = "4.4.0-nam.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "766ce48171a49ac3994ec43fa69f25464112e3f79aa0766d699676bf3a2440d3" +dependencies = [ + "backtrace", + "cc", + "cfg-if", + "corosensei", + "crossbeam-queue", + "dashmap", + "derivative", + "enum-iterator", + "fnv", + "indexmap 1.9.3", + "lazy_static", + "libc", + "mach2", + "memoffset", + "more-asserts", + "nam-wasmer-types", + "region", + "rustversion", + "scopeguard", + "thiserror 1.0.69", + "windows-sys 0.59.0", +] + [[package]] name = "namada_account" version = "0.251.0" @@ -5059,6 +5228,7 @@ dependencies = [ "ics23", "itertools 0.14.0", "masp_primitives", + "nam-wasmer", "namada_core", "namada_sdk", "namada_test_utils", @@ -5077,7 +5247,6 @@ dependencies = [ "tempfile", "test-log", "tokio", - "wasmer", ] [[package]] @@ -5182,6 +5351,10 @@ dependencies = [ "clru", "git2", "nam-wasm-instrument", + "nam-wasmer", + "nam-wasmer-cache", + "nam-wasmer-compiler-singlepass", + "nam-wasmer-vm", "namada_account", "namada_core", "namada_events", @@ -5198,10 +5371,6 @@ dependencies = [ "tempfile", "thiserror 2.0.12", "tracing", - "wasmer", - "wasmer-cache", - "wasmer-compiler-singlepass", - "wasmer-vm", "wasmparser", ] @@ -8724,174 +8893,6 @@ dependencies = [ "leb128", ] -[[package]] -name = "wasmer" -version = "4.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d920d06243e9f456c336c428a34560357dedf59d9febaae14f1995ac120cff6" -dependencies = [ - "bytes", - "cfg-if", - "derivative", - "indexmap 1.9.3", - "js-sys", - "more-asserts", - "rustc-demangle", - "serde", - "serde-wasm-bindgen", - "shared-buffer", - "target-lexicon", - "thiserror 1.0.69", - "tracing", - "wasm-bindgen", - "wasmer-compiler", - "wasmer-compiler-cranelift", - "wasmer-derive", - "wasmer-types", - "wasmer-vm", - "wat", - "windows-sys 0.59.0", -] - -[[package]] -name = "wasmer-cache" -version = "4.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e2aa507d7ab1d7f6038f60ca107bc4629c5dbf3a0e18427091b7576b0ffbbd9" -dependencies = [ - "blake3", - "hex", - "thiserror 1.0.69", - "wasmer", -] - -[[package]] -name = "wasmer-compiler" -version = "4.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e01832173aa52345e480965f18c638a8a5a9e5e4d85a48675bdf1964147dc7f" -dependencies = [ - "backtrace", - "bytes", - "cfg-if", - "enum-iterator", - "enumset", - "lazy_static", - "leb128", - "libc", - "memmap2 0.6.2", - "more-asserts", - "region", - "rkyv", - "self_cell", - "shared-buffer", - "smallvec", - "thiserror 1.0.69", - "wasmer-types", - "wasmer-vm", - "wasmparser", - "windows-sys 0.59.0", - "xxhash-rust", -] - -[[package]] -name = "wasmer-compiler-cranelift" -version = "4.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c1618f53b492cf6649beeb372930e376e0f52d9842c0c5eb5aa2b548251dab6" -dependencies = [ - "cranelift-codegen", - "cranelift-entity", - "cranelift-frontend", - "gimli 0.26.2", - "more-asserts", - "rayon", - "smallvec", - "target-lexicon", - "tracing", - "wasmer-compiler", - "wasmer-types", -] - -[[package]] -name = "wasmer-compiler-singlepass" -version = "4.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2b111c55d0b8a30dba67afe8766c56b53f0055653f0bb14b1a337056263ae48" -dependencies = [ - "byteorder", - "dynasm", - "dynasmrt", - "enumset", - "gimli 0.26.2", - "lazy_static", - "more-asserts", - "rayon", - "smallvec", - "wasmer-compiler", - "wasmer-types", -] - -[[package]] -name = "wasmer-derive" -version = "4.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c5875633aea92153b6a561cb07363785ca9e07792ca6cd7c1cc371761001d8f" -dependencies = [ - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "wasmer-types" -version = "4.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fb32f0d231b591e4c8a65e81d4647fa3180496d71a123d4948dba8551bba9c2" -dependencies = [ - "bytecheck", - "enum-iterator", - "enumset", - "getrandom 0.2.15", - "hex", - "indexmap 1.9.3", - "more-asserts", - "rkyv", - "sha2 0.10.8", - "target-lexicon", - "thiserror 1.0.69", - "xxhash-rust", -] - -[[package]] -name = "wasmer-vm" -version = "4.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e38e9301f5bb9f18da9cda4002d74d2cb6ac1f36dcf919fd77f91fca321fb1e5" -dependencies = [ - "backtrace", - "cc", - "cfg-if", - "corosensei", - "crossbeam-queue", - "dashmap", - "derivative", - "enum-iterator", - "fnv", - "indexmap 1.9.3", - "lazy_static", - "libc", - "mach2", - "memoffset", - "more-asserts", - "region", - "scopeguard", - "thiserror 1.0.69", - "wasmer-types", - "windows-sys 0.59.0", -] - [[package]] name = "wasmparser" version = "0.121.2" diff --git a/wasm/Makefile b/wasm/Makefile index c17703793d9..98600195e9a 100644 --- a/wasm/Makefile +++ b/wasm/Makefile @@ -5,15 +5,15 @@ nightly := $(shell cat ../rust-nightly-version) # Build all wasms in release mode all: - RUSTFLAGS='-C link-arg=-s' $(cargo) build --release --target wasm32-unknown-unknown --target-dir 'target' + RUSTFLAGS='-C link-arg=-s -C target-feature=-bulk-memory,-bulk-memory-opt' $(cargo) build --release --target wasm32-unknown-unknown --target-dir 'target' cp target/wasm32-unknown-unknown/release/*.wasm . release-unwind: - RUSTFLAGS='-C link-arg=-s' $(cargo) build --features debug-panic-hook --profile release_unwind --target wasm32-unknown-unknown --target-dir 'target' + RUSTFLAGS='-C link-arg=-s -C target-feature=-bulk-memory,-bulk-memory-opt' $(cargo) build --features debug-panic-hook --profile release_unwind --target wasm32-unknown-unknown --target-dir 'target' cp target/wasm32-unknown-unknown/release_unwind/*.wasm . debug: - RUSTFLAGS='-C link-arg=-s' $(cargo) build --target wasm32-unknown-unknown --target-dir 'target' + RUSTFLAGS='-C link-arg=-s -C target-feature=-bulk-memory,-bulk-memory-opt' $(cargo) build --target wasm32-unknown-unknown --target-dir 'target' cp target/wasm32-unknown-unknown/debug/*.wasm . check: diff --git a/wasm/rust-toolchain.toml b/wasm/rust-toolchain.toml index 715e1f5e403..c2985a34165 100644 --- a/wasm/rust-toolchain.toml +++ b/wasm/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.85.1" -components = ["rustc", "cargo", "rust-std", "rust-docs", "rls", "rust-analysis"] +channel = "1.91.1" +components = ["rustc", "cargo", "rust-std", "rust-docs", "rust-analyzer"] diff --git a/wasm/tx_become_validator/src/lib.rs b/wasm/tx_become_validator/src/lib.rs index 30e45d2b138..4dc0cca6ea4 100644 --- a/wasm/tx_become_validator/src/lib.rs +++ b/wasm/tx_become_validator/src/lib.rs @@ -22,7 +22,7 @@ fn apply_tx(ctx: &mut Ctx, tx_data: BatchedTx) -> TxResult { key::common::PublicKey::Secp256k1(become_validator.eth_hot_key.clone()), become_validator.protocol_key.clone(), ]; - verify_signatures_of_pks(&tx_data.tx, all_pks).true_or_else(|| { + verify_signatures_of_pks(&tx_data.tx, all_pks).ext_true_or_else(|| { const ERR_MSG: &str = "Keys ownership signature verification failed"; debug_log!("{ERR_MSG}"); Error::new_const(ERR_MSG) diff --git a/wasm/tx_change_consensus_key/src/lib.rs b/wasm/tx_change_consensus_key/src/lib.rs index 94ab22c2bad..c1c1eab6dc4 100644 --- a/wasm/tx_change_consensus_key/src/lib.rs +++ b/wasm/tx_change_consensus_key/src/lib.rs @@ -15,7 +15,7 @@ fn apply_tx(ctx: &mut Ctx, tx_data: BatchedTx) -> TxResult { // Check that the tx has been signed with the new consensus key verify_signatures_of_pks(&tx_data.tx, vec![consensus_key.clone()]) - .true_or_else(|| { + .ext_true_or_else(|| { const ERR_MSG: &str = "Consensus key ownership signature verification failed"; debug_log!("{ERR_MSG}"); diff --git a/wasm/vp_implicit/src/lib.rs b/wasm/vp_implicit/src/lib.rs index 8ad708c6de6..26367e33be6 100644 --- a/wasm/vp_implicit/src/lib.rs +++ b/wasm/vp_implicit/src/lib.rs @@ -125,7 +125,7 @@ fn validate_tx( if owner == &addr { let key_was_not_already_revealed = !ctx.has_key_pre(key).into_vp_error()?; - key_was_not_already_revealed.ok_or_else(|| { + key_was_not_already_revealed.ext_ok_or_else(|| { VpError::Erased(format!( "Public key of {addr} has already been revealed" )) @@ -148,7 +148,7 @@ fn validate_tx( // Check that address matches with the address // derived from the PK - pk_derived_addr_is_correct.ok_or_else(|| { + pk_derived_addr_is_correct.ext_ok_or_else(|| { VpError::Erased(format!( "The address derived from the revealed \ public key {addr_from_pk} does not match \ @@ -191,7 +191,7 @@ fn validate_tx( Ok(()) } KeyType::TokenMinted => { - verifiers.contains(&address::MULTITOKEN).ok_or_else(|| { + verifiers.contains(&address::MULTITOKEN).ext_ok_or_else(|| { VpError::Erased( "The Multitoken VP should have been a verifier for \ this transaction, since a token was minted" diff --git a/wasm/vp_user/src/lib.rs b/wasm/vp_user/src/lib.rs index d53ea783044..28af7ea306e 100644 --- a/wasm/vp_user/src/lib.rs +++ b/wasm/vp_user/src/lib.rs @@ -151,7 +151,7 @@ fn validate_tx( Ok(()) } KeyType::TokenMinted => { - verifiers.contains(&address::MULTITOKEN).ok_or_else(|| { + verifiers.contains(&address::MULTITOKEN).ext_ok_or_else(|| { VpError::Erased( "The Multitoken VP should have been a verifier for \ this transaction, since a token was minted" diff --git a/wasm_for_tests/Makefile b/wasm_for_tests/Makefile index db5fbbd1c00..62d1ef50fd8 100644 --- a/wasm_for_tests/Makefile +++ b/wasm_for_tests/Makefile @@ -32,15 +32,15 @@ wasms += vp_verify_signature # Build all wasms in release mode all: - RUSTFLAGS='-C link-arg=-s' $(cargo) build --release --target wasm32-unknown-unknown --target-dir 'target' + RUSTFLAGS='-C link-arg=-s -C target-feature=-bulk-memory,-bulk-memory-opt' $(cargo) build --release --target wasm32-unknown-unknown --target-dir 'target' cp target/wasm32-unknown-unknown/release/*.wasm . release-unwind: - RUSTFLAGS='-C link-arg=-s' $(cargo) build --features debug-panic-hook --profile release_unwind --target wasm32-unknown-unknown --target-dir 'target' + RUSTFLAGS='-C link-arg=-s -C target-feature=-bulk-memory,-bulk-memory-opt' $(cargo) build --features debug-panic-hook --profile release_unwind --target wasm32-unknown-unknown --target-dir 'target' cp target/wasm32-unknown-unknown/release_unwind/*.wasm . debug: - RUSTFLAGS='-C link-arg=-s' $(cargo) build --target wasm32-unknown-unknown --target-dir 'target' + RUSTFLAGS='-C link-arg=-s -C target-feature=-bulk-memory,-bulk-memory-opt' $(cargo) build --target wasm32-unknown-unknown --target-dir 'target' cp target/wasm32-unknown-unknown/debug/*.wasm . check: