refactor: move program_methods to the root of repo

This commit is contained in:
Daniil Polyakov 2025-12-16 16:22:35 +03:00
parent 7d12502542
commit 90a1ee994f
30 changed files with 23 additions and 21 deletions

View File

@ -7,7 +7,7 @@ edition = "2024"
thiserror = "2.0.12"
risc0-zkvm = { version = "3.0.3", features = ['std'] }
nssa-core = { path = "core", features = ["host"] }
program-methods = { path = "program_methods", optional = true }
program-methods = { path = "../program_methods", optional = true }
serde = "1.0.219"
sha2 = "0.10.9"
secp256k1 = "0.31.1"
@ -21,7 +21,7 @@ risc0-build = "3.0.3"
risc0-binfmt = "3.0.2"
[dev-dependencies]
test-program-methods = { path = "test_program_methods" }
test-program-methods = { path = "../test_program_methods" }
hex-literal = "1.0.0"
[features]

View File

@ -15,12 +15,13 @@ fn build_deterministic() -> Result<(), Box<dyn std::error::Error>> {
let mod_dir = out_dir.join("program_methods");
let mod_file = mod_dir.join("mod.rs");
println!("cargo:rerun-if-changed=program_methods/guest/src");
println!("cargo:rerun-if-changed=program_methods/guest/Cargo.toml");
let guest_manifest = manifest_dir.join("program_methods/guest/Cargo.toml");
println!("cargo:rerun-if-changed=../program_methods/guest/src");
println!("cargo:rerun-if-changed=../program_methods/guest/Cargo.toml");
let build_cur_dir = manifest_dir.join("..").canonicalize()?;
let guest_manifest = build_cur_dir.join("program_methods/guest/Cargo.toml");
let status = Command::new("cargo")
.current_dir(build_cur_dir)
.args(["risczero", "build", "--manifest-path"])
.arg(&guest_manifest)
.status()?;
@ -29,7 +30,7 @@ fn build_deterministic() -> Result<(), Box<dyn std::error::Error>> {
}
let target_dir =
manifest_dir.join("program_methods/guest/target/riscv32im-risc0-zkvm-elf/docker/");
manifest_dir.join("../program_methods/guest/target/riscv32im-risc0-zkvm-elf/docker/");
let bins = fs::read_dir(&target_dir)?
.filter_map(Result::ok)

View File

@ -1,12 +0,0 @@
use nssa_core::program::{read_nssa_inputs, write_nssa_outputs, ProgramInput, AccountPostState};
type Instruction = ();
fn main() {
let (ProgramInput { pre_states, .. }, instruction_words) = read_nssa_inputs::<Instruction>();
let post_states = pre_states.iter().map(|account| {
AccountPostState::new(account.account.clone())
}).collect();
write_nssa_outputs(instruction_words, pre_states, post_states);
}

View File

@ -7,5 +7,5 @@ edition = "2024"
[dependencies]
risc0-zkvm = { version = "3.0.3", features = ['std'] }
nssa-core = { path = "../../core" }
nssa-core = { path = "../../nssa/core" }
serde = { version = "1.0.219", default-features = false }

View File

@ -7,5 +7,5 @@ edition = "2024"
[dependencies]
risc0-zkvm = { version = "3.0.3", features = ['std'] }
nssa-core = { path = "../../core" }
nssa-core = { path = "../../nssa/core" }
serde = { version = "1.0.219", default-features = false }

View File

@ -0,0 +1,13 @@
use nssa_core::program::{AccountPostState, ProgramInput, read_nssa_inputs, write_nssa_outputs};
type Instruction = ();
fn main() {
let (ProgramInput { pre_states, .. }, instruction_words) = read_nssa_inputs::<Instruction>();
let post_states = pre_states
.iter()
.map(|account| AccountPostState::new(account.account.clone()))
.collect();
write_nssa_outputs(instruction_words, pre_states, post_states);
}