Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.36.1 rc3 #3289

Merged
merged 10 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions .changelog/unreleased/bug-fixes/3287-no-default-mainnet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Switch off the "mainnet" feature by default for now.
([\#3287](https://github.com/anoma/namada/pull/3287))
2 changes: 2 additions & 0 deletions .changelog/unreleased/improvements/3254-rust-1.78.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Updated Rust toolchain to v1.78.0.
([\#3254](https://github.com/anoma/namada/pull/3254))
10 changes: 5 additions & 5 deletions Cargo.lock

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

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,12 @@ ledger-transport-hid = "0.10.0"
libc = "0.2.97"
libloading = "0.7.2"
linkme = "0.3.24"
# branch = "murisi/alternative-num-traits"
masp_primitives = { git = "https://github.com/anoma/masp", rev = "6fc4692841a2241633792c429cc66b42023e5bf3" }
masp_proofs = { git = "https://github.com/anoma/masp", rev = "6fc4692841a2241633792c429cc66b42023e5bf3", default-features = false, features = ["local-prover"] }
# branch = "main"
masp_primitives = { git = "https://github.com/anoma/masp", rev = "3aacc707c5948e7423589ac617305448bead9842" }
masp_proofs = { git = "https://github.com/anoma/masp", rev = "3aacc707c5948e7423589ac617305448bead9842", default-features = false, features = ["local-prover"] }
num256 = "0.3.5"
num_cpus = "1.13.0"
num-derive = "0.3.3"
num-derive = "0.4"
num-rational = "0.4.1"
num-traits = "0.2.14"
once_cell = "1.8.0"
Expand Down
2 changes: 1 addition & 1 deletion crates/apps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ name = "namadar"
path = "src/bin/namada-relayer/main.rs"

[features]
default = ["namada/mainnet", "migrations"]
default = ["migrations"]
mainnet = ["namada_apps_lib/mainnet"]
jemalloc = ["namada_node/jemalloc"]
migrations = ["namada/migrations", "namada_apps_lib/migrations"]
Expand Down
6 changes: 4 additions & 2 deletions crates/core/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1083,16 +1083,18 @@ macro_rules! impl_int_key_seg {

impl KeySeg for $signed {
fn parse(string: String) -> Result<Self> {
// get signed int from a unsigned int complemented with a min
// get signed int from a unsigned int complemented with a max
// value
let complemented = <$unsigned>::parse(string)?;
#[allow(clippy::cast_possible_wrap)]
let signed = (complemented as $signed) ^ <$signed>::MIN;
Ok(signed)
}

fn raw(&self) -> String {
// signed int is converted to unsigned int that preserves the
// order by complementing it with a min value
// order by complementing it with a max value
#[allow(clippy::cast_sign_loss)]
let complemented = (*self ^ <$signed>::MIN) as $unsigned;
complemented.raw()
}
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/uint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ impl Uint {
q_hat
} else {
// here q_hat >= q_j >= q_hat - 1
u64::max_value()
u64::MAX
};

// ex. 20:
Expand Down
4 changes: 2 additions & 2 deletions crates/merkle_tree/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1422,7 +1422,7 @@ mod test {
&value,
));
// for the verification of the base tree
value = sub_root.clone();
value.clone_from(&sub_root);
}
// Check the base root
assert_eq!(sub_root, tree.root().0);
Expand Down Expand Up @@ -1486,7 +1486,7 @@ mod test {
&value,
));
// for the verification of the base tree
value = sub_root.clone();
value.clone_from(&sub_root);
}
// Check the base root
assert_eq!(sub_root, tree.root().0);
Expand Down
2 changes: 2 additions & 0 deletions crates/namada/src/ledger/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,10 @@ mod test {
/// tx wasm compilation cache
pub tx_wasm_cache: TxCache<WasmCacheRoAccess>,
/// VP wasm compilation cache directory
#[allow(dead_code)] // never read
pub vp_cache_dir: TempDir,
/// tx wasm compilation cache directory
#[allow(dead_code)] // never read
pub tx_cache_dir: TempDir,
}

Expand Down
6 changes: 2 additions & 4 deletions crates/node/src/bench_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -672,8 +672,7 @@ pub struct BenchShieldedUtils {
context_dir: WrapperTempDir,
}

#[cfg_attr(feature = "async-send", async_trait::async_trait)]
#[cfg_attr(not(feature = "async-send"), async_trait::async_trait(?Send))]
#[async_trait::async_trait(?Send)]
impl ShieldedUtils for BenchShieldedUtils {
fn local_tx_prover(&self) -> LocalTxProver {
if let Ok(params_dir) = std::env::var(masp::ENV_VAR_MASP_PARAMS_DIR) {
Expand Down Expand Up @@ -768,8 +767,7 @@ impl ShieldedUtils for BenchShieldedUtils {
}
}

#[cfg_attr(feature = "async-send", async_trait::async_trait)]
#[cfg_attr(not(feature = "async-send"), async_trait::async_trait(?Send))]
#[async_trait::async_trait(?Send)]
impl Client for BenchShell {
type Error = std::io::Error;

Expand Down
12 changes: 3 additions & 9 deletions crates/node/src/shell/finalize_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5436,9 +5436,7 @@ mod test_finalize_block {
);
// Assert that the last tx didn't run
assert!(
inner_results
.get(&batch.commitments()[2].get_hash())
.is_none()
!inner_results.contains_key(&batch.commitments()[2].get_hash())
);

// Check storage modifications are missing
Expand Down Expand Up @@ -5554,9 +5552,7 @@ mod test_finalize_block {
);
// Assert that the last tx didn't run
assert!(
inner_results
.get(&batch.commitments()[2].get_hash())
.is_none()
!inner_results.contains_key(&batch.commitments()[2].get_hash())
);

// Check storage modifications are missing
Expand Down Expand Up @@ -5603,9 +5599,7 @@ mod test_finalize_block {
);
// Assert that the last tx didn't run
assert!(
inner_results
.get(&batch.commitments()[2].get_hash())
.is_none()
!inner_results.contains_key(&batch.commitments()[2].get_hash())
);

// Check storage modifications
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 @@ -1059,7 +1059,7 @@ where
response.code = ResultCode::InvalidTx.into();
response.log = "The wrapper gas limit overflowed gas \
representation"
.to_owned();
.to_string();
return response;
}
};
Expand Down
1 change: 1 addition & 0 deletions crates/node/src/shell/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ where
// NOTE: we are testing `namada::ledger::queries_ext`,
// which is not possible from `namada` since we do not have
// access to the `Shell` there
#[allow(clippy::cast_possible_truncation)]
#[cfg(test)]
mod test_queries {
use namada::core::storage::Epoch;
Expand Down
3 changes: 1 addition & 2 deletions crates/node/src/shell/testing/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,8 +675,7 @@ impl MockNode {
}
}

#[cfg_attr(feature = "async-send", async_trait::async_trait)]
#[cfg_attr(not(feature = "async-send"), async_trait::async_trait(?Send))]
#[async_trait::async_trait(?Send)]
impl<'a> Client for &'a MockNode {
type Error = Report;

Expand Down
8 changes: 0 additions & 8 deletions crates/proof_of_stake/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,14 +378,6 @@ where
total_consensus_stake_handle().set(storage, total, epoch, 0)
}

/// Used below in `fn unbond_tokens` to update the bond and unbond amounts
#[derive(Eq, Hash, PartialEq)]
struct BondAndUnbondUpdates {
bond_start: Epoch,
new_bond_value: token::Change,
unbond_value: token::Change,
}

/// Unbond tokens that are bonded between a validator and a source (self or
/// delegator).
///
Expand Down
2 changes: 2 additions & 0 deletions crates/sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ version.workspace = true
[features]
default = ["tendermint-rpc", "download-params", "std", "rand", "migrations"]

mainnet = ["namada_core/mainnet", "namada_events/mainnet"]

multicore = ["masp_proofs/multicore"]

namada-sdk = ["tendermint-rpc", "masp_primitives/transparent-inputs"]
Expand Down
33 changes: 15 additions & 18 deletions crates/sdk/src/masp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ use borsh_ext::BorshSerializeExt;
use lazy_static::lazy_static;
use masp_primitives::asset_type::AssetType;
#[cfg(feature = "mainnet")]
use masp_primitives::consensus::MainNetwork;
use masp_primitives::consensus::MainNetwork as Network;
#[cfg(not(feature = "mainnet"))]
use masp_primitives::consensus::TestNetwork;
use masp_primitives::consensus::TestNetwork as Network;
use masp_primitives::convert::AllowedConversion;
use masp_primitives::ff::PrimeField;
use masp_primitives::group::GroupEncoding;
Expand Down Expand Up @@ -90,10 +90,7 @@ pub const ENV_VAR_MASP_PARAMS_DIR: &str = "NAMADA_MASP_PARAMS_DIR";
pub const ENV_VAR_MASP_TEST_SEED: &str = "NAMADA_MASP_TEST_SEED";

/// The network to use for MASP
#[cfg(feature = "mainnet")]
const NETWORK: MainNetwork = MainNetwork;
#[cfg(not(feature = "mainnet"))]
const NETWORK: TestNetwork = TestNetwork;
const NETWORK: Network = Network;

// TODO these could be exported from masp_proof crate
/// Spend circuit name
Expand Down Expand Up @@ -1655,7 +1652,7 @@ impl<U: ShieldedUtils + MaybeSend + MaybeSync> ShieldedContext<U> {
u32::MAX - 20
}
};
let mut builder = Builder::<TestNetwork, _>::new(
let mut builder = Builder::<Network, _>::new(
NETWORK,
// NOTE: this is going to add 20 more blocks to the actual
// expiration but there's no other exposed function that we could
Expand Down Expand Up @@ -2674,7 +2671,7 @@ pub mod testing {
value: u64,
)(
address in arb_transparent_address(),
expiration_height in arb_height(BranchId::MASP, &TestNetwork),
expiration_height in arb_height(BranchId::MASP, &Network),
mut rng in arb_rng().prop_map(TestCsprng),
bparams_rng in arb_rng().prop_map(TestCsprng),
prover_rng in arb_rng().prop_map(TestCsprng),
Expand All @@ -2689,7 +2686,7 @@ pub mod testing {
.to_payment_address(div)
.expect("a PaymentAddress");

let mut builder = Builder::<TestNetwork, _>::new(
let mut builder = Builder::<Network, _>::new(
NETWORK,
// NOTE: this is going to add 20 more blocks to the actual
// expiration but there's no other exposed function that we could
Expand Down Expand Up @@ -2835,7 +2832,7 @@ pub mod testing {
asset_range,
),
)(
expiration_height in arb_height(BranchId::MASP, &TestNetwork),
expiration_height in arb_height(BranchId::MASP, &Network),
spend_descriptions in assets
.iter()
.map(|(asset, values)| arb_spend_descriptions(asset.clone(), values.clone()))
Expand All @@ -2846,10 +2843,10 @@ pub mod testing {
.collect::<Vec<_>>(),
assets in Just(assets),
) -> (
Builder::<TestNetwork>,
Builder::<Network>,
HashMap<AssetData, u64>,
) {
let mut builder = Builder::<TestNetwork, _>::new(
let mut builder = Builder::<Network, _>::new(
NETWORK,
// NOTE: this is going to add 20 more blocks to the actual
// expiration but there's no other exposed function that we could
Expand Down Expand Up @@ -2902,7 +2899,7 @@ pub mod testing {
asset_range,
),
)(
expiration_height in arb_height(BranchId::MASP, &TestNetwork),
expiration_height in arb_height(BranchId::MASP, &Network),
txins in assets
.iter()
.map(|(asset, values)| arb_txouts(asset.clone(), values.clone(), source))
Expand All @@ -2913,10 +2910,10 @@ pub mod testing {
.collect::<Vec<_>>(),
assets in Just(assets),
) -> (
Builder::<TestNetwork>,
Builder::<Network>,
HashMap<AssetData, u64>,
) {
let mut builder = Builder::<TestNetwork, _>::new(
let mut builder = Builder::<Network, _>::new(
NETWORK,
// NOTE: this is going to add 20 more blocks to the actual
// expiration but there's no other exposed function that we could
Expand Down Expand Up @@ -2945,7 +2942,7 @@ pub mod testing {
asset_range,
),
)(
expiration_height in arb_height(BranchId::MASP, &TestNetwork),
expiration_height in arb_height(BranchId::MASP, &Network),
spend_descriptions in assets
.iter()
.map(|(asset, values)| arb_spend_descriptions(asset.clone(), values.clone()))
Expand All @@ -2956,10 +2953,10 @@ pub mod testing {
.collect::<Vec<_>>(),
assets in Just(assets),
) -> (
Builder::<TestNetwork>,
Builder::<Network>,
HashMap<AssetData, u64>,
) {
let mut builder = Builder::<TestNetwork, _>::new(
let mut builder = Builder::<Network, _>::new(
NETWORK,
// NOTE: this is going to add 20 more blocks to the actual
// expiration but there's no other exposed function that we could
Expand Down
8 changes: 8 additions & 0 deletions crates/sdk/src/queries/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,14 @@ macro_rules! router_type {
// paste the generated methods
$( $methods )*
}

impl Default for $name {
fn default() -> Self {
Self {
prefix: String::new(),
}
}
}
}
};

Expand Down
5 changes: 1 addition & 4 deletions crates/sdk/src/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,7 @@ pub async fn process_tx(
pub async fn is_reveal_pk_needed<C: crate::queries::Client + Sync>(
client: &C,
address: &Address,
) -> Result<bool>
where
C: crate::queries::Client + Sync,
{
) -> Result<bool> {
// Check if PK revealed
Ok(!has_revealed_pk(client, address).await?)
}
Expand Down
Loading
Loading