From e6114d9f83256d6c31ec1f5a0743009225a8428f Mon Sep 17 00:00:00 2001 From: yaziciahmet Date: Tue, 17 Dec 2024 23:21:29 +0100 Subject: [PATCH] Pass forks as arg --- crates/citrea-stf/src/verifier.rs | 3 +++ crates/prover-services/src/parallel/mod.rs | 3 ++- .../sovereign-sdk/full-node/sov-stf-runner/src/mock/mod.rs | 2 ++ .../module-system/sov-modules-stf-blueprint/src/lib.rs | 6 +++--- .../sovereign-sdk/rollup-interface/src/state_machine/stf.rs | 2 ++ .../batch-proof-bitcoin/src/bin/batch_proof_bitcoin.rs | 2 +- guests/risc0/batch-proof-mock/src/bin/batch_proof_mock.rs | 2 +- 7 files changed, 14 insertions(+), 6 deletions(-) diff --git a/crates/citrea-stf/src/verifier.rs b/crates/citrea-stf/src/verifier.rs index 2d6214776..621d7dad8 100644 --- a/crates/citrea-stf/src/verifier.rs +++ b/crates/citrea-stf/src/verifier.rs @@ -1,3 +1,4 @@ +use sov_modules_api::fork::Fork; use sov_rollup_interface::da::{BlockHeaderTrait, DaNamespace, DaVerifier}; use sov_rollup_interface::stf::{ApplySequencerCommitmentsOutput, StateTransitionFunction}; use sov_rollup_interface::zk::{BatchProofCircuitInput, BatchProofCircuitOutput}; @@ -27,6 +28,7 @@ where &mut self, data: BatchProofCircuitInput, pre_state: Stf::PreState, + forks: &[Fork], ) -> Result, Da::Error> { println!("Running sequencer commitments in DA slot"); @@ -73,6 +75,7 @@ where data.da_block_headers_of_soft_confirmations, data.soft_confirmations, data.preproven_commitments.clone(), + forks, ); println!("out of apply_soft_confirmations_from_sequencer_commitments"); diff --git a/crates/prover-services/src/parallel/mod.rs b/crates/prover-services/src/parallel/mod.rs index 763e797ad..a097a364b 100644 --- a/crates/prover-services/src/parallel/mod.rs +++ b/crates/prover-services/src/parallel/mod.rs @@ -2,6 +2,7 @@ use std::ops::DerefMut; use std::sync::Arc; use async_trait::async_trait; +use citrea_primitives::forks::get_forks; use futures::future; use sov_db::ledger_db::LedgerDB; use sov_rollup_interface::da::DaData; @@ -262,7 +263,7 @@ where let guest = vm.simulate_with_hints(); let data = guest.read_from_host(); verifier - .run_sequencer_commitments_in_da_slot(data, zk_storage) + .run_sequencer_commitments_in_da_slot(data, zk_storage, get_forks().inner()) .map(|_| Vec::default()) .map_err(|e| { anyhow::anyhow!("Guest execution must succeed but failed with {:?}", e) diff --git a/crates/sovereign-sdk/full-node/sov-stf-runner/src/mock/mod.rs b/crates/sovereign-sdk/full-node/sov-stf-runner/src/mock/mod.rs index d1bbc262f..9ca38533f 100644 --- a/crates/sovereign-sdk/full-node/sov-stf-runner/src/mock/mod.rs +++ b/crates/sovereign-sdk/full-node/sov-stf-runner/src/mock/mod.rs @@ -1,4 +1,5 @@ use sov_modules_api::default_context::DefaultContext; +use sov_modules_api::fork::Fork; use sov_modules_api::transaction::Transaction; use sov_rollup_interface::da::DaSpec; use sov_rollup_interface::spec::SpecId; @@ -61,6 +62,7 @@ impl StateTransitionFunction for MockStf { Vec>, >, _preproven_commitment_indicies: Vec, + _forks: &[Fork], ) -> ApplySequencerCommitmentsOutput { todo!() } diff --git a/crates/sovereign-sdk/module-system/sov-modules-stf-blueprint/src/lib.rs b/crates/sovereign-sdk/module-system/sov-modules-stf-blueprint/src/lib.rs index c10c23bc1..e1732b06b 100644 --- a/crates/sovereign-sdk/module-system/sov-modules-stf-blueprint/src/lib.rs +++ b/crates/sovereign-sdk/module-system/sov-modules-stf-blueprint/src/lib.rs @@ -2,11 +2,11 @@ #![doc = include_str!("../README.md")] use borsh::BorshDeserialize; -use citrea_primitives::forks::get_forks; use itertools::Itertools; use rs_merkle::algorithms::Sha256; use rs_merkle::MerkleTree; use sov_modules_api::da::BlockHeaderTrait; +use sov_modules_api::fork::Fork; use sov_modules_api::hooks::{ ApplySoftConfirmationHooks, FinalizeHook, HookSoftConfirmationInfo, SlotHooks, TxHooks, }; @@ -438,6 +438,7 @@ where Vec>, >, preproven_commitment_indices: Vec, + forks: &[Fork], ) -> ApplySequencerCommitmentsOutput { let mut state_diff = CumulativeStateDiff::default(); @@ -508,8 +509,7 @@ where let mut previous_batch_hash = soft_confirmations[0][0].prev_hash(); let mut last_commitment_end_height: Option = None; - let mut fork_manager = - ForkManager::new(get_forks().inner(), sequencer_commitments_range.0 as u64); + let mut fork_manager = ForkManager::new(forks, sequencer_commitments_range.0 as u64); // should panic if number of sequencer commitments, soft confirmations, slot headers and witnesses don't match for (((sequencer_commitment, soft_confirmations), da_block_headers), witnesses) in diff --git a/crates/sovereign-sdk/rollup-interface/src/state_machine/stf.rs b/crates/sovereign-sdk/rollup-interface/src/state_machine/stf.rs index da4d54ac3..8c8f69507 100644 --- a/crates/sovereign-sdk/rollup-interface/src/state_machine/stf.rs +++ b/crates/sovereign-sdk/rollup-interface/src/state_machine/stf.rs @@ -16,6 +16,7 @@ use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize}; use crate::da::DaSpec; +use crate::fork::Fork; use crate::soft_confirmation::SignedSoftConfirmation; use crate::spec::SpecId; use crate::zk::CumulativeStateDiff; @@ -229,6 +230,7 @@ pub trait StateTransitionFunction { slot_headers: VecDeque>, soft_confirmations: VecDeque>>, preproven_commitment_indicies: Vec, + forks: &[Fork], ) -> ApplySequencerCommitmentsOutput; } diff --git a/guests/risc0/batch-proof-bitcoin/src/bin/batch_proof_bitcoin.rs b/guests/risc0/batch-proof-bitcoin/src/bin/batch_proof_bitcoin.rs index 25225d6db..5906bd7ce 100644 --- a/guests/risc0/batch-proof-bitcoin/src/bin/batch_proof_bitcoin.rs +++ b/guests/risc0/batch-proof-bitcoin/src/bin/batch_proof_bitcoin.rs @@ -70,7 +70,7 @@ pub fn main() { let data = guest.read_from_host(); let out = stf_verifier - .run_sequencer_commitments_in_da_slot(data, storage) + .run_sequencer_commitments_in_da_slot(data, storage, FORKS) .expect("Prover must be honest"); guest.commit(&out); diff --git a/guests/risc0/batch-proof-mock/src/bin/batch_proof_mock.rs b/guests/risc0/batch-proof-mock/src/bin/batch_proof_mock.rs index c6e4f6f1a..77e8b372c 100644 --- a/guests/risc0/batch-proof-mock/src/bin/batch_proof_mock.rs +++ b/guests/risc0/batch-proof-mock/src/bin/batch_proof_mock.rs @@ -64,7 +64,7 @@ pub fn main() { let data = guest.read_from_host(); let out = stf_verifier - .run_sequencer_commitments_in_da_slot(data, storage) + .run_sequencer_commitments_in_da_slot(data, storage, FORKS) .expect("Prover must be honest"); guest.commit(&out);