Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ exclude = [

[workspace.package]
authors = ["Heliax AG <hello@heliax.dev>"]
edition = "2021"
edition = "2024"
documentation = "https://docs.namada.net/"
homepage = "https://namada.net/"
keywords = ["blockchain", "privacy", "crypto", "protocol", "network"]
license = "GPL-3.0"
readme = "README.md"
repository = "https://github.com/namada-net/namada"
version = "0.251.0"
rust-version = "1.83" # MSRV
rust-version = "1.85" # MSRV

[workspace.dependencies]
namada_account = { version = "0.251.0", path = "crates/account" }
Expand Down
9 changes: 5 additions & 4 deletions crates/apps_lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ pub mod cmds {
}

fn parse(matches: &ArgMatches) -> Option<Self> {
let gen = SubCmd::parse(matches).map(Self::KeyGen);
let r#gen = SubCmd::parse(matches).map(Self::KeyGen);
let derive = SubCmd::parse(matches).map(Self::KeyDerive);
let pay_addr_gen = SubCmd::parse(matches).map(Self::PayAddrGen);
let key_addr_list = SubCmd::parse(matches).map(Self::KeyAddrList);
Expand All @@ -614,7 +614,8 @@ pub mod cmds {
let key_addr_add = SubCmd::parse(matches).map(Self::KeyAddrAdd);
let key_addr_remove =
SubCmd::parse(matches).map(Self::KeyAddrRemove);
gen.or(derive)
r#gen
.or(derive)
.or(pay_addr_gen)
.or(key_addr_list)
.or(key_addr_find)
Expand Down Expand Up @@ -1090,12 +1091,12 @@ pub mod cmds {

fn parse(matches: &ArgMatches) -> Option<Self> {
matches.subcommand_matches(Self::CMD).and_then(|matches| {
let gen = SubCmd::parse(matches).map(Self::Gen);
let r#gen = SubCmd::parse(matches).map(Self::Gen);
let validator_cfg = SubCmd::parse(matches)
.map(Self::UpdateValidatorLocalConfig);
let local_cfg =
SubCmd::parse(matches).map(Self::UpdateLocalConfig);
gen.or(validator_cfg).or(local_cfg)
r#gen.or(validator_cfg).or(local_cfg)
})
}

Expand Down
8 changes: 4 additions & 4 deletions crates/apps_lib/src/client/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1088,8 +1088,8 @@ pub async fn sign_offline(
signature.pubkey,
);

let signature_path = match output_folder_path {
Some(ref path) => path.join(filename).to_string_lossy().to_string(),
let signature_path = match &output_folder_path {
Some(path) => path.join(filename).to_string_lossy().to_string(),
None => filename,
};

Expand All @@ -1111,8 +1111,8 @@ pub async fn sign_offline(
"offline_wrapper_signature_{}.sig",
header_hash.to_string().to_lowercase()
);
let signature_path = match output_folder_path {
Some(ref path) => path.join(filename).to_string_lossy().to_string(),
let signature_path = match &output_folder_path {
Some(path) => path.join(filename).to_string_lossy().to_string(),
None => filename,
};

Expand Down
2 changes: 1 addition & 1 deletion crates/apps_lib/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ mod tests {
.unwrap();

let moniker = "moniker_from_env";
env::set_var("NAMADA_LEDGER__COMETBFT__MONIKER", moniker);
unsafe { env::set_var("NAMADA_LEDGER__COMETBFT__MONIKER", moniker) };
let config = Config::load(&base_dir, &chain_id, None);

assert_eq!(config.ledger.cometbft.moniker.as_ref(), moniker);
Expand Down
4 changes: 2 additions & 2 deletions crates/apps_lib/src/config/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ mod test {
#[test]
fn test_num_of_threads_from_valid_env_var(value in 1_usize..) {
let env_var = "anythingXYZ1";
env::set_var(env_var, value.to_string());
unsafe { env::set_var(env_var, value.to_string()) };
assert_eq!(num_of_threads_aux(env_var, value), Either::Left(value));
}

Expand All @@ -114,7 +114,7 @@ mod test {
fn test_num_of_threads_from_invalid_env_var(value in ..1_usize) {
let env_var = "anythingXYZ2";
let val_string = value.to_string();
env::set_var(env_var, &val_string);
unsafe { env::set_var(env_var, &val_string) };
assert_eq!(
num_of_threads_aux(env_var, value),
Either::Right(val_string)
Expand Down
4 changes: 2 additions & 2 deletions crates/apps_lib/src/wallet/pre_genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub fn gen_and_store(
store_dir: &Path,
) -> std::io::Result<ValidatorWallet> {
let password = read_and_confirm_encryption_password(unsafe_dont_encrypt);
let validator = gen(scheme, password);
let validator = r#gen(scheme, password);
let data = validator.store.encode();
let wallet_path = validator_file_name(store_dir);
// Make sure the dir exists
Expand Down Expand Up @@ -106,7 +106,7 @@ pub fn load(store_dir: &Path) -> Result<ValidatorWallet, ReadError> {

/// Generate a new [`ValidatorWallet`] with required pre-genesis keys. Will
/// prompt for password when `!unsafe_dont_encrypt`.
fn gen(
fn r#gen(
scheme: SchemeType,
password: Option<Zeroizing<String>>,
) -> ValidatorWallet {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ mod tests {
.ref_to();

match hot_key {
common::PublicKey::Secp256k1(ref k) => k.into(),
common::PublicKey::Secp256k1(k) => k.into(),
_ => panic!("Test failed"),
}
};
Expand All @@ -190,7 +190,7 @@ mod tests {
&keys.get(&validator).expect("Test failed").eth_gov.ref_to();

match cold_key {
common::PublicKey::Secp256k1(ref k) => k.into(),
common::PublicKey::Secp256k1(k) => k.into(),
_ => panic!("Test failed"),
}
};
Expand Down
2 changes: 1 addition & 1 deletion crates/ethereum_bridge/src/vp/eth_bridge_vp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ mod tests {
/// Return some arbitrary random key belonging to this account
fn arbitrary_key() -> Key {
let mut rng = rand::thread_rng();
let rn = rng.gen::<u64>();
let rn = rng.r#gen::<u64>();
storage::prefix()
.push(&format!("arbitrary key segment {}", rn))
.expect("should always be able to construct this key")
Expand Down
4 changes: 2 additions & 2 deletions crates/governance/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ where
{
let vote_prefix_key =
governance_keys::get_proposal_vote_prefix_key(proposal_id);
let vote_iter = iter_prefix::<ProposalVote>(storage, &vote_prefix_key)?;
let vote_iter = iter_prefix::<ProposalVote>(storage, vote_prefix_key)?;

let votes = vote_iter
.filter_map(|vote_result| {
Expand Down Expand Up @@ -344,7 +344,7 @@ where
let mut ids = BTreeSet::<u64>::new();
let proposals_key =
governance_keys::get_commiting_proposals_prefix(current_epoch.0);
for key_val in namada_state::iter_prefix_bytes(storage, &proposals_key)? {
for key_val in namada_state::iter_prefix_bytes(storage, proposals_key)? {
let (key, _) = key_val?;
let activation_epoch = governance_keys::get_commit_proposal_epoch(&key)
.expect("this key segment should correspond to an epoch number");
Expand Down
4 changes: 2 additions & 2 deletions crates/ibc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ where
let msg = decode_message::<Transfer>(tx_data)
.into_storage_result()
.ok();
let tx = if let Some(IbcMessage::Envelope(ref envelope)) = msg {
Some(extract_masp_tx_from_envelope(envelope).ok_or_else(|| {
let tx = if let Some(IbcMessage::Envelope(envelope)) = msg {
Some(extract_masp_tx_from_envelope(&envelope).ok_or_else(|| {
StorageError::new_const(
"Missing MASP transaction in IBC message",
)
Expand Down
2 changes: 1 addition & 1 deletion crates/ibc/src/vp/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ where

fn read_bytes(&self, key: &Key) -> Result<Option<Vec<u8>>> {
match self.store.get(key) {
Some(StorageModification::Write { ref value }) => {
Some(StorageModification::Write { value }) => {
let gas = checked!(key.len() + value.len())? as u64;
self.ctx.ctx.charge_gas(
checked!(gas * MEMORY_ACCESS_GAS_PER_BYTE)?.into(),
Expand Down
12 changes: 6 additions & 6 deletions crates/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ use syn::{ItemEnum, ItemFn, ItemStruct, LitByte, parse_macro_input};
pub fn transaction(_attr: TokenStream, input: TokenStream) -> TokenStream {
let ast = parse_macro_input!(input as ItemFn);
let ident = &ast.sig.ident;
let gen = quote! {
let r#gen = quote! {
// Use `rlsf` as the global allocator.
#[global_allocator]
static ALLOC: rlsf::SmallGlobalTlsf = rlsf::SmallGlobalTlsf::new();

#ast

// The module entrypoint callable by wasm runtime
#[no_mangle]
#[unsafe(no_mangle)]
extern "C" fn _apply_tx(tx_data_ptr: u64, tx_data_len: u64) -> u64 {
let slice = unsafe {
core::slice::from_raw_parts(
Expand Down Expand Up @@ -64,7 +64,7 @@ pub fn transaction(_attr: TokenStream, input: TokenStream) -> TokenStream {
}
}
};
TokenStream::from(gen)
TokenStream::from(r#gen)
}

/// Generate WASM binding for validity predicate main entrypoint function.
Expand All @@ -87,15 +87,15 @@ pub fn validity_predicate(
) -> TokenStream {
let ast = parse_macro_input!(input as ItemFn);
let ident = &ast.sig.ident;
let gen = quote! {
let r#gen = quote! {
// Use `rlsf` as the global allocator.
#[global_allocator]
static ALLOC: rlsf::SmallGlobalTlsf = rlsf::SmallGlobalTlsf::new();

#ast

// The module entrypoint callable by wasm runtime
#[no_mangle]
#[unsafe(no_mangle)]
extern "C" fn _validate_tx(
// VP's account's address
addr_ptr: u64,
Expand Down Expand Up @@ -156,7 +156,7 @@ pub fn validity_predicate(
}
}
};
TokenStream::from(gen)
TokenStream::from(r#gen)
}

#[proc_macro_derive(StorageKeys)]
Expand Down
10 changes: 3 additions & 7 deletions crates/merkle_tree/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -748,14 +748,10 @@ impl<H: StorageHasher + Default> MerkleTree<H> {
StringKey::try_from_bytes(sub_key.to_string().as_bytes())?;
let mut nep = self.ibc.non_membership_proof(&string_key)?;
// Replace the values and the leaf op for the verification
if let Some(ref mut nep) = nep.proof {
if let Some(nep) = &mut nep.proof {
match nep {
Ics23Proof::Nonexist(ref mut ep) => {
let NonExistenceProof {
ref mut left,
ref mut right,
..
} = ep;
Ics23Proof::Nonexist(ep) => {
let NonExistenceProof { left, right, .. } = ep;
if let Some(left) = left.as_mut() {
left.leaf = Some(ibc_leaf_spec::<H>());
}
Expand Down
2 changes: 1 addition & 1 deletion crates/node/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ where
},
gas_meter_kind,
) {
Err(Error::GasError(ref msg)) => {
Err(Error::GasError(msg)) => {
// Gas error aborts the execution of the entire batch
tx_result.insert_inner_tx_result(
wrapper_hash,
Expand Down
2 changes: 1 addition & 1 deletion crates/node/src/shell/finalize_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4298,7 +4298,7 @@ mod test_finalize_block {

let num_slashes = namada_sdk::state::iter_prefix_bytes(
&shell.state,
&slashes_prefix(),
slashes_prefix(),
)?
.filter(|kv_res| {
let (k, _v) = kv_res.as_ref().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion crates/node/src/shell/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1644,7 +1644,7 @@ pub mod test_utils {
/// Invalidate a valid signature `sig`.
pub fn invalidate_signature(sig: common::Signature) -> common::Signature {
match sig {
common::Signature::Ed25519(ed25519::Signature(ref sig)) => {
common::Signature::Ed25519(ed25519::Signature(sig)) => {
let mut sig_bytes = sig.to_bytes();
sig_bytes[0] = sig_bytes[0].wrapping_add(1);
common::Signature::Ed25519(ed25519::Signature(sig_bytes.into()))
Expand Down
2 changes: 1 addition & 1 deletion crates/node/src/shims/abcipp_shim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ impl AbciService {
let (resp_send, recv) = tokio::sync::oneshot::channel();
let result = self.shell_send.send((req.clone(), resp_send));
async move {
let genesis_time = if let Req::InitChain(ref init) = req {
let genesis_time = if let Req::InitChain(init) = req {
Some(
DateTimeUtc::try_from(init.time)
.expect("Should be able to parse genesis time."),
Expand Down
10 changes: 5 additions & 5 deletions crates/node/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ mod tests {
}

// Then try to iterate over their prefix
let iter = state::iter_prefix(&state, &prefix)
let iter = state::iter_prefix(&state, prefix.clone())
.unwrap()
.map(Result::unwrap);

Expand All @@ -804,7 +804,7 @@ mod tests {
state.commit_block().unwrap();

// Again, try to iterate over their prefix
let iter = state::iter_prefix(&state, &prefix)
let iter = state::iter_prefix(&state, prefix.clone())
.unwrap()
.map(Result::unwrap);
itertools::assert_equal(iter, expected);
Expand All @@ -822,7 +822,7 @@ mod tests {
state.write(&key, i / 2).unwrap();
}

let iter = state::iter_prefix(&state, &prefix)
let iter = state::iter_prefix(&state, prefix.clone())
.unwrap()
.map(Result::unwrap);

Expand All @@ -842,7 +842,7 @@ mod tests {
}

// Check that iter_prefix doesn't return deleted keys anymore
let iter = state::iter_prefix(&state, &prefix)
let iter = state::iter_prefix(&state, prefix.clone())
.unwrap()
.map(Result::unwrap);
let expected = merged
Expand All @@ -855,7 +855,7 @@ mod tests {
state.commit_block().unwrap();

// And check again
let iter = state::iter_prefix(&state, &prefix)
let iter = state::iter_prefix(&state, prefix.clone())
.unwrap()
.map(Result::unwrap);
itertools::assert_equal(iter, expected);
Expand Down
6 changes: 3 additions & 3 deletions crates/node/src/storage/rocksdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ impl RocksDB {
let reprot_cf = self.get_column_family(REPLAY_PROTECTION_CF)?;
tracing::info!("Restoring replay protection state");
// Remove the "current" tx hashes
for (ref current_key, _, _) in self.iter_current_replay_protection() {
for (current_key, _, _) in self.iter_current_replay_protection() {
batch.0.delete_cf(reprot_cf, current_key);
}

Expand Down Expand Up @@ -1738,13 +1738,13 @@ impl DB for RocksDB {
self.get_column_family(REPLAY_PROTECTION_CF)?;
let stripped_prefix = Some(replay_protection::current_prefix());

for (ref hash_str, _, _) in iter_prefix(
for (hash_str, _, _) in iter_prefix(
self,
replay_protection_cf,
stripped_prefix.as_ref(),
None,
) {
let hash = namada_sdk::hash::Hash::from_str(hash_str)
let hash = namada_sdk::hash::Hash::from_str(&hash_str)
.expect("Failed hash conversion");
let current_key = replay_protection::current_key(&hash);
let key = replay_protection::key(&hash);
Expand Down
4 changes: 2 additions & 2 deletions crates/proof_of_stake/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ where
let prefix = bonds_for_source_prefix(address);
match epoch {
Some(epoch) => {
let iter = iter_prefix_bytes(storage, &prefix)?;
let iter = iter_prefix_bytes(storage, prefix)?;
for res in iter {
let (key, _) = res?;
if let Some((bond_id, bond_epoch)) = is_bond_key(&key) {
Expand All @@ -309,7 +309,7 @@ where
Ok(false)
}
None => {
let iter = iter_prefix_bytes(storage, &prefix)?;
let iter = iter_prefix_bytes(storage, prefix)?;
for res in iter {
let (key, _) = res?;
if let Some((bond_id, _epoch)) = is_bond_key(&key) {
Expand Down
4 changes: 2 additions & 2 deletions crates/proof_of_stake/src/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ where
// We have to iterate raw bytes, cause the epoched data `last_update` field
// gets matched here too
let mut raw_bonds =
iter_prefix_bytes(storage, &prefix)?.filter_map(|result| {
iter_prefix_bytes(storage, prefix)?.filter_map(|result| {
if let Ok((key, val_bytes)) = result {
if let Some((bond_id, start)) = storage_key::is_bond_key(&key) {
if source.is_some()
Expand Down Expand Up @@ -276,7 +276,7 @@ where
None => storage_key::unbonds_prefix(),
};
let mut raw_unbonds =
iter_prefix_bytes(storage, &prefix)?.filter_map(|result| {
iter_prefix_bytes(storage, prefix)?.filter_map(|result| {
if let Ok((key, val_bytes)) = result {
if let Some((bond_id, start, withdraw)) =
storage_key::is_unbond_key(&key)
Expand Down
Loading
Loading