Skip to content

Commit

Permalink
Merge remote-tracking branch 'namada/rust-1.65.0' (#736) into main
Browse files Browse the repository at this point in the history
evil: fmt and clippy for new rust

* namada/rust-1.65.0:
  ci: update rust/docker image
  fix newly found clippy issues
  update rustfmt config for nightly-2022-11-03
  bump Rust nightly to 2022-11-03
  wallet/store: fix unused print alias arg
  bump Rust to v1.65.0, yay!
  • Loading branch information
juped committed Nov 30, 2022
2 parents 6ed4833 + 70b760a commit 40a44cf
Show file tree
Hide file tree
Showing 53 changed files with 203 additions and 298 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build-and-test-bridge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
timeout-minutes: 30
runs-on: ${{ matrix.os }}
container:
image: ghcr.io/anoma/namada:wasm-0.8.0
image: ghcr.io/anoma/namada:wasm-0.11.0
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -143,7 +143,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
nightly_version: [nightly-2022-05-20]
nightly_version: [nightly-2022-11-03]
mold_version: [1.7.0]
make:
- name: ABCI
Expand Down Expand Up @@ -503,4 +503,4 @@ jobs:
run: sccache --show-stats
- name: Stop sccache server
if: always()
run: sccache --stop-server || true
run: sccache --stop-server || true
6 changes: 3 additions & 3 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
timeout-minutes: 30
runs-on: ${{ matrix.os }}
container:
image: ghcr.io/anoma/namada:wasm-0.8.0
image: ghcr.io/anoma/namada:wasm-0.11.0
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -146,7 +146,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
nightly_version: [nightly-2022-05-20]
nightly_version: [nightly-2022-11-03]
mold_version: [1.7.0]
make:
- name: ABCI
Expand Down Expand Up @@ -506,4 +506,4 @@ jobs:
run: sccache --show-stats
- name: Stop sccache server
if: always()
run: sccache --stop-server || true
run: sccache --stop-server || true
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
nightly_version: [nightly-2022-05-20]
nightly_version: [nightly-2022-11-03]
make:
- name: Clippy
command: clippy
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
nightly_version: [nightly-2022-05-20]
nightly_version: [nightly-2022-11-03]
make:
- name: Audit
command: audit
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
nightly_version: [nightly-2022-05-20]
nightly_version: [nightly-2022-11-03]
mdbook_version: [rust-lang/[email protected]]
mdbook_mermaid: [badboy/[email protected]]
mdbook_linkcheck: [Michael-F-Bryan/[email protected]]
Expand Down
3 changes: 1 addition & 2 deletions apps/src/bin/anoma-wallet/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,7 @@ fn address_or_alias_find(ctx: Context, args: args::AddressOrAliasFind) {
message."
);
} else if args.alias.is_some() {
if let Some(address) =
wallet.find_address(&args.alias.as_ref().unwrap())
if let Some(address) = wallet.find_address(args.alias.as_ref().unwrap())
{
println!("Found address {}", address.to_pretty_string());
} else {
Expand Down
1 change: 1 addition & 0 deletions apps/src/lib/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3419,6 +3419,7 @@ pub fn anoma_node_cli() -> Result<(cmds::AnomaNode, Context)> {
cmds::AnomaNode::parse_or_print_help(app)
}

#[allow(clippy::large_enum_variant)]
pub enum AnomaClient {
WithoutContext(cmds::Utils, args::Global),
WithContext(Box<(cmds::AnomaClientWithContext, Context)>),
Expand Down
2 changes: 1 addition & 1 deletion apps/src/lib/cli/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl Context {

let chain_dir = global_args
.base_dir
.join(&global_config.default_chain_id.as_str());
.join(global_config.default_chain_id.as_str());
let genesis_file_path = global_args
.base_dir
.join(format!("{}.toml", global_config.default_chain_id.as_str()));
Expand Down
10 changes: 5 additions & 5 deletions apps/src/lib/client/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1240,7 +1240,7 @@ pub async fn query_proposal_result(
cli::safe_exit(1)
}

let file = File::open(&path.join("proposal"))
let file = File::open(path.join("proposal"))
.expect("Proposal file must exist.");
let proposal: OfflineProposal =
serde_json::from_reader(file).expect(
Expand Down Expand Up @@ -2420,11 +2420,11 @@ pub async fn query_tx_response(
// applied to the blockchain
let query_event_opt =
response_block_results.end_block_events.and_then(|events| {
(&events)
events
.iter()
.find(|event| {
event.type_str == tx_query.event_type()
&& (&event.attributes).iter().any(|tag| {
&& event.attributes.iter().any(|tag| {
tag.key.as_ref() == "hash"
&& tag.value.as_ref() == tx_query.tx_hash()
})
Expand All @@ -2439,8 +2439,8 @@ pub async fn query_tx_response(
)
})?;
// Reformat the event attributes so as to ease value extraction
let event_map: std::collections::HashMap<&str, &str> = (&query_event
.attributes)
let event_map: std::collections::HashMap<&str, &str> = query_event
.attributes
.iter()
.map(|tag| (tag.key.as_ref(), tag.value.as_ref()))
.collect();
Expand Down
13 changes: 6 additions & 7 deletions apps/src/lib/client/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,7 @@ pub fn init_network(
archive_dir,
}: args::InitNetwork,
) {
let mut config =
genesis_config::open_genesis_config(&genesis_path).unwrap();
let mut config = genesis_config::open_genesis_config(genesis_path).unwrap();

// Update the WASM checksums
let checksums =
Expand Down Expand Up @@ -654,7 +653,7 @@ pub fn init_network(
fs::rename(&temp_dir, &chain_dir).unwrap();

// Copy the WASM checksums
let wasm_dir_full = chain_dir.join(&config::DEFAULT_WASM_DIR);
let wasm_dir_full = chain_dir.join(config::DEFAULT_WASM_DIR);
fs::create_dir_all(&wasm_dir_full).unwrap();
fs::copy(
&wasm_checksums_path,
Expand All @@ -671,14 +670,14 @@ pub fn init_network(
.join(config::DEFAULT_BASE_DIR);
let temp_validator_chain_dir =
validator_dir.join(temp_chain_id.as_str());
let validator_chain_dir = validator_dir.join(&chain_id.as_str());
let validator_chain_dir = validator_dir.join(chain_id.as_str());
// Rename the generated directories for validators from `temp_chain_id`
// to `chain_id`
std::fs::rename(&temp_validator_chain_dir, &validator_chain_dir)
std::fs::rename(temp_validator_chain_dir, &validator_chain_dir)
.unwrap();

// Copy the WASM checksums
let wasm_dir_full = validator_chain_dir.join(&config::DEFAULT_WASM_DIR);
let wasm_dir_full = validator_chain_dir.join(config::DEFAULT_WASM_DIR);
fs::create_dir_all(&wasm_dir_full).unwrap();
fs::copy(
&wasm_checksums_path,
Expand Down Expand Up @@ -1042,7 +1041,7 @@ pub fn write_tendermint_node_key(
.create(true)
.write(true)
.truncate(true)
.open(&node_key_path)
.open(node_key_path)
.expect("Couldn't create validator node key file");
serde_json::to_writer_pretty(file, &tm_node_keypair_json)
.expect("Couldn't write validator node key file");
Expand Down
17 changes: 8 additions & 9 deletions apps/src/lib/config/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ pub mod genesis_config {

Validator {
pos_data: GenesisValidator {
address: Address::decode(&config.address.as_ref().unwrap())
address: Address::decode(config.address.as_ref().unwrap())
.unwrap(),
tokens: token::Amount::whole(config.tokens.unwrap_or_default()),
consensus_key: config
Expand Down Expand Up @@ -369,8 +369,7 @@ pub mod genesis_config {
let token_vp_config = wasm.get(token_vp_name).unwrap();

TokenAccount {
address: Address::decode(&config.address.as_ref().unwrap())
.unwrap(),
address: Address::decode(config.address.as_ref().unwrap()).unwrap(),
vp_code_path: token_vp_config.filename.to_owned(),
vp_sha256: token_vp_config
.sha256
Expand All @@ -388,7 +387,7 @@ pub mod genesis_config {
.iter()
.map(|(alias_or_address, amount)| {
(
match Address::decode(&alias_or_address) {
match Address::decode(alias_or_address) {
Ok(address) => address,
Err(decode_err) => {
if let Some(alias) =
Expand Down Expand Up @@ -451,8 +450,7 @@ pub mod genesis_config {
let account_vp_config = wasm.get(account_vp_name).unwrap();

EstablishedAccount {
address: Address::decode(&config.address.as_ref().unwrap())
.unwrap(),
address: Address::decode(config.address.as_ref().unwrap()).unwrap(),
vp_code_path: account_vp_config.filename.to_owned(),
vp_sha256: account_vp_config
.sha256
Expand All @@ -474,7 +472,7 @@ pub mod genesis_config {
.iter()
.map(|(address, hex)| {
(
storage::Key::parse(&address).unwrap(),
storage::Key::parse(address).unwrap(),
hex.to_bytes().unwrap(),
)
})
Expand Down Expand Up @@ -535,6 +533,7 @@ pub mod genesis_config {
.iter()
.map(|(name, cfg)| (name.clone(), load_implicit(cfg)))
.collect();
#[allow(clippy::iter_kv_map)]
let token_accounts = token
.iter()
.map(|(_name, cfg)| {
Expand Down Expand Up @@ -935,8 +934,8 @@ pub fn genesis() -> Genesis {
((&validator.account_key).into(), default_key_tokens),
]);
let token_accounts = address::tokens()
.into_iter()
.map(|(address, _)| TokenAccount {
.into_keys()
.map(|address| TokenAccount {
address,
vp_code_path: vp_token_path.into(),
vp_sha256: Default::default(),
Expand Down
2 changes: 1 addition & 1 deletion apps/src/lib/node/ledger/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl Shell {
CheckTxType::New => MempoolTxType::NewTransaction,
CheckTxType::Recheck => MempoolTxType::RecheckTransaction,
};
Ok(Response::CheckTx(self.mempool_validate(&*tx.tx, r#type)))
Ok(Response::CheckTx(self.mempool_validate(&tx.tx, r#type)))
}
Request::ListSnapshots(_) => {
Ok(Response::ListSnapshots(Default::default()))
Expand Down
2 changes: 1 addition & 1 deletion apps/src/lib/node/ledger/shell/init_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ where
pos_inflation_amount,
} = genesis.parameters;
let implicit_vp =
wasm_loader::read_wasm(&self.wasm_dir, &implicit_vp_code_path)
wasm_loader::read_wasm(&self.wasm_dir, implicit_vp_code_path)
.map_err(Error::ReadingWasm)?;
// In dev, we don't check the hash
#[cfg(feature = "dev")]
Expand Down
2 changes: 1 addition & 1 deletion apps/src/lib/node/ledger/shell/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ pub type Result<T> = std::result::Result<T, Error>;
pub fn reset(config: config::Ledger) -> Result<()> {
// simply nuke the DB files
let db_path = &config.db_dir();
match std::fs::remove_dir_all(&db_path) {
match std::fs::remove_dir_all(db_path) {
Err(e) if e.kind() == std::io::ErrorKind::NotFound => (),
res => res.map_err(Error::RemoveDB)?,
};
Expand Down
2 changes: 1 addition & 1 deletion apps/src/lib/node/ledger/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ mod tests {
assert_eq!(gas, key.len() as u64);
let (result, gas) = storage.read(&key).expect("read failed");
let read_value: u64 =
types::decode(&result.expect("value doesn't exist"))
types::decode(result.expect("value doesn't exist"))
.expect("decoding failed");
assert_eq!(read_value, value);
assert_eq!(gas, key.len() as u64 + value_bytes_len as u64);
Expand Down
2 changes: 1 addition & 1 deletion apps/src/lib/node/ledger/storage/rocksdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ impl DB for RocksDB {

// Write the new key-val
self.0
.put(&subspace_key.to_string(), value)
.put(subspace_key.to_string(), value)
.map_err(|e| Error::DBError(e.into_string()))?;

Ok(size_diff)
Expand Down
6 changes: 3 additions & 3 deletions apps/src/lib/node/ledger/tendermint_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub async fn run(

// init and run a tendermint node child process
let output = Command::new(&tendermint_path)
.args(&["init", &mode, "--home", &home_dir_string])
.args(["init", &mode, "--home", &home_dir_string])
.output()
.await
.map_err(Error::Init)?;
Expand All @@ -110,7 +110,7 @@ pub async fn run(
update_tendermint_config(&home_dir, config).await?;

let mut tendermint_node = Command::new(&tendermint_path);
tendermint_node.args(&[
tendermint_node.args([
"start",
"--proxy_app",
&ledger_address,
Expand Down Expand Up @@ -170,7 +170,7 @@ pub fn reset(tendermint_dir: impl AsRef<Path>) -> Result<()> {
let tendermint_dir = tendermint_dir.as_ref().to_string_lossy();
// reset all the Tendermint state, if any
std::process::Command::new(tendermint_path)
.args(&[
.args([
"reset-state",
"unsafe-all",
// NOTE: log config: https://docs.tendermint.com/master/nodes/logging.html#configuring-log-levels
Expand Down
7 changes: 2 additions & 5 deletions apps/src/lib/wallet/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ impl Store {
if alias.is_empty() {
println!(
"Empty alias given, defaulting to {}.",
alias = Into::<Alias>::into(pkh.to_string())
Into::<Alias>::into(pkh.to_string())
);
}
// Addresses and keypairs can share aliases, so first remove any
Expand Down Expand Up @@ -573,10 +573,7 @@ impl Store {
address: Address,
) -> Option<Alias> {
if alias.is_empty() {
println!(
"Empty alias given, defaulting to {}.",
alias = address.encode()
);
println!("Empty alias given, defaulting to {}.", address.encode());
}
// Addresses and keypairs can share aliases, so first remove any keys
// sharing the same namesake before checking if alias has been used.
Expand Down
4 changes: 2 additions & 2 deletions docker/namada-wasm/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# This docker is used for deterministic wasm builds

# The version should be matching the version set in wasm/rust-toolchain.toml
FROM rust:1.61.0-bullseye
FROM rust:1.65.0-bullseye

WORKDIR /__w/namada/namada

# The version should be matching the version set above
RUN rustup toolchain install 1.61.0 --profile minimal
RUN rustup toolchain install 1.65.0 --profile minimal
RUN rustup target add wasm32-unknown-unknown

# Download binaryen and extract wasm-opt
Expand Down
2 changes: 1 addition & 1 deletion docker/namada/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM lukemathwalker/cargo-chef:latest-rust-1.61.0 AS chef
FROM lukemathwalker/cargo-chef:latest-rust-1.65.0 AS chef
WORKDIR /app

FROM chef AS planner
Expand Down
9 changes: 4 additions & 5 deletions encoding_spec/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,11 @@ fn md_fmt_type(type_name: impl AsRef<str>) -> String {
fn write_generated_code_notice(
file: &mut std::fs::File,
) -> Result<(), Box<dyn std::error::Error>> {
let path = std::file!();
writeln!(
file,
"<!--- THIS PAGE IS GENERATED FROM CODE: {}. Do not edit manually! -->",
std::file!()
"<!--- THIS PAGE IS GENERATED FROM CODE: {path}. Do not edit \
manually! -->",
)?;
Ok(())
}
Expand All @@ -390,9 +391,7 @@ fn escape_fragment_anchor(string: impl AsRef<str>) -> String {
// mdBook turns headings fragment links to lowercase
string
.as_ref()
.replace('>', "")
.replace('<', "")
.replace(',', "")
.replace(['>', '<', ','], "")
.replace(' ', "-")
.replace(':', "")
.to_ascii_lowercase()
Expand Down
Loading

0 comments on commit 40a44cf

Please sign in to comment.