Skip to content

Commit

Permalink
avoid unnecessary clone of InmemoryDB
Browse files Browse the repository at this point in the history
  • Loading branch information
vedhavyas committed Jan 9, 2025
1 parent fa4fce9 commit dfc3827
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion crates/sp-domains-fraud-proof/src/execution_prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ where
// TODO: avoid using the String API specified by `execution_method()`
// https://github.com/paritytech/substrate/discussions/11095
if let Some((delta, post_delta_root)) = delta_changes {
let delta_backend = create_delta_backend(trie_backend, delta, post_delta_root);
let delta_backend = create_delta_backend(trie_backend, &delta, post_delta_root);
sp_state_machine::prove_execution_on_trie_backend(
&delta_backend,
&mut Default::default(),
Expand Down
13 changes: 5 additions & 8 deletions domains/client/block-builder/src/custom_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub struct CollectedStorageChanges<H: Hasher> {
/// and `delta`.
pub fn create_delta_backend<'a, S, H>(
backend: &'a TrieBackend<S, H>,
delta: BackendTransaction<H>,
delta: &'a BackendTransaction<H>,
post_delta_root: H::Out,
) -> TrieBackend<DeltaBackend<'a, S, H>, H>
where
Expand All @@ -51,7 +51,7 @@ where

fn create_delta_backend_with_maybe_delta<'a, S, H>(
backend: &'a TrieBackend<S, H>,
maybe_delta: Option<BackendTransaction<H>>,
maybe_delta: Option<&'a BackendTransaction<H>>,
post_delta_root: H::Out,
) -> TrieBackend<DeltaBackend<'a, S, H>, H>
where
Expand All @@ -76,7 +76,7 @@ where
H: 'a + Hasher,
{
backend: &'a S,
delta: Option<BackendTransaction<H>>,
delta: Option<&'a BackendTransaction<H>>,
_phantom: PhantomData<H>,
}

Expand All @@ -87,7 +87,7 @@ where
{
fn get(&self, key: &H::Out, prefix: Prefix) -> Result<Option<DBValue>, String> {
if let Some(db) = &self.delta
&& let Some(v) = HashDB::get(db, key, prefix)
&& let Some(v) = HashDB::get(*db, key, prefix)
{
Ok(Some(v))
} else {
Expand Down Expand Up @@ -294,10 +294,7 @@ where
.map_err(sp_blockchain::Error::RuntimeCode)?;
let mut overlayed_changes = OverlayedChanges::default();
let (state_root, delta) = if let Some(changes) = &self.maybe_storage_changes {
(
changes.transaction_storage_root,
Some(changes.transaction.clone()),
)
(changes.transaction_storage_root, Some(&changes.transaction))
} else {
(*trie_backend.root(), None)
};
Expand Down

0 comments on commit dfc3827

Please sign in to comment.