Skip to content

Commit

Permalink
Add overlay getter for externalities
Browse files Browse the repository at this point in the history
  • Loading branch information
ark0f committed Jul 11, 2024
1 parent 2719544 commit 7a41c56
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
5 changes: 5 additions & 0 deletions substrate/primitives/externalities/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,11 @@ pub trait Externalities: ExtensionStore {
///
/// Get all the keys that have been read or written to during the benchmark.
fn get_read_and_written_keys(&self) -> Vec<(Vec<u8>, u32, u32, bool)>;

/// Access to `OverlayChanges<H>` for `gear-tasks`.
fn gear_overlayed_changes(&self) -> Option<Box<dyn Any + Send>> {
None
}
}

/// Extension for the [`Externalities`] trait.
Expand Down
6 changes: 5 additions & 1 deletion substrate/primitives/state-machine/src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ where

impl<'a, H, B> Externalities for Ext<'a, H, B>
where
H: Hasher,
H: Hasher + 'static,
H::Out: Ord + 'static + codec::Codec,
B: Backend<H>,
{
Expand Down Expand Up @@ -651,6 +651,10 @@ where
fn get_read_and_written_keys(&self) -> Vec<(Vec<u8>, u32, u32, bool)> {
self.backend.get_read_and_written_keys()
}

fn gear_overlayed_changes(&self) -> Option<Box<dyn Any + Send>> {
Some(Box::new(self.overlay.clone()))
}
}

impl<'a, H, B> Ext<'a, H, B>
Expand Down
8 changes: 4 additions & 4 deletions substrate/primitives/state-machine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ mod execution {

impl<'a, B, H, Exec> StateMachine<'a, B, H, Exec>
where
H: Hasher,
H: Hasher + 'static,
H::Out: Ord + 'static + codec::Codec,
Exec: CodeExecutor + Clone + 'static,
B: Backend<H>,
Expand Down Expand Up @@ -331,7 +331,7 @@ mod execution {
) -> Result<(Vec<u8>, StorageProof), Box<dyn Error>>
where
B: AsTrieBackend<H>,
H: Hasher,
H: Hasher + 'static,
H::Out: Ord + 'static + codec::Codec,
Exec: CodeExecutor + Clone + 'static,
{
Expand Down Expand Up @@ -367,7 +367,7 @@ mod execution {
) -> Result<(Vec<u8>, StorageProof), Box<dyn Error>>
where
S: trie_backend_essence::TrieBackendStorage<H>,
H: Hasher,
H: Hasher + 'static,
H::Out: Ord + 'static + codec::Codec,
Exec: CodeExecutor + 'static + Clone,
{
Expand Down Expand Up @@ -429,7 +429,7 @@ mod execution {
runtime_code: &RuntimeCode,
) -> Result<Vec<u8>, Box<dyn Error>>
where
H: Hasher,
H: Hasher + 'static,
H::Out: Ord + 'static + codec::Codec,
Exec: CodeExecutor + Clone + 'static,
{
Expand Down

0 comments on commit 7a41c56

Please sign in to comment.