Skip to content

Commit

Permalink
Merge branch 'tomas/update-toolchain' (#3690)
Browse files Browse the repository at this point in the history
* tomas/update-toolchain:
  ci: rm threads rustflag
  ci: add toolchain to cache key
  changelog: add #3690
  make: add wasm target to nightly
  disable warning from unexpected_cfgs for cfg(fuzzing)
  Rust and clippy suggested fixes
  rustfmt: update config
  update stable Rust to 1.81.0
  update Rust nightly to 2024-09-08
  • Loading branch information
tzemanovic committed Sep 14, 2024
2 parents c43c09c + 092bf3b commit 463d282
Show file tree
Hide file tree
Showing 77 changed files with 313 additions and 242 deletions.
2 changes: 2 additions & 0 deletions .changelog/unreleased/improvements/3690-rust-1.81.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Updated toolchain to Rust 1.81.0.
([\#3690](https://github.com/anoma/namada/pull/3690))
28 changes: 12 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ env:
CACHE_BUCKET: github-runners-remote-cache-shared
SCCACHE_BUCKET: github-runners-remote-cache-shared
AWS_REGION: us-west-2
NIGHTLY: nightly-2024-05-15
NIGHTLY: nightly-2024-09-08
NAMADA_MASP_PARAMS_DIR: /masp/.masp-params

jobs:
Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:
RUNS_ON_S3_BUCKET_CACHE: ${{ env.CACHE_BUCKET }}
with:
path: /usr/local/cargo
key: /cache/${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/Cargo.lock') }}
key: /cache/${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/Cargo.lock') }}-${{ env.NIGHTLY }}
- name: Start sccache server
id: sccache
run: sccache --start-server
Expand Down Expand Up @@ -122,18 +122,14 @@ jobs:
RUNS_ON_S3_BUCKET_CACHE: ${{ env.CACHE_BUCKET }}
with:
path: /usr/local/cargo
key: /cache/${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/Cargo.lock') }}
key: /cache/${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/Cargo.lock') }}-${{ env.NIGHTLY }}
- name: Start sccache server
id: sccache
run: sccache --start-server
- name: Clippy lints
run: make clippy
env:
RUSTFLAGS: "-Z threads=8"
- name: Check format
run: make fmt-check
env:
RUSTFLAGS: "-Z threads=8"
- name: Clean cargo cache
if: steps.cache.outputs.cache-hit != 'true'
run: cargo cache --autoclean-expensive
Expand Down Expand Up @@ -184,7 +180,7 @@ jobs:
RUNS_ON_S3_BUCKET_CACHE: ${{ env.CACHE_BUCKET }}
with:
path: /usr/local/cargo
key: /cache/${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/Cargo.lock') }}
key: /cache/${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/Cargo.lock') }}-${{ env.NIGHTLY }}
- name: Build ${{ matrix.make.name }}
run: make ${{ matrix.make.command }}
- name: Upload ${{ matrix.make.name }} artifacts
Expand Down Expand Up @@ -224,7 +220,7 @@ jobs:
RUNS_ON_S3_BUCKET_CACHE: ${{ env.CACHE_BUCKET }}
with:
path: /usr/local/cargo
key: /cache/${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/Cargo.lock') }}
key: /cache/${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/Cargo.lock') }}-${{ env.NIGHTLY }}
- name: Download wasm artifacts
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -277,7 +273,7 @@ jobs:
RUNS_ON_S3_BUCKET_CACHE: ${{ env.CACHE_BUCKET }}
with:
path: /usr/local/cargo
key: /cache/${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/Cargo.lock') }}
key: /cache/${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/Cargo.lock') }}-${{ env.NIGHTLY }}
- name: Start sccache server
id: sccache
run: sccache --start-server
Expand Down Expand Up @@ -335,7 +331,7 @@ jobs:
RUNS_ON_S3_BUCKET_CACHE: ${{ env.CACHE_BUCKET }}
with:
path: /usr/local/cargo
key: /cache/${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/Cargo.lock') }}
key: /cache/${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/Cargo.lock') }}-${{ env.NIGHTLY }}
- name: Start sccache server
id: sccache
run: sccache --start-server
Expand Down Expand Up @@ -378,7 +374,7 @@ jobs:
RUNS_ON_S3_BUCKET_CACHE: ${{ env.CACHE_BUCKET }}
with:
path: /usr/local/cargo
key: /cache/${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/Cargo.lock') }}
key: /cache/${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/Cargo.lock') }}-${{ env.NIGHTLY }}
- name: Start sccache server
id: sccache
run: sccache --start-server
Expand Down Expand Up @@ -438,7 +434,7 @@ jobs:
RUNS_ON_S3_BUCKET_CACHE: ${{ env.CACHE_BUCKET }}
with:
path: /usr/local/cargo
key: /cache/${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/Cargo.lock') }}
key: /cache/${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/Cargo.lock') }}-${{ env.NIGHTLY }}
- name: Start sccache server
id: sccache
run: sccache --start-server
Expand Down Expand Up @@ -490,7 +486,7 @@ jobs:
RUNS_ON_S3_BUCKET_CACHE: ${{ env.CACHE_BUCKET }}
with:
path: /usr/local/cargo
key: /cache/${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/Cargo.lock') }}
key: /cache/${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/Cargo.lock') }}-${{ env.NIGHTLY }}
- name: Start sccache server
id: sccache
run: sccache --start-server
Expand Down Expand Up @@ -558,7 +554,7 @@ jobs:
RUNS_ON_S3_BUCKET_CACHE: ${{ env.CACHE_BUCKET }}
with:
path: /usr/local/cargo
key: /cache/${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/Cargo.lock') }}
key: /cache/${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/Cargo.lock') }}-${{ env.NIGHTLY }}
- name: Start sccache server
id: sccache
run: sccache --start-server
Expand Down Expand Up @@ -679,7 +675,7 @@ jobs:
RUNS_ON_S3_BUCKET_CACHE: ${{ env.CACHE_BUCKET }}
with:
path: /usr/local/cargo
key: /cache/${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/Cargo.lock') }}
key: /cache/${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/Cargo.lock') }}-${{ env.NIGHTLY }}
- name: Start sccache server
id: sccache
run: sccache --start-server
Expand Down
25 changes: 17 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ rlimit = "0.5.4"
# TEMP branch "tomas/no-jemalloc-win", replace once upstreamed
rocksdb = {git = "https://github.com/heliaxdev/rust-rocksdb", rev = "4dc7f4fdfa17e923d3078d51261e3db66707754d", features = ['zstd'], default-features = false}
rpassword = "5.0.1"
rustversion = "1.0"
serde = {version = "1.0.125", features = ["derive"]}
serde_bytes = "0.11.5"
serde_json = "1.0.62"
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM lukemathwalker/cargo-chef:latest-rust-1.78.0-bookworm AS chef
FROM lukemathwalker/cargo-chef:latest-rust-1.81.0-bookworm AS chef
WORKDIR /app

FROM chef AS planner
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ clippy-wasm = $(cargo) +$(nightly) clippy --manifest-path $(wasm)/Cargo.toml --a

# Need a separate command for benchmarks to prevent the "testing" feature flag from being activated
clippy:
$(cargo) +$(nightly) clippy $(jobs) --all-targets --workspace --exclude namada_benchmarks -- -D warnings --check-cfg 'cfg(fuzzing)' && \
$(cargo) +$(nightly) clippy $(jobs) --all-targets --package namada_benchmarks -- -D warnings --check-cfg 'cfg(fuzzing)' && \
$(cargo) +$(nightly) clippy $(jobs) --all-targets --workspace --exclude namada_benchmarks -- -D warnings && \
$(cargo) +$(nightly) clippy $(jobs) --all-targets --package namada_benchmarks -- -D warnings && \
make -C $(wasms) clippy && \
make -C $(wasms_for_tests) clippy

Expand Down Expand Up @@ -373,6 +373,7 @@ dev-deps:
$(rustup) toolchain install $(nightly)
$(rustup) target add wasm32-unknown-unknown
$(rustup) component add rustfmt clippy miri --toolchain $(nightly)
$(rustup) target add wasm32-unknown-unknown --toolchain $(nightly)
$(cargo) install cargo-watch unclog wasm-opt cargo-fuzz

test-miri:
Expand Down
4 changes: 3 additions & 1 deletion crates/apps_lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3911,9 +3911,11 @@ pub mod args {
Self: Sized,
Self::Error: Into<std::convert::Infallible>,
{
// The `Err` pattern should be removed from 1.82 again: https://github.com/rust-lang/rust/issues/129352
#[allow(unreachable_patterns)]
match self.to_sdk(ctx).map_err(Into::into) {
Ok(x) => x,
Err(e) => match e {},
Err(_) => unreachable!(),
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions crates/apps_lib/src/config/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,10 +373,11 @@ pub struct ImplicitAccount {
pub public_key: common::PublicKey,
}

/// Protocol parameters. This is almost the same as
/// `ledger::parameters::Parameters`, but instead of having the `implicit_vp`
/// WASM code bytes, it only has the name and sha as the actual code is loaded
/// on `init_chain`
/// Protocol parameters.
///
/// This is almost the same as [`crate::parameters::Parameters`], but instead of
/// having the `implicit_vp` WASM code bytes, it only has the name and sha as
/// the actual code is loaded on `init_chain`
#[derive(
Clone,
Debug,
Expand Down
7 changes: 4 additions & 3 deletions crates/apps_lib/src/config/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ use crate::cli;
use crate::tendermint_config::net::Address as TendermintAddress;

/// Find how many threads to use from an environment variable if it's set and
/// valid (>= 1). If the environment variable is invalid, exits the process with
/// an error. or return 1 if the default value is not >= 1. Otherwise returns
/// the default.
/// valid (>= 1).
///
/// If the environment variable is invalid, exits the process with an error. or
/// return 1 if the default value is not >= 1. Otherwise returns the default.
pub fn num_of_threads(env_var: impl AsRef<str>, default: usize) -> usize {
match num_of_threads_aux(&env_var, default) {
Either::Left(num) => num,
Expand Down
3 changes: 1 addition & 2 deletions crates/apps_lib/src/wallet/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,10 @@ pub fn gen_validator_keys(
protocol_keypair_scheme: SchemeType,
) -> ValidatorKeys {
let eth_bridge_keypair = eth_bridge_keypair
.map(|k| {
.inspect(|k| {
if !matches!(&k, common::SecretKey::Secp256k1(_)) {
panic!("Ethereum bridge keys can only be of kind Secp256k1");
}
k
})
.unwrap_or_else(|| gen_secret_key(SchemeType::Secp256k1, &mut OsRng));
let protocol_keypair = protocol_keypair
Expand Down
3 changes: 3 additions & 0 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,6 @@ rand.workspace = true
rand_core.workspace = true
tokio = { workspace = true, features = ["full"] }
toml.workspace = true

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(fuzzing)'] }
19 changes: 10 additions & 9 deletions crates/core/src/dec.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//! A non-negative fixed precision decimal type for computation primarily in the
//! PoS module. For rounding, any computation that exceeds the specified
//! precision is truncated down to the closest value with the specified
//! precision.
//! A non-negative fixed precision decimal type.
//!
//! This is used for computation primarily in the PoS module. For rounding, any
//! computation that exceeds the specified precision is truncated down to the
//! closest value with the specified precision.

use std::fmt::{Debug, Display, Formatter};
use std::str::FromStr;
Expand Down Expand Up @@ -67,11 +68,11 @@ impl Dec {
/// The division is performed in the following way:
///
/// 1. The absolute values of the numerator and denominator are used for the
/// division.
/// 2. The result is calculated to a fixed precision defined
/// by [`POS_DECIMAL_PRECISION`].
/// 3. If either the numerator or
/// denominator (but not both) is negative, the result is negated.
/// division.
/// 2. The result is calculated to a fixed precision defined by
/// [`POS_DECIMAL_PRECISION`].
/// 3. If either the numerator or denominator (but not both) is negative,
/// the result is negated.
/// 4. If the division is impossible (e.g., division by zero or overflow),
/// `None` is returned.
///
Expand Down
10 changes: 5 additions & 5 deletions crates/core/src/key/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,11 @@ pub trait SecretKey:
}
}

/// Represents a digital signature scheme. More precisely this trait captures
/// the concepts of public keys, private keys, and signatures as well as
/// the algorithms over these concepts to generate keys, sign messages, and
/// verify signatures.

/// Represents a digital signature scheme.
///
/// More precisely this trait captures the concepts of public keys, private
/// keys, and signatures as well as the algorithms over these concepts to
/// generate keys, sign messages, and verify signatures.
pub trait SigScheme: Eq + Ord + Debug + Serialize + Default {
/// Represents the signature for this scheme
type Signature: 'static + Signature;
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ impl Key {
/// Iterates over all addresses in the key segments
pub fn iter_addresses<'k, 'this: 'k>(
&'this self,
) -> impl Iterator<Item = &'_ Address> + 'k {
) -> impl Iterator<Item = &'this Address> + 'k {
self.segments.iter().filter_map(|s| match s {
DbKeySeg::AddressSeg(addr) => Some(addr),
_ => None,
Expand Down
4 changes: 2 additions & 2 deletions crates/core/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,11 +585,11 @@ impl Display for DenominatedAmount {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let string = self.to_string_precise();
let string = if self.denom.0 > 0 {
string.trim_end_matches(&['0'])
string.trim_end_matches(['0'])
} else {
&string
};
let string = string.trim_end_matches(&['.']);
let string = string.trim_end_matches(['.']);
f.write_str(string)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@ where
}

/// Applies derived state changes to storage, based on Ethereum `events` which
/// were newly seen by some consensus validator(s). For `events` which have
/// been seen by enough voting power (`>= 2/3`), extra state changes may take
/// place, such as minting of wrapped ERC20s.
/// were newly seen by some consensus validator(s).
///
/// For `events` which have been seen by enough voting power (`>= 2/3`), extra
/// state changes may take place, such as minting of wrapped ERC20s.
///
/// This function is deterministic based on some existing blockchain state and
/// the passed `events`.
Expand Down
Loading

0 comments on commit 463d282

Please sign in to comment.