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

Update end_slot_hook #742

Merged
merged 6 commits into from
Aug 28, 2023
Merged
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
7 changes: 6 additions & 1 deletion examples/demo-stf/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,13 @@ impl<C: Context, Cond: ValidityCondition> SlotHooks<Cond> for Runtime<C> {

fn end_slot_hook(
&self,
_working_set: &mut sov_state::WorkingSet<<Self::Context as sov_modules_api::Spec>::Storage>,
#[allow(unused_variables)] root_hash: [u8; 32],
neysofu marked this conversation as resolved.
Show resolved Hide resolved
#[allow(unused_variables)] working_set: &mut sov_state::WorkingSet<
<Self::Context as sov_modules_api::Spec>::Storage,
>,
) {
#[cfg(feature = "experimental")]
self.evm.end_slot_hook(root_hash, working_set);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ impl<C: Context, Cond: ValidityCondition> SlotHooks<Cond> for TestRuntime<C, Con
self.chain_state.begin_slot_hook(slot_data, working_set)
}

fn end_slot_hook(&self, _working_set: &mut WorkingSet<<Self::Context as Spec>::Storage>) {}
fn end_slot_hook(
&self,
_root_hash: [u8; 32],
_working_set: &mut WorkingSet<<Self::Context as Spec>::Storage>,
) {
}
}

impl<C: Context, Cond: ValidityCondition> BlobSelector for TestRuntime<C, Cond> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,10 @@ impl<Ctx: Context, Cond: ValidityCondition> SlotHooks<Cond> for ChainState<Ctx,
);
}

fn end_slot_hook(&self, _working_set: &mut WorkingSet<<Self::Context as Spec>::Storage>) {}
fn end_slot_hook(
&self,
_root_hash: [u8; 32],
_working_set: &mut WorkingSet<<Self::Context as Spec>::Storage>,
) {
}
}
9 changes: 9 additions & 0 deletions module-system/module-implementations/sov-evm/src/hooks.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use sov_state::WorkingSet;

use crate::Evm;

impl<C: sov_modules_api::Context> Evm<C> {
pub fn end_slot_hook(&self, _root_hash: [u8; 32], _working_set: &mut WorkingSet<C::Storage>) {
// TODO implement block creation logic.
}
}
2 changes: 2 additions & 0 deletions module-system/module-implementations/sov-evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ pub mod call;
pub mod evm;
#[cfg(feature = "experimental")]
pub mod genesis;
#[cfg(feature = "experimental")]
pub mod hooks;
#[cfg(feature = "native")]
#[cfg(feature = "experimental")]
pub mod query;
Expand Down
6 changes: 5 additions & 1 deletion module-system/sov-modules-api/src/hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,9 @@ pub trait SlotHooks<Condition: ValidityCondition> {
working_set: &mut WorkingSet<<Self::Context as Spec>::Storage>,
);

fn end_slot_hook(&self, working_set: &mut WorkingSet<<Self::Context as Spec>::Storage>);
fn end_slot_hook(
&self,
root_hash: [u8; 32],
working_set: &mut WorkingSet<<Self::Context as Spec>::Storage>,
);
}
3 changes: 1 addition & 2 deletions module-system/sov-modules-stf-template/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ where
.expect("jellyfish merkle tree update must succeed");

let mut working_set = WorkingSet::new(self.current_storage.clone());

self.runtime.end_slot_hook(&mut working_set);
self.runtime.end_slot_hook(root_hash, &mut working_set);
neysofu marked this conversation as resolved.
Show resolved Hide resolved

(jmt::RootHash(root_hash), witness)
}
Expand Down