Skip to content

Commit c74e397

Browse files
authored
Merge pull request #11 from movementlabsxyz/0xmovses/ENG-110-standup-mockrollup
ENG-110 Stand up a MockRollup Sov-labs rollup
2 parents 15f44e9 + 32dbac7 commit c74e397

File tree

5,682 files changed

+1588
-585515
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

5,682 files changed

+1588
-585515
lines changed

Cargo.toml

+46-43
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,53 @@
1-
[workspace.package]
2-
authors = ["Movement Labs"]
3-
edition = "2021"
4-
repository = "https://github.com/movemntdev/sdk"
5-
license = "Apache-2.0"
6-
71
[workspace]
2+
83
resolver = "2"
4+
95
members = [
10-
"protocol-units/data-availability",
11-
"protocol-units/zkfp/host",
12-
"protocol-units/zkfp/methods",
13-
"protocol-units/zkfp/methods/guest"
6+
"m2/rollup",
7+
"m2/stf",
148
]
159

16-
exclude = [
17-
"shared-sequencer/movement-sequencer"
18-
]
10+
[workspace.package]
11+
version = "0.3.0"
12+
edition = "2021"
13+
license = "MIT OR Apache-2.0"
14+
authors = ["Movement Labs"]
15+
publish = false
16+
rust-version = "1.73"
1917

2018
[workspace.dependencies]
21-
anyhow = "1.0"
22-
# To try (experimental) std support, add `features = [ "std" ]` to risc0-zkvm
23-
risc0-zkvm = { version = "0.20.1", features = ["std"] }
24-
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
25-
serde = "1.0"
26-
tempfile = "3.2.0"
27-
28-
# Move dependencies
29-
move-vm-runtime = { path = "protocol-units/zkfp/vendors/move/language/move-vm/runtime" }
30-
move-vm-test-utils = { path = "protocol-units/zkfp/vendors/move/language/move-vm/test-utils" }
31-
move-binary-format = { path = "protocol-units/zkfp/vendors/move/language/move-binary-format" }
32-
move-vm-types = { path = "protocol-units/zkfp/vendors/move/language/move-vm/types"}
33-
move-core-types = { path = "protocol-units/zkfp/vendors/move/language/move-core/types" }
34-
move-compiler = { path = "protocol-units/zkfp/vendors/move/language/move-compiler" }
35-
move-stdlib = { path = "protocol-units/zkfp/vendors/move/language/move-stdlib" }
36-
37-
38-
# Always optimize; building and running the guest takes much longer without optimization.
39-
[profile.dev]
40-
opt-level = 3
41-
42-
[profile.dev.build-override]
43-
opt-level = 3
44-
45-
[profile.release]
46-
debug = 1
47-
lto = true
48-
49-
[profile.release.build-override]
50-
opt-level = 3
19+
sov-modules-api = { git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "517e99e558513e24983d8d09ef16a73675ea1a1b" }
20+
sov-state = { git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "517e99e558513e24983d8d09ef16a73675ea1a1b" }
21+
sov-accounts = { git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "517e99e558513e24983d8d09ef16a73675ea1a1b" }
22+
sov-bank = { git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "517e99e558513e24983d8d09ef16a73675ea1a1b" }
23+
sov-ledger-rpc = { git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "517e99e558513e24983d8d09ef16a73675ea1a1b" }
24+
sov-sequencer-registry = { git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "517e99e558513e24983d8d09ef16a73675ea1a1b" }
25+
sov-modules-stf-blueprint = { git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "517e99e558513e24983d8d09ef16a73675ea1a1b" }
26+
sov-modules-rollup-blueprint = { git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "517e99e558513e24983d8d09ef16a73675ea1a1b" }
27+
sov-stf-runner = { git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "517e99e558513e24983d8d09ef16a73675ea1a1b" }
28+
sov-db = { git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "517e99e558513e24983d8d09ef16a73675ea1a1b" }
29+
sov-sequencer = { git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "517e99e558513e24983d8d09ef16a73675ea1a1b" }
30+
sov-rollup-interface = { git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "517e99e558513e24983d8d09ef16a73675ea1a1b" }
31+
sov-risc0-adapter = { git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "517e99e558513e24983d8d09ef16a73675ea1a1b" }
32+
sov-mock-zkvm = { git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "517e99e558513e24983d8d09ef16a73675ea1a1b" }
33+
sov-first-read-last-write-cache = { git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "517e99e558513e24983d8d09ef16a73675ea1a1b" }
34+
sov-cli = { git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "517e99e558513e24983d8d09ef16a73675ea1a1b" }
35+
sov-mock-da = { git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "517e99e558513e24983d8d09ef16a73675ea1a1b" }
36+
sov-celestia-adapter = { git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "517e99e558513e24983d8d09ef16a73675ea1a1b" }
37+
sov-prover-storage-manager = { git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "517e99e558513e24983d8d09ef16a73675ea1a1b" }
38+
39+
stf-starter = { path = "./crates/stf" }
40+
41+
serde = { version = "1.0.192", features = ["derive", "rc"] }
42+
serde_json = { version = "1.0" }
43+
44+
anyhow = "1.0.68"
45+
clap = { version = "4.4.10", features = ["derive"] }
46+
async-trait = "0.1.71"
47+
borsh = { version = "0.10.3", features = ["rc", "bytes"] }
48+
tracing = "0.1.40"
49+
tokio = { version = "1", features = ["full"] }
50+
tempfile = "3.5"
51+
jsonrpsee = { version = "0.20.1", features = ["jsonrpsee-types"] }
52+
53+
risc0-build = "0.20"

m2/provers/risc0/Cargo.toml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[package]
2+
name = "m2-risc0"
3+
version = "0.3.0"
4+
edition = "2021"
5+
resolver = "2"
6+
license = "MIT OR Apache-2.0"
7+
publish = false
8+
9+
[build-dependencies]
10+
risc0-build = { workspace = true }
11+
12+
[package.metadata.risc0]
13+
methods = ["guest-celestia", "guest-mock"]
14+
15+
[features]
16+
bench = []

m2/provers/risc0/build.rs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
use std::collections::HashMap;
2+
3+
fn main() {
4+
if std::env::var("SKIP_GUEST_BUILD").is_ok() {
5+
println!("Skipping guest build for CI run");
6+
let out_dir = std::env::var_os("OUT_DIR").unwrap();
7+
let out_dir = std::path::Path::new(&out_dir);
8+
let methods_path = out_dir.join("methods.rs");
9+
10+
let elf = r#"
11+
pub const ROLLUP_ELF: &[u8] = &[];
12+
pub const MOCK_DA_ELF: &[u8] = &[];
13+
"#;
14+
15+
std::fs::write(methods_path, elf).expect("Failed to write mock rollup elf");
16+
} else {
17+
let guest_pkg_to_options = get_guest_options();
18+
risc0_build::embed_methods_with_options(guest_pkg_to_options);
19+
}
20+
}
21+
22+
fn get_guest_options() -> HashMap<&'static str, risc0_build::GuestOptions> {
23+
HashMap::new()
24+
}
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
[package]
2+
name = "sov-demo-prover-guest-celestia"
3+
version = "0.3.0"
4+
edition = "2021"
5+
resolver = "2"
6+
7+
[workspace]
8+
9+
[dependencies]
10+
anyhow = "1.0.68"
11+
ahash = "=0.8.6" # Force ahash to an old version to prevent build issues: https://github.com/risc0/risc0/issues/1406. This can be removed once risc0 updates to rust 1.72
12+
time-macros = "=0.2.15" # Same as above
13+
14+
risc0-zkvm = { version = "0.20", default-features = false, features = ["std"] }
15+
risc0-zkvm-platform = "0.20"
16+
17+
m2-stf = { path = "../../../stf" }
18+
19+
sov-rollup-interface = { git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "517e99e558513e24983d8d09ef16a73675ea1a1b" }
20+
sov-celestia-adapter = { git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "517e99e558513e24983d8d09ef16a73675ea1a1b" }
21+
sov-modules-api = { git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "517e99e558513e24983d8d09ef16a73675ea1a1b" }
22+
sov-modules-stf-blueprint = { git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "517e99e558513e24983d8d09ef16a73675ea1a1b" }
23+
sov-risc0-adapter = { git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "517e99e558513e24983d8d09ef16a73675ea1a1b" }
24+
sov-state = { git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "517e99e558513e24983d8d09ef16a73675ea1a1b" }
25+
26+
[patch.crates-io]
27+
sha2 = { git = "https://github.com/risc0/RustCrypto-hashes", tag = "sha2-v0.10.8-risczero.0" }
28+
ed25519-dalek = { git = "https://github.com/risc0/curve25519-dalek", tag = "curve25519-4.1.0-risczero.1" }
29+
crypto-bigint = { git = "https://github.com/risc0/RustCrypto-crypto-bigint", tag = "v0.5.2-risc0" }
30+
31+
[profile.dev]
32+
opt-level = 3
33+
34+
[profile.dev.build-override]
35+
opt-level = 3
36+
37+
[profile.release]
38+
debug = 1
39+
lto = true
40+
41+
[profile.release.build-override]
42+
opt-level = 3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// TODO: Rename this file to change the name of this method from METHOD_NAME
2+
3+
#![no_main]
4+
5+
use m2_stf::runtime::Runtime;
6+
use m2_stf::StfVerifier;
7+
use sov_celestia_adapter::types::Namespace;
8+
use sov_celestia_adapter::verifier::CelestiaVerifier;
9+
use sov_modules_api::default_spec::ZkDefaultSpec;
10+
use sov_modules_stf_blueprint::kernels::basic::BasicKernel;
11+
use sov_modules_stf_blueprint::StfBlueprint;
12+
use sov_risc0_adapter::guest::Risc0Guest;
13+
use sov_risc0_adapter::Risc0Verifier;
14+
use sov_state::ZkStorage;
15+
16+
/// The namespace for the rollup on Celestia. Must be kept in sync with the "rollup/src/lib.rs"
17+
const ROLLUP_NAMESPACE: Namespace = Namespace::const_v0(*b"sov-celest");
18+
19+
risc0_zkvm::guest::entry!(main);
20+
21+
pub fn main() {
22+
let guest = Risc0Guest::new();
23+
let storage = ZkStorage::new();
24+
let stf: StfBlueprint<
25+
ZkDefaultSpec<Risc0Verifier>,
26+
_,
27+
Risc0Verifier,
28+
Runtime<_, _>,
29+
BasicKernel<_, _>,
30+
> = StfBlueprint::new();
31+
32+
let stf_verifier = StfVerifier::new(
33+
stf,
34+
CelestiaVerifier {
35+
rollup_namespace: ROLLUP_NAMESPACE,
36+
},
37+
);
38+
stf_verifier
39+
.run_block(guest, storage)
40+
.expect("Prover must be honest");
41+
}
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
[workspace]
2+
3+
[package]
4+
name = "guest-mock-starter"
5+
version = "0.3.0"
6+
edition = "2021"
7+
resolver = "2"
8+
9+
[dependencies]
10+
anyhow = "1.0.68"
11+
ahash = "=0.8.6" # Force ahash to an old version to prevent build issues: https://github.com/risc0/risc0/issues/1406. This can be removed once risc0 updates to rust 1.72
12+
time-macros = "=0.2.15"
13+
risc0-zkvm = { version = "0.20", default-features = false, features = ["std"] }
14+
risc0-zkvm-platform = "0.20"
15+
16+
serde = { version = "1.0.188", features = ["derive", "rc"] }
17+
18+
19+
sov-rollup-interface = { git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "517e99e558513e24983d8d09ef16a73675ea1a1b" }
20+
sov-mock-da = { git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "517e99e558513e24983d8d09ef16a73675ea1a1b" }
21+
sov-modules-stf-blueprint = { git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "517e99e558513e24983d8d09ef16a73675ea1a1b" }
22+
sov-modules-api = { git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "517e99e558513e24983d8d09ef16a73675ea1a1b" }
23+
sov-risc0-adapter = { git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "517e99e558513e24983d8d09ef16a73675ea1a1b" }
24+
sov-state = { git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "517e99e558513e24983d8d09ef16a73675ea1a1b" }
25+
26+
m2-stf = { path = "../../../stf" }
27+
28+
[patch.crates-io]
29+
sha2 = { git = "https://github.com/risc0/RustCrypto-hashes", tag = "sha2-v0.10.8-risczero.0" }
30+
ed25519-dalek = { git = "https://github.com/risc0/curve25519-dalek", tag = "curve25519-4.1.0-risczero.1" }
31+
crypto-bigint = { git = "https://github.com/risc0/RustCrypto-crypto-bigint", tag = "v0.5.2-risc0" }
32+
33+
[profile.dev]
34+
opt-level = 3
35+
36+
[profile.dev.build-override]
37+
opt-level = 3
38+
39+
[profile.release]
40+
debug = 1
41+
lto = true
42+
43+
[profile.release.build-override]
44+
opt-level = 3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#![no_main]
2+
//! This binary implements the verification logic for the rollup. This is the code that runs inside
3+
//! of the zkvm in order to generate proofs for the rollup.
4+
5+
use m2_stf::runtime::Runtime;
6+
use m2_stf::StfVerifier;
7+
use sov_mock_da::MockDaVerifier;
8+
use sov_modules_api::default_spec::ZkDefaultSpec;
9+
use sov_modules_stf_blueprint::kernels::basic::BasicKernel;
10+
use sov_modules_stf_blueprint::StfBlueprint;
11+
use sov_risc0_adapter::guest::Risc0Guest;
12+
use sov_risc0_adapter::Risc0Verifier;
13+
use sov_state::ZkStorage;
14+
15+
#[cfg(feature = "bench")]
16+
fn report_bench_metrics(start_cycles: usize, end_cycles: usize) {
17+
let cycles_per_block = (end_cycles - start_cycles) as u64;
18+
let tuple = ("Cycles per block".to_string(), cycles_per_block);
19+
let mut serialized = Vec::new();
20+
serialized.extend(tuple.0.as_bytes());
21+
serialized.push(0);
22+
let size_bytes = tuple.1.to_ne_bytes();
23+
serialized.extend(&size_bytes);
24+
25+
// calculate the syscall name.
26+
let cycle_string = String::from("cycle_metrics\0");
27+
let metrics_syscall_name =
28+
risc0_zkvm_platform::syscall::SyscallName::from_bytes_with_nul(cycle_string.as_ptr());
29+
30+
risc0_zkvm::guest::env::send_recv_slice::<u8, u8>(metrics_syscall_name, &serialized);
31+
}
32+
33+
risc0_zkvm::guest::entry!(main);
34+
35+
pub fn main() {
36+
let guest = Risc0Guest::new();
37+
let storage = ZkStorage::new();
38+
#[cfg(feature = "bench")]
39+
let start_cycles = risc0_zkvm_platform::syscall::sys_cycle_count();
40+
41+
let stf: StfBlueprint<ZkDefaultSpec<Risc0Verifier>, _, _, Runtime<_, _>, BasicKernel<_, _>> =
42+
StfBlueprint::new();
43+
44+
let stf_verifier = StfVerifier::new(stf, MockDaVerifier {});
45+
46+
stf_verifier
47+
.run_block(guest, storage)
48+
.expect("Prover must be honest");
49+
50+
#[cfg(feature = "bench")]
51+
{
52+
let end_cycles = risc0_zkvm_platform::syscall::sys_cycle_count();
53+
report_bench_metrics(start_cycles, end_cycles);
54+
}
55+
}
File renamed without changes.

m2/rollup/Cargo.toml

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
[package]
2+
name = "m2-rollup"
3+
version = "0.1.0"
4+
edition = { workspace = true }
5+
resolver = "2"
6+
authors = { workspace = true }
7+
license = { workspace = true }
8+
homepage = "sovereign.xyz"
9+
publish = false
10+
11+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
12+
13+
[dependencies]
14+
sov-modules-api = { workspace = true, features = ["native"] }
15+
sov-state = { workspace = true }
16+
sov-prover-storage-manager = { workspace = true }
17+
sov-accounts = { workspace = true, features = ["native"] }
18+
sov-bank = { workspace = true, features = ["native"] }
19+
sov-ledger-rpc = { workspace = true, features = ["server"] }
20+
sov-sequencer-registry = { workspace = true, features = ["native"] }
21+
sov-modules-rollup-blueprint = { workspace = true }
22+
sov-modules-stf-blueprint = { workspace = true, features = ["native"] }
23+
sov-stf-runner = { workspace = true, features = ["native"] }
24+
sov-cli = { workspace = true, optional = true }
25+
26+
sov-db = { workspace = true }
27+
sov-sequencer = { workspace = true }
28+
sov-rollup-interface = { workspace = true }
29+
sov-mock-da = { workspace = true, features = ["native"], optional=true }
30+
sov-celestia-adapter = { workspace = true, features = ["native"], optional=true }
31+
32+
anyhow = { workspace = true }
33+
async-trait = { workspace = true }
34+
borsh = { workspace = true }
35+
clap = { workspace = true }
36+
serde = { workspace = true }
37+
tracing = { workspace = true }
38+
serde_json = { workspace = true }
39+
jsonrpsee = { workspace = true }
40+
tokio = { workspace = true }
41+
42+
m2-risc0 = { path = "../provers/risc0" }
43+
m2-stf = { path = "../stf", features = ["native"] }
44+
sov-risc0-adapter = { workspace = true, features = ["native"] }
45+
46+
# binary dependencies
47+
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
48+
49+
[dev-dependencies]
50+
tempfile = { workspace = true }
51+
sov-mock-zkvm = { workspace = true, features = ["native"] }
52+
53+
[features]
54+
default = ["mock_da"] # set mock_da as the default feature
55+
mock_da = ["sov-mock-da"]
56+
celestia_da = ["sov-celestia-adapter"]
57+
58+
[[bin]]
59+
name = "node"
60+
path = "src/bin/node.rs"
61+
62+
[[bin]]
63+
name = "starter-cli-wallet"
64+
path = "src/bin/starter_cli_wallet.rs"

0 commit comments

Comments
 (0)