From 0699d30d3acbe7096fabe31e2049cdbda7117f1b Mon Sep 17 00:00:00 2001 From: pmantica11 <151664502+pmantica11@users.noreply.github.com> Date: Tue, 28 May 2024 09:43:06 -0600 Subject: [PATCH] Use gnark prover (#97) * Use grank prover * Intermediate commit * Intermediate commit * Use Grank prover * Fix * Fix merge issues --- Cargo.lock | 322 ++++++++++++++++-- Cargo.toml | 4 + src/api/api.rs | 13 + .../get_multiple_compressed_account_proofs.rs | 10 +- src/api/method/get_validity_proof.rs | 258 ++++++++++++++ src/api/method/mod.rs | 1 + src/api/rpc_server.rs | 6 + src/openapi/mod.rs | 6 +- ...2Hd6eBBRvYETrwLW5KQf7N8egGBo1mP5PLUAX7T3pm | 1 + ...HeEZkFVXQYHk56d5EjPvhkJ6U3F3bryxjbtbD7ZBpL | 1 + ...NUGnArM8KQyjirY1xxfK8QF9tdS79ANdjFfHCDmdR7 | 1 + tests/integration_tests/e2e_tests.rs | 56 +-- ...sts__e2e_mint_and_transfer-bob-proofs.snap | 8 +- ..._mint_and_transfer-bob-validity-proof.snap | 31 ++ ..._e2e_mint_and_transfer-charles-proofs.snap | 8 +- ...t_and_transfer-charles-validity-proof.snap | 31 ++ ...tests__lamport_transfers-payer-proofs.snap | 4 +- ...amport_transfers-payer-validity-proof.snap | 26 ++ ...ts__lamport_transfers-receiver-proofs.snap | 8 +- ...ort_transfers-receiver-validity-proof.snap | 31 ++ ..._tests__validity_proof-payer-accounts.snap | 25 ++ ...__validity_proof-payer-validity-proof.snap | 26 ++ 22 files changed, 814 insertions(+), 63 deletions(-) create mode 100644 src/api/method/get_validity_proof.rs create mode 100644 tests/data/transactions/validity_proof/4ETLuGztX78vTrqxV5gucpQeD6ayEYrpA7bfMA9RJ1rKto2Hd6eBBRvYETrwLW5KQf7N8egGBo1mP5PLUAX7T3pm create mode 100644 tests/data/transactions/validity_proof/5YJgpi1BePKtFVQjcAqwgbFL4pMGjBpLbnuaXE3kJe2yRJHeEZkFVXQYHk56d5EjPvhkJ6U3F3bryxjbtbD7ZBpL create mode 100644 tests/data/transactions/validity_proof/N955JL3hSckkfpaB8r2W6vpMQCGXfuzcsYVdkj15zxUxSNUGnArM8KQyjirY1xxfK8QF9tdS79ANdjFfHCDmdR7 create mode 100644 tests/integration_tests/snapshots/integration_tests__e2e_tests__e2e_mint_and_transfer-bob-validity-proof.snap create mode 100644 tests/integration_tests/snapshots/integration_tests__e2e_tests__e2e_mint_and_transfer-charles-validity-proof.snap create mode 100644 tests/integration_tests/snapshots/integration_tests__e2e_tests__lamport_transfers-payer-validity-proof.snap create mode 100644 tests/integration_tests/snapshots/integration_tests__e2e_tests__lamport_transfers-receiver-validity-proof.snap create mode 100644 tests/integration_tests/snapshots/integration_tests__e2e_tests__validity_proof-payer-accounts.snap create mode 100644 tests/integration_tests/snapshots/integration_tests__e2e_tests__validity_proof-payer-validity-proof.snap diff --git a/Cargo.lock b/Cargo.lock index 478448af..c81d4929 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -832,6 +832,12 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +[[package]] +name = "base64" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" + [[package]] name = "base64ct" version = "1.6.0" @@ -2037,6 +2043,21 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "form_urlencoded" version = "1.2.1" @@ -2307,7 +2328,26 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "http", + "http 0.2.12", + "indexmap 2.2.6", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "h2" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "816ec7294445779408f36fe57bc5b7fc1cf59664059096c65f905c1c61f58069" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 1.1.0", "indexmap 2.2.6", "slab", "tokio", @@ -2481,6 +2521,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + [[package]] name = "http-body" version = "0.4.6" @@ -2488,7 +2539,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", - "http", + "http 0.2.12", + "pin-project-lite", +] + +[[package]] +name = "http-body" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +dependencies = [ + "bytes", + "http 1.1.0", +] + +[[package]] +name = "http-body-util" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0475f8b2ac86659c21b64320d5d653f9efe42acd2a4e560073ec61a155a34f1d" +dependencies = [ + "bytes", + "futures-core", + "http 1.1.0", + "http-body 1.0.0", "pin-project-lite", ] @@ -2526,9 +2600,9 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2", - "http", - "http-body", + "h2 0.3.26", + "http 0.2.12", + "http-body 0.4.6", "httparse", "httpdate", "itoa", @@ -2540,6 +2614,26 @@ dependencies = [ "want", ] +[[package]] +name = "hyper" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe575dd17d0862a9a33781c8c4696a55c320909004a67a00fb286ba8b1bc496d" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2 0.4.4", + "http 1.1.0", + "http-body 1.0.0", + "httparse", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + [[package]] name = "hyper-rustls" version = "0.24.2" @@ -2547,13 +2641,49 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", - "http", - "hyper", + "http 0.2.12", + "hyper 0.14.28", "rustls 0.21.10", "tokio", "tokio-rustls 0.24.1", ] +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper 1.3.1", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "hyper 1.3.1", + "pin-project-lite", + "socket2 0.5.6", + "tokio", + "tower", + "tower-service", + "tracing", +] + [[package]] name = "iana-time-zone" version = "0.1.60" @@ -2785,7 +2915,7 @@ dependencies = [ "futures-channel", "futures-util", "globset", - "hyper", + "hyper 0.14.28", "jsonrpsee-types", "parking_lot 0.12.1", "rand 0.8.5", @@ -2819,8 +2949,8 @@ checksum = "cf4d945a6008c9b03db3354fb3c83ee02d2faa9f2e755ec1dfb69c3551b8f4ba" dependencies = [ "futures-channel", "futures-util", - "http", - "hyper", + "http 0.2.12", + "hyper 0.14.28", "jsonrpsee-core", "jsonrpsee-types", "serde", @@ -3101,6 +3231,24 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "native-tls" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "nix" version = "0.26.4" @@ -3337,12 +3485,50 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" +[[package]] +name = "openssl" +version = "0.10.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" +dependencies = [ + "bitflags 2.5.0", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.59", +] + [[package]] name = "openssl-probe" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "openssl-sys" +version = "0.9.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "option-ext" version = "0.2.0" @@ -3505,7 +3691,8 @@ dependencies = [ "env_logger 0.10.2", "function_name", "futures", - "hyper", + "hex", + "hyper 0.14.28", "indexmap 2.2.6", "insta", "itertools 0.12.1", @@ -3514,8 +3701,11 @@ dependencies = [ "lazy_static", "light-poseidon", "log", + "num-bigint 0.4.4", + "num-traits", "num_enum 0.7.2", "once_cell", + "reqwest 0.12.4", "rstest", "sea-orm", "sea-orm-migration", @@ -4040,10 +4230,10 @@ dependencies = [ "encoding_rs", "futures-core", "futures-util", - "h2", - "http", - "http-body", - "hyper", + "h2 0.3.26", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.28", "hyper-rustls", "ipnet", "js-sys", @@ -4053,7 +4243,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "rustls 0.21.10", - "rustls-pemfile", + "rustls-pemfile 1.0.4", "serde", "serde_json", "serde_urlencoded", @@ -4068,7 +4258,49 @@ dependencies = [ "wasm-bindgen-futures", "web-sys", "webpki-roots 0.25.4", - "winreg", + "winreg 0.50.0", +] + +[[package]] +name = "reqwest" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "566cafdd92868e0939d3fb961bd0dc25fcfaaed179291093b3d43e6b3150ea10" +dependencies = [ + "base64 0.22.0", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2 0.4.4", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.3.1", + "hyper-tls", + "hyper-util", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls-pemfile 2.1.2", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "system-configuration", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg 0.52.0", ] [[package]] @@ -4284,7 +4516,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" dependencies = [ "openssl-probe", - "rustls-pemfile", + "rustls-pemfile 1.0.4", "schannel", "security-framework", ] @@ -4298,6 +4530,22 @@ dependencies = [ "base64 0.21.7", ] +[[package]] +name = "rustls-pemfile" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" +dependencies = [ + "base64 0.22.0", + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "beb461507cee2c2ff151784c52762cf4d9ff6a61f3e80968600ed24fa837fa54" + [[package]] name = "rustls-webpki" version = "0.101.7" @@ -4838,7 +5086,7 @@ dependencies = [ "base64 0.13.1", "bytes", "futures", - "http", + "http 0.2.12", "httparse", "log", "rand 0.8.5", @@ -5029,7 +5277,7 @@ dependencies = [ "gethostname", "lazy_static", "log", - "reqwest", + "reqwest 0.11.27", "solana-sdk", "thiserror", ] @@ -5176,7 +5424,7 @@ dependencies = [ "crossbeam-channel", "futures-util", "log", - "reqwest", + "reqwest 0.11.27", "semver", "serde", "serde_derive", @@ -5260,7 +5508,7 @@ dependencies = [ "bs58 0.4.0", "indicatif", "log", - "reqwest", + "reqwest 0.11.27", "semver", "serde", "serde_derive", @@ -5283,7 +5531,7 @@ dependencies = [ "base64 0.21.7", "bs58 0.4.0", "jsonrpc-core", - "reqwest", + "reqwest 0.11.27", "semver", "serde", "serde_derive", @@ -5875,7 +6123,7 @@ dependencies = [ "rand 0.8.5", "rust_decimal", "rustls 0.20.9", - "rustls-pemfile", + "rustls-pemfile 1.0.4", "serde", "serde_json", "sha1", @@ -6201,6 +6449,16 @@ dependencies = [ "syn 2.0.59", ] +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + [[package]] name = "tokio-rustls" version = "0.23.4" @@ -6333,8 +6591,8 @@ dependencies = [ "bytes", "futures-core", "futures-util", - "http", - "http-body", + "http 0.2.12", + "http-body 0.4.6", "http-range-header", "httpdate", "iri-string", @@ -6453,7 +6711,7 @@ dependencies = [ "byteorder", "bytes", "data-encoding", - "http", + "http 0.2.12", "httparse", "log", "rand 0.8.5", @@ -7018,6 +7276,16 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "winreg" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + [[package]] name = "wyz" version = "0.5.1" diff --git a/Cargo.toml b/Cargo.toml index bf877369..fa451718 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -76,7 +76,11 @@ sqlx = {version = "0.6.2", features = [ thiserror = "1.0.31" # time pinned because of https://github.com/launchbadge/sqlx/issues/3189 ark-bn254 = "0.4.0" +hex = "0.4.3" +num-bigint = "0.4.4" +num-traits = "0.2.18" num_enum = "0.7.2" +reqwest = "0.12.4" time = "=0.3.34" tokio = {version = "1.23.0", features = ["full"]} tower = {version = "0.4.13", features = ["full"]} diff --git a/src/api/api.rs b/src/api/api.rs index d540d7c7..691fc8af 100644 --- a/src/api/api.rs +++ b/src/api/api.rs @@ -32,6 +32,7 @@ use super::method::get_latest_non_voting_signatures::get_latest_non_voting_signa use super::method::get_transaction_with_compression_info::{ get_transaction_with_compression_info, GetTransactionRequest, GetTransactionResponse, }; +use super::method::get_validity_proof::{get_validity_proof, CompressedProofWithContext}; use super::method::utils::GetLatestSignaturesRequest; use super::method::utils::{AccountBalanceResponse, GetPaginatedSignaturesResponse, HashRequest}; use super::{ @@ -251,6 +252,13 @@ impl PhotonApi { .await } + pub async fn get_validity_proof( + &self, + request: HashList, + ) -> Result { + get_validity_proof(self.db_conn.as_ref(), request).await + } + pub async fn get_latest_compression_signatures( &self, request: GetLatestSignaturesRequest, @@ -282,6 +290,11 @@ impl PhotonApi { request: Some(HashList::schema().1), response: GetMultipleCompressedAccountProofsResponse::schema().1, }, + OpenApiSpec { + name: "getValidityProof".to_string(), + request: Some(HashList::schema().1), + response: CompressedProofWithContext::schema().1, + }, OpenApiSpec { name: "getCompressedTokenAccountsByOwner".to_string(), request: Some(GetCompressedTokenAccountsByOwner::schema().1), diff --git a/src/api/method/get_multiple_compressed_account_proofs.rs b/src/api/method/get_multiple_compressed_account_proofs.rs index 656350ee..366c80c9 100644 --- a/src/api/method/get_multiple_compressed_account_proofs.rs +++ b/src/api/method/get_multiple_compressed_account_proofs.rs @@ -22,6 +22,7 @@ use crate::common::typedefs::hash::Hash; #[serde(deny_unknown_fields, rename_all = "camelCase")] pub struct MerkleProofWithContext { pub proof: Vec, + pub root: Hash, pub leaf_index: u32, pub hash: Hash, pub merkle_tree: SerializablePubkey, @@ -111,7 +112,7 @@ pub async fn get_multiple_compressed_account_proofs_helper( hash )))?; - let proofs = required_node_indices + let mut proof = required_node_indices .iter() .enumerate() .map(|(level, idx)| { @@ -147,8 +148,13 @@ pub async fn get_multiple_compressed_account_proofs_helper( hash )))?; + let root = proof.pop().ok_or(PhotonApiError::UnexpectedError( + "Root node not found in proof".to_string(), + ))?; + Ok(MerkleProofWithContext { - proof: proofs, + proof, + root, leaf_index: leaf_model.leaf_idx.ok_or(PhotonApiError::RecordNotFound( "Leaf index not found".to_string(), ))? as u32, diff --git a/src/api/method/get_validity_proof.rs b/src/api/method/get_validity_proof.rs new file mode 100644 index 00000000..44227e9d --- /dev/null +++ b/src/api/method/get_validity_proof.rs @@ -0,0 +1,258 @@ +use crate::{api::error::PhotonApiError, common::typedefs::hash::Hash}; +use lazy_static::lazy_static; +use num_bigint::BigUint; +use reqwest::Client; +use sea_orm::DatabaseConnection; +use serde::{Deserialize, Serialize}; +use std::str::FromStr; +use utoipa::ToSchema; + +use super::get_multiple_compressed_account_proofs::{ + get_multiple_compressed_account_proofs_helper, HashList, +}; + +lazy_static! { + static ref FIELD_SIZE: BigUint = BigUint::from_str( + "21888242871839275222246405745257275088548364400416034343698204186575808495616" + ) + .unwrap(); +} + +#[derive(Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +struct HexInputsForProver { + root: String, + path_index: u32, + path_elements: Vec, + leaf: String, +} + +#[derive(Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +struct HexBatchInputsForProver { + #[serde(rename = "input-compressed-accounts")] + input_compressed_accounts: Vec, +} + +#[derive(Serialize, Deserialize, ToSchema)] +#[serde(rename_all = "camelCase")] +pub struct CompressedProofWithContext { + pub compressed_proof: CompressedProof, + roots: Vec, + root_indices: Vec, + leaf_indices: Vec, + leaves: Vec, + merkle_trees: Vec, +} + +fn hash_to_hex(hash: &Hash) -> String { + let bytes = hash.to_vec(); + let hex = hex::encode(bytes); + format!("0x{}", hex) +} + +#[derive(Serialize, Deserialize, Debug)] +struct GnarkProofJson { + ar: [String; 2], + bs: [[String; 2]; 2], + krs: [String; 2], +} + +#[derive(Debug)] +struct ProofABC { + a: Vec, + b: Vec, + c: Vec, +} + +#[derive(Serialize, Deserialize, ToSchema, Default)] +pub struct CompressedProof { + a: Vec, + b: Vec, + c: Vec, +} + +fn deserialize_hex_string_to_bytes(hex_str: &str) -> Vec { + let hex_str = if hex_str.starts_with("0x") { + &hex_str[2..] + } else { + hex_str + }; + + // Left pad with 0s if the length is not 64 + let hex_str = format!("{:0>64}", hex_str); + + hex::decode(&hex_str).expect("Failed to decode hex string") +} + +fn proof_from_json_struct(json: GnarkProofJson) -> ProofABC { + let proof_ax = deserialize_hex_string_to_bytes(&json.ar[0]); + let proof_ay = deserialize_hex_string_to_bytes(&json.ar[1]); + let proof_a = [proof_ax, proof_ay].concat(); + + let proof_bx0 = deserialize_hex_string_to_bytes(&json.bs[0][0]); + let proof_bx1 = deserialize_hex_string_to_bytes(&json.bs[0][1]); + let proof_by0 = deserialize_hex_string_to_bytes(&json.bs[1][0]); + let proof_by1 = deserialize_hex_string_to_bytes(&json.bs[1][1]); + let proof_b = [proof_bx0, proof_bx1, proof_by0, proof_by1].concat(); + + let proof_cx = deserialize_hex_string_to_bytes(&json.krs[0]); + let proof_cy = deserialize_hex_string_to_bytes(&json.krs[1]); + let proof_c = [proof_cx, proof_cy].concat(); + + ProofABC { + a: proof_a, + b: proof_b, + c: proof_c, + } +} + +fn y_element_is_positive_g1(y_element: &BigUint) -> bool { + y_element <= &(FIELD_SIZE.clone() - y_element) +} + +fn y_element_is_positive_g2(y_element1: &BigUint, y_element2: &BigUint) -> bool { + let field_midpoint = FIELD_SIZE.clone() / 2u32; + + if y_element1 < &field_midpoint { + true + } else if y_element1 > &field_midpoint { + false + } else { + y_element2 < &field_midpoint + } +} + +fn add_bitmask_to_byte(byte: u8, is_positive: bool) -> u8 { + if is_positive { + byte | 0x80 + } else { + byte & 0x7F + } +} + +fn negate_and_compress_proof(proof: ProofABC) -> CompressedProof { + let proof_a = &proof.a; + let proof_b = &proof.b; + let proof_c = &proof.c; + + let a_x_element = &mut proof_a[0..32].to_vec(); + let a_y_element = BigUint::from_bytes_be(&proof_a[32..64]); + + let proof_a_is_positive = !y_element_is_positive_g1(&a_y_element); + a_x_element[0] = add_bitmask_to_byte(a_x_element[0], proof_a_is_positive); + + let b_x_element = &mut proof_b[0..64].to_vec(); + let b_y_element = &proof_b[64..128]; + let b_y1_element = BigUint::from_bytes_be(&b_y_element[0..32]); + let b_y2_element = BigUint::from_bytes_be(&b_y_element[32..64]); + + let proof_b_is_positive = y_element_is_positive_g2(&b_y1_element, &b_y2_element); + b_x_element[0] = add_bitmask_to_byte(b_x_element[0], proof_b_is_positive); + + let c_x_element = &mut proof_c[0..32].to_vec(); + let c_y_element = BigUint::from_bytes_be(&proof_c[32..64]); + + let proof_c_is_positive = y_element_is_positive_g1(&c_y_element); + c_x_element[0] = add_bitmask_to_byte(c_x_element[0], proof_c_is_positive); + + CompressedProof { + a: a_x_element.clone(), + b: b_x_element.clone(), + c: c_x_element.clone(), + } +} + +pub async fn get_validity_proof( + conn: &DatabaseConnection, + hashes: HashList, +) -> Result { + if hashes.0.is_empty() { + return Err(PhotonApiError::UnexpectedError( + "No hashes provided for proof generation".to_string(), + )); + } + let client = Client::new(); + let prover_endpoint = "http://localhost:3001"; // Change this as necessary + + // Get merkle proofs + let merkle_proofs_with_context = + get_multiple_compressed_account_proofs_helper(conn, hashes.0).await?; + + let mut inputs: Vec = Vec::new(); + for proof in merkle_proofs_with_context.clone() { + let input = HexInputsForProver { + root: hash_to_hex(&proof.root), + path_index: proof.leaf_index, + path_elements: proof.proof.iter().map(|x| hash_to_hex(x)).collect(), + leaf: hash_to_hex(&proof.hash), + }; + inputs.push(input); + } + + let batch_inputs = HexBatchInputsForProver { + input_compressed_accounts: inputs, + }; + + let inclusion_proof_url = format!("{}/prove", prover_endpoint); + let json_body = serde_json::to_string(&batch_inputs).map_err(|e| { + PhotonApiError::UnexpectedError(format!( + "Got an error while serializing the request {}", + e.to_string() + )) + })?; + let res = client + .post(&inclusion_proof_url) + .body(json_body.clone()) + .header("Content-Type", "application/json") + .send() + .await + .map_err(|e| { + PhotonApiError::UnexpectedError(format!("Error fetching proof {}", e.to_string())) + })?; + + if !res.status().is_success() { + return Err(PhotonApiError::UnexpectedError(format!( + "Error fetching proof {}", + res.status().to_string(), + ))); + } + + let text = res.text().await.map_err(|e| { + PhotonApiError::UnexpectedError(format!("Error fetching proof {}", e.to_string())) + })?; + + let proof: GnarkProofJson = serde_json::from_str(&text).map_err(|e| { + PhotonApiError::UnexpectedError(format!( + "Got an error while deserializing the response {}", + e.to_string() + )) + })?; + + let proof = proof_from_json_struct(proof); + let compressed_proof = negate_and_compress_proof(proof); + + Ok(CompressedProofWithContext { + compressed_proof, + roots: merkle_proofs_with_context + .iter() + .map(|x| x.root.clone().to_string()) + .collect(), + root_indices: merkle_proofs_with_context + .iter() + .map(|x| x.root_seq) + .collect(), + leaf_indices: merkle_proofs_with_context + .iter() + .map(|x| x.leaf_index) + .collect(), + leaves: merkle_proofs_with_context + .iter() + .map(|x| x.hash.clone().to_string()) + .collect(), + merkle_trees: merkle_proofs_with_context + .iter() + .map(|x| x.merkle_tree.clone().to_string()) + .collect(), + }) +} diff --git a/src/api/method/mod.rs b/src/api/method/mod.rs index bd5bdf87..98df60e1 100644 --- a/src/api/method/mod.rs +++ b/src/api/method/mod.rs @@ -18,4 +18,5 @@ pub mod get_latest_non_voting_signatures; pub mod get_multiple_compressed_account_proofs; pub mod get_multiple_compressed_accounts; pub mod get_transaction_with_compression_info; +pub mod get_validity_proof; pub mod utils; diff --git a/src/api/rpc_server.rs b/src/api/rpc_server.rs index 7d2f00d2..2d3fcb4e 100644 --- a/src/api/rpc_server.rs +++ b/src/api/rpc_server.rs @@ -268,6 +268,12 @@ fn build_rpc_module( .map_err(Into::into) }, )?; + module.register_async_method("getValidityProof", |rpc_params, rpc_context| async move { + let ApiAndIndexer { api, indexer } = rpc_context.as_ref(); + conditionally_index_latest_blocks(indexer).await; + let payload = rpc_params.parse()?; + api.get_validity_proof(payload).await.map_err(Into::into) + })?; module.register_async_method( "getLatestCompressionSignatures", diff --git a/src/openapi/mod.rs b/src/openapi/mod.rs index 262fbbe4..a03eab8d 100644 --- a/src/openapi/mod.rs +++ b/src/openapi/mod.rs @@ -7,6 +7,8 @@ use crate::api::method::get_multiple_compressed_account_proofs::MerkleProofWithC use crate::api::method::get_multiple_compressed_accounts::AccountList; use crate::api::method::get_transaction_with_compression_info::AccountWithOptionalTokenData; +use crate::api::method::get_validity_proof::CompressedProof; +use crate::api::method::get_validity_proof::CompressedProofWithContext; use crate::api::method::utils::Context; use crate::api::method::utils::Limit; use crate::api::method::utils::PaginatedSignatureInfoList; @@ -78,7 +80,9 @@ const JSON_CONTENT_TYPE: &str = "application/json"; AccountState, AccountWithOptionalTokenData, UnixTimestamp, - UnsignedInteger + UnsignedInteger, + CompressedProof, + CompressedProofWithContext )))] struct ApiDoc; diff --git a/tests/data/transactions/validity_proof/4ETLuGztX78vTrqxV5gucpQeD6ayEYrpA7bfMA9RJ1rKto2Hd6eBBRvYETrwLW5KQf7N8egGBo1mP5PLUAX7T3pm b/tests/data/transactions/validity_proof/4ETLuGztX78vTrqxV5gucpQeD6ayEYrpA7bfMA9RJ1rKto2Hd6eBBRvYETrwLW5KQf7N8egGBo1mP5PLUAX7T3pm new file mode 100644 index 00000000..1798e83b --- /dev/null +++ b/tests/data/transactions/validity_proof/4ETLuGztX78vTrqxV5gucpQeD6ayEYrpA7bfMA9RJ1rKto2Hd6eBBRvYETrwLW5KQf7N8egGBo1mP5PLUAX7T3pm @@ -0,0 +1 @@ +{"slot":33,"transaction":["AaGnQ+CcN7AjnPuLQ/TeNX1A2GfpzahQvhyFBn+XOejRUlrYLE9T7V0r+RfugNjXmF4nBe9aR/UYfM6nsFs/5wqAAQAHCuYKUBfZlcrgaJr6J8AIBPN6lyYp1QkSvf0x13vIb5QLsW59Lug0r1wz/S3TSnQmOY2O4L36K6YLXevV+QUv5zlETX0gTIA9tAHPRSx5dpkRs7dzIqN/ZtYBV6+xXzFBRQMGRm/lIRcy/+ytunLDm+e8jOW7xfcSayxDmzpAAAAAUWwytQBJW8Xd12pFBWuS/CX8e68+yKjmbwbZR2y6uFMOk0MhnnnW7qJcTxu17COx851pv2IOd4Bl3jlDcCIw6wu8D8C7R8ovdMQRLpSrE8+jxjTl3BfqywPNGiPNfnh81/rcnOkzRlVEOWGXY+St8XrqvZsYR5GQUT0IMZiUTD9BbD2wNHXqhcavQ6sML4++KFWFi/g/4Gcx30CKXBmgHQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJqhR+k9yJxLSrhu3HSeNiECqzyNLyc2jtSnRhzvrp4wCAwAFAkBCDwAECgAABQYHCAEECQJXGhCpBxXK8hlLAAAAAAAAAAAAAAAAAQAAAOYKUBfZlcrgaJr6J8AIBPN6lyYp1QkSvf0x13vIb5QLAMqaOwAAAAAAAAEAAAAAAAAAAAABAMqaOwAAAAABAA==","base64"],"meta":{"err":null,"status":{"Ok":null},"fee":5000,"preBalances":[2000000000,0,9496836480,1,1141440,1169280,1141440,0,1141440,1],"postBalances":[999994850,1000000000,9496836630,1,1141440,1169280,1141440,0,1141440,1],"innerInstructions":[{"index":1,"instructions":[{"programIdIndex":9,"accounts":[0,1],"data":"3Bxs3zzLZLuLQEYX","stackHeight":2},{"programIdIndex":8,"accounts":[0,7,5,6,9,2],"data":"5wPdbtbk7M4b3JSHrvzsqaE87aDpZLBDivFc4ZEXBey7DMEGE8kVrdxkszbZXm","stackHeight":2},{"programIdIndex":6,"accounts":[],"data":"LcYsUQdeQKxGUiMMFfD4pZgkFNr3k3cRuoFyrnCmq4CHUtoZLo1JaquAUtFpm39gnKaDf6AKymVRbKiPjBG8pGK4WwYHgA6FEbFpokSfDAxGUH7FFumz84ZeBu92gqqJNXyJaeDmuCMXGPbdNihdYvmaL22jQqq14i6tQcimbuHKPHqKupSSHTR775GPTysVXLUp4Dp7zxJv2UwDH5uHgWbaXCZoFRQd9k1DeGvoZU7HenFJW6kEA9LUqmWrfTEmfb6JuVGAshXRikrbBXnbCvZ8FHXgb26d1urUvYAZSZGaA1X1x4UVLmRhtsSNLhEhKVZGWvULSJkYkbpXFziW78S5Znuk7qyWBHQBGcoTQKQmVzeVfq1196TMy73a5jgiA8Pk4QQwxkSBfp8AqmSKsBMjxiwThw4Uhf1fU7X8esJ8Mqh6Ksno48g9Ucpe961BeM4VLQVtp16SkvKHWARq3aQRASZgPnkBJmWHdfCjdE8Ehu4mQwTxrx2WZFFJTSPZFD4wPa6EiNvV6F9oHjcjE2ieQthX7kJdtyWefkaJXKdqeCnfETcowtU7zqxaqpGjbWcvGJyyb7ostkY7PqRUqwL7PB735dFy2RRwEtNerYgYizdb7pobsK8oVWc6wqQ5pxw7KQJYjJjq6rwU8ujs65avTYWhJFMjaXtDgoBBhgtX8h8zpLiyivqRiBscZhFQtJnYu2xPcPYhBYc6CKZVGokv6QSWqcHvWgmBb5m5kfnnc26TkGEhvr2ZAK6QNtRkn3PFWGeR5AV1WAvnpFWFUQkKLo7m61YYsE5bSV1jXS6ZhiRyatBvgqn7NV9aX9DrzpGMGAvDSWRLATTqKeJmF8grfVg79XLFVNjB4x3Up9eEEwzHrYb3ofj5SjZFyC6euNu4jGaKHs62bqKZE7drouZrxeJGZWq2FzWKXXgjQcbFatXj5NhARTpztUQtLfTABEi9FqDB1aH3uvzYsnxTJ5or9vNf4y3cNN48shAStTb2Zf8so8wJpYUEjtxBqQf6qZ85jwKbd8MKJQKRPgAvnC819Re61RVzZjWE7wiBGH1aw3cEGR4KxbbfpPECLDsfx26cwLtpBGfSi5pFU9ShA7UXHCiDYdmZ6e2WTbcNWBr3TZHwHwjeK4urDyNVj3METcNwcV1213xZ22bQowH2TdehDY8k4JLRBoEJvjm4zSctUuwUYPNpdBxk7GeNR8WPBhx3sMTBcgZGNi9pMeSpJUeZnzSSLb8fwyhVPELsudwXkK7E3ZXNR7TwSt4kLjsCpDEW67FQi5MTUr8ARhZcaU8zZvr6oz8NSD4ZXnArtXfStNbLdcGEXVjNhqoA5HLYwYY9KZafV7u","stackHeight":3},{"programIdIndex":9,"accounts":[0,2],"data":"3Bxs4Rwr9ZeRDby9","stackHeight":3},{"programIdIndex":6,"accounts":[],"data":"1111zaZ9wsp8kxfRBdZ7K1xifEhCTswwgtp5LidkHWPTZKxFCt1VwbDHM6quq6jpVFaJMT4QiAyRRQh8VBnxprBgeogGWjUACyzsfriqW7F6eVJd1eByqj9XsJbnwFi8cPApGfqxf98xjfPvQYdEWnwazdbXFJjGp1UHnHJJ8upQnVYy2dE9momwSVu","stackHeight":2}]}],"logMessages":["Program ComputeBudget111111111111111111111111111111 invoke [1]","Program ComputeBudget111111111111111111111111111111 success","Program 6UqiSPd2mRCTTwkzhcs1M6DGYsqHWd5jiPueX3LwDMXQ invoke [1]","Program log: Instruction: Invoke","Program 11111111111111111111111111111111 invoke [2]","Program 11111111111111111111111111111111 success","Program 5QPEJ5zDsVou9FQS3KCauKswM3VwBEBu4dpL9xTqkWwN invoke [2]","Program log: Instruction: AppendLeavesToMerkleTrees","Program noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV invoke [3]","Program noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV consumed 38 of 925444 compute units","Program noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV success","Program 11111111111111111111111111111111 invoke [3]","Program 11111111111111111111111111111111 success","Program 5QPEJ5zDsVou9FQS3KCauKswM3VwBEBu4dpL9xTqkWwN consumed 55231 of 972893 compute units","Program 5QPEJ5zDsVou9FQS3KCauKswM3VwBEBu4dpL9xTqkWwN success","Program noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV invoke [2]","Program noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV consumed 38 of 915617 compute units","Program noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV success","Program 6UqiSPd2mRCTTwkzhcs1M6DGYsqHWd5jiPueX3LwDMXQ consumed 84740 of 999850 compute units","Program 6UqiSPd2mRCTTwkzhcs1M6DGYsqHWd5jiPueX3LwDMXQ success"],"preTokenBalances":[],"postTokenBalances":[],"rewards":[],"loadedAddresses":{"writable":[],"readonly":[]},"computeUnitsConsumed":84890},"version":0,"blockTime":1715633585} \ No newline at end of file diff --git a/tests/data/transactions/validity_proof/5YJgpi1BePKtFVQjcAqwgbFL4pMGjBpLbnuaXE3kJe2yRJHeEZkFVXQYHk56d5EjPvhkJ6U3F3bryxjbtbD7ZBpL b/tests/data/transactions/validity_proof/5YJgpi1BePKtFVQjcAqwgbFL4pMGjBpLbnuaXE3kJe2yRJHeEZkFVXQYHk56d5EjPvhkJ6U3F3bryxjbtbD7ZBpL new file mode 100644 index 00000000..3b19662a --- /dev/null +++ b/tests/data/transactions/validity_proof/5YJgpi1BePKtFVQjcAqwgbFL4pMGjBpLbnuaXE3kJe2yRJHeEZkFVXQYHk56d5EjPvhkJ6U3F3bryxjbtbD7ZBpL @@ -0,0 +1 @@ +{"slot":33,"transaction":["AeMQboiiOszJ6yHdYo3d7UW9gJySVkuVskfk4OUBFQmRLmDKKJovymyxnHxdCiN4yfMv2iOwrjFNCPnPM5l0owGAAQAHCn/Accwatj8xPCVGUG84/wLEYz7HXKMzG659Ajf4S6DWsW59Lug0r1wz/S3TSnQmOY2O4L36K6YLXevV+QUv5zlETX0gTIA9tAHPRSx5dpkRs7dzIqN/ZtYBV6+xXzFBRQMGRm/lIRcy/+ytunLDm+e8jOW7xfcSayxDmzpAAAAAUWwytQBJW8Xd12pFBWuS/CX8e68+yKjmbwbZR2y6uFMOk0MhnnnW7qJcTxu17COx851pv2IOd4Bl3jlDcCIw6wu8D8C7R8ovdMQRLpSrE8+jxjTl3BfqywPNGiPNfnh81/rcnOkzRlVEOWGXY+St8XrqvZsYR5GQUT0IMZiUTD9BbD2wNHXqhcavQ6sML4++KFWFi/g/4Gcx30CKXBmgHQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAbjwumeqh2MuAbsc3O504C/8ZXEBlEKUoSpfvKDHBneUCAwAFAkBCDwAECgAABQYHCAEECQJXGhCpBxXK8hlLAAAAAAAAAAAAAAAAAQAAAH/Accwatj8xPCVGUG84/wLEYz7HXKMzG659Ajf4S6DWAMqaOwAAAAAAAAEAAAAAAAAAAAABAMqaOwAAAAABAA==","base64"],"meta":{"err":null,"status":{"Ok":null},"fee":5000,"preBalances":[2000000000,0,9496836480,1,1141440,1169280,1141440,0,1141440,1],"postBalances":[999994850,1000000000,9496836630,1,1141440,1169280,1141440,0,1141440,1],"innerInstructions":[{"index":1,"instructions":[{"programIdIndex":9,"accounts":[0,1],"data":"3Bxs3zzLZLuLQEYX","stackHeight":2},{"programIdIndex":8,"accounts":[0,7,5,6,9,2],"data":"5wPdbtbk7M4b3JSHrvziUAzEFxHaf5JSAe9u8Sq2AKaEKAg6cLLJCbspumMfrc","stackHeight":2},{"programIdIndex":6,"accounts":[],"data":"LcYsUQdeQKxGUiMMFfD4pZgkFNr3k3cRuoFyrnCmq4CHUtoZLo1JaquAUtFpkuiezCVGJE2K2LuCfwxjogc1vLTyou5Yg9fg28BdEe9iG7ruAS3GSPE9Mimt97jUFg3NmSrTqYPZASmXDQCwjxhpLyB8sdeGyL3rV85eLEXK9scDDx1R3xfXMW6FSLU7FweRgqnVyUyp5yqomARAPCMbXcd7RGnQApy6t5fVQThb4vfPBrBeoEnPHvVewZrVVL2Lh5Ser37DcMv6LeaeS61dJEVVp9mPjf1bBmGTQzUC7xMUNA3ey1BWxrU4j6M8hwBdUEa1JJhsK89gGuchm8u8wG2TMZ4JBRa4GXhnwuv5XTkTsqtqtBLr8RypQ5sNgpU98JTQzwN7aaHq3LrrkKgFQSkQ8G8ganZQdmhEtWFCDTnwrEhmKshg9iDKR2W8pMymfwE4frNFTcDBLombr32B8BXKa93HtoxLvFxh1rHVHhh7u72diZ9ebRYitE1Upm2MGWvrJtqvqQ9fbez72XQRwGsjABwufEHmzvn3XE1sqJsntPARcadrY2vQa8omexhGCMLCaw8gXJ9Atk3qbXUZ1gybhfzKBFPmdGEPR32h64RFArk1aDUkBc98sDpQo5f7R1SNCW2z6eTZgRFpiynUGazqV5WREzAt163cquWMeJjrdv2LfuN5oSkBsps1DoQV17pVeKVfiWzRJ56ysRXQvkYxSn18qSdaBQRBuBvBi3nh99WewaDdJjHBiuUWyb87Ab3tPqRaxLJwcUV1DPjxjazbZ7ZAujLQSRT1gNFeatXvAGEiMiRFrrWbAmVjjbUS3B9h7rtkpLCFS9KXyhZAwk8yL3W57E7mKsTaNcxe9Rd9u2fLgBUYU3yw4fcJK6R6184NpCcNtmyqNijvPj28qKB3pacHh8Ykb9jzJsnBa44H4v5mAtAQmDVLWNp6jLbtiYhwGiNhQnLU9W8HQjyXLnkm11nhAzmfok12DCe9hUUc8tjBBRpd8e2qdHAxqLdqpzHq2oUUrBJYvPZ5fm845fZiT6Xqx8dCFCoyRyowZXmG69PTP2cK1rHUQeZDWEMDWy7ijZbQUiQZyP1piD41mFNtBmM4jFRPEhHBtL1wv8rVxAdDh1yDdQRjutVeNMUdiKCD17QhGp14XhgD4U1yohxUiV2myvSu7C7udEVch1DCc3wbqfUEH9T1U28SKGYLYpyGDeiM2RxUF4uP2NXdYd79dKNNyY8QVCwMj4QSeMUfDc6WWsnmmFUNL1oUjufSr76NEMBNio6iCZL2G1f5qwcb6SJby8uMgLAfSnTSF2Qsn7ReKzZEfdAxW586J65yjH2hVvX9KKd","stackHeight":3},{"programIdIndex":9,"accounts":[0,2],"data":"3Bxs4Rwr9ZeRDby9","stackHeight":3},{"programIdIndex":6,"accounts":[],"data":"1111zaZ9wWhF428a8xPZo38FyocUWc9TULJbEvHDCB37J2GVrc6gpji4xt2WmCTR5FXyLYmcN9EefGrAykq4MUnc7FC5NZEbUE5evpoA5HJmacNfp7FCsZiuuqickHXosMcPFVm3C9Eg5K9vHDpmwJGcSDoaKHsvTeYbqSyzr7zceKveLTqd6KeEQgP","stackHeight":2}]}],"logMessages":["Program ComputeBudget111111111111111111111111111111 invoke [1]","Program ComputeBudget111111111111111111111111111111 success","Program 6UqiSPd2mRCTTwkzhcs1M6DGYsqHWd5jiPueX3LwDMXQ invoke [1]","Program log: Instruction: Invoke","Program 11111111111111111111111111111111 invoke [2]","Program 11111111111111111111111111111111 success","Program 5QPEJ5zDsVou9FQS3KCauKswM3VwBEBu4dpL9xTqkWwN invoke [2]","Program log: Instruction: AppendLeavesToMerkleTrees","Program noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV invoke [3]","Program noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV consumed 38 of 925444 compute units","Program noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV success","Program 11111111111111111111111111111111 invoke [3]","Program 11111111111111111111111111111111 success","Program 5QPEJ5zDsVou9FQS3KCauKswM3VwBEBu4dpL9xTqkWwN consumed 55231 of 972893 compute units","Program 5QPEJ5zDsVou9FQS3KCauKswM3VwBEBu4dpL9xTqkWwN success","Program noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV invoke [2]","Program noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV consumed 38 of 915617 compute units","Program noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV success","Program 6UqiSPd2mRCTTwkzhcs1M6DGYsqHWd5jiPueX3LwDMXQ consumed 84740 of 999850 compute units","Program 6UqiSPd2mRCTTwkzhcs1M6DGYsqHWd5jiPueX3LwDMXQ success"],"preTokenBalances":[],"postTokenBalances":[],"rewards":[],"loadedAddresses":{"writable":[],"readonly":[]},"computeUnitsConsumed":84890},"version":0,"blockTime":1715632591} \ No newline at end of file diff --git a/tests/data/transactions/validity_proof/N955JL3hSckkfpaB8r2W6vpMQCGXfuzcsYVdkj15zxUxSNUGnArM8KQyjirY1xxfK8QF9tdS79ANdjFfHCDmdR7 b/tests/data/transactions/validity_proof/N955JL3hSckkfpaB8r2W6vpMQCGXfuzcsYVdkj15zxUxSNUGnArM8KQyjirY1xxfK8QF9tdS79ANdjFfHCDmdR7 new file mode 100644 index 00000000..95b2c36c --- /dev/null +++ b/tests/data/transactions/validity_proof/N955JL3hSckkfpaB8r2W6vpMQCGXfuzcsYVdkj15zxUxSNUGnArM8KQyjirY1xxfK8QF9tdS79ANdjFfHCDmdR7 @@ -0,0 +1 @@ +{"slot":33,"transaction":["ARI6xqf4fPn9MzSVoV10sGsbnbHLCzPpzCdXziuLJQ7H4oBBoMCSnXDUVuGwy0DMOLTYJHEHv1AbUjmg7I34tQaAAQAHCrWPTVaR7Z0NUFA0d3RlDTjhFnPX21Ii638QELPOU17AsW59Lug0r1wz/S3TSnQmOY2O4L36K6YLXevV+QUv5zlETX0gTIA9tAHPRSx5dpkRs7dzIqN/ZtYBV6+xXzFBRQMGRm/lIRcy/+ytunLDm+e8jOW7xfcSayxDmzpAAAAAUWwytQBJW8Xd12pFBWuS/CX8e68+yKjmbwbZR2y6uFMOk0MhnnnW7qJcTxu17COx851pv2IOd4Bl3jlDcCIw6wu8D8C7R8ovdMQRLpSrE8+jxjTl3BfqywPNGiPNfnh81/rcnOkzRlVEOWGXY+St8XrqvZsYR5GQUT0IMZiUTD9BbD2wNHXqhcavQ6sML4++KFWFi/g/4Gcx30CKXBmgHQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA+LhdiveS6cw2Mv3Jhv/oVkuXisl2U53EtH/IIq2/aioCAwAFAkBCDwAECgAABQYHCAEECQJXGhCpBxXK8hlLAAAAAAAAAAAAAAAAAQAAALWPTVaR7Z0NUFA0d3RlDTjhFnPX21Ii638QELPOU17AAMqaOwAAAAAAAAEAAAAAAAAAAAABAMqaOwAAAAABAA==","base64"],"meta":{"err":null,"status":{"Ok":null},"fee":5000,"preBalances":[2000000000,0,9496836480,1,1141440,1169280,1141440,0,1141440,1],"postBalances":[999994850,1000000000,9496836630,1,1141440,1169280,1141440,0,1141440,1],"innerInstructions":[{"index":1,"instructions":[{"programIdIndex":9,"accounts":[0,1],"data":"3Bxs3zzLZLuLQEYX","stackHeight":2},{"programIdIndex":8,"accounts":[0,7,5,6,9,2],"data":"5wPdbtbk7M4b3JSHrw1r8BC1dZ2Q2ZhEQvufWDcCoG6vcEWwLt6UpzwYmv79E8","stackHeight":2},{"programIdIndex":6,"accounts":[],"data":"LcYsUQdeQKxGUiMMFfD4pZgkFNr3k3cRuoFyrnCmq4CHUtoZLo1JaquAUtFpmooCimcshg66NUr3KZGZqAwDzdBujhBLcVcHLYqzTLFZjPqaaP36bGmxiuFioyQKtTquhij5V4qusDP1cQZHt6beJGSCkKPiDewstcUG6PKfdwsP5EX2RK4drUHkRNBrVJyf4Po8HAhAQTPFJLLBViEmSMgiYgzfmHU6DRkEWPi5vVZ45CYLGHSKxWVCLC6MQHfx1w7CbJbejB1ocdVZD4kz9QR8WmZBFEKreCHxpD8AzVtZzzDGr7gdd46ZN4Dyt9RCVBhmzp4smN56fbE4LXzdANJ32jh3ctc1VENtLR9fF4W24SBgu55KAqCmgVVYqGKW366jT72V3CzYsKs63R1JWjzhMR6oYoieVwQAHAeCZzDP4YigkXhXYfDjoQn3AViLD2tekgqNsLRL5AoiVtHjki4WqXAsSrsRkVz8n3TCjbo8eDk55uiyZDsM5nuHmZy9eKbpGjhVh4hhRyJRexoVQJ9LkxPcX7tSJd8YSrDHWvLifhgHs769W5ZoFyP59quVhDuRPDBfU8SzkEWWr1X6gcKX2aewLxz8PmM5psPcuyb8jEvkSRgTw5VJ7L3gH8xbLFkPHpdqoKghrE7NMrPtzJPjonMydvQneeANH6UqdjHGd9gDiCqRAxKsBo3gKTkn6txn6G3mZ3mAWi3pdTKDi85o3bHv72vxTEnkyzJQJ1gCDYbbSHERRuNZ6jwYz7ugFLwjT7a8fW6juVu3p2eCCVFHqgLsyLTztzgT8i9MhEkS4WU4W7XBKQobTyocKHVgmK1mgdyPRhjx8bdiT5QbB2vFjoVhWLfSHw6KZ2TqnUDhaj1k2SCKjvAJme8u6TAL9giMU7cNTDprGJQUtGGrfFfNzpC36h42x2EHsBzaiaZhbEjUdLr1yXxLypdRjaCVTqoCpS7J9U5J21yXG1T5i6vJJcswSLA9BtjFEFGBqkkuKdgoMZrABgsXim7byCQBaJHSvSbR5v8mL3sLtngA8hHV9HXtNRRL5tk9ar6bpcfqewmcUR9rqJEPYAYfqnW4C6fyh9BX5Efnwo96NdLfDSq3ky6qCwLFBWKyD8Rg7fJhH66s2SGSgLoysmHDNswiyQKKUHuD7pR4MWsepio3o292gDvNjskeS9QJbY8DmMNRhbC26ogNEpt7LP9jXZyEHspEvwNgXR5eJkU7Yup37nVWjoYHyRfqyvWVmwQpnio6t5UVrBm92K32KvcvAYKkQWrYVQNeA1bBntetp7JWPRs51ejY4Qq6sAC4KwNvsSqBw8rZ8jNE8oatBfBzLkuJ2aHmu5BmHyH","stackHeight":3},{"programIdIndex":9,"accounts":[0,2],"data":"3Bxs4Rwr9ZeRDby9","stackHeight":3},{"programIdIndex":6,"accounts":[],"data":"1111zaZ9z4gww18EChtNRRd6UY6nfCu292wLArUbRHASYrucRzxCqdrgzUakH73Xx7jrA5DpsTABnC2hoW2oShEWWGbGAsxyNeNhjVW783t3vhrYMQFXeUtJwV3HyJ8eg5tVTfxyKrZYHcvmX3tu5wD6m2HLVzZztiGM6PBJzRyU3D3Q4SuqffwrWaj","stackHeight":2}]}],"logMessages":["Program ComputeBudget111111111111111111111111111111 invoke [1]","Program ComputeBudget111111111111111111111111111111 success","Program 6UqiSPd2mRCTTwkzhcs1M6DGYsqHWd5jiPueX3LwDMXQ invoke [1]","Program log: Instruction: Invoke","Program 11111111111111111111111111111111 invoke [2]","Program 11111111111111111111111111111111 success","Program 5QPEJ5zDsVou9FQS3KCauKswM3VwBEBu4dpL9xTqkWwN invoke [2]","Program log: Instruction: AppendLeavesToMerkleTrees","Program noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV invoke [3]","Program noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV consumed 38 of 925444 compute units","Program noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV success","Program 11111111111111111111111111111111 invoke [3]","Program 11111111111111111111111111111111 success","Program 5QPEJ5zDsVou9FQS3KCauKswM3VwBEBu4dpL9xTqkWwN consumed 55231 of 972893 compute units","Program 5QPEJ5zDsVou9FQS3KCauKswM3VwBEBu4dpL9xTqkWwN success","Program noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV invoke [2]","Program noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV consumed 38 of 915617 compute units","Program noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV success","Program 6UqiSPd2mRCTTwkzhcs1M6DGYsqHWd5jiPueX3LwDMXQ consumed 84740 of 999850 compute units","Program 6UqiSPd2mRCTTwkzhcs1M6DGYsqHWd5jiPueX3LwDMXQ success"],"preTokenBalances":[],"postTokenBalances":[],"rewards":[],"loadedAddresses":{"writable":[],"readonly":[]},"computeUnitsConsumed":84890},"version":0,"blockTime":1715634279} \ No newline at end of file diff --git a/tests/integration_tests/e2e_tests.rs b/tests/integration_tests/e2e_tests.rs index 7b10c844..10b52be2 100644 --- a/tests/integration_tests/e2e_tests.rs +++ b/tests/integration_tests/e2e_tests.rs @@ -1,6 +1,7 @@ use function_name::named; use photon_indexer::api::method::get_compressed_accounts_by_owner::GetCompressedAccountsByOwnerRequest; use photon_indexer::api::method::get_transaction_with_compression_info::get_transaction_helper; +use photon_indexer::api::method::get_validity_proof::CompressedProof; use photon_indexer::common::typedefs::serializable_pubkey::SerializablePubkey; use photon_indexer::ingester::index_block; use solana_sdk::pubkey::Pubkey; @@ -46,8 +47,6 @@ async fn test_e2e_mint_and_transfer( ) .await; - let payer_pubkey = - SerializablePubkey::try_from("Eax3ar7Sg53JvTWirvNRNgyxn22LAusNjcmMPdR1zs5t").unwrap(); let bob_pubkey = SerializablePubkey::try_from("6hct2FBjZeQZ7Sscip1Xep3b94jCh7FvtaKqpfhne1Ak").unwrap(); let charles_pubkey = @@ -84,7 +83,6 @@ async fn test_e2e_mint_and_transfer( for (person, pubkey) in [ ("bob", bob_pubkey.clone()), ("charles", charles_pubkey.clone()), - ("payer", payer_pubkey.clone()), ] { let accounts = setup .api @@ -95,20 +93,30 @@ async fn test_e2e_mint_and_transfer( .await .unwrap(); assert_json_snapshot!(format!("{}-{}-accounts", name.clone(), person), accounts); + let hash_list = HashList( + accounts + .value + .items + .iter() + .map(|x| x.account.hash.clone()) + .collect(), + ); let proofs = setup .api - .get_multiple_compressed_account_proofs(HashList( - accounts - .value - .items - .iter() - .map(|x| x.account.hash.clone()) - .collect(), - )) + .get_multiple_compressed_account_proofs(hash_list.clone()) .await .unwrap(); assert_json_snapshot!(format!("{}-{}-proofs", name.clone(), person), proofs); + let mut validity_proof = setup.api.get_validity_proof(hash_list).await.unwrap(); + // The Gnark prover has some randomness. + validity_proof.compressed_proof = CompressedProof::default(); + + assert_json_snapshot!( + format!("{}-{}-validity-proof", name.clone(), person), + validity_proof + ); + let mut cursor = None; let limit = Limit::new(1).unwrap(); let mut signatures = Vec::new(); @@ -288,20 +296,30 @@ async fn test_lamport_transfers( format!("{}-{}-accounts", name.clone(), owner_name), accounts ); + let hash_list = HashList( + accounts + .value + .items + .iter() + .map(|x| x.hash.clone()) + .collect(), + ); let proofs = setup .api - .get_multiple_compressed_account_proofs(HashList( - accounts - .value - .items - .iter() - .map(|x| x.hash.clone()) - .collect(), - )) + .get_multiple_compressed_account_proofs(hash_list.clone()) .await .unwrap(); assert_json_snapshot!(format!("{}-{}-proofs", name.clone(), owner_name), proofs); + let mut validity_proof = setup.api.get_validity_proof(hash_list).await.unwrap(); + // The Gnark prover has some randomness. + validity_proof.compressed_proof = CompressedProof::default(); + + assert_json_snapshot!( + format!("{}-{}-validity-proof", name.clone(), owner_name), + validity_proof + ); + let signatures = setup .api .get_compression_signatures_for_owner(photon_indexer::api::method::get_compression_signatures_for_owner::GetCompressionSignaturesForOwnerRequest { diff --git a/tests/integration_tests/snapshots/integration_tests__e2e_tests__e2e_mint_and_transfer-bob-proofs.snap b/tests/integration_tests/snapshots/integration_tests__e2e_tests__e2e_mint_and_transfer-bob-proofs.snap index ede73335..a948dfd2 100644 --- a/tests/integration_tests/snapshots/integration_tests__e2e_tests__e2e_mint_and_transfer-bob-proofs.snap +++ b/tests/integration_tests/snapshots/integration_tests__e2e_tests__e2e_mint_and_transfer-bob-proofs.snap @@ -34,9 +34,9 @@ expression: proofs "2fomPS2xUPwXxVF8hx5YtMpBHmQKSZKushUiWYsy9Eqx", "3Pi3nRu4fWpnW5rYDAoraX1Q2xDCRQ24Dq8TEY7gaSBn", "3dbMMyehykAriNZ8FMJgPc1N6YSzm9ZfV2HcW9sbaXzP", - "4EE5KQnQ6Tvo78gGhTu8serpJV4srbRhYZ3rdvCiRa5e", - "HscaujxE2kLS7pAYL3pNziJEsQmMVkYhNqj8hNBommE" + "4EE5KQnQ6Tvo78gGhTu8serpJV4srbRhYZ3rdvCiRa5e" ], + "root": "HscaujxE2kLS7pAYL3pNziJEsQmMVkYhNqj8hNBommE", "leafIndex": 3, "hash": "2kQ8YtyQwKVJkwepnWEKGJLTNp89VcVGFj2VpxaSAfot", "merkleTree": "5bdFnXU47QjzGpzHfXnxcEi5WXyxzEAZzd1vrE39bf1W", @@ -69,9 +69,9 @@ expression: proofs "2fomPS2xUPwXxVF8hx5YtMpBHmQKSZKushUiWYsy9Eqx", "3Pi3nRu4fWpnW5rYDAoraX1Q2xDCRQ24Dq8TEY7gaSBn", "3dbMMyehykAriNZ8FMJgPc1N6YSzm9ZfV2HcW9sbaXzP", - "4EE5KQnQ6Tvo78gGhTu8serpJV4srbRhYZ3rdvCiRa5e", - "HscaujxE2kLS7pAYL3pNziJEsQmMVkYhNqj8hNBommE" + "4EE5KQnQ6Tvo78gGhTu8serpJV4srbRhYZ3rdvCiRa5e" ], + "root": "HscaujxE2kLS7pAYL3pNziJEsQmMVkYhNqj8hNBommE", "leafIndex": 6, "hash": "2uSnD5swaYewEshv4YJdQJpQauciUqCAzMeeFmAQZ5Kk", "merkleTree": "5bdFnXU47QjzGpzHfXnxcEi5WXyxzEAZzd1vrE39bf1W", diff --git a/tests/integration_tests/snapshots/integration_tests__e2e_tests__e2e_mint_and_transfer-bob-validity-proof.snap b/tests/integration_tests/snapshots/integration_tests__e2e_tests__e2e_mint_and_transfer-bob-validity-proof.snap new file mode 100644 index 00000000..ba134042 --- /dev/null +++ b/tests/integration_tests/snapshots/integration_tests__e2e_tests__e2e_mint_and_transfer-bob-validity-proof.snap @@ -0,0 +1,31 @@ +--- +source: tests/integration_tests/e2e_tests.rs +expression: validity_proof +--- +{ + "compressedProof": { + "a": [], + "b": [], + "c": [] + }, + "roots": [ + "HscaujxE2kLS7pAYL3pNziJEsQmMVkYhNqj8hNBommE", + "HscaujxE2kLS7pAYL3pNziJEsQmMVkYhNqj8hNBommE" + ], + "rootIndices": [ + 7, + 7 + ], + "leafIndices": [ + 3, + 6 + ], + "leaves": [ + "2kQ8YtyQwKVJkwepnWEKGJLTNp89VcVGFj2VpxaSAfot", + "2uSnD5swaYewEshv4YJdQJpQauciUqCAzMeeFmAQZ5Kk" + ], + "merkleTrees": [ + "5bdFnXU47QjzGpzHfXnxcEi5WXyxzEAZzd1vrE39bf1W", + "5bdFnXU47QjzGpzHfXnxcEi5WXyxzEAZzd1vrE39bf1W" + ] +} diff --git a/tests/integration_tests/snapshots/integration_tests__e2e_tests__e2e_mint_and_transfer-charles-proofs.snap b/tests/integration_tests/snapshots/integration_tests__e2e_tests__e2e_mint_and_transfer-charles-proofs.snap index c76b3911..8771930d 100644 --- a/tests/integration_tests/snapshots/integration_tests__e2e_tests__e2e_mint_and_transfer-charles-proofs.snap +++ b/tests/integration_tests/snapshots/integration_tests__e2e_tests__e2e_mint_and_transfer-charles-proofs.snap @@ -34,9 +34,9 @@ expression: proofs "2fomPS2xUPwXxVF8hx5YtMpBHmQKSZKushUiWYsy9Eqx", "3Pi3nRu4fWpnW5rYDAoraX1Q2xDCRQ24Dq8TEY7gaSBn", "3dbMMyehykAriNZ8FMJgPc1N6YSzm9ZfV2HcW9sbaXzP", - "4EE5KQnQ6Tvo78gGhTu8serpJV4srbRhYZ3rdvCiRa5e", - "HscaujxE2kLS7pAYL3pNziJEsQmMVkYhNqj8hNBommE" + "4EE5KQnQ6Tvo78gGhTu8serpJV4srbRhYZ3rdvCiRa5e" ], + "root": "HscaujxE2kLS7pAYL3pNziJEsQmMVkYhNqj8hNBommE", "leafIndex": 5, "hash": "viWgYSEkYMKzWPpdaHUi92bezKgK5nCcNoXGormrNFN", "merkleTree": "5bdFnXU47QjzGpzHfXnxcEi5WXyxzEAZzd1vrE39bf1W", @@ -69,9 +69,9 @@ expression: proofs "2fomPS2xUPwXxVF8hx5YtMpBHmQKSZKushUiWYsy9Eqx", "3Pi3nRu4fWpnW5rYDAoraX1Q2xDCRQ24Dq8TEY7gaSBn", "3dbMMyehykAriNZ8FMJgPc1N6YSzm9ZfV2HcW9sbaXzP", - "4EE5KQnQ6Tvo78gGhTu8serpJV4srbRhYZ3rdvCiRa5e", - "HscaujxE2kLS7pAYL3pNziJEsQmMVkYhNqj8hNBommE" + "4EE5KQnQ6Tvo78gGhTu8serpJV4srbRhYZ3rdvCiRa5e" ], + "root": "HscaujxE2kLS7pAYL3pNziJEsQmMVkYhNqj8hNBommE", "leafIndex": 4, "hash": "3YzsxMin1Dyjj4BevRUX9tcp7XJEJaXk5cM7CnHuKJxn", "merkleTree": "5bdFnXU47QjzGpzHfXnxcEi5WXyxzEAZzd1vrE39bf1W", diff --git a/tests/integration_tests/snapshots/integration_tests__e2e_tests__e2e_mint_and_transfer-charles-validity-proof.snap b/tests/integration_tests/snapshots/integration_tests__e2e_tests__e2e_mint_and_transfer-charles-validity-proof.snap new file mode 100644 index 00000000..339b5152 --- /dev/null +++ b/tests/integration_tests/snapshots/integration_tests__e2e_tests__e2e_mint_and_transfer-charles-validity-proof.snap @@ -0,0 +1,31 @@ +--- +source: tests/integration_tests/e2e_tests.rs +expression: validity_proof +--- +{ + "compressedProof": { + "a": [], + "b": [], + "c": [] + }, + "roots": [ + "HscaujxE2kLS7pAYL3pNziJEsQmMVkYhNqj8hNBommE", + "HscaujxE2kLS7pAYL3pNziJEsQmMVkYhNqj8hNBommE" + ], + "rootIndices": [ + 7, + 7 + ], + "leafIndices": [ + 5, + 4 + ], + "leaves": [ + "viWgYSEkYMKzWPpdaHUi92bezKgK5nCcNoXGormrNFN", + "3YzsxMin1Dyjj4BevRUX9tcp7XJEJaXk5cM7CnHuKJxn" + ], + "merkleTrees": [ + "5bdFnXU47QjzGpzHfXnxcEi5WXyxzEAZzd1vrE39bf1W", + "5bdFnXU47QjzGpzHfXnxcEi5WXyxzEAZzd1vrE39bf1W" + ] +} diff --git a/tests/integration_tests/snapshots/integration_tests__e2e_tests__lamport_transfers-payer-proofs.snap b/tests/integration_tests/snapshots/integration_tests__e2e_tests__lamport_transfers-payer-proofs.snap index 5be89434..28198d9a 100644 --- a/tests/integration_tests/snapshots/integration_tests__e2e_tests__lamport_transfers-payer-proofs.snap +++ b/tests/integration_tests/snapshots/integration_tests__e2e_tests__lamport_transfers-payer-proofs.snap @@ -34,9 +34,9 @@ expression: proofs "2fomPS2xUPwXxVF8hx5YtMpBHmQKSZKushUiWYsy9Eqx", "3Pi3nRu4fWpnW5rYDAoraX1Q2xDCRQ24Dq8TEY7gaSBn", "3dbMMyehykAriNZ8FMJgPc1N6YSzm9ZfV2HcW9sbaXzP", - "4EE5KQnQ6Tvo78gGhTu8serpJV4srbRhYZ3rdvCiRa5e", - "oBZ8HtbVEkNnC8qiciKc1CjdmjYSCWSpWTbVebsmEFN" + "4EE5KQnQ6Tvo78gGhTu8serpJV4srbRhYZ3rdvCiRa5e" ], + "root": "oBZ8HtbVEkNnC8qiciKc1CjdmjYSCWSpWTbVebsmEFN", "leafIndex": 3, "hash": "227BXTcxfhvpTTAUBu2H3wVaBjqLbXijmsjaSiESBWaE", "merkleTree": "5bdFnXU47QjzGpzHfXnxcEi5WXyxzEAZzd1vrE39bf1W", diff --git a/tests/integration_tests/snapshots/integration_tests__e2e_tests__lamport_transfers-payer-validity-proof.snap b/tests/integration_tests/snapshots/integration_tests__e2e_tests__lamport_transfers-payer-validity-proof.snap new file mode 100644 index 00000000..3774727f --- /dev/null +++ b/tests/integration_tests/snapshots/integration_tests__e2e_tests__lamport_transfers-payer-validity-proof.snap @@ -0,0 +1,26 @@ +--- +source: tests/integration_tests/e2e_tests.rs +expression: validity_proof +--- +{ + "compressedProof": { + "a": [], + "b": [], + "c": [] + }, + "roots": [ + "oBZ8HtbVEkNnC8qiciKc1CjdmjYSCWSpWTbVebsmEFN" + ], + "rootIndices": [ + 5 + ], + "leafIndices": [ + 3 + ], + "leaves": [ + "227BXTcxfhvpTTAUBu2H3wVaBjqLbXijmsjaSiESBWaE" + ], + "merkleTrees": [ + "5bdFnXU47QjzGpzHfXnxcEi5WXyxzEAZzd1vrE39bf1W" + ] +} diff --git a/tests/integration_tests/snapshots/integration_tests__e2e_tests__lamport_transfers-receiver-proofs.snap b/tests/integration_tests/snapshots/integration_tests__e2e_tests__lamport_transfers-receiver-proofs.snap index 500b0860..477d397f 100644 --- a/tests/integration_tests/snapshots/integration_tests__e2e_tests__lamport_transfers-receiver-proofs.snap +++ b/tests/integration_tests/snapshots/integration_tests__e2e_tests__lamport_transfers-receiver-proofs.snap @@ -34,9 +34,9 @@ expression: proofs "2fomPS2xUPwXxVF8hx5YtMpBHmQKSZKushUiWYsy9Eqx", "3Pi3nRu4fWpnW5rYDAoraX1Q2xDCRQ24Dq8TEY7gaSBn", "3dbMMyehykAriNZ8FMJgPc1N6YSzm9ZfV2HcW9sbaXzP", - "4EE5KQnQ6Tvo78gGhTu8serpJV4srbRhYZ3rdvCiRa5e", - "oBZ8HtbVEkNnC8qiciKc1CjdmjYSCWSpWTbVebsmEFN" + "4EE5KQnQ6Tvo78gGhTu8serpJV4srbRhYZ3rdvCiRa5e" ], + "root": "oBZ8HtbVEkNnC8qiciKc1CjdmjYSCWSpWTbVebsmEFN", "leafIndex": 2, "hash": "13berapdgyicVUiET7SAn1EVXjN7SttUXssCUxhw5KKZ", "merkleTree": "5bdFnXU47QjzGpzHfXnxcEi5WXyxzEAZzd1vrE39bf1W", @@ -69,9 +69,9 @@ expression: proofs "2fomPS2xUPwXxVF8hx5YtMpBHmQKSZKushUiWYsy9Eqx", "3Pi3nRu4fWpnW5rYDAoraX1Q2xDCRQ24Dq8TEY7gaSBn", "3dbMMyehykAriNZ8FMJgPc1N6YSzm9ZfV2HcW9sbaXzP", - "4EE5KQnQ6Tvo78gGhTu8serpJV4srbRhYZ3rdvCiRa5e", - "oBZ8HtbVEkNnC8qiciKc1CjdmjYSCWSpWTbVebsmEFN" + "4EE5KQnQ6Tvo78gGhTu8serpJV4srbRhYZ3rdvCiRa5e" ], + "root": "oBZ8HtbVEkNnC8qiciKc1CjdmjYSCWSpWTbVebsmEFN", "leafIndex": 4, "hash": "3tbNrbE827fHKJAhqnRG72riqXr15PPGiaK5MWEkYN38", "merkleTree": "5bdFnXU47QjzGpzHfXnxcEi5WXyxzEAZzd1vrE39bf1W", diff --git a/tests/integration_tests/snapshots/integration_tests__e2e_tests__lamport_transfers-receiver-validity-proof.snap b/tests/integration_tests/snapshots/integration_tests__e2e_tests__lamport_transfers-receiver-validity-proof.snap new file mode 100644 index 00000000..3d67c260 --- /dev/null +++ b/tests/integration_tests/snapshots/integration_tests__e2e_tests__lamport_transfers-receiver-validity-proof.snap @@ -0,0 +1,31 @@ +--- +source: tests/integration_tests/e2e_tests.rs +expression: validity_proof +--- +{ + "compressedProof": { + "a": [], + "b": [], + "c": [] + }, + "roots": [ + "oBZ8HtbVEkNnC8qiciKc1CjdmjYSCWSpWTbVebsmEFN", + "oBZ8HtbVEkNnC8qiciKc1CjdmjYSCWSpWTbVebsmEFN" + ], + "rootIndices": [ + 5, + 5 + ], + "leafIndices": [ + 2, + 4 + ], + "leaves": [ + "13berapdgyicVUiET7SAn1EVXjN7SttUXssCUxhw5KKZ", + "3tbNrbE827fHKJAhqnRG72riqXr15PPGiaK5MWEkYN38" + ], + "merkleTrees": [ + "5bdFnXU47QjzGpzHfXnxcEi5WXyxzEAZzd1vrE39bf1W", + "5bdFnXU47QjzGpzHfXnxcEi5WXyxzEAZzd1vrE39bf1W" + ] +} diff --git a/tests/integration_tests/snapshots/integration_tests__e2e_tests__validity_proof-payer-accounts.snap b/tests/integration_tests/snapshots/integration_tests__e2e_tests__validity_proof-payer-accounts.snap new file mode 100644 index 00000000..a3a8042f --- /dev/null +++ b/tests/integration_tests/snapshots/integration_tests__e2e_tests__validity_proof-payer-accounts.snap @@ -0,0 +1,25 @@ +--- +source: tests/integration_tests/e2e_tests.rs +expression: accounts +--- +{ + "context": { + "slot": 0 + }, + "value": { + "items": [ + { + "hash": "334UZYa441wLV8NSJgo348J7A6Z7aujGWMF3v8WL9bAL", + "address": null, + "data": null, + "owner": "9bgye2ogVR3fb6DCMwbA6A1MT3wmGmFnxPPVt3SQ9yp1", + "lamports": 1000000000, + "tree": "5bdFnXU47QjzGpzHfXnxcEi5WXyxzEAZzd1vrE39bf1W", + "leafIndex": 0, + "seq": 1, + "slotCreated": 0 + } + ], + "cursor": null + } +} diff --git a/tests/integration_tests/snapshots/integration_tests__e2e_tests__validity_proof-payer-validity-proof.snap b/tests/integration_tests/snapshots/integration_tests__e2e_tests__validity_proof-payer-validity-proof.snap new file mode 100644 index 00000000..4f4dad5f --- /dev/null +++ b/tests/integration_tests/snapshots/integration_tests__e2e_tests__validity_proof-payer-validity-proof.snap @@ -0,0 +1,26 @@ +--- +source: tests/integration_tests/e2e_tests.rs +expression: validity_proof +--- +{ + "compressedProof": { + "a": [], + "b": [], + "c": [] + }, + "roots": [ + "4B9KobBhDsbtegrWd22VVAcU83tLWbLo8yrKFc9spEEs" + ], + "rootIndices": [ + 1 + ], + "leafIndices": [ + 0 + ], + "leaves": [ + "4AiUmKwenqJpsvcj4TAoqJw3gnrBRkTpGXsSyrNUu4Xr" + ], + "merkleTrees": [ + "5bdFnXU47QjzGpzHfXnxcEi5WXyxzEAZzd1vrE39bf1W" + ] +}