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

Draft 0.28.1 #2274

Closed
wants to merge 21 commits into from
Closed
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/2261-fix-sdk-0.28.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Fix sdk compilation when using async-send feature flag.
([\#2261](https://github.com/anoma/namada/pull/2261))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Added back missing changed storage keys in transaction results.
([\#2263](https://github.com/anoma/namada/pull/2263))
2 changes: 2 additions & 0 deletions .changelog/unreleased/bug-fixes/2264-fix-bp-tree-pruning.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Fix to skip pruning BridgePool Merkle trees when no signed nonce
([\#2264](https://github.com/anoma/namada/issues/2264))
2 changes: 2 additions & 0 deletions .changelog/unreleased/bug-fixes/2270-masp-rewards-fixes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Initialize token total supply to zero at init chain.
([\#2270](https://github.com/anoma/namada/pull/2270))
2 changes: 2 additions & 0 deletions .changelog/unreleased/improvements/2272-cache-masp-keys.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Preload and cache MASP verifying keys on ledger start-up.
([\#2272](https://github.com/anoma/namada/pull/2272))
2 changes: 2 additions & 0 deletions .changelog/unreleased/improvements/2273-pre-gen-wallet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Now join-network will try to look for non validator wallet in more places.
([\#2273](https://github.com/anoma/namada/pull/2273))
1 change: 1 addition & 0 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ check-mainnet:
check-crates:
$(foreach p,$(crates), echo "Checking $(p)" && cargo +$(nightly) check -Z unstable-options --tests -p $(p) && ) \
make -C $(wasms_for_tests) check && \
cargo check --package namada --target wasm32-unknown-unknown --no-default-features --features "namada-sdk"
cargo check --package namada --target wasm32-unknown-unknown --no-default-features --features "namada-sdk" && \
cargo check --package namada_sdk --all-features

clippy-wasm = $(cargo) +$(nightly) clippy --manifest-path $(wasm)/Cargo.toml --all-targets -- -D warnings

Expand Down
17 changes: 13 additions & 4 deletions apps/src/lib/client/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,12 @@ pub async fn join_network(

// Pre-load the validator pre-genesis wallet and its keys to validate that
// everything is in place before downloading the network archive
let validator_alias_and_pre_genesis_wallet =
validator_alias_and_dir.map(|(validator_alias, pre_genesis_dir)| {
let validator_alias_and_pre_genesis_wallet = validator_alias_and_dir
.as_ref()
.map(|(validator_alias, pre_genesis_dir)| {
(
alias::Alias::from(validator_alias),
pre_genesis::load(&pre_genesis_dir).unwrap_or_else(|err| {
pre_genesis::load(pre_genesis_dir).unwrap_or_else(|err| {
eprintln!(
"Error loading validator pre-genesis wallet {err}",
);
Expand Down Expand Up @@ -262,7 +263,15 @@ pub async fn join_network(

// Try to load pre-genesis wallet, if any
let pre_genesis_wallet_path = base_dir.join(PRE_GENESIS_DIR);
let pre_genesis_wallet = crate::wallet::load(&pre_genesis_wallet_path);
let pre_genesis_wallet =
if let Some(wallet) = crate::wallet::load(&pre_genesis_wallet_path) {
Some(wallet)
} else {
validator_alias_and_dir
.as_ref()
.and_then(|(_, path)| crate::wallet::load(path))
};

// Derive wallet from genesis
let wallet = genesis.derive_wallet(
&chain_dir,
Expand Down
4 changes: 4 additions & 0 deletions apps/src/lib/node/ledger/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ async fn run_aux(config: config::Ledger, wasm_dir: PathBuf) {
}
};

tracing::info!("Loading MASP verifying keys.");
let _ = namada_sdk::masp::preload_verifying_keys();
tracing::info!("Done loading MASP verifying keys.");

// Start ABCI server and broadcaster (the latter only if we are a validator
// node)
let (abci, broadcaster, shell_handler) = start_abci_broadcaster_shell(
Expand Down
3 changes: 2 additions & 1 deletion apps/src/lib/node/ledger/shell/finalize_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,8 @@ where
tx_event["hash"],
result
);
changed_keys.append(&mut result.changed_keys);
changed_keys
.extend(result.changed_keys.iter().cloned());
stats.increment_successful_txs();
if let Some(wrapper) = embedding_wrapper {
self.commit_inner_tx_hash(wrapper);
Expand Down
10 changes: 2 additions & 8 deletions apps/src/lib/node/ledger/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,11 +591,8 @@ mod tests {
);
let new_epoch_start = BlockHeight(1);
let signed_root_key = bridge_pool::get_signed_root_key();
// the first nonce isn't written for a test skipping pruning
let nonce = Uint::default();
let root_proof =
BridgePoolRootProof::new((KeccakHash::default(), nonce));
let bytes = types::encode(&root_proof);
storage.write(&signed_root_key, bytes).unwrap();

storage
.begin_block(BlockHash::default(), new_epoch_start)
Expand All @@ -622,11 +619,8 @@ mod tests {
.write(&key, types::encode(&value))
.expect("write failed");

// the second nonce isn't written for a test skipping pruning
let nonce = nonce + 1;
let root_proof =
BridgePoolRootProof::new((KeccakHash::default(), nonce));
let bytes = types::encode(&root_proof);
storage.write(&signed_root_key, bytes).unwrap();

storage.block.epoch = storage.block.epoch.next();
storage.block.pred_epochs.new_epoch(new_epoch_start);
Expand Down
14 changes: 9 additions & 5 deletions apps/src/lib/node/ledger/storage/rocksdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1453,17 +1453,21 @@ impl DB for RocksDB {
&self,
height: BlockHeight,
last_height: BlockHeight,
) -> Result<Uint> {
) -> Result<Option<Uint>> {
let nonce_key = bridge_pool::get_signed_root_key();
let bytes = if height == BlockHeight(0) || height >= last_height {
self.read_subspace_val(&nonce_key)?
} else {
self.read_subspace_val_with_height(&nonce_key, height, last_height)?
};
let bytes = bytes.expect("Signed root should exist");
let bp_root_proof = BridgePoolRootProof::try_from_slice(&bytes)
.map_err(Error::BorshCodingError)?;
Ok(bp_root_proof.data.1)
match bytes {
Some(bytes) => {
let bp_root_proof = BridgePoolRootProof::try_from_slice(&bytes)
.map_err(Error::BorshCodingError)?;
Ok(Some(bp_root_proof.data.1))
}
None => Ok(None),
}
}

fn write_replay_protection_entry(
Expand Down
4 changes: 2 additions & 2 deletions core/src/ledger/storage/mockdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,8 +593,8 @@ impl DB for MockDB {
&self,
_height: BlockHeight,
_last_height: BlockHeight,
) -> Result<Uint> {
Ok(Uint::default())
) -> Result<Option<Uint>> {
Ok(None)
}

fn write_replay_protection_entry(
Expand Down
29 changes: 21 additions & 8 deletions core/src/ledger/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ pub trait DB: std::fmt::Debug {
&self,
height: BlockHeight,
last_height: BlockHeight,
) -> Result<Uint>;
) -> Result<Option<Uint>>;

/// Write a replay protection entry
fn write_replay_protection_entry(
Expand Down Expand Up @@ -1178,7 +1178,10 @@ where
}

// Prune the BridgePool subtree stores with invalid nonce
let mut epoch = self.get_oldest_epoch_with_valid_nonce()?;
let mut epoch = match self.get_oldest_epoch_with_valid_nonce()? {
Some(epoch) => epoch,
None => return Ok(()),
};
while oldest_epoch < epoch {
epoch = epoch.prev();
self.db.prune_merkle_tree_store(
Expand Down Expand Up @@ -1216,11 +1219,15 @@ where
}

/// Get oldest epoch which has the valid signed nonce of the bridge pool
pub fn get_oldest_epoch_with_valid_nonce(&self) -> Result<Epoch> {
fn get_oldest_epoch_with_valid_nonce(&self) -> Result<Option<Epoch>> {
let last_height = self.get_last_block_height();
let current_nonce = self
let current_nonce = match self
.db
.read_bridge_pool_signed_nonce(last_height, last_height)?;
.read_bridge_pool_signed_nonce(last_height, last_height)?
{
Some(nonce) => nonce,
None => return Ok(None),
};
let (mut epoch, _) = self.get_last_epoch();
// We don't need to check the older epochs because their Merkle tree
// snapshots have been already removed
Expand All @@ -1235,13 +1242,19 @@ where
Some(h) => h,
None => continue,
};
let nonce =
self.db.read_bridge_pool_signed_nonce(height, last_height)?;
let nonce = match self
.db
.read_bridge_pool_signed_nonce(height, last_height)?
{
Some(nonce) => nonce,
// skip pruning when the old epoch doesn't have the signed nonce
None => break,
};
if nonce < current_nonce {
break;
}
}
Ok(epoch)
Ok(Some(epoch))
}

/// Check it the given transaction's hash is already present in storage
Expand Down
3 changes: 3 additions & 0 deletions core/src/types/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,9 @@ impl Parameters {
wl_storage
.write(&masp_kd_gain_key(address), kd_gain_nom)
.expect("The nominal derivative gain must be initialized");
wl_storage
.write(&minted_balance_key(address), Amount::zero())
.expect("The total minted balance key must initialized");
}
}

Expand Down
1 change: 1 addition & 0 deletions sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ ethers.workspace = true
fd-lock = { workspace = true, optional = true }
futures.workspace = true
itertools.workspace = true
lazy_static.workspace= true
masp_primitives.workspace = true
masp_proofs.workspace = true
namada_core = {path = "../core", default-features = false, features = ["rand"]}
Expand Down
6 changes: 4 additions & 2 deletions sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,11 +542,13 @@ pub trait Namada: Sized + MaybeSync + MaybeSend {
tx: &mut Tx,
args: &args::Tx,
signing_data: SigningTxData,
with: impl Fn(Tx, common::PublicKey, HashSet<signing::Signable>, D) -> F,
with: impl Fn(Tx, common::PublicKey, HashSet<signing::Signable>, D) -> F
+ MaybeSend
+ MaybeSync,
user_data: D,
) -> crate::error::Result<()>
where
D: Clone,
D: Clone + MaybeSend + MaybeSync,
F: MaybeSend
+ MaybeSync
+ std::future::Future<Output = crate::error::Result<Tx>>,
Expand Down
Loading
Loading