diff --git a/examples/demo-stf/src/hooks_impl.rs b/examples/demo-stf/src/hooks_impl.rs index c3f55d754..38e786a69 100644 --- a/examples/demo-stf/src/hooks_impl.rs +++ b/examples/demo-stf/src/hooks_impl.rs @@ -90,6 +90,13 @@ impl SlotHooks for Runtime { #[cfg(feature = "experimental")] self.evm .begin_slot_hook(slot_header.hash().into(), working_set); + + self.chain_state.begin_slot_hook( + slot_header, + validity_condition, + pre_state_root, + working_set, + ); } fn end_slot_hook( @@ -98,6 +105,8 @@ impl SlotHooks for Runtime { ) { #[cfg(feature = "experimental")] self.evm.end_slot_hook(working_set); + + self.chain_state.end_slot_hook(working_set); } } @@ -111,5 +120,8 @@ impl FinalizeHook for Runtime { - verifier.run_block(vm.simulate_with_hints()).map_err(|e| { + tracing::info_span!("guest_execution").in_scope(|| match config { + ProofGenConfig::Simulate(verifier) => verifier + .run_block(vm.simulate_with_hints()) + .map_err(|e| { anyhow::anyhow!("Guest execution must succeed but failed with {:?}", e) - })?; - } - ProofGenConfig::Execute => vm.run(false)?, - ProofGenConfig::Prover => vm.run(true)?, - } + }) + .map(|_| ()), + ProofGenConfig::Execute => vm.run(false), + ProofGenConfig::Prover => vm.run(true), + })?; } let next_state_root = slot_result.state_root; diff --git a/rollup-interface/src/state_machine/mocks/da.rs b/rollup-interface/src/state_machine/mocks/da.rs index 20c38d2eb..d4229fb3c 100644 --- a/rollup-interface/src/state_machine/mocks/da.rs +++ b/rollup-interface/src/state_machine/mocks/da.rs @@ -373,7 +373,7 @@ impl DaVerifier for MockDaVerifier { _inclusion_proof: ::InclusionMultiProof, _completeness_proof: ::CompletenessProof, ) -> Result<::ValidityCondition, Self::Error> { - Ok(MockValidityCond { is_valid: true }) + Ok(Default::default()) } } diff --git a/rollup-interface/src/state_machine/mocks/validity_condition.rs b/rollup-interface/src/state_machine/mocks/validity_condition.rs index e96b72df4..f7ad4ceb2 100644 --- a/rollup-interface/src/state_machine/mocks/validity_condition.rs +++ b/rollup-interface/src/state_machine/mocks/validity_condition.rs @@ -9,22 +9,20 @@ use crate::zk::{ValidityCondition, ValidityConditionChecker}; /// A trivial test validity condition structure that only contains a boolean #[derive( - Debug, - BorshDeserialize, - BorshSerialize, - Serialize, - Deserialize, - PartialEq, - Clone, - Copy, - Default, - Eq, + Debug, BorshDeserialize, BorshSerialize, Serialize, Deserialize, PartialEq, Clone, Copy, Eq, )] pub struct MockValidityCond { /// The associated validity condition field. If it is true, the validity condition is verified pub is_valid: bool, } +// Validity conditions should usually be valid +impl Default for MockValidityCond { + fn default() -> Self { + Self { is_valid: true } + } +} + impl ValidityCondition for MockValidityCond { type Error = Error; fn combine(&self, rhs: Self) -> Result {