From 89bb67dddb281e63d1e5d9fdc6293d2dade92e6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Mon, 22 Jan 2024 14:13:10 +0000 Subject: [PATCH] rename new fns --- .../apps/src/lib/node/ledger/shell/finalize_block.rs | 3 ++- crates/apps/src/lib/node/ledger/shell/init_chain.rs | 6 +++--- crates/apps/src/lib/node/ledger/storage/mod.rs | 2 +- crates/benches/native_vps.rs | 2 +- crates/ibc/src/context/common.rs | 2 +- crates/namada/src/ledger/ibc/mod.rs | 6 +++--- crates/shielded_token/src/conversion.rs | 6 +++--- crates/shielded_token/src/storage.rs | 12 ++++++------ crates/shielded_token/src/utils.rs | 6 +++--- crates/state/src/lib.rs | 6 +++--- crates/storage/src/lib.rs | 4 ++-- 11 files changed, 28 insertions(+), 27 deletions(-) diff --git a/crates/apps/src/lib/node/ledger/shell/finalize_block.rs b/crates/apps/src/lib/node/ledger/shell/finalize_block.rs index c9a1f9997c..75bc6707cd 100644 --- a/crates/apps/src/lib/node/ledger/shell/finalize_block.rs +++ b/crates/apps/src/lib/node/ledger/shell/finalize_block.rs @@ -606,7 +606,8 @@ where let anchor_key = token::storage_key::masp_commitment_anchor_key( updated_tree.root(), ); - self.wl_storage.write_without_merkldiffs(&anchor_key, ())?; + self.wl_storage + .write_without_merkle_diffs(&anchor_key, ())?; } if update_for_tendermint { diff --git a/crates/apps/src/lib/node/ledger/shell/init_chain.rs b/crates/apps/src/lib/node/ledger/shell/init_chain.rs index efd2ad2c9c..815bec90d9 100644 --- a/crates/apps/src/lib/node/ledger/shell/init_chain.rs +++ b/crates/apps/src/lib/node/ledger/shell/init_chain.rs @@ -141,7 +141,7 @@ where let note_commitment_tree_key = token::storage_key::masp_commitment_tree_key(); self.wl_storage - .write_without_merkldiffs( + .write_without_merkle_diffs( ¬e_commitment_tree_key, empty_commitment_tree, ) @@ -149,12 +149,12 @@ where let commitment_tree_anchor_key = token::storage_key::masp_commitment_anchor_key(anchor); self.wl_storage - .write_without_merkldiffs(&commitment_tree_anchor_key, ()) + .write_without_merkle_diffs(&commitment_tree_anchor_key, ()) .unwrap(); // Init masp convert anchor let convert_anchor_key = token::storage_key::masp_convert_anchor_key(); - self.wl_storage.write_without_merkldiffs( + self.wl_storage.write_without_merkle_diffs( &convert_anchor_key, namada::types::hash::Hash( bls12_381::Scalar::from( diff --git a/crates/apps/src/lib/node/ledger/storage/mod.rs b/crates/apps/src/lib/node/ledger/storage/mod.rs index 03bcaec966..be406dbf90 100644 --- a/crates/apps/src/lib/node/ledger/storage/mod.rs +++ b/crates/apps/src/lib/node/ledger/storage/mod.rs @@ -829,7 +829,7 @@ mod tests { assert!(res.is_none()); // Write key-val-2 without merklizing or diffs - wls.write_without_merkldiffs(&key2, val2).unwrap(); + wls.write_without_merkle_diffs(&key2, val2).unwrap(); // Read from WlStorage should return val2 let res = wls.read::(&key2).unwrap().unwrap(); diff --git a/crates/benches/native_vps.rs b/crates/benches/native_vps.rs index 1439c2d708..dd64893cd9 100644 --- a/crates/benches/native_vps.rs +++ b/crates/benches/native_vps.rs @@ -515,7 +515,7 @@ fn setup_storage_for_masp_verification( shielded_ctx .shell .wl_storage - .write_without_merkldiffs(&anchor_key, ()) + .write_without_merkle_diffs(&anchor_key, ()) .unwrap(); shielded_ctx.shell.commit_block(); // Cache the masp tx so that it can be returned when queried diff --git a/crates/ibc/src/context/common.rs b/crates/ibc/src/context/common.rs index 44d5b09df8..11fa0693cc 100644 --- a/crates/ibc/src/context/common.rs +++ b/crates/ibc/src/context/common.rs @@ -643,7 +643,7 @@ pub trait IbcCommonContext: IbcStorageContext { u64::checked_add(count, 1).ok_or_else(|| ClientError::Other { description: format!("The counter overflow: Key {key}"), })?; - self.write_without_merkldiffs(key, count) + self.write_without_merkle_diffs(key, count) .map_err(ContextError::from) } diff --git a/crates/namada/src/ledger/ibc/mod.rs b/crates/namada/src/ledger/ibc/mod.rs index 7a54825168..606d0133e9 100644 --- a/crates/namada/src/ledger/ibc/mod.rs +++ b/crates/namada/src/ledger/ibc/mod.rs @@ -20,18 +20,18 @@ where // the client counter let key = client_counter_key(); storage - .write_without_merkldiffs(&key, init_value) + .write_without_merkle_diffs(&key, init_value) .expect("Unable to write the initial client counter"); // the connection counter let key = connection_counter_key(); storage - .write_without_merkldiffs(&key, init_value) + .write_without_merkle_diffs(&key, init_value) .expect("Unable to write the initial connection counter"); // the channel counter let key = channel_counter_key(); storage - .write_without_merkldiffs(&key, init_value) + .write_without_merkle_diffs(&key, init_value) .expect("Unable to write the initial channel counter"); } diff --git a/crates/shielded_token/src/conversion.rs b/crates/shielded_token/src/conversion.rs index 5c8fbca0e2..abf62e4502 100644 --- a/crates/shielded_token/src/conversion.rs +++ b/crates/shielded_token/src/conversion.rs @@ -163,12 +163,12 @@ where // but we should make sure the return value's ratio matches // this new inflation rate in 'update_allowed_conversions', // otherwise we will have an inaccurate view of inflation - wl_storage.write_without_merkldiffs( + wl_storage.write_without_merkle_diffs( &masp_last_inflation_key(addr), inflation_amount, )?; - wl_storage.write_without_merkldiffs( + wl_storage.write_without_merkle_diffs( &masp_last_locked_ratio_key(addr), locked_ratio, )?; @@ -442,7 +442,7 @@ where wl_storage.storage.conversion_state.tree = FrozenCommitmentTree::merge(&tree_parts); // Update the anchor in storage - wl_storage.write_without_merkldiffs( + wl_storage.write_without_merkle_diffs( &crate::storage_key::masp_convert_anchor_key(), namada_core::types::hash::Hash( bls12_381::Scalar::from( diff --git a/crates/shielded_token/src/storage.rs b/crates/shielded_token/src/storage.rs index 2bc9cab994..bd29634a3e 100644 --- a/crates/shielded_token/src/storage.rs +++ b/crates/shielded_token/src/storage.rs @@ -22,25 +22,25 @@ where kp_gain_nom, locked_ratio_target: locked_target, } = params; - storage.write_without_merkldiffs( + storage.write_without_merkle_diffs( &masp_last_inflation_key(address), Amount::zero(), )?; - storage.write_without_merkldiffs( + storage.write_without_merkle_diffs( &masp_last_locked_ratio_key(address), Dec::zero(), )?; - storage.write_without_merkldiffs( + storage.write_without_merkle_diffs( &masp_max_reward_rate_key(address), max_rate, )?; - storage.write_without_merkldiffs( + storage.write_without_merkle_diffs( &masp_locked_ratio_target_key(address), locked_target, )?; storage - .write_without_merkldiffs(&masp_kp_gain_key(address), kp_gain_nom)?; + .write_without_merkle_diffs(&masp_kp_gain_key(address), kp_gain_nom)?; storage - .write_without_merkldiffs(&masp_kd_gain_key(address), kd_gain_nom)?; + .write_without_merkle_diffs(&masp_kd_gain_key(address), kd_gain_nom)?; Ok(()) } diff --git a/crates/shielded_token/src/utils.rs b/crates/shielded_token/src/utils.rs index 2ebdc37076..ffa0068a99 100644 --- a/crates/shielded_token/src/utils.rs +++ b/crates/shielded_token/src/utils.rs @@ -19,7 +19,7 @@ fn reveal_nullifiers( .sapling_bundle() .map_or(&vec![], |description| &description.shielded_spends) { - ctx.write_without_merkldiffs( + ctx.write_without_merkle_diffs( &masp_nullifier_key(&description.nullifier), (), )?; @@ -53,7 +53,7 @@ pub fn update_note_commitment_tree( })?; } - ctx.write_without_merkldiffs(&tree_key, commitment_tree)?; + ctx.write_without_merkle_diffs(&tree_key, commitment_tree)?; } } @@ -74,7 +74,7 @@ pub fn handle_masp_tx( // If storage key has been supplied, then pin this transaction to it if let Some(key) = pin_key { - ctx.write_without_merkldiffs( + ctx.write_without_merkle_diffs( &masp_pin_tx_key(key), IndexedTx { height: ctx.get_block_height()?, diff --git a/crates/state/src/lib.rs b/crates/state/src/lib.rs index cc07feff29..10a4c86da5 100644 --- a/crates/state/src/lib.rs +++ b/crates/state/src/lib.rs @@ -450,7 +450,7 @@ where } /// Write with diffs but no merklization - pub fn write_without_merkl( + pub fn write_without_merkle( &mut self, key: &Key, value: impl AsRef<[u8]>, @@ -459,7 +459,7 @@ where } /// Write without diffs or merklization - pub fn write_without_merkldiffs( + pub fn write_without_merkle_diffs( &mut self, key: &Key, value: impl AsRef<[u8]>, @@ -1420,7 +1420,7 @@ mod tests { assert!(res.is_none()); // Write key-val-2 without merklizing or diffs - wls.write_without_merkldiffs(&key2, val2).unwrap(); + wls.write_without_merkle_diffs(&key2, val2).unwrap(); // Read from WlStorage should return val2 let res = wls.read::(&key2).unwrap().unwrap(); diff --git a/crates/storage/src/lib.rs b/crates/storage/src/lib.rs index fe0acf9b05..674da8c044 100644 --- a/crates/storage/src/lib.rs +++ b/crates/storage/src/lib.rs @@ -175,7 +175,7 @@ pub trait StorageWrite { /// Write a value to be encoded with Borsh at the given key to storage. /// Additionally, write the data to the diffs. Do not add to the merkle /// tree. - fn write_without_merkl( + fn write_without_merkle( &mut self, key: &storage::Key, val: T, @@ -185,7 +185,7 @@ pub trait StorageWrite { /// Write a value to be encoded with Borsh at the given key to storage. /// Do not update the diffs or merkle tree. - fn write_without_merkldiffs( + fn write_without_merkle_diffs( &mut self, key: &storage::Key, val: T,