Skip to content

Commit

Permalink
Move create_zk_app_template back
Browse files Browse the repository at this point in the history
  • Loading branch information
bkolad committed Oct 8, 2023
1 parent 9c3279c commit 62e450d
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 23 deletions.
4 changes: 2 additions & 2 deletions examples/demo-prover/methods/guest-celestia/src/bin/rollup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#![no_main]

use const_rollup_config::ROLLUP_NAMESPACE_RAW;
use demo_stf::{AppVerifier, ZkApp};
use demo_stf::{create_zk_app_template, AppVerifier};
use sov_celestia_adapter::types::NamespaceId;
use sov_celestia_adapter::verifier::CelestiaVerifier;
use sov_risc0_adapter::guest::Risc0Guest;
Expand All @@ -16,7 +16,7 @@ risc0_zkvm::guest::entry!(main);
pub fn main() {
let guest = Risc0Guest::new();
let mut stf_verifier = AppVerifier::new(
ZkApp::<Risc0Guest, _>::default().stf,
create_zk_app_template::<Risc0Guest, _>(),
CelestiaVerifier {
rollup_namespace: ROLLUP_NAMESPACE,
},
Expand Down
4 changes: 2 additions & 2 deletions examples/demo-prover/methods/guest-mock/src/bin/mock_da.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![no_main]

use demo_stf::{AppVerifier, ZkApp};
use demo_stf::{create_zk_app_template, AppVerifier};
use sov_risc0_adapter::guest::Risc0Guest;

use sov_rollup_interface::mocks::MockDaVerifier;
Expand All @@ -11,7 +11,7 @@ pub fn main() {
let guest = Risc0Guest::new();

let mut stf_verifier =
AppVerifier::new(ZkApp::<Risc0Guest, _>::default().stf, MockDaVerifier {});
AppVerifier::new(create_zk_app_template::<Risc0Guest, _>(), MockDaVerifier {});

stf_verifier
.run_block(guest)
Expand Down
5 changes: 3 additions & 2 deletions examples/demo-rollup/src/rollup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use anyhow::Context;
use const_rollup_config::SEQUENCER_DA_ADDRESS;
use demo_stf::genesis_config::{get_genesis_config, GenesisPaths, StorageConfig};
use demo_stf::runtime::{get_rpc_methods, GenesisConfig, Runtime};
use demo_stf::{App, AppVerifier, DefaultContext, ZkApp};
use demo_stf::{create_zk_app_template, App, AppVerifier};
#[cfg(feature = "experimental")]
use secp256k1::SecretKey;
use sov_celestia_adapter::verifier::address::CelestiaAddress;
Expand All @@ -17,6 +17,7 @@ use sov_cli::wallet_state::PrivateKeyAndAddress;
use sov_db::ledger_db::LedgerDB;
#[cfg(feature = "experimental")]
use sov_ethereum::experimental::EthRpcConfig;
use sov_modules_api::default_context::DefaultContext;
use sov_modules_api::default_context::ZkDefaultContext;
#[cfg(feature = "experimental")]
use sov_modules_api::default_signature::private_key::DefaultPrivateKey;
Expand Down Expand Up @@ -69,7 +70,7 @@ pub fn configure_prover<Vm: ZkvmHost, Da: DaService>(
) -> Prover<ZkStf<Da::Spec, Vm::Guest>, Da, Vm> {
let config = match cfg {
DemoProverConfig::Simulate => ProofGenConfig::Simulate(AppVerifier::new(
ZkApp::<Vm::Guest, _>::default().stf,
create_zk_app_template::<Vm::Guest, _>(),
da_verifier,
)),
DemoProverConfig::Execute => ProofGenConfig::Execute,
Expand Down
2 changes: 1 addition & 1 deletion examples/demo-rollup/tests/bank/mod.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use std::net::SocketAddr;

use borsh::BorshSerialize;
use demo_stf::app::DefaultPrivateKey;
use demo_stf::genesis_config::GenesisPaths;
use demo_stf::runtime::RuntimeCall;
use jsonrpsee::core::client::{Subscription, SubscriptionClientT};
use jsonrpsee::rpc_params;
use methods::MOCK_DA_ELF;
use sov_demo_rollup::DemoProverConfig;
use sov_modules_api::default_context::DefaultContext;
use sov_modules_api::default_signature::private_key::DefaultPrivateKey;
use sov_modules_api::transaction::Transaction;
use sov_modules_api::{PrivateKey, Spec};
use sov_risc0_adapter::host::Risc0Host;
Expand Down
22 changes: 6 additions & 16 deletions examples/demo-stf/src/app.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#[cfg(feature = "native")]
pub use sov_modules_api::default_context::DefaultContext;
pub use sov_modules_api::default_context::ZkDefaultContext;
#[cfg(feature = "native")]
pub use sov_modules_api::default_signature::private_key::DefaultPrivateKey;
use sov_modules_api::default_context::DefaultContext;
use sov_modules_api::default_context::ZkDefaultContext;
#[cfg(feature = "native")]
use sov_modules_api::Spec;
use sov_modules_stf_template::AppTemplate;
Expand Down Expand Up @@ -53,16 +51,8 @@ impl<Vm: Zkvm, Da: DaSpec> App<Vm, Da> {
}
}

/// Contains StateTransitionFunction for the `zk` context.
pub struct ZkApp<Vm: Zkvm, Da: DaSpec> {
pub stf: AppTemplate<ZkDefaultContext, Da, Vm, Runtime<ZkDefaultContext, Da>>,
}

impl<Vm: Zkvm, Da: DaSpec> Default for ZkApp<Vm, Da> {
fn default() -> Self {
let storage = ZkStorage::new();
Self {
stf: AppTemplate::new(storage, Runtime::default()),
}
}
pub fn create_zk_app_template<Vm: Zkvm, Da: DaSpec>(
) -> AppTemplate<ZkDefaultContext, Da, Vm, Runtime<ZkDefaultContext, Da>> {
let storage = ZkStorage::new();
AppTemplate::new(storage, Runtime::default())
}
1 change: 1 addition & 0 deletions examples/demo-stf/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub mod tests;
pub mod cli;

use runtime::Runtime;
use sov_modules_api::default_context::ZkDefaultContext;
use sov_modules_stf_template::AppTemplate;
use sov_rollup_interface::da::DaVerifier;
pub use sov_state::ArrayWitness;
Expand Down

0 comments on commit 62e450d

Please sign in to comment.