diff --git a/artifacts/lee/privacy_preserving_circuit/privacy_preserving_circuit.bin b/artifacts/lee/privacy_preserving_circuit/privacy_preserving_circuit.bin index 54ac2c2a2..d87538d5c 100644 Binary files a/artifacts/lee/privacy_preserving_circuit/privacy_preserving_circuit.bin and b/artifacts/lee/privacy_preserving_circuit/privacy_preserving_circuit.bin differ diff --git a/artifacts/lez/programs/amm.bin b/artifacts/lez/programs/amm.bin index 843ed4f75..1f9a8bf7c 100644 Binary files a/artifacts/lez/programs/amm.bin and b/artifacts/lez/programs/amm.bin differ diff --git a/artifacts/lez/programs/associated_token_account.bin b/artifacts/lez/programs/associated_token_account.bin index 3129f7206..89b286222 100644 Binary files a/artifacts/lez/programs/associated_token_account.bin and b/artifacts/lez/programs/associated_token_account.bin differ diff --git a/artifacts/lez/programs/authenticated_transfer.bin b/artifacts/lez/programs/authenticated_transfer.bin index ede942730..f43eafaa0 100644 Binary files a/artifacts/lez/programs/authenticated_transfer.bin and b/artifacts/lez/programs/authenticated_transfer.bin differ diff --git a/artifacts/lez/programs/bridge.bin b/artifacts/lez/programs/bridge.bin index fe8eaa414..39aa47927 100644 Binary files a/artifacts/lez/programs/bridge.bin and b/artifacts/lez/programs/bridge.bin differ diff --git a/artifacts/lez/programs/bridge_lock.bin b/artifacts/lez/programs/bridge_lock.bin index 0d405eee2..6d162c158 100644 Binary files a/artifacts/lez/programs/bridge_lock.bin and b/artifacts/lez/programs/bridge_lock.bin differ diff --git a/artifacts/lez/programs/clock.bin b/artifacts/lez/programs/clock.bin index bf44d69c6..185332614 100644 Binary files a/artifacts/lez/programs/clock.bin and b/artifacts/lez/programs/clock.bin differ diff --git a/artifacts/lez/programs/cross_zone_inbox.bin b/artifacts/lez/programs/cross_zone_inbox.bin index 2e8d2051e..97c019b08 100644 Binary files a/artifacts/lez/programs/cross_zone_inbox.bin and b/artifacts/lez/programs/cross_zone_inbox.bin differ diff --git a/artifacts/lez/programs/cross_zone_outbox.bin b/artifacts/lez/programs/cross_zone_outbox.bin index 632e4fdd5..bd78dee52 100644 Binary files a/artifacts/lez/programs/cross_zone_outbox.bin and b/artifacts/lez/programs/cross_zone_outbox.bin differ diff --git a/artifacts/lez/programs/faucet.bin b/artifacts/lez/programs/faucet.bin index aaa58ef69..1d1fbd2af 100644 Binary files a/artifacts/lez/programs/faucet.bin and b/artifacts/lez/programs/faucet.bin differ diff --git a/artifacts/lez/programs/pinata.bin b/artifacts/lez/programs/pinata.bin index ff58cea27..54cc466a3 100644 Binary files a/artifacts/lez/programs/pinata.bin and b/artifacts/lez/programs/pinata.bin differ diff --git a/artifacts/lez/programs/pinata_token.bin b/artifacts/lez/programs/pinata_token.bin index 438ef82d4..062ddc0d9 100644 Binary files a/artifacts/lez/programs/pinata_token.bin and b/artifacts/lez/programs/pinata_token.bin differ diff --git a/artifacts/lez/programs/ping_receiver.bin b/artifacts/lez/programs/ping_receiver.bin index c1eec6912..774e73f65 100644 Binary files a/artifacts/lez/programs/ping_receiver.bin and b/artifacts/lez/programs/ping_receiver.bin differ diff --git a/artifacts/lez/programs/ping_sender.bin b/artifacts/lez/programs/ping_sender.bin index 5d0660435..8f320b58f 100644 Binary files a/artifacts/lez/programs/ping_sender.bin and b/artifacts/lez/programs/ping_sender.bin differ diff --git a/artifacts/lez/programs/sequencer_stake.bin b/artifacts/lez/programs/sequencer_stake.bin index 9dcc9cc5f..0cf1b076c 100644 Binary files a/artifacts/lez/programs/sequencer_stake.bin and b/artifacts/lez/programs/sequencer_stake.bin differ diff --git a/artifacts/lez/programs/token.bin b/artifacts/lez/programs/token.bin index 7dc4525a6..6453a84ae 100644 Binary files a/artifacts/lez/programs/token.bin and b/artifacts/lez/programs/token.bin differ diff --git a/artifacts/lez/programs/vault.bin b/artifacts/lez/programs/vault.bin index 07031e875..293e67e03 100644 Binary files a/artifacts/lez/programs/vault.bin and b/artifacts/lez/programs/vault.bin differ diff --git a/artifacts/lez/programs/wrapped_token.bin b/artifacts/lez/programs/wrapped_token.bin index 88c27166a..9021e9567 100644 Binary files a/artifacts/lez/programs/wrapped_token.bin and b/artifacts/lez/programs/wrapped_token.bin differ diff --git a/lee/privacy_preserving_circuit/src/output.rs b/lee/privacy_preserving_circuit/src/output.rs index 01d3cf7d9..2ccf3e476 100644 --- a/lee/privacy_preserving_circuit/src/output.rs +++ b/lee/privacy_preserving_circuit/src/output.rs @@ -24,7 +24,6 @@ pub fn compute_circuit_output( states_iter, ) = execution_state.into_parts(); let mut output = PrivacyPreservingCircuitOutput { - public_pre_states: Vec::new(), public_diffs, private_actions: Vec::new(), block_validity_window, @@ -43,7 +42,9 @@ pub fn compute_circuit_output( { match account_identity { InputAccountIdentity::Public => { - output.public_pre_states.push(pre_state); + // No longer exported: `pre_state` for public accounts is now witness-only. This + // account's effect is captured entirely by `execution_state`'s `public_diffs` + // (already merged into `output` above via `into_parts`). } InputAccountIdentity::Private(PrivateWitness { vpk, diff --git a/lee/state_machine/core/src/circuit_io.rs b/lee/state_machine/core/src/circuit_io.rs index b3fff0208..584802ea9 100644 --- a/lee/state_machine/core/src/circuit_io.rs +++ b/lee/state_machine/core/src/circuit_io.rs @@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize}; use crate::{ AuthorizationSecretKey, Commitment, CommitmentSetDigest, Identifier, MembershipProof, Nullifier, NullifierPublicKey, NullifierSecretKey, - account::{AccountId, AccountWithMetadata, Data}, + account::{AccountId, Data}, encryption::{EncryptedAccountData, ViewTag, ViewingPublicKey}, program::{ AccountDiffOutput, BlockValidityWindow, PdaSeed, ProgramId, ProgramOutput, @@ -194,9 +194,6 @@ pub struct PublicDiff { #[derive(Serialize, Deserialize)] #[cfg_attr(any(feature = "host", test), derive(Debug, PartialEq, Eq, Default))] pub struct PrivacyPreservingCircuitOutput { - /// What the circuit witnessed as each public account's pre-state, used only to check the - /// proof is internally consistent — never reconciled against live state. - pub public_pre_states: Vec, pub public_diffs: Vec, pub private_actions: Vec, pub block_validity_window: BlockValidityWindow, @@ -240,35 +237,13 @@ mod tests { use super::*; use crate::{ Commitment, Nullifier, - account::{Account, AccountDiff, AccountId, AccountWithMetadata, BalanceDiff, Nonce}, + account::{Account, AccountDiff, AccountId, BalanceDiff}, encryption::{Ciphertext, EphemeralPublicKey}, }; #[test] fn privacy_preserving_circuit_output_to_bytes_is_compatible_with_from_slice() { let output = PrivacyPreservingCircuitOutput { - public_pre_states: vec![ - AccountWithMetadata::new( - Account { - program_owner: [1, 2, 3, 4, 5, 6, 7, 8].into(), - balance: 12_345_678_901_234_567_890, - data: b"test data".to_vec().try_into().unwrap(), - nonce: Nonce(0xFFFF_FFFF_FFFF_FFFE), - }, - true, - AccountId::new([0; 32]), - ), - AccountWithMetadata::new( - Account { - program_owner: [9, 9, 9, 8, 8, 8, 7, 7].into(), - balance: 123_123_123_456_456_567_112, - data: b"test data".to_vec().try_into().unwrap(), - nonce: Nonce(9_999_999_999_999_999_999_999), - }, - false, - AccountId::new([1; 32]), - ), - ], public_diffs: vec![ PublicDiff { account_id: AccountId::new([0; 32]), diff --git a/lee/state_machine/src/privacy_preserving_transaction/circuit/tests.rs b/lee/state_machine/src/privacy_preserving_transaction/circuit/tests.rs index a6f2db6e4..3979dd439 100644 --- a/lee/state_machine/src/privacy_preserving_transaction/circuit/tests.rs +++ b/lee/state_machine/src/privacy_preserving_transaction/circuit/tests.rs @@ -101,9 +101,6 @@ fn prove_privacy_preserving_execution_circuit_public_and_private_pre_accounts() assert!(proof.is_valid_for(&output)); - let [sender_pre] = output.public_pre_states.try_into().unwrap(); - assert_eq!(sender_pre, expected_sender_pre); - // The sender's `AccountDiff`, not a materialized post-state — this is the whole point of // `AccountDiff`: the circuit never commits to a specific public post-state, only to what // changed, so the sequencer can replay it against whatever the account's live state is by @@ -236,7 +233,6 @@ fn prove_privacy_preserving_execution_circuit_fully_private() { .unwrap(); assert!(proof.is_valid_for(&output)); - assert!(output.public_pre_states.is_empty()); assert!(output.public_diffs.is_empty()); let sender_nullifier = expected_new_nullifiers[0].0; let recipient_nullifier = expected_new_nullifiers[1].0; diff --git a/lee/state_machine/src/privacy_preserving_transaction/message.rs b/lee/state_machine/src/privacy_preserving_transaction/message.rs index 651f2db00..28e1b05df 100644 --- a/lee/state_machine/src/privacy_preserving_transaction/message.rs +++ b/lee/state_machine/src/privacy_preserving_transaction/message.rs @@ -1,8 +1,10 @@ +use std::collections::HashSet; + use borsh::{BorshDeserialize, BorshSerialize}; use lee_core::{ Commitment, CommitmentSetDigest, Nullifier, PrivacyPreservingCircuitOutput, PrivateAction, PublicDiff, - account::{AccountWithMetadata, Nonce}, + account::Nonce, program::{BlockValidityWindow, TimestampValidityWindow}, }; pub use lee_core::{EncryptedAccountData, ViewTag}; @@ -14,7 +16,8 @@ const PREFIX: &[u8; 32] = b"/LEE/v0.3/Message/Privacy/\x00\x00\x00\x00\x00\x00"; #[derive(Clone, Default, PartialEq, Eq, BorshSerialize, BorshDeserialize)] pub struct Message { - pub public_pre_states: Vec, + /// Raw, per-call, unaggregated diffs for public accounts. See + /// `PrivacyPreservingCircuitOutput::public_diffs`. pub public_diffs: Vec, pub nonces: Vec, pub private_actions: Vec, @@ -46,7 +49,6 @@ impl std::fmt::Debug for Message { }) .collect(); f.debug_struct("Message") - .field("public_pre_states", &self.public_pre_states) .field("public_diffs", &self.public_diffs) .field("nonces", &self.nonces) .field("private_actions", &private_actions) @@ -61,7 +63,6 @@ impl Message { #[must_use] pub fn from_circuit_output(nonces: Vec, output: PrivacyPreservingCircuitOutput) -> Self { Self { - public_pre_states: output.public_pre_states, public_diffs: output.public_diffs, nonces, private_actions: output.private_actions, @@ -87,15 +88,17 @@ impl Message { .collect() } - /// The unique set of public accounts this transaction touches — sourced from - /// `public_pre_states`, not `public_diffs`, since a diff can legitimately repeat an account - /// (multiple calls touching the same account within one transaction), while a pre-state is - /// witnessed exactly once per account. + /// The unique set of public accounts this transaction touches. `public_diffs` can + /// legitimately repeat an account (multiple calls touching the same account within one + /// transaction), so this dedups — callers rely on "each affected account listed once" (see + /// `PrivacyPreservingTransaction::affected_public_account_ids`). #[must_use] pub fn public_account_ids(&self) -> Vec { - self.public_pre_states + let mut seen = HashSet::new(); + self.public_diffs .iter() - .map(|pre| pre.account_id) + .map(|diff| diff.account_id) + .filter(|id| seen.insert(*id)) .collect() } @@ -120,7 +123,7 @@ pub mod tests { use lee_core::{ Commitment, EncryptionScheme, EphemeralPublicKey, EphemeralSecretKey, Nullifier, NullifierPublicKey, PrivateAccountKind, PrivateAction, PublicDiff, SharedSecretKey, - account::{Account, AccountDiff, AccountId, AccountWithMetadata, BalanceDiff, Nonce}, + account::{Account, AccountDiff, AccountId, BalanceDiff, Nonce}, encryption::{Ciphertext, ViewingPublicKey}, program::{AccountDiffOutput, BlockValidityWindow, TimestampValidityWindow}, }; @@ -151,11 +154,6 @@ pub mod tests { let public_account_id = AccountId::new([1; 32]); Message { - public_pre_states: vec![AccountWithMetadata::new( - Account::default(), - false, - public_account_id, - )], public_diffs: vec![PublicDiff { account_id: public_account_id, executing_program_id: [1, 2, 3, 4, 5, 6, 7, 8], @@ -185,7 +183,6 @@ pub mod tests { #[test] fn hash_privacy_pinned() { let msg = Message { - public_pre_states: vec![], public_diffs: vec![], nonces: vec![Nonce(5)], private_actions: vec![], @@ -201,7 +198,6 @@ pub mod tests { let unbounded_window_bytes: &[u8] = &[0, 0]; let expected_borsh_vec: Vec = [ - empty_vec_bytes, // public_pre_states empty_vec_bytes, // public_diffs nonces_bytes, empty_vec_bytes, // private_actions diff --git a/lee/state_machine/src/state/tests/circuit.rs b/lee/state_machine/src/state/tests/circuit.rs index b77f85b2d..4f1511dcd 100644 --- a/lee/state_machine/src/state/tests/circuit.rs +++ b/lee/state_machine/src/state/tests/circuit.rs @@ -448,7 +448,6 @@ fn private_pda_claim_succeeds() { let (output, _proof) = result.expect("private PDA claim should succeed"); assert_eq!(output.private_actions.len(), 1); - assert!(output.public_pre_states.is_empty()); assert!(output.public_diffs.is_empty()); } diff --git a/lee/state_machine/src/validated_state_diff/mod.rs b/lee/state_machine/src/validated_state_diff/mod.rs index 5eaf1a5b8..0f23439e8 100644 --- a/lee/state_machine/src/validated_state_diff/mod.rs +++ b/lee/state_machine/src/validated_state_diff/mod.rs @@ -360,7 +360,6 @@ impl ValidatedStateDiff { let witness_set = &tx.witness_set; let commitments = message.commitments(); let nullifiers = message.nullifiers(); - let public_account_ids = message.public_account_ids(); // 1. Commitments or nullifiers are non empty ensure!( @@ -370,12 +369,6 @@ impl ValidatedStateDiff { ) ); - // 2. Check there are no duplicate account_ids in the public_account_ids list. - ensure!( - n_unique(&public_account_ids) == public_account_ids.len(), - LeeError::InvalidInput("Duplicate account_ids found in message".into()) - ); - // Check there are no duplicate nullifiers in the new_nullifiers list ensure!( n_unique(&nullifiers.iter().map(|(n, _)| n).collect::>()) == nullifiers.len(), @@ -388,7 +381,7 @@ impl ValidatedStateDiff { LeeError::InvalidInput("Duplicate commitments found in message".into()) ); - // 3. Nonce checks and Valid signatures + // 2. Nonce checks and Valid signatures // Check exactly one nonce is provided for each signature ensure!( message.nonces.len() == witness_set.signatures_and_public_keys.len(), @@ -434,13 +427,13 @@ impl ValidatedStateDiff { ) ); - // 4. Proof verification + // 3. Proof verification check_privacy_preserving_circuit_proof_is_valid(&witness_set.proof, message)?; - // 5. Commitment freshness + // 4. Commitment freshness state.check_commitments_are_new(&commitments)?; - // 6. Nullifier uniqueness + // 5. Nullifier uniqueness state.check_nullifiers_are_valid(&nullifiers)?; // Replay each public diff against live state, one at a time — never trusting anything @@ -619,18 +612,15 @@ fn authenticate_public_transaction_signers( Ok(signer_account_ids) } -/// Verifies the proof against exactly what the circuit witnessed and output — deliberately *not* -/// reconciled against live sequencer state for public accounts. Reconciling `public_pre_states` -/// against live state here is exactly the race condition `AccountDiff` exists to avoid: it would -/// tie this proof's validity to a specific public-account snapshot, invalidating it the moment -/// that account changes before this transaction is processed. Materialization (which *does* use -/// live state) happens separately, later, via `message.public_diffs`. +/// Verifies the proof against exactly what the circuit witnessed and output. Public account +/// pre-states are a circuit-internal secret witness never committed to the journal at all, so +/// there is nothing here to reconcile against live state in the first place. Materialization +/// (which *does* use live state) happens separately, later, via `message.public_diffs`. fn check_privacy_preserving_circuit_proof_is_valid( proof: &Proof, message: &Message, ) -> Result<(), LeeError> { let output = PrivacyPreservingCircuitOutput { - public_pre_states: message.public_pre_states.clone(), public_diffs: message.public_diffs.clone(), private_actions: message.private_actions.clone(), block_validity_window: message.block_validity_window, diff --git a/lee/state_machine/src/validated_state_diff/tests.rs b/lee/state_machine/src/validated_state_diff/tests.rs index 1dd8827e4..bdb84f8b4 100644 --- a/lee/state_machine/src/validated_state_diff/tests.rs +++ b/lee/state_machine/src/validated_state_diff/tests.rs @@ -438,7 +438,6 @@ fn privacy_garbage_proof_is_rejected() { )); let commitment = Commitment::new(&account_id, &Account::default()); let message = Message { - public_pre_states: vec![], public_diffs: vec![], nonces: vec![], private_actions: vec![PrivateAction { @@ -534,7 +533,7 @@ fn privacy_transaction_survives_public_state_changing_after_proving() { }, }), ], - &program.clone().into(), + &program.into(), ) .expect("execute_and_prove should succeed"); diff --git a/lez/explorer_service/src/components/transaction_details.rs b/lez/explorer_service/src/components/transaction_details.rs index 8f33c43ea..26874829a 100644 --- a/lez/explorer_service/src/components/transaction_details.rs +++ b/lez/explorer_service/src/components/transaction_details.rs @@ -68,8 +68,7 @@ pub fn PrivacyPreservingTxDetails(tx: PrivacyPreservingTransaction) -> impl Into witness_set, } = tx; let PrivacyPreservingMessage { - public_pre_states, - public_diffs: _, + public_diffs, nonces, private_actions, block_validity_window, @@ -77,10 +76,14 @@ pub fn PrivacyPreservingTxDetails(tx: PrivacyPreservingTransaction) -> impl Into signer_account_ids: _, } = message; let private_action_count = private_actions.len(); - let public_account_ids: Vec<_> = public_pre_states - .into_iter() - .map(|pre_state| pre_state.account_id) - .collect(); + let public_account_ids: Vec<_> = { + let mut seen = std::collections::HashSet::new(); + public_diffs + .into_iter() + .map(|diff| diff.account_id) + .filter(|id| seen.insert(*id)) + .collect() + }; let public_account_count = public_account_ids.len(); let WitnessSet { signatures_and_public_keys: _, diff --git a/lez/explorer_service/src/components/transaction_preview.rs b/lez/explorer_service/src/components/transaction_preview.rs index ec60fb23e..e9f47e2ba 100644 --- a/lez/explorer_service/src/components/transaction_preview.rs +++ b/lez/explorer_service/src/components/transaction_preview.rs @@ -38,9 +38,14 @@ pub fn TransactionPreview(transaction: Transaction) -> impl IntoView { message, witness_set: _, } = tx; + let public_account_count: std::collections::HashSet<_> = message + .public_diffs + .iter() + .map(|diff| diff.account_id) + .collect(); format!( "{} public accounts, {} commitments", - message.public_pre_states.len(), + public_account_count.len(), message.private_actions.len() ) } diff --git a/lez/indexer/ffi/indexer_ffi.h b/lez/indexer/ffi/indexer_ffi.h index 9e2c6cd65..f9449ae53 100644 --- a/lez/indexer/ffi/indexer_ffi.h +++ b/lez/indexer/ffi/indexer_ffi.h @@ -195,50 +195,6 @@ typedef struct FfiPublicTransactionBody { FfiSignaturePubKeyList witness_set; } FfiPublicTransactionBody; -/** - * Account data structure - C-compatible version of lee Account. - * - * Note: `balance` and `nonce` are u128 values represented as little-endian - * byte arrays since C doesn't have native u128 support. - */ -typedef struct FfiAccount { - struct FfiBytes32 program_owner; - /** - * Balance as little-endian [u8; 16]. - */ - struct FfiU128 balance; - /** - * Pointer to account data bytes. - */ - uint8_t *data; - /** - * Length of account data. - */ - uintptr_t data_len; - /** - * Capacity of account data. - */ - uintptr_t data_cap; - /** - * Nonce as little-endian [u8; 16]. - */ - struct FfiU128 nonce; -} FfiAccount; - -typedef struct FfiAccountWithMetadata { - struct FfiAccount account; - bool is_authorized; - FfiAccountId account_id; -} FfiAccountWithMetadata; - -typedef struct FfiVec_FfiAccountWithMetadata { - struct FfiAccountWithMetadata *entries; - uintptr_t len; - uintptr_t capacity; -} FfiVec_FfiAccountWithMetadata; - -typedef struct FfiVec_FfiAccountWithMetadata FfiPublicPreStateList; - /** * C-compatible tagged `BalanceDiff`: `is_sub` selects `Sub` over `Add`. */ @@ -321,7 +277,6 @@ typedef struct FfiVec_FfiPrivateAction { typedef struct FfiVec_FfiPrivateAction FfiPrivateActionList; typedef struct FfiPrivacyPreservingMessage { - FfiPublicPreStateList public_pre_states; FfiPublicDiffList public_diffs; FfiNonceList nonces; FfiPrivateActionList private_actions; @@ -389,6 +344,36 @@ typedef struct PointerResult_FfiBlockOpt__OperationStatus { enum OperationStatus error; } PointerResult_FfiBlockOpt__OperationStatus; +/** + * Account data structure - C-compatible version of lee Account. + * + * Note: `balance` and `nonce` are u128 values represented as little-endian + * byte arrays since C doesn't have native u128 support. + */ +typedef struct FfiAccount { + struct FfiProgramId program_owner; + /** + * Balance as little-endian [u8; 16]. + */ + struct FfiU128 balance; + /** + * Pointer to account data bytes. + */ + uint8_t *data; + /** + * Length of account data. + */ + uintptr_t data_len; + /** + * Capacity of account data. + */ + uintptr_t data_cap; + /** + * Nonce as little-endian [u8; 16]. + */ + struct FfiU128 nonce; +} FfiAccount; + /** * Simple wrapper around a pointer to a value or an error. * diff --git a/lez/indexer/ffi/src/api/types/transaction.rs b/lez/indexer/ffi/src/api/types/transaction.rs index 9e9ec4e2b..b7bbd2ae6 100644 --- a/lez/indexer/ffi/src/api/types/transaction.rs +++ b/lez/indexer/ffi/src/api/types/transaction.rs @@ -1,7 +1,7 @@ use indexer_service_protocol::{ - AccountDiff, AccountDiffOutput, AccountId, AccountWithMetadata, BalanceDiff, Ciphertext, Claim, - Commitment, CommitmentSetDigest, EncryptedAccountData, EphemeralPublicKey, HashType, Nullifier, - PdaSeed, PrivacyPreservingMessage, PrivacyPreservingTransaction, PrivateAction, + AccountDiff, AccountDiffOutput, AccountId, BalanceDiff, Ciphertext, Claim, Commitment, + CommitmentSetDigest, EncryptedAccountData, EphemeralPublicKey, HashType, Nullifier, PdaSeed, + PrivacyPreservingMessage, PrivacyPreservingTransaction, PrivateAction, ProgramDeploymentMessage, ProgramDeploymentTransaction, ProgramId, Proof, PublicDiff, PublicKey, PublicMessage, PublicTransaction, Signature, Transaction, ValidityWindow, WitnessSet, @@ -10,11 +10,9 @@ use indexer_service_protocol::{ use crate::api::types::{ FfiAccountId, FfiBytes32, FfiHashType, FfiOption, FfiProgramId, FfiPublicKey, FfiSignature, FfiU128, FfiVec, - account::FfiAccount, vectors::{ FfiAccountIdList, FfiInstructionDataList, FfiNonceList, FfiPrivateActionList, - FfiProgramDeploymentMessage, FfiProof, FfiPublicDiffList, FfiPublicPreStateList, - FfiSignaturePubKeyList, FfiVecU8, + FfiProgramDeploymentMessage, FfiProof, FfiPublicDiffList, FfiSignaturePubKeyList, FfiVecU8, }, }; @@ -159,10 +157,6 @@ impl From> for PrivacyPreservingTransaction { Self { hash: HashType(value.hash.data), message: PrivacyPreservingMessage { - public_pre_states: { - let std_vec: Vec<_> = value.message.public_pre_states.into(); - std_vec.into_iter().map(Into::into).collect() - }, public_diffs: { let std_vec: Vec<_> = value.message.public_diffs.into(); std_vec.into_iter().map(Into::into).collect() @@ -224,46 +218,6 @@ impl From> for PrivacyPreservingTransaction { } } -#[repr(C)] -pub struct FfiAccountWithMetadata { - pub account: FfiAccount, - pub is_authorized: bool, - pub account_id: FfiAccountId, -} - -impl From for FfiAccountWithMetadata { - fn from(value: AccountWithMetadata) -> Self { - let AccountWithMetadata { - account, - is_authorized, - account_id, - } = value; - let account: lee::Account = account.try_into().expect("Source is in blocks, must fit"); - Self { - account: account.into(), - is_authorized, - account_id: account_id.into(), - } - } -} - -impl From for AccountWithMetadata { - fn from(value: FfiAccountWithMetadata) -> Self { - let FfiAccountWithMetadata { - account, - is_authorized, - account_id, - } = value; - Self { - account: account.into(), - is_authorized, - account_id: AccountId { - value: account_id.data, - }, - } - } -} - /// C-compatible tagged `BalanceDiff`: `is_sub` selects `Sub` over `Add`. #[repr(C)] pub struct FfiBalanceDiff { @@ -470,7 +424,6 @@ impl From for FfiPrivateAction { #[repr(C)] pub struct FfiPrivacyPreservingMessage { - pub public_pre_states: FfiPublicPreStateList, pub public_diffs: FfiPublicDiffList, pub nonces: FfiNonceList, pub private_actions: FfiPrivateActionList, @@ -482,7 +435,6 @@ pub struct FfiPrivacyPreservingMessage { impl From for FfiPrivacyPreservingMessage { fn from(value: PrivacyPreservingMessage) -> Self { let PrivacyPreservingMessage { - public_pre_states, public_diffs, nonces, private_actions, @@ -492,11 +444,6 @@ impl From for FfiPrivacyPreservingMessage { } = value; Self { - public_pre_states: public_pre_states - .into_iter() - .map(Into::into) - .collect::>() - .into(), public_diffs: public_diffs .into_iter() .map(Into::into) diff --git a/lez/indexer/ffi/src/api/types/vectors.rs b/lez/indexer/ffi/src/api/types/vectors.rs index 32c5f468e..e05dcaf5c 100644 --- a/lez/indexer/ffi/src/api/types/vectors.rs +++ b/lez/indexer/ffi/src/api/types/vectors.rs @@ -1,9 +1,6 @@ use crate::api::types::{ FfiAccountId, FfiNonce, FfiVec, - transaction::{ - FfiAccountWithMetadata, FfiPrivateAction, FfiPublicDiff, FfiSignaturePubKeyEntry, - FfiTransaction, - }, + transaction::{FfiPrivateAction, FfiPublicDiff, FfiSignaturePubKeyEntry, FfiTransaction}, }; pub type FfiVecU8 = FfiVec; @@ -22,8 +19,6 @@ pub type FfiProof = FfiVecU8; pub type FfiProgramDeploymentMessage = FfiVecU8; -pub type FfiPublicPreStateList = FfiVec; - pub type FfiPublicDiffList = FfiVec; pub type FfiPrivateActionList = FfiVec; diff --git a/lez/indexer/service/protocol/src/convert.rs b/lez/indexer/service/protocol/src/convert.rs index 6c9c57461..eaf9f8b15 100644 --- a/lez/indexer/service/protocol/src/convert.rs +++ b/lez/indexer/service/protocol/src/convert.rs @@ -3,11 +3,11 @@ use lee_core::account::Nonce; use crate::{ - Account, AccountDiff, AccountDiffOutput, AccountId, AccountWithMetadata, BalanceDiff, - BedrockStatus, Block, BlockBody, BlockHeader, BlockIngestError, Ciphertext, Claim, Commitment, - CommitmentSetDigest, CrossZoneHalt, Data, EncryptedAccountData, EphemeralPublicKey, HashType, - IndexerStatus, IndexerSyncState, Nullifier, PdaSeed, PeerHealth, PeerStatus, - PrivacyPreservingMessage, PrivacyPreservingTransaction, PrivateAction, + Account, AccountDiff, AccountDiffOutput, AccountId, BalanceDiff, BedrockStatus, Block, + BlockBody, BlockHeader, BlockIngestError, Ciphertext, Claim, Commitment, CommitmentSetDigest, + CrossZoneHalt, Data, EncryptedAccountData, EphemeralPublicKey, HashType, IndexerStatus, + IndexerSyncState, Nullifier, PdaSeed, PeerHealth, PeerStatus, PrivacyPreservingMessage, + PrivacyPreservingTransaction, PrivateAction, ProgramDeploymentMessage, ProgramDeploymentTransaction, ProgramId, Proof, PublicDiff, PublicKey, PublicMessage, PublicTransaction, Signature, StallReason, Transaction, ValidityWindow, WitnessSet, @@ -281,38 +281,6 @@ impl From for lee::public_transaction::Message { } } -impl From for AccountWithMetadata { - fn from(value: lee_core::account::AccountWithMetadata) -> Self { - let lee_core::account::AccountWithMetadata { - account, - is_authorized, - account_id, - } = value; - Self { - account: account.into(), - is_authorized, - account_id: account_id.into(), - } - } -} - -impl TryFrom for lee_core::account::AccountWithMetadata { - type Error = lee_core::account::data::DataTooBigError; - - fn try_from(value: AccountWithMetadata) -> Result { - let AccountWithMetadata { - account, - is_authorized, - account_id, - } = value; - Ok(Self { - account: account.try_into()?, - is_authorized, - account_id: account_id.into(), - }) - } -} - impl From for BalanceDiff { fn from(value: lee_core::account::BalanceDiff) -> Self { match value { @@ -458,7 +426,6 @@ impl From for PrivateAction { impl From for PrivacyPreservingMessage { fn from(value: lee::privacy_preserving_transaction::message::Message) -> Self { let lee::privacy_preserving_transaction::message::Message { - public_pre_states, public_diffs, nonces, private_actions, @@ -467,7 +434,6 @@ impl From for PrivacyPres signer_account_ids, } = value; Self { - public_pre_states: public_pre_states.into_iter().map(Into::into).collect(), public_diffs: public_diffs.into_iter().map(Into::into).collect(), nonces: nonces.iter().map(|x| x.0).collect(), private_actions: private_actions.into_iter().map(Into::into).collect(), @@ -494,7 +460,6 @@ impl TryFrom for lee::privacy_preserving_transaction:: fn try_from(value: PrivacyPreservingMessage) -> Result { let PrivacyPreservingMessage { - public_pre_states, public_diffs, nonces, private_actions, @@ -503,16 +468,10 @@ impl TryFrom for lee::privacy_preserving_transaction:: signer_account_ids, } = value; - let public_pre_states = public_pre_states - .into_iter() - .map(TryInto::try_into) - .collect::, _>>() - .map_err(|e| lee::error::LeeError::InvalidInput(format!("{e}")))?; let public_diffs = public_diffs.into_iter().map(Into::into).collect(); let private_actions = private_actions.into_iter().map(Into::into).collect(); Ok(Self { - public_pre_states, public_diffs, nonces: nonces .iter() diff --git a/lez/indexer/service/protocol/src/lib.rs b/lez/indexer/service/protocol/src/lib.rs index 64e715428..68527400c 100644 --- a/lez/indexer/service/protocol/src/lib.rs +++ b/lez/indexer/service/protocol/src/lib.rs @@ -255,13 +255,6 @@ pub struct PublicMessage { pub type InstructionData = Vec; -#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)] -pub struct AccountWithMetadata { - pub account: Account, - pub is_authorized: bool, - pub account_id: AccountId, -} - #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)] pub enum BalanceDiff { Add(u128), @@ -319,7 +312,6 @@ pub struct PrivateAction { #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)] pub struct PrivacyPreservingMessage { - pub public_pre_states: Vec, pub public_diffs: Vec, pub nonces: Vec, pub private_actions: Vec, diff --git a/lez/indexer/service/src/mock_service.rs b/lez/indexer/service/src/mock_service.rs index 4d9b4f494..68168b70d 100644 --- a/lez/indexer/service/src/mock_service.rs +++ b/lez/indexer/service/src/mock_service.rs @@ -9,9 +9,9 @@ use std::{collections::HashMap, sync::Arc, time::Duration}; use indexer_service_protocol::{ - Account, AccountDiff, AccountDiffOutput, AccountId, AccountWithMetadata, BalanceDiff, - BedrockStatus, Block, BlockBody, BlockHeader, BlockId, Commitment, CommitmentSetDigest, Data, - EncryptedAccountData, HashType, IndexerStatus, IndexerSyncState, PrivacyPreservingMessage, + Account, AccountDiff, AccountDiffOutput, AccountId, BalanceDiff, BedrockStatus, Block, + BlockBody, BlockHeader, BlockId, Commitment, CommitmentSetDigest, Data, EncryptedAccountData, + HashType, IndexerStatus, IndexerSyncState, PrivacyPreservingMessage, PrivacyPreservingTransaction, PrivateAction, ProgramDeploymentMessage, ProgramDeploymentTransaction, ProgramId, PublicDiff, PublicMessage, PublicTransaction, Signature, Transaction, ValidityWindow, WitnessSet, @@ -305,9 +305,9 @@ impl indexer_service_rpc::RpcServer for MockIndexerService { Transaction::Public(pub_tx) => pub_tx.message.account_ids.contains(&account_id), Transaction::PrivacyPreserving(priv_tx) => priv_tx .message - .public_pre_states + .public_diffs .iter() - .any(|pre_state| pre_state.account_id == account_id), + .any(|diff| diff.account_id == account_id), Transaction::ProgramDeployment(_) => false, }) .cloned() @@ -389,16 +389,6 @@ fn mock_privacy_preserving_tx( Transaction::PrivacyPreserving(PrivacyPreservingTransaction { hash: tx_hash, message: PrivacyPreservingMessage { - public_pre_states: vec![AccountWithMetadata { - account: Account { - program_owner: AccountId { value: [1_u8; 32] }, - balance: 500, - data: Data(vec![0xdd, 0xee]), - nonce: block_id as u128, - }, - is_authorized: true, - account_id: public_account_id, - }], public_diffs: vec![PublicDiff { account_id: public_account_id, executing_program_id: ProgramId([1_u32; 8]), diff --git a/lez/programs/amm/src/tests.rs b/lez/programs/amm/src/tests.rs index d2ab2f47c..f022c6dbb 100644 --- a/lez/programs/amm/src/tests.rs +++ b/lez/programs/amm/src/tests.rs @@ -21,9 +21,6 @@ use crate::{ const TOKEN_PROGRAM_ID: ProgramId = [15; 8]; const AMM_PROGRAM_ID: ProgramId = [42; 8]; -/// Builds the `AccountDiff` a program must have emitted to turn `pre` into `expected_post`, for -/// asserting against `AccountDiffOutput::diff()` in tests that (pre-diff-native-refactor) used to -/// compare full post-state `Account`s directly. struct BalanceForTests; struct ChainedCallForTests; struct IdForTests; @@ -1930,6 +1927,9 @@ impl AccountsForExeTests { } } +/// Builds the `AccountDiff` a program must have emitted to turn `pre` into `expected_post`, for +/// asserting against `AccountDiffOutput::diff()` in tests that (pre-diff-native-refactor) used to +/// compare full post-state `Account`s directly. fn expected_diff(pre: &AccountWithMetadata, expected_post: &Account) -> AccountDiff { let diff_balance = if expected_post.balance >= pre.account.balance { BalanceDiff::Add(expected_post.balance - pre.account.balance) diff --git a/lez/programs/token/src/tests.rs b/lez/programs/token/src/tests.rs index 6072af25b..c34cbb003 100644 --- a/lez/programs/token/src/tests.rs +++ b/lez/programs/token/src/tests.rs @@ -532,6 +532,9 @@ impl IdForTests { } } +/// Builds the `AccountDiff` a program must have emitted to turn `pre` into `expected_post`, for +/// asserting against `AccountDiffOutput::diff()` in tests that (pre-diff-native-refactor) used to +/// compare full post-state `Account`s directly. fn expected_diff(pre: &AccountWithMetadata, expected_post: &Account) -> AccountDiff { let diff_balance = if expected_post.balance >= pre.account.balance { BalanceDiff::Add(expected_post.balance - pre.account.balance) diff --git a/test_fixtures/fixtures/prebuilt_sequencer_db.dump b/test_fixtures/fixtures/prebuilt_sequencer_db.dump index a5461bd9f..851ec3d4b 100644 Binary files a/test_fixtures/fixtures/prebuilt_sequencer_db.dump and b/test_fixtures/fixtures/prebuilt_sequencer_db.dump differ