diff --git a/Cargo.toml b/Cargo.toml index 9b773b8..f1d9a26 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,15 +12,43 @@ members = [ "common", "nssa", "nssa/core", + "program_methods", + "program_methods/guest", + "test_program_methods", + "test_program_methods/guest", "integration_tests/proc_macro_test_attribute", "examples/program_deployment", + "examples/program_deployment/methods", + "examples/program_deployment/methods/guest", ] [workspace.dependencies] +nssa = { path = "nssa" } +nssa_core = { path = "nssa/core" } +common = { path = "common" } +mempool = { path = "mempool" } +storage = { path = "storage" } +key_protocol = { path = "key_protocol" } +sequencer_core = { path = "sequencer_core" } +sequencer_rpc = { path = "sequencer_rpc" } +sequencer_runner = { path = "sequencer_runner" } +wallet = { path = "wallet" } +program_methods = { path = "program_methods" } +test_program_methods = { path = "test_program_methods" } + +tokio = { version = "1.28.2", features = [ + "net", + "rt-multi-thread", + "sync", + "fs", +] } +risc0-zkvm = { version = "3.0.3", features = ['std'] } +risc0-build = "3.0.3" anyhow = "1.0.98" num_cpus = "1.13.1" openssl = { version = "0.10", features = ["vendored"] } openssl-probe = { version = "0.1.2" } +serde = { version = "1.0.60", default-features = false, features = ["derive"] } serde_json = "1.0.81" actix = "0.13.0" actix-cors = "0.6.1" @@ -33,9 +61,9 @@ lru = "0.7.8" thiserror = "2.0.12" sha2 = "0.10.8" hex = "0.4.3" +bytemuck = "1.24.0" aes-gcm = "0.10.3" toml = "0.7.4" -secp256k1-zkp = "0.11.0" bincode = "1.3.3" tempfile = "3.14.0" light-poseidon = "0.3.0" @@ -54,43 +82,17 @@ rocksdb = { version = "0.24.0", default-features = false, features = [ "snappy", "bindgen-runtime", ] } - -[workspace.dependencies.rand] -features = ["std", "std_rng", "getrandom"] -version = "0.8.5" - -[workspace.dependencies.k256] -features = ["ecdsa-core", "arithmetic", "expose-field", "serde", "pem"] -version = "0.13.3" - -[workspace.dependencies.elliptic-curve] -features = ["arithmetic"] -version = "0.13.8" - -[workspace.dependencies.serde] -features = ["derive"] -version = "1.0.60" - -[workspace.dependencies.actix-web] -default-features = false -features = ["macros"] -version = "=4.1.0" - -[workspace.dependencies.clap] -features = ["derive", "env"] -version = "4.5.42" - -[workspace.dependencies.tokio-retry] -version = "0.3.0" - -[workspace.dependencies.reqwest] -features = ["json"] -version = "0.11.16" - -[workspace.dependencies.tokio] -features = ["net", "rt-multi-thread", "sync", "fs"] -version = "1.28.2" - -[workspace.dependencies.tracing] -features = ["std"] -version = "0.1.13" +rand = { version = "0.8.5", features = ["std", "std_rng", "getrandom"] } +k256 = { version = "0.13.3", features = [ + "ecdsa-core", + "arithmetic", + "expose-field", + "serde", + "pem", +] } +elliptic-curve = { version = "0.13.8", features = ["arithmetic"] } +actix-web = { version = "=4.1.0", default-features = false, features = [ + "macros", +] } +clap = { version = "4.5.42", features = ["derive", "env"] } +reqwest = { version = "0.11.16", features = ["json"] } diff --git a/common/Cargo.toml b/common/Cargo.toml index 920ad2a..a6e26fa 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -4,18 +4,16 @@ version = "0.1.0" edition = "2024" [dependencies] +nssa.workspace = true +nssa_core.workspace = true + anyhow.workspace = true thiserror.workspace = true serde_json.workspace = true serde.workspace = true reqwest.workspace = true - sha2.workspace = true log.workspace = true hex.workspace = true -nssa-core = { path = "../nssa/core", features = ["host"] } borsh.workspace = true base64.workspace = true - -[dependencies.nssa] -path = "../nssa" diff --git a/examples/program_deployment/Cargo.toml b/examples/program_deployment/Cargo.toml index 21d4fc8..725febf 100644 --- a/examples/program_deployment/Cargo.toml +++ b/examples/program_deployment/Cargo.toml @@ -4,10 +4,11 @@ version = "0.1.0" edition = "2024" [dependencies] +nssa_core.workspace = true +nssa.workspace = true +wallet.workspace = true +key_protocol.workspace = true + tokio = { workspace = true, features = ["macros"] } -wallet = { path = "../../wallet" } -nssa-core = { path = "../../nssa/core" } -nssa = { path = "../../nssa" } -key_protocol = { path = "../../key_protocol/" } -clap = "4.5.53" -serde = "1.0.228" +clap.workspace = true +serde.workspace = true diff --git a/examples/program_deployment/methods/Cargo.toml b/examples/program_deployment/methods/Cargo.toml index 0317d2b..a25aecf 100644 --- a/examples/program_deployment/methods/Cargo.toml +++ b/examples/program_deployment/methods/Cargo.toml @@ -1,10 +1,10 @@ [package] -name = "test-program-methods" +name = "example_program_deployment_methods" version = "0.1.0" edition = "2024" [build-dependencies] -risc0-build = { version = "3.0.3" } +risc0-build.workspace = true [package.metadata.risc0] methods = ["guest"] diff --git a/examples/program_deployment/methods/guest/Cargo.toml b/examples/program_deployment/methods/guest/Cargo.toml index 8e2a199..4e5ac88 100644 --- a/examples/program_deployment/methods/guest/Cargo.toml +++ b/examples/program_deployment/methods/guest/Cargo.toml @@ -1,13 +1,12 @@ [package] -name = "programs" +name = "example_program_deployment_programs" version = "0.1.0" edition = "2024" -[workspace] - [dependencies] -risc0-zkvm = { version = "3.0.3", features = ['std'] } -nssa-core = { path = "../../../../nssa/core" } -serde = { version = "1.0.219", default-features = false } -hex = "0.4.3" -bytemuck = "1.24.0" +nssa_core.workspace = true + +serde.workspace = true +hex.workspace = true +bytemuck.workspace = true +risc0-zkvm.workspace = true diff --git a/examples/program_deployment/methods/guest/src/bin/simple_tail_call.rs b/examples/program_deployment/methods/guest/src/bin/simple_tail_call.rs index d2bb58c..9a6fe62 100644 --- a/examples/program_deployment/methods/guest/src/bin/simple_tail_call.rs +++ b/examples/program_deployment/methods/guest/src/bin/simple_tail_call.rs @@ -9,7 +9,6 @@ use nssa_core::program::{ // It reads a single account, emits it unchanged, and then triggers a tail call // to the Hello World program with a fixed greeting. - /// This needs to be set to the ID of the Hello world program. /// To get the ID run **from the root directoy of the repository**: /// `cargo risczero build --manifest-path examples/program_deployment/methods/guest/Cargo.toml` diff --git a/integration_tests/Cargo.toml b/integration_tests/Cargo.toml index 58be5a5..529eb65 100644 --- a/integration_tests/Cargo.toml +++ b/integration_tests/Cargo.toml @@ -4,6 +4,16 @@ version = "0.1.0" edition = "2024" [dependencies] +nssa_core = { workspace = true, features = ["host"] } +nssa = { workspace = true, features = ["no_docker"] } +sequencer_core = { workspace = true, features = ["testnet"] } +sequencer_runner.workspace = true +wallet.workspace = true +common.workspace = true +key_protocol.workspace = true +proc_macro_test_attribute = { path = "./proc_macro_test_attribute" } + +clap = { workspace = true, features = ["derive", "env"] } anyhow.workspace = true env_logger.workspace = true log.workspace = true @@ -14,31 +24,3 @@ tokio.workspace = true hex.workspace = true tempfile.workspace = true borsh.workspace = true - -nssa-core = { path = "../nssa/core", features = ["host"] } - -proc_macro_test_attribute = { path = "./proc_macro_test_attribute" } - -[dependencies.clap] -features = ["derive", "env"] -workspace = true - -[dependencies.sequencer_core] -path = "../sequencer_core" -features = ["testnet"] - -[dependencies.sequencer_runner] -path = "../sequencer_runner" - -[dependencies.wallet] -path = "../wallet" - -[dependencies.common] -path = "../common" - -[dependencies.key_protocol] -path = "../key_protocol" - -[dependencies.nssa] -path = "../nssa" -features = ["no_docker"] diff --git a/integration_tests/src/data_changer.bin b/integration_tests/src/data_changer.bin new file mode 100644 index 0000000..3d062c3 Binary files /dev/null and b/integration_tests/src/data_changer.bin differ diff --git a/key_protocol/Cargo.toml b/key_protocol/Cargo.toml index 103a1de..39c1028 100644 --- a/key_protocol/Cargo.toml +++ b/key_protocol/Cargo.toml @@ -4,22 +4,19 @@ version = "0.1.0" edition = "2024" [dependencies] +nssa.workspace = true +nssa_core.workspace = true +common.workspace = true + anyhow.workspace = true serde.workspace = true k256.workspace = true sha2.workspace = true rand.workspace = true base58.workspace = true -hex = "0.4.3" +hex.workspace = true aes-gcm.workspace = true bip39.workspace = true hmac-sha512.workspace = true thiserror.workspace = true -nssa-core = { path = "../nssa/core", features = ["host"] } itertools.workspace = true - -[dependencies.common] -path = "../common" - -[dependencies.nssa] -path = "../nssa" diff --git a/nssa/Cargo.toml b/nssa/Cargo.toml index 19e70dd..ccb07f4 100644 --- a/nssa/Cargo.toml +++ b/nssa/Cargo.toml @@ -4,16 +4,17 @@ version = "0.1.0" edition = "2024" [dependencies] -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 } -serde = "1.0.219" -sha2 = "0.10.9" +nssa_core = { workspace = true, features = ["host"] } + +thiserror.workspace = true +risc0-zkvm.workspace = true +program_methods = { workspace = true, optional = true } +serde.workspace = true +sha2.workspace = true +rand.workspace = true +borsh.workspace = true +hex.workspace = true secp256k1 = "0.31.1" -rand = "0.8" -borsh = "1.5.7" -hex = "0.4.3" risc0-binfmt = "3.0.2" [build-dependencies] @@ -21,9 +22,9 @@ risc0-build = "3.0.3" risc0-binfmt = "3.0.2" [dev-dependencies] -test-program-methods = { path = "../test_program_methods" } +test_program_methods.workspace = true hex-literal = "1.0.0" [features] default = [] -no_docker = ["program-methods"] +no_docker = ["program_methods"] diff --git a/nssa/core/Cargo.toml b/nssa/core/Cargo.toml index 80fe7df..f317d34 100644 --- a/nssa/core/Cargo.toml +++ b/nssa/core/Cargo.toml @@ -1,21 +1,21 @@ [package] -name = "nssa-core" +name = "nssa_core" version = "0.1.0" edition = "2024" [dependencies] -risc0-zkvm = { version = "3.0.3", features = ['std'] } -serde = { version = "1.0", default-features = false } -thiserror = { version = "2.0.12" } -bytemuck = { version = "1.13", optional = true } +risc0-zkvm.workspace = true +borsh.workspace = true +serde = { workspace = true } +thiserror.workspace = true chacha20 = { version = "0.9", default-features = false } -k256 = { version = "0.13.3", optional = true } -base58 = { version = "0.2.0", optional = true } -anyhow = { version = "1.0.98", optional = true } -borsh = "1.5.7" +bytemuck = { workspace = true, optional = true } +k256 = { workspace = true, optional = true } +base58 = { workspace = true, optional = true } +anyhow = { workspace = true, optional = true } [dev-dependencies] -serde_json = "1.0.81" +serde_json.workspace = true [features] default = [] diff --git a/nssa/core/src/account.rs b/nssa/core/src/account.rs index c152581..bd18c80 100644 --- a/nssa/core/src/account.rs +++ b/nssa/core/src/account.rs @@ -44,11 +44,10 @@ impl AccountWithMetadata { } } -#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Hash, BorshSerialize, BorshDeserialize)] -#[cfg_attr( - any(feature = "host", test), - derive(Debug, Copy, PartialOrd, Ord, Default) +#[derive( + Copy, Clone, Serialize, Deserialize, PartialEq, Eq, Hash, BorshSerialize, BorshDeserialize, )] +#[cfg_attr(any(feature = "host", test), derive(Debug, PartialOrd, Ord, Default))] pub struct AccountId { value: [u8; 32], } diff --git a/program_methods/Cargo.toml b/program_methods/Cargo.toml index 40dab21..5f0688a 100644 --- a/program_methods/Cargo.toml +++ b/program_methods/Cargo.toml @@ -1,10 +1,10 @@ [package] -name = "program-methods" +name = "program_methods" version = "0.1.0" edition = "2024" [build-dependencies] -risc0-build = { version = "3.0.3" } +risc0-build.workspace = true [package.metadata.risc0] methods = ["guest"] diff --git a/program_methods/guest/Cargo.lock b/program_methods/guest/Cargo.lock index 2c293ec..a9e314e 100644 --- a/program_methods/guest/Cargo.lock +++ b/program_methods/guest/Cargo.lock @@ -1571,7 +1571,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a5b0c77c1b780822bc749a33e39aeb2c07584ab93332303babeabb645298a76e" [[package]] -name = "nssa-core" +name = "nssa_core" version = "0.1.0" dependencies = [ "borsh", @@ -1811,7 +1811,7 @@ dependencies = [ name = "programs" version = "0.1.0" dependencies = [ - "nssa-core", + "nssa_core", "risc0-zkvm", "serde", ] diff --git a/program_methods/guest/Cargo.toml b/program_methods/guest/Cargo.toml index cf60940..37c1a8d 100644 --- a/program_methods/guest/Cargo.toml +++ b/program_methods/guest/Cargo.toml @@ -3,9 +3,8 @@ name = "programs" version = "0.1.0" edition = "2024" -[workspace] - [dependencies] -risc0-zkvm = { version = "3.0.3", features = ['std'] } -nssa-core = { path = "../../nssa/core" } -serde = { version = "1.0.219", default-features = false } +nssa_core.workspace = true + +risc0-zkvm.workspace = true +serde = { workspace = true, default-features = false } diff --git a/program_methods/guest/src/bin/privacy_preserving_circuit.rs b/program_methods/guest/src/bin/privacy_preserving_circuit.rs index 8d1688a..ffe4b13 100644 --- a/program_methods/guest/src/bin/privacy_preserving_circuit.rs +++ b/program_methods/guest/src/bin/privacy_preserving_circuit.rs @@ -107,7 +107,7 @@ fn main() { } else { pre_states.push(pre.clone()); } - state_diff.insert(pre.account_id.clone(), post.account().clone()); + state_diff.insert(pre.account_id, post.account().clone()); } // TODO: Modify when multi-chain calls are supported in the circuit diff --git a/program_methods/guest/src/bin/token.rs b/program_methods/guest/src/bin/token.rs index 739295b..1de0921 100644 --- a/program_methods/guest/src/bin/token.rs +++ b/program_methods/guest/src/bin/token.rs @@ -6,36 +6,35 @@ use nssa_core::{ }; // The token program has three functions: -// 1. New token definition. -// Arguments to this function are: -// * Two **default** accounts: [definition_account, holding_account]. -// The first default account will be initialized with the token definition account values. The second account will -// be initialized to a token holding account for the new token, holding the entire total supply. -// * An instruction data of 23-bytes, indicating the total supply and the token name, with -// the following layout: -// [0x00 || total_supply (little-endian 16 bytes) || name (6 bytes)] -// The name cannot be equal to [0x00, 0x00, 0x00, 0x00, 0x00, 0x00] -// 2. Token transfer -// Arguments to this function are: +// 1. New token definition. Arguments to this function are: +// * Two **default** accounts: [definition_account, holding_account]. The first default account +// will be initialized with the token definition account values. The second account will be +// initialized to a token holding account for the new token, holding the entire total supply. +// * An instruction data of 23-bytes, indicating the total supply and the token name, with the +// following layout: [0x00 || total_supply (little-endian 16 bytes) || name (6 bytes)] The +// name cannot be equal to [0x00, 0x00, 0x00, 0x00, 0x00, 0x00] +// 2. Token transfer Arguments to this function are: // * Two accounts: [sender_account, recipient_account]. -// * An instruction data byte string of length 23, indicating the total supply with the following layout -// [0x01 || amount (little-endian 16 bytes) || 0x00 || 0x00 || 0x00 || 0x00 || 0x00 || 0x00]. -// 3. Initialize account with zero balance -// Arguments to this function are: +// * An instruction data byte string of length 23, indicating the total supply with the +// following layout [0x01 || amount (little-endian 16 bytes) || 0x00 || 0x00 || 0x00 || 0x00 +// || 0x00 || 0x00]. +// 3. Initialize account with zero balance Arguments to this function are: // * Two accounts: [definition_account, account_to_initialize]. -// * An dummy byte string of length 23, with the following layout -// [0x02 || 0x00 || 0x00 || 0x00 || ... || 0x00 || 0x00]. -// 4. Burn tokens from a Token Holding account (thus lowering total supply) -// Arguments to this function are: +// * An dummy byte string of length 23, with the following layout [0x02 || 0x00 || 0x00 || 0x00 +// || ... || 0x00 || 0x00]. +// 4. Burn tokens from a Token Holding account (thus lowering total supply) Arguments to this +// function are: // * Two accounts: [definition_account, holding_account]. // * Authorization required: holding_account -// * An instruction data byte string of length 23, indicating the balance to burn with the folloiwng layout +// * An instruction data byte string of length 23, indicating the balance to burn with the +// folloiwng layout // [0x03 || amount (little-endian 16 bytes) || 0x00 || 0x00 || 0x00 || 0x00 || 0x00 || 0x00]. -// 5. Mint additional supply of tokens tokens to a Token Holding account (thus increasing total supply) -// Arguments to this function are: +// 5. Mint additional supply of tokens tokens to a Token Holding account (thus increasing total +// supply) Arguments to this function are: // * Two accounts: [definition_account, holding_account]. // * Authorization required: definition_account -// * An instruction data byte string of length 23, indicating the balance to mint with the folloiwng layout +// * An instruction data byte string of length 23, indicating the balance to mint with the +// folloiwng layout // [0x04 || amount (little-endian 16 bytes) || 0x00 || 0x00 || 0x00 || 0x00 || 0x00 || 0x00]. const TOKEN_DEFINITION_TYPE: u8 = 0; @@ -89,10 +88,10 @@ impl TokenDefinition { } impl TokenHolding { - fn new(definition_id: &AccountId) -> Self { + fn new(definition_id: AccountId) -> Self { Self { account_type: TOKEN_HOLDING_TYPE, - definition_id: definition_id.clone(), + definition_id, balance: 0, } } @@ -142,7 +141,7 @@ fn transfer(pre_states: &[AccountWithMetadata], balance_to_move: u128) -> Vec Vec panic!("Invalid selection"), } } @@ -1093,8 +1091,7 @@ mod tests { BalanceEnum::MintSuccess => 50_000, BalanceEnum::InitSupplyMint => 150_000, BalanceEnum::HoldingBalanceMint => 51_000, - BalanceEnum::MintOverflow => (2 as u128).pow(128) - 40_000, - _ => panic!("Invalid selection"), + BalanceEnum::MintOverflow => 2u128.pow(128) - 40_000, } } @@ -1290,7 +1287,7 @@ mod tests { assert!( *holding_post.account() == helper_account_constructor(AccountsEnum::InitMint).account ); - assert!(holding_post.requires_claim() == true); + assert!(holding_post.requires_claim()); } #[test] diff --git a/sequencer_core/Cargo.toml b/sequencer_core/Cargo.toml index 32c263c..158d436 100644 --- a/sequencer_core/Cargo.toml +++ b/sequencer_core/Cargo.toml @@ -4,6 +4,12 @@ version = "0.1.0" edition = "2024" [dependencies] +nssa.workspace = true +nssa_core.workspace = true +common.workspace = true +storage.workspace = true +mempool.workspace = true + base58.workspace = true anyhow.workspace = true serde.workspace = true @@ -11,19 +17,6 @@ rand.workspace = true tempfile.workspace = true chrono.workspace = true log.workspace = true -nssa-core = { path = "../nssa/core", features = ["host"] } - -[dependencies.storage] -path = "../storage" - -[dependencies.mempool] -path = "../mempool" - -[dependencies.common] -path = "../common" - -[dependencies.nssa] -path = "../nssa" [features] default = [] diff --git a/sequencer_rpc/Cargo.toml b/sequencer_rpc/Cargo.toml index 395660f..2abd540 100644 --- a/sequencer_rpc/Cargo.toml +++ b/sequencer_rpc/Cargo.toml @@ -4,6 +4,11 @@ version = "0.1.0" edition = "2024" [dependencies] +nssa.workspace = true +common.workspace = true +mempool.workspace = true +sequencer_core.workspace = true + anyhow.workspace = true serde_json.workspace = true log.workspace = true @@ -11,25 +16,10 @@ serde.workspace = true actix-cors.workspace = true futures.workspace = true base58.workspace = true -hex = "0.4.3" +hex.workspace = true tempfile.workspace = true base64.workspace = true itertools.workspace = true - actix-web.workspace = true tokio.workspace = true borsh.workspace = true - -# TODO: Move to workspace - -[dependencies.sequencer_core] -path = "../sequencer_core" - -[dependencies.common] -path = "../common" - -[dependencies.nssa] -path = "../nssa" - -[dependencies.mempool] -path = "../mempool" diff --git a/sequencer_runner/Cargo.toml b/sequencer_runner/Cargo.toml index 2f105ee..7200145 100644 --- a/sequencer_runner/Cargo.toml +++ b/sequencer_runner/Cargo.toml @@ -4,25 +4,15 @@ version = "0.1.0" edition = "2024" [dependencies] +common.workspace = true +sequencer_core = { workspace = true, features = ["testnet"] } +sequencer_rpc.workspace = true + +clap = { workspace = true, features = ["derive", "env"] } anyhow.workspace = true serde_json.workspace = true env_logger.workspace = true log.workspace = true actix.workspace = true - actix-web.workspace = true tokio.workspace = true - -[dependencies.clap] -features = ["derive", "env"] -workspace = true - -[dependencies.sequencer_rpc] -path = "../sequencer_rpc" - -[dependencies.sequencer_core] -path = "../sequencer_core" -features = ["testnet"] - -[dependencies.common] -path = "../common" diff --git a/storage/Cargo.toml b/storage/Cargo.toml index 2fd4628..4678560 100644 --- a/storage/Cargo.toml +++ b/storage/Cargo.toml @@ -4,10 +4,8 @@ version = "0.1.0" edition = "2024" [dependencies] +common.workspace = true + thiserror.workspace = true borsh.workspace = true - rocksdb.workspace = true - -[dependencies.common] -path = "../common" diff --git a/test_program_methods/Cargo.toml b/test_program_methods/Cargo.toml index 0317d2b..345c479 100644 --- a/test_program_methods/Cargo.toml +++ b/test_program_methods/Cargo.toml @@ -1,10 +1,10 @@ [package] -name = "test-program-methods" +name = "test_program_methods" version = "0.1.0" edition = "2024" [build-dependencies] -risc0-build = { version = "3.0.3" } +risc0-build.workspace = true [package.metadata.risc0] methods = ["guest"] diff --git a/test_program_methods/guest/Cargo.lock b/test_program_methods/guest/Cargo.lock index b2337cc..7edd368 100644 --- a/test_program_methods/guest/Cargo.lock +++ b/test_program_methods/guest/Cargo.lock @@ -1576,7 +1576,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a5b0c77c1b780822bc749a33e39aeb2c07584ab93332303babeabb645298a76e" [[package]] -name = "nssa-core" +name = "nssa_core" version = "0.1.0" dependencies = [ "borsh", @@ -1825,7 +1825,7 @@ dependencies = [ name = "programs" version = "0.1.0" dependencies = [ - "nssa-core", + "nssa_core", "risc0-zkvm", "serde", ] diff --git a/test_program_methods/guest/Cargo.toml b/test_program_methods/guest/Cargo.toml index cf60940..2c65dc4 100644 --- a/test_program_methods/guest/Cargo.toml +++ b/test_program_methods/guest/Cargo.toml @@ -1,11 +1,10 @@ [package] -name = "programs" +name = "test_programs" version = "0.1.0" edition = "2024" -[workspace] - [dependencies] -risc0-zkvm = { version = "3.0.3", features = ['std'] } -nssa-core = { path = "../../nssa/core" } -serde = { version = "1.0.219", default-features = false } +nssa_core.workspace = true + +risc0-zkvm.workspace = true +serde = { workspace = true, default-features = false } diff --git a/test_program_methods/guest/src/bin/burner.rs b/test_program_methods/guest/src/bin/burner.rs index 5deef7c..3002e39 100644 --- a/test_program_methods/guest/src/bin/burner.rs +++ b/test_program_methods/guest/src/bin/burner.rs @@ -20,5 +20,9 @@ fn main() { let mut account_post = account_pre.clone(); account_post.balance -= balance_to_burn; - write_nssa_outputs(instruction_words, vec![pre], vec![AccountPostState::new(account_post)]); + write_nssa_outputs( + instruction_words, + vec![pre], + vec![AccountPostState::new(account_post)], + ); } diff --git a/test_program_methods/guest/src/bin/chain_caller.rs b/test_program_methods/guest/src/bin/chain_caller.rs index f2d3cb6..0cdac8d 100644 --- a/test_program_methods/guest/src/bin/chain_caller.rs +++ b/test_program_methods/guest/src/bin/chain_caller.rs @@ -13,9 +13,9 @@ fn main() { let ( ProgramInput { pre_states, - instruction: (balance, auth_transfer_id, num_chain_calls, pda_seed), + instruction: (balance, auth_transfer_id, num_chain_calls, pda_seed), }, - instruction_words + instruction_words, ) = read_nssa_inputs::(); let [recipient_pre, sender_pre] = match pre_states.try_into() { @@ -37,7 +37,7 @@ fn main() { let new_chained_call = ChainedCall { program_id: auth_transfer_id, instruction_data: instruction_data.clone(), - pre_states: vec![running_sender_pre.clone(), running_recipient_pre.clone()], // <- Account order permutation here + pre_states: vec![running_sender_pre.clone(), running_recipient_pre.clone()], /* <- Account order permutation here */ pda_seeds: pda_seed.iter().cloned().collect(), }; chained_calls.push(new_chained_call); diff --git a/test_program_methods/guest/src/bin/data_changer.rs b/test_program_methods/guest/src/bin/data_changer.rs index 9154440..cd1cc19 100644 --- a/test_program_methods/guest/src/bin/data_changer.rs +++ b/test_program_methods/guest/src/bin/data_changer.rs @@ -4,7 +4,13 @@ type Instruction = Vec; /// A program that modifies the account data by setting bytes sent in instruction. fn main() { - let (ProgramInput { pre_states, instruction: data }, instruction_words) = read_nssa_inputs::(); + let ( + ProgramInput { + pre_states, + instruction: data, + }, + instruction_words, + ) = read_nssa_inputs::(); let [pre] = match pre_states.try_into() { Ok(array) => array, @@ -13,7 +19,9 @@ fn main() { let account_pre = &pre.account; let mut account_post = account_pre.clone(); - account_post.data = data.try_into().expect("provided data should fit into data limit"); + account_post.data = data + .try_into() + .expect("provided data should fit into data limit"); write_nssa_outputs( instruction_words, diff --git a/test_program_methods/guest/src/bin/minter.rs b/test_program_methods/guest/src/bin/minter.rs index 51baa5e..6bc6855 100644 --- a/test_program_methods/guest/src/bin/minter.rs +++ b/test_program_methods/guest/src/bin/minter.rs @@ -1,4 +1,4 @@ -use nssa_core::program::{read_nssa_inputs, write_nssa_outputs, AccountPostState, ProgramInput}; +use nssa_core::program::{AccountPostState, ProgramInput, read_nssa_inputs, write_nssa_outputs}; type Instruction = (); @@ -14,5 +14,9 @@ fn main() { let mut account_post = account_pre.clone(); account_post.balance += 1; - write_nssa_outputs(instruction_words, vec![pre], vec![AccountPostState::new(account_post)]); + write_nssa_outputs( + instruction_words, + vec![pre], + vec![AccountPostState::new(account_post)], + ); } diff --git a/test_program_methods/guest/src/bin/nonce_changer.rs b/test_program_methods/guest/src/bin/nonce_changer.rs index 4ca6c73..17aa966 100644 --- a/test_program_methods/guest/src/bin/nonce_changer.rs +++ b/test_program_methods/guest/src/bin/nonce_changer.rs @@ -1,9 +1,9 @@ -use nssa_core::program::{read_nssa_inputs, write_nssa_outputs, AccountPostState, ProgramInput}; +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::(); + let (ProgramInput { pre_states, .. }, instruction_words) = read_nssa_inputs::(); let [pre] = match pre_states.try_into() { Ok(array) => array, @@ -14,5 +14,9 @@ fn main() { let mut account_post = account_pre.clone(); account_post.nonce += 1; - write_nssa_outputs(instruction_words ,vec![pre], vec![AccountPostState::new(account_post)]); + write_nssa_outputs( + instruction_words, + vec![pre], + vec![AccountPostState::new(account_post)], + ); } diff --git a/test_program_methods/guest/src/bin/program_owner_changer.rs b/test_program_methods/guest/src/bin/program_owner_changer.rs index 2b212c1..232fa30 100644 --- a/test_program_methods/guest/src/bin/program_owner_changer.rs +++ b/test_program_methods/guest/src/bin/program_owner_changer.rs @@ -1,4 +1,4 @@ -use nssa_core::program::{read_nssa_inputs, write_nssa_outputs, AccountPostState, ProgramInput}; +use nssa_core::program::{AccountPostState, ProgramInput, read_nssa_inputs, write_nssa_outputs}; type Instruction = (); @@ -14,5 +14,9 @@ fn main() { let mut account_post = account_pre.clone(); account_post.program_owner = [0, 1, 2, 3, 4, 5, 6, 7]; - write_nssa_outputs(instruction_words, vec![pre], vec![AccountPostState::new(account_post)]); + write_nssa_outputs( + instruction_words, + vec![pre], + vec![AccountPostState::new(account_post)], + ); } diff --git a/wallet/Cargo.toml b/wallet/Cargo.toml index c93b357..d34203f 100644 --- a/wallet/Cargo.toml +++ b/wallet/Cargo.toml @@ -4,6 +4,11 @@ version = "0.1.0" edition = "2024" [dependencies] +nssa_core.workspace = true +nssa.workspace = true +common.workspace = true +key_protocol.workspace = true + anyhow.workspace = true serde_json.workspace = true env_logger.workspace = true @@ -12,24 +17,14 @@ serde.workspace = true tokio.workspace = true tempfile.workspace = true clap.workspace = true -nssa-core = { path = "../nssa/core" } base64.workspace = true -bytemuck = "1.23.2" +bytemuck.workspace = true borsh.workspace = true base58.workspace = true -hex = "0.4.3" +hex.workspace = true rand.workspace = true itertools.workspace = true sha2.workspace = true futures.workspace = true async-stream = "0.3.6" indicatif = { version = "0.18.3", features = ["improved_unicode"] } - -[dependencies.key_protocol] -path = "../key_protocol" - -[dependencies.nssa] -path = "../nssa" - -[dependencies.common] -path = "../common"