Skip to content

Commit

Permalink
fixup! Merge branch 'fraccaman+bat/commit-only-merkle-tree' (#2926)
Browse files Browse the repository at this point in the history
  • Loading branch information
tzemanovic committed Apr 5, 2024
1 parent 6dba218 commit 57c56e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
5 changes: 1 addition & 4 deletions crates/state/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ pub use namada_core::storage::{
EPOCH_TYPE_LENGTH,
};
use namada_core::tendermint::merkle::proof::ProofOps;
use namada_gas::{
MEMORY_ACCESS_GAS_PER_BYTE, STORAGE_ACCESS_GAS_PER_BYTE,
STORAGE_WRITE_GAS_PER_BYTE,
};
use namada_gas::{MEMORY_ACCESS_GAS_PER_BYTE, STORAGE_ACCESS_GAS_PER_BYTE};
use namada_merkle_tree::Error as MerkleTreeError;
pub use namada_merkle_tree::{
self as merkle_tree, ics23_specs, MembershipProof, MerkleTree,
Expand Down
10 changes: 5 additions & 5 deletions crates/state/src/wl_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use crate::{
MembershipProof, MerkleTree, MerkleTreeError, ProofOps, Result, State,
StateRead, StorageHasher, StorageResult, StoreType, DB,
EPOCH_SWITCH_BLOCKS_DELAY, STORAGE_ACCESS_GAS_PER_BYTE,
STORAGE_WRITE_GAS_PER_BYTE,
};

/// Owned state with full R/W access.
Expand Down Expand Up @@ -727,7 +726,7 @@ where

/// Write a value to the specified subspace and returns the gas cost and the
/// size difference
#[cfg(any(test, feature = "testing"))]
#[cfg(any(test, feature = "testing", feature = "benches"))]
pub fn db_write(
&mut self,
key: &Key,
Expand All @@ -752,7 +751,8 @@ where
}

let len = value.len();
let gas = (key.len() + len) as u64 * STORAGE_WRITE_GAS_PER_BYTE;
let gas =
(key.len() + len) as u64 * namada_gas::STORAGE_WRITE_GAS_PER_BYTE;
let size_diff = self.db.write_subspace_val(
self.in_mem.block.height,
key,
Expand All @@ -764,7 +764,7 @@ where

/// Delete the specified subspace and returns the gas cost and the size
/// difference
#[cfg(any(test, feature = "testing"))]
#[cfg(any(test, feature = "testing", feature = "benches"))]
pub fn db_delete(&mut self, key: &Key) -> Result<(u64, i64)> {
// Note that this method is the same as `StorageWrite::delete`,
// but with gas and storage bytes len diff accounting
Expand All @@ -781,7 +781,7 @@ where
)?;
}
let gas = (key.len() + deleted_bytes_len as usize) as u64
* STORAGE_WRITE_GAS_PER_BYTE;
* namada_gas::STORAGE_WRITE_GAS_PER_BYTE;
Ok((gas, deleted_bytes_len))
}

Expand Down

0 comments on commit 57c56e6

Please sign in to comment.