Skip to content

Commit

Permalink
Pass forks as arg
Browse files Browse the repository at this point in the history
  • Loading branch information
yaziciahmet committed Dec 17, 2024
1 parent d9d9d0a commit e6114d9
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 6 deletions.
3 changes: 3 additions & 0 deletions crates/citrea-stf/src/verifier.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -27,6 +28,7 @@ where
&mut self,
data: BatchProofCircuitInput<Stf::StateRoot, Stf::Witness, Da::Spec, Stf::Transaction>,
pre_state: Stf::PreState,
forks: &[Fork],
) -> Result<BatchProofCircuitOutput<Da::Spec, Stf::StateRoot>, Da::Error> {
println!("Running sequencer commitments in DA slot");

Expand Down Expand Up @@ -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");
Expand Down
3 changes: 2 additions & 1 deletion crates/prover-services/src/parallel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions crates/sovereign-sdk/full-node/sov-stf-runner/src/mock/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -61,6 +62,7 @@ impl<Da: DaSpec> StateTransitionFunction<Da> for MockStf {
Vec<sov_modules_api::SignedSoftConfirmation<Self::Transaction>>,
>,
_preproven_commitment_indicies: Vec<usize>,
_forks: &[Fork],
) -> ApplySequencerCommitmentsOutput<Self::StateRoot> {
todo!()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -438,6 +438,7 @@ where
Vec<SignedSoftConfirmation<Self::Transaction>>,
>,
preproven_commitment_indices: Vec<usize>,
forks: &[Fork],
) -> ApplySequencerCommitmentsOutput<Self::StateRoot> {
let mut state_diff = CumulativeStateDiff::default();

Expand Down Expand Up @@ -508,8 +509,7 @@ where
let mut previous_batch_hash = soft_confirmations[0][0].prev_hash();
let mut last_commitment_end_height: Option<u64> = 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -229,6 +230,7 @@ pub trait StateTransitionFunction<Da: DaSpec> {
slot_headers: VecDeque<Vec<Da::BlockHeader>>,
soft_confirmations: VecDeque<Vec<SignedSoftConfirmation<Self::Transaction>>>,
preproven_commitment_indicies: Vec<usize>,
forks: &[Fork],
) -> ApplySequencerCommitmentsOutput<Self::StateRoot>;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion guests/risc0/batch-proof-mock/src/bin/batch_proof_mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e6114d9

Please sign in to comment.