Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Commit

Permalink
Remove stf.rs and use sov-app-template instead. (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkolad authored Apr 1, 2023
1 parent 90462e4 commit 05f5c71
Show file tree
Hide file tree
Showing 10 changed files with 133 additions and 398 deletions.
51 changes: 29 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 9 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ tokio = { version = "1", features = ["full"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
sha2 = "0.10.6"
jupiter = { git = "https://github.com/Sovereign-Labs/Jupiter.git", rev = "43b3b4ce86ad0fa2a925e590275c68f7e4483438" }
accounts = { git = "https://github.com/Sovereign-Labs/sovereign.git", rev = "3f21032e7414400587f734abdefa3fd9c6081b25" }
election = { git = "https://github.com/Sovereign-Labs/sovereign.git", rev = "3f21032e7414400587f734abdefa3fd9c6081b25" }
sovereign-sdk = { git = "https://github.com/Sovereign-Labs/sovereign.git", rev = "3f21032e7414400587f734abdefa3fd9c6081b25" }
sov-state = { git = "https://github.com/Sovereign-Labs/sovereign.git", features = ["temp"], rev = "3f21032e7414400587f734abdefa3fd9c6081b25" }
sov-modules-api = { git = "https://github.com/Sovereign-Labs/sovereign.git", features = ["mocks"], rev = "3f21032e7414400587f734abdefa3fd9c6081b25" }
sov-modules-macros = { git = "https://github.com/Sovereign-Labs/sovereign.git", rev = "3f21032e7414400587f734abdefa3fd9c6081b25" }
sovereign-db = { git = "https://github.com/Sovereign-Labs/sovereign.git", features = ["temp"], rev = "3f21032e7414400587f734abdefa3fd9c6081b25" }
jupiter = { path ="../Jupiter"}
sov-app-template = { git = "https://github.com/Sovereign-Labs/sovereign.git", rev = "bfdb58159ff9215a84aa60b9a4d3ce1f32136597" }
accounts = { git = "https://github.com/Sovereign-Labs/sovereign.git", rev = "bfdb58159ff9215a84aa60b9a4d3ce1f32136597" }
election = { git = "https://github.com/Sovereign-Labs/sovereign.git", rev = "bfdb58159ff9215a84aa60b9a4d3ce1f32136597" }
sovereign-sdk = { git = "https://github.com/Sovereign-Labs/sovereign.git", rev = "bfdb58159ff9215a84aa60b9a4d3ce1f32136597" }
sov-state = { git = "https://github.com/Sovereign-Labs/sovereign.git", features = ["temp"], rev = "bfdb58159ff9215a84aa60b9a4d3ce1f32136597" }
sov-modules-api = { git = "https://github.com/Sovereign-Labs/sovereign.git", features = ["mocks"], rev = "bfdb58159ff9215a84aa60b9a4d3ce1f32136597" }
sov-modules-macros = { git = "https://github.com/Sovereign-Labs/sovereign.git", rev = "bfdb58159ff9215a84aa60b9a4d3ce1f32136597" }
sovereign-db = { git = "https://github.com/Sovereign-Labs/sovereign.git", features = ["temp"], rev = "bfdb58159ff9215a84aa60b9a4d3ce1f32136597" }
tracing = "0.1.37"
tracing-subscriber = "0.3.16"

Expand Down
41 changes: 0 additions & 41 deletions src/batch.rs

This file was deleted.

59 changes: 0 additions & 59 deletions src/context.rs

This file was deleted.

9 changes: 4 additions & 5 deletions src/helpers.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
use sov_modules_api::DispatchQuery;
use sov_modules_api::{mocks::MockContext, DispatchQuery};
use sov_state::{mocks::MockStorageSpec, ProverStorage, WorkingSet};

use crate::{context::DemoContext, runtime::Runtime};

use crate::runtime::Runtime;
pub(crate) fn run_query(
runtime: &mut Runtime<DemoContext>,
runtime: &mut Runtime<MockContext>,
query: Vec<u8>,
storage: ProverStorage<MockStorageSpec>,
) -> String {
let module = Runtime::<DemoContext>::decode_query(&query).unwrap();
let module = Runtime::<MockContext>::decode_query(&query).unwrap();
let query_response = runtime.dispatch_query(module, &mut WorkingSet::new(storage));

String::from_utf8(query_response.response).unwrap()
Expand Down
25 changes: 13 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use batch::Batch;
use context::DemoContext;
use jsonrpsee::http_client::HeaderMap;
use jupiter::{
da_app::{CelestiaApp, TmHash},
da_service::{CelestiaService, FilteredCelestiaBlock},
};
use sha2::{Digest, Sha256};
use sov_app_template::{AppTemplate, Batch};
use sov_modules_api::mocks::MockContext;
use sov_state::ProverStorage;
use sovereign_db::{
ledger_db::{LedgerDB, SlotCommitBuilder},
Expand All @@ -21,24 +21,23 @@ use sovereign_sdk::{
};
use sovereign_sdk::{da::DaLayerTrait, stf::StateTransitionFunction};
use sovereign_sdk::{db::SlotStore, serial::Decode};
use stf::Demo;

use tracing::Level;
use tx_verifier::DemoAppTxVerifier;
use tx_verifier_impl::DemoAppTxVerifier;

use crate::{
data_generation::QueryGenerator, helpers::run_query, runtime::Runtime, tx_hooks::DemoAppTxHooks,
data_generation::QueryGenerator, helpers::run_query, runtime::Runtime,
tx_hooks_impl::DemoAppTxHooks,
};
mod batch;
mod context;

mod data_generation;
mod helpers;
mod runtime;
mod stf;
mod tx_hooks;
mod tx_verifier;
mod tx_hooks_impl;
mod tx_verifier_impl;

type C = DemoContext;
type DemoApp = Demo<C, DemoAppTxVerifier<C>, Runtime<C>, DemoAppTxHooks<C>>;
type C = MockContext;
type DemoApp = AppTemplate<C, DemoAppTxVerifier<C>, Runtime<C>, DemoAppTxHooks<C>>;
const CELESTIA_NODE_AUTH_TOKEN: &'static str = "";

const START_HEIGHT: u64 = HEIGHT_OF_FIRST_TXS - 5;
Expand Down Expand Up @@ -168,6 +167,7 @@ async fn main() -> Result<(), anyhow::Error> {
}
}
}

demo.end_slot();
data_to_persist.slot_data = Some(StoredSlot {
hash: DbHash::new(slot_hash.to_vec()),
Expand All @@ -177,6 +177,7 @@ async fn main() -> Result<(), anyhow::Error> {
});
item_numbers.batch_number += num_batches as u64;
ledger_db.commit_slot(data_to_persist.finalize()?)?;

println!(
"Current state: {}",
run_query(
Expand Down
Loading

0 comments on commit 05f5c71

Please sign in to comment.