Skip to content
Open
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
4 changes: 2 additions & 2 deletions bin/citrea/src/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use citrea_common::RpcConfig;
use ethereum_rpc::{EthRpcConfig, FeeHistoryCacheConfig, GasPriceOracleConfig};
use reth_tasks::TaskExecutor;
use sov_db::ledger_db::LedgerDB;
use sov_modules_api::default_context::DefaultContext;
use sov_modules_api::default_context::NativeContext;
use sov_rollup_interface::services::da::DaService;
use sov_state::ProverStorage;
use tokio::sync::broadcast;
Expand All @@ -31,7 +31,7 @@ pub fn register_ethereum<Da: DaService>(
}
};

let ethereum_rpc = ethereum_rpc::create_rpc_module::<DefaultContext, Da>(
let ethereum_rpc = ethereum_rpc::create_rpc_module::<NativeContext, Da>(
da_service,
eth_rpc_config,
rpc_config,
Expand Down
6 changes: 3 additions & 3 deletions bin/citrea/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use citrea_common::utils::is_dev_mode_enabled_via_environment;
use citrea_common::{from_toml_path, FromEnv, FullNodeConfig, NodeType, StartVariant};
use citrea_light_client_prover::circuit::initial_values::InitialValueProvider;
use citrea_stf::genesis_config::GenesisPaths;
use citrea_stf::runtime::{CitreaRuntime, DefaultContext};
use citrea_stf::runtime::{CitreaRuntime, NativeContext};
use clap::Parser;
use metrics_exporter_prometheus::PrometheusBuilder;
use reth_tasks::TaskManager;
Expand Down Expand Up @@ -111,15 +111,15 @@ async fn main() -> anyhow::Result<()> {
#[instrument(level = "trace", skip_all, err)]
async fn start_rollup<S, DaC>(
network: Network,
runtime_genesis_paths: &<CitreaRuntime<DefaultContext, <S as RollupBlueprint>::DaSpec> as sov_modules_stf_blueprint::Runtime<DefaultContext, <S as RollupBlueprint>::DaSpec>>::GenesisPaths,
runtime_genesis_paths: &<CitreaRuntime<NativeContext, <S as RollupBlueprint>::DaSpec> as sov_modules_stf_blueprint::Runtime<NativeContext, <S as RollupBlueprint>::DaSpec>>::GenesisPaths,
rollup_config_path: Option<String>,
node_type: NodeWithConfig,
stop_conditions: StopConditions,
) -> Result<(), anyhow::Error>
where
DaC: serde::de::DeserializeOwned + DebugTrait + Clone + FromEnv + Send + Sync + 'static,
S: CitreaRollupBlueprint<DaConfig = DaC>,
<DefaultContext as Spec>::Storage: NativeStorage,
<NativeContext as Spec>::Storage: NativeStorage,
Network: InitialValueProvider<<S as RollupBlueprint>::DaSpec>,
{
let rollup_config: FullNodeConfig<DaC> = match rollup_config_path {
Expand Down
4 changes: 2 additions & 2 deletions bin/citrea/src/rollup/bitcoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use jsonrpsee::RpcModule;
use prover_services::{ParallelProverService, ProofGenMode};
use reth_tasks::TaskExecutor;
use sov_db::ledger_db::LedgerDB;
use sov_modules_api::default_context::DefaultContext;
use sov_modules_api::default_context::NativeContext;
use sov_modules_api::{SpecId, Zkvm};
use sov_modules_rollup_blueprint::RollupBlueprint;
use sov_modules_stf_blueprint::Runtime;
Expand Down Expand Up @@ -77,7 +77,7 @@ impl RollupBlueprint for BitcoinRollup {
let mut rpc_methods = RpcModule::new(());

if !matches!(node_type, NodeType::LightClientProver) {
let methods = <CitreaRuntime<DefaultContext, Self::DaSpec>>::rpc_methods(
let methods = <CitreaRuntime<NativeContext, Self::DaSpec>>::rpc_methods(
storage,
ledger_db.clone(),
);
Expand Down
6 changes: 3 additions & 3 deletions bin/citrea/src/rollup/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use prover_services::{ParallelProverService, ProofGenMode};
use reth_tasks::TaskExecutor;
use sov_db::ledger_db::LedgerDB;
use sov_mock_da::{MockDaConfig, MockDaService, MockDaSpec, MockDaVerifier};
use sov_modules_api::default_context::DefaultContext;
use sov_modules_api::default_context::NativeContext;
use sov_modules_api::{Spec, SpecId, Zkvm};
use sov_modules_rollup_blueprint::RollupBlueprint;
use sov_modules_stf_blueprint::Runtime;
Expand Down Expand Up @@ -47,15 +47,15 @@ impl RollupBlueprint for MockDemoRollup {
fn create_rpc_methods(
&self,
_node_type: NodeType,
storage: <DefaultContext as Spec>::Storage,
storage: <NativeContext as Spec>::Storage,
ledger_db: &LedgerDB,
_da_service: &Arc<Self::DaService>,
backup_manager: &Arc<BackupManager>,
rpc_config: RpcConfig,
) -> Result<jsonrpsee::RpcModule<()>, anyhow::Error> {
// runtime rpc.
let mut rpc_methods =
<CitreaRuntime<DefaultContext, Self::DaSpec>>::rpc_methods(storage, ledger_db.clone());
<CitreaRuntime<NativeContext, Self::DaSpec>>::rpc_methods(storage, ledger_db.clone());

// ledger rpc.
let ledger_db_methods = sov_ledger_rpc::server::create_rpc_module::<LedgerDB>(
Expand Down
12 changes: 4 additions & 8 deletions bin/citrea/src/rollup/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use citrea_light_client_prover::circuit::initial_values::InitialValueProvider;
use citrea_light_client_prover::da_block_handler::L1BlockHandler as LightClientProverL1BlockHandler;
use citrea_primitives::forks::get_forks;
use citrea_sequencer::CitreaSequencer;
use citrea_stf::runtime::{CitreaRuntime, DefaultContext};
use citrea_stf::runtime::{CitreaRuntime, NativeContext};
use citrea_storage_ops::pruning::PrunerService;
use citrea_storage_ops::rollback::Rollback;
use jsonrpsee::RpcModule;
Expand Down Expand Up @@ -45,8 +45,8 @@ pub use citrea_fullnode::StopConditions;
pub use mock::*;

type GenesisParams<T> = StfGenesisParams<
<CitreaRuntime<DefaultContext, <T as RollupBlueprint>::DaSpec> as RuntimeTrait<
DefaultContext,
<CitreaRuntime<NativeContext, <T as RollupBlueprint>::DaSpec> as RuntimeTrait<
NativeContext,
<T as RollupBlueprint>::DaSpec,
>>::GenesisConfig,
>;
Expand Down Expand Up @@ -438,11 +438,7 @@ pub trait CitreaRollupBlueprint: RollupBlueprint {
fn init_chain(
&self,
genesis_config: GenesisParams<Self>,
stf: &StfBlueprint<
DefaultContext,
Self::DaSpec,
CitreaRuntime<DefaultContext, Self::DaSpec>,
>,
stf: &StfBlueprint<NativeContext, Self::DaSpec, CitreaRuntime<NativeContext, Self::DaSpec>>,
ledger_db: &LedgerDB,
storage_manager: &ProverStorageManager,
) -> anyhow::Result<InitParams> {
Expand Down
2 changes: 1 addition & 1 deletion bin/citrea/tests/bitcoin/batch_prover_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ async fn parallel_proving_test() -> Result<()> {
// )
// .unwrap();

// let address = k256_pub_key_sequencer.to_address::<<DefaultContext as Spec>::Address>();
// let address = k256_pub_key_sequencer.to_address::<<NativeContext as Spec>::Address>();

// // Going to ignore the first byte here because it's the call prefix
// // It is an enum of modules:
Expand Down
6 changes: 3 additions & 3 deletions crates/batch-prover/src/l2_syncer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use reth_tasks::shutdown::GracefulShutdown;
use sov_db::ledger_db::BatchProverLedgerOps;
use sov_db::schema::types::L2BlockNumber;
use sov_keys::default_signature::K256PublicKey;
use sov_modules_api::default_context::DefaultContext;
use sov_modules_api::default_context::NativeContext;
use sov_modules_stf_blueprint::StfBlueprint;
use sov_prover_storage_manager::ProverStorageManager;
use sov_rollup_interface::fork::ForkManager;
Expand Down Expand Up @@ -51,7 +51,7 @@ where
/// Data availability service instance
da_service: Arc<DA>,
/// State transition function blueprint
stf: StfBlueprint<DefaultContext, DA::Spec, CitreaRuntime<DefaultContext, DA::Spec>>,
stf: StfBlueprint<NativeContext, DA::Spec, CitreaRuntime<NativeContext, DA::Spec>>,
/// Manager for prover storage
storage_manager: ProverStorageManager,
/// Database for ledger operations
Expand Down Expand Up @@ -101,7 +101,7 @@ where
pub fn new(
runner_config: RunnerConfig,
init_params: InitParams,
stf: StfBlueprint<DefaultContext, DA::Spec, CitreaRuntime<DefaultContext, DA::Spec>>,
stf: StfBlueprint<NativeContext, DA::Spec, CitreaRuntime<NativeContext, DA::Spec>>,
public_keys: RollupPublicKeys,
da_service: Arc<DA>,
ledger_db: DB,
Expand Down
6 changes: 3 additions & 3 deletions crates/batch-prover/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub use partition::PartitionMode;
use prover::Prover;
use prover_services::ParallelProverService;
use sov_db::ledger_db::BatchProverLedgerOps;
use sov_modules_api::default_context::DefaultContext;
use sov_modules_api::default_context::NativeContext;
use sov_modules_api::fork::ForkManager;
use sov_modules_api::{SpecId, Zkvm};
use sov_modules_stf_blueprint::StfBlueprint;
Expand Down Expand Up @@ -104,9 +104,9 @@ pub async fn build_services<DA, DB, Vm>(
rpc_config: RpcConfig,
init_params: InitParams,
native_stf: StfBlueprint<
DefaultContext,
NativeContext,
<DA as DaService>::Spec,
CitreaRuntime<DefaultContext, <DA as DaService>::Spec>,
CitreaRuntime<NativeContext, <DA as DaService>::Spec>,
>,
public_keys: RollupPublicKeys,
da_service: Arc<DA>,
Expand Down
6 changes: 3 additions & 3 deletions crates/batch-prover/src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use citrea_common::{BatchProverConfig, ProverGuestRunConfig};
use citrea_primitives::compression::compress_blob;
use citrea_primitives::forks::fork_from_block_number;
use citrea_primitives::{network_to_dev_mode, MAX_TX_BODY_SIZE, MAX_WITNESS_CACHE_SIZE};
use citrea_stf::runtime::{CitreaRuntime, DefaultContext};
use citrea_stf::runtime::{CitreaRuntime, NativeContext};
use futures::stream::FuturesUnordered;
use futures::StreamExt;
use prover_services::{ParallelProverService, ProofData, ProofWithDuration};
Expand Down Expand Up @@ -1053,7 +1053,7 @@ fn generate_cumulative_witness<Da: DaService, DB: BatchProverLedgerOps>(
let mut cache_prune_l2_heights = vec![];

let mut stf =
StfBlueprint::<DefaultContext, Da::Spec, CitreaRuntime<DefaultContext, Da::Spec>>::new();
StfBlueprint::<NativeContext, Da::Spec, CitreaRuntime<NativeContext, Da::Spec>>::new();

let last_l2_height = committed_l2_blocks
.back()
Expand Down Expand Up @@ -1159,7 +1159,7 @@ fn generate_cumulative_witness<Da: DaService, DB: BatchProverLedgerOps>(

// we don't care about the return here
// we only care about the last hash witness getting filled (or not)
let _ = citrea_stf::verifier::get_last_l1_hash_on_contract::<DefaultContext>(
let _ = citrea_stf::verifier::get_last_l1_hash_on_contract::<NativeContext>(
cumulative_state_log,
prover_storage,
&mut last_l1_hash_witness,
Expand Down
4 changes: 2 additions & 2 deletions crates/batch-prover/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use base64::Engine;
use citrea_common::rpc::utils::internal_rpc_error;
use citrea_common::RpcConfig;
use citrea_primitives::forks::fork_from_block_number;
use citrea_stf::runtime::DefaultContext;
use citrea_stf::runtime::NativeContext;
use citrea_stf::verifier::get_last_l1_hash_on_contract;
use jsonrpsee::core::RpcResult;
use jsonrpsee::proc_macros::rpc;
Expand Down Expand Up @@ -481,7 +481,7 @@ where
.context
.storage_manager
.create_storage_for_l2_height(last_l2_block.height + 1);
let last_l1_hash_on_contract = get_last_l1_hash_on_contract::<DefaultContext>(
let last_l1_hash_on_contract = get_last_l1_hash_on_contract::<NativeContext>(
Default::default(),
storage,
&mut Default::default(),
Expand Down
2 changes: 1 addition & 1 deletion crates/citrea-stf/src/genesis_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use anyhow::Context as _;
use citrea_evm::EvmConfig;
use l2_block_rule_enforcer::L2BlockRuleEnforcerConfig;
use sov_accounts::AccountConfig;
pub use sov_modules_api::default_context::DefaultContext;
pub use sov_modules_api::default_context::NativeContext;
use sov_modules_api::Context;
use sov_modules_stf_blueprint::Runtime as RuntimeTrait;
use sov_rollup_interface::da::DaSpec;
Expand Down
2 changes: 1 addition & 1 deletion crates/citrea-stf/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use l2_block_rule_enforcer::{L2BlockRuleEnforcerRpcImpl, L2BlockRuleEnforcerRpcS
#[cfg(feature = "native")]
use sov_accounts::{AccountsRpcImpl, AccountsRpcServer};
#[cfg(feature = "native")]
pub use sov_modules_api::default_context::DefaultContext;
pub use sov_modules_api::default_context::NativeContext;
#[cfg(feature = "native")]
use sov_modules_api::macros::expose_rpc;
use sov_modules_api::macros::DefaultRuntime;
Expand Down
26 changes: 11 additions & 15 deletions crates/citrea-stf/src/test_utils.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![allow(missing_docs)]
use citrea_evm::{keccak256, Evm, BITCOIN_LIGHT_CLIENT_CONTRACT_ADDRESS, U256};
use sov_modules_api::default_context::{DefaultContext, ZkDefaultContext};
use sov_modules_api::default_context::{NativeContext, ZkContext};
use sov_modules_api::{StateReaderAndWriter, WorkingSet};
use sov_prover_storage_manager::ProverStorageManager;
use sov_rollup_interface::zk::StorageRootHash;
Expand All @@ -19,34 +19,30 @@ pub fn init_storage_manager() -> ProverStorageManager {

pub fn set_next_l1_height(working_set: &mut WorkingSet<ProverStorage>) {
// Set Next L1 height for light client contract
let prefix = Evm::<ZkDefaultContext>::default().storage.prefix().clone();
let inner_evm_key = Evm::<ZkDefaultContext>::get_storage_address(
&BITCOIN_LIGHT_CLIENT_CONTRACT_ADDRESS,
&U256::ZERO,
);
let prefix = Evm::<ZkContext>::default().storage.prefix().clone();
let inner_evm_key =
Evm::<ZkContext>::get_storage_address(&BITCOIN_LIGHT_CLIENT_CONTRACT_ADDRESS, &U256::ZERO);
let key = StorageKey::new(&prefix, &inner_evm_key, &BorshCodec);
let value = StorageValue::new(&U256::from(1), &BorshCodec);
working_set.set(&key, value);
}

pub fn cache_next_l1_height(working_set: &mut WorkingSet<ProverStorage>) {
// Set Next L1 height for light client contract
let prefix = Evm::<ZkDefaultContext>::default().storage.prefix().clone();
let inner_evm_key = Evm::<ZkDefaultContext>::get_storage_address(
&BITCOIN_LIGHT_CLIENT_CONTRACT_ADDRESS,
&U256::ZERO,
);
let prefix = Evm::<ZkContext>::default().storage.prefix().clone();
let inner_evm_key =
Evm::<ZkContext>::get_storage_address(&BITCOIN_LIGHT_CLIENT_CONTRACT_ADDRESS, &U256::ZERO);
let key = StorageKey::new(&prefix, &inner_evm_key, &BorshCodec);
working_set.get(&key);
}

pub fn set_last_l1_hash(working_set: &mut WorkingSet<ProverStorage>) {
let prefix = Evm::<DefaultContext>::default().storage.prefix().clone();
let prefix = Evm::<NativeContext>::default().storage.prefix().clone();
let mut bytes = [0u8; 64];
bytes[0..32].copy_from_slice(&U256::from(0).to_be_bytes::<32>());
bytes[32..64].copy_from_slice(&U256::from(1).to_be_bytes::<32>());
let evm_storage_slot = keccak256(bytes).into();
let inner_evm_key = Evm::<DefaultContext>::get_storage_address(
let inner_evm_key = Evm::<NativeContext>::get_storage_address(
&BITCOIN_LIGHT_CLIENT_CONTRACT_ADDRESS,
&evm_storage_slot,
);
Expand All @@ -55,12 +51,12 @@ pub fn set_last_l1_hash(working_set: &mut WorkingSet<ProverStorage>) {
}

pub fn cache_last_l1_hash(working_set: &mut WorkingSet<ProverStorage>) {
let prefix = Evm::<DefaultContext>::default().storage.prefix().clone();
let prefix = Evm::<NativeContext>::default().storage.prefix().clone();
let mut bytes = [0u8; 64];
bytes[0..32].copy_from_slice(&U256::from(0).to_be_bytes::<32>());
bytes[32..64].copy_from_slice(&U256::from(1).to_be_bytes::<32>());
let evm_storage_slot = keccak256(bytes).into();
let inner_evm_key = Evm::<DefaultContext>::get_storage_address(
let inner_evm_key = Evm::<NativeContext>::get_storage_address(
&BITCOIN_LIGHT_CLIENT_CONTRACT_ADDRESS,
&evm_storage_slot,
);
Expand Down
Loading