mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-08-27 04:11:08 +00:00
feat(lee): remove public_pre_states from privacy-preserving circuit output
Public accounts' pre-transaction values no longer need to be part of the circuit's proven public output. Materialization already replays public_diffs against live sequencer state, never the witnessed pre-state, and proof-internal consistency has nothing left to check once the field isn't part of the output at all. Duplicate/inconsistent witnessing was already structurally impossible via the circuit's own post_states tracking, independent of whether pre_state was exported, so no new in-circuit assertion is needed to compensate. Drop the field from PrivacyPreservingCircuitOutput and Message; reimplement Message::public_account_ids() from deduped public_diffs account ids. Update every downstream mirror (indexer protocol/FFI, explorer UI, mock service) to the same id-only shape, and rebuild the guest ELF, program artifacts, and prebuilt sequencer fixture to match the changed journal layout.
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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,
|
||||
|
||||
@@ -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<AccountWithMetadata>,
|
||||
pub public_diffs: Vec<PublicDiff>,
|
||||
pub private_actions: Vec<PrivateAction>,
|
||||
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]),
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<AccountWithMetadata>,
|
||||
/// Raw, per-call, unaggregated diffs for public accounts. See
|
||||
/// `PrivacyPreservingCircuitOutput::public_diffs`.
|
||||
pub public_diffs: Vec<PublicDiff>,
|
||||
pub nonces: Vec<Nonce>,
|
||||
pub private_actions: Vec<PrivateAction>,
|
||||
@@ -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<Nonce>, 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<AccountId> {
|
||||
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<u8> = [
|
||||
empty_vec_bytes, // public_pre_states
|
||||
empty_vec_bytes, // public_diffs
|
||||
nonces_bytes,
|
||||
empty_vec_bytes, // private_actions
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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::<Vec<_>>()) == 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,
|
||||
|
||||
@@ -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");
|
||||
|
||||
|
||||
@@ -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: _,
|
||||
|
||||
@@ -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()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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<Box<FfiPrivateTransactionBody>> 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<Box<FfiPrivateTransactionBody>> for PrivacyPreservingTransaction {
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct FfiAccountWithMetadata {
|
||||
pub account: FfiAccount,
|
||||
pub is_authorized: bool,
|
||||
pub account_id: FfiAccountId,
|
||||
}
|
||||
|
||||
impl From<AccountWithMetadata> 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<FfiAccountWithMetadata> 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<PrivateAction> 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<PrivacyPreservingMessage> for FfiPrivacyPreservingMessage {
|
||||
fn from(value: PrivacyPreservingMessage) -> Self {
|
||||
let PrivacyPreservingMessage {
|
||||
public_pre_states,
|
||||
public_diffs,
|
||||
nonces,
|
||||
private_actions,
|
||||
@@ -492,11 +444,6 @@ impl From<PrivacyPreservingMessage> for FfiPrivacyPreservingMessage {
|
||||
} = value;
|
||||
|
||||
Self {
|
||||
public_pre_states: public_pre_states
|
||||
.into_iter()
|
||||
.map(Into::into)
|
||||
.collect::<Vec<_>>()
|
||||
.into(),
|
||||
public_diffs: public_diffs
|
||||
.into_iter()
|
||||
.map(Into::into)
|
||||
|
||||
@@ -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<u8>;
|
||||
@@ -22,8 +19,6 @@ pub type FfiProof = FfiVecU8;
|
||||
|
||||
pub type FfiProgramDeploymentMessage = FfiVecU8;
|
||||
|
||||
pub type FfiPublicPreStateList = FfiVec<FfiAccountWithMetadata>;
|
||||
|
||||
pub type FfiPublicDiffList = FfiVec<FfiPublicDiff>;
|
||||
|
||||
pub type FfiPrivateActionList = FfiVec<FfiPrivateAction>;
|
||||
|
||||
@@ -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<PublicMessage> for lee::public_transaction::Message {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<lee_core::account::AccountWithMetadata> 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<AccountWithMetadata> for lee_core::account::AccountWithMetadata {
|
||||
type Error = lee_core::account::data::DataTooBigError;
|
||||
|
||||
fn try_from(value: AccountWithMetadata) -> Result<Self, Self::Error> {
|
||||
let AccountWithMetadata {
|
||||
account,
|
||||
is_authorized,
|
||||
account_id,
|
||||
} = value;
|
||||
Ok(Self {
|
||||
account: account.try_into()?,
|
||||
is_authorized,
|
||||
account_id: account_id.into(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl From<lee_core::account::BalanceDiff> for BalanceDiff {
|
||||
fn from(value: lee_core::account::BalanceDiff) -> Self {
|
||||
match value {
|
||||
@@ -458,7 +426,6 @@ impl From<lee_core::PrivateAction> for PrivateAction {
|
||||
impl From<lee::privacy_preserving_transaction::message::Message> 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<lee::privacy_preserving_transaction::message::Message> 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<PrivacyPreservingMessage> for lee::privacy_preserving_transaction::
|
||||
|
||||
fn try_from(value: PrivacyPreservingMessage) -> Result<Self, Self::Error> {
|
||||
let PrivacyPreservingMessage {
|
||||
public_pre_states,
|
||||
public_diffs,
|
||||
nonces,
|
||||
private_actions,
|
||||
@@ -503,16 +468,10 @@ impl TryFrom<PrivacyPreservingMessage> for lee::privacy_preserving_transaction::
|
||||
signer_account_ids,
|
||||
} = value;
|
||||
|
||||
let public_pre_states = public_pre_states
|
||||
.into_iter()
|
||||
.map(TryInto::try_into)
|
||||
.collect::<Result<Vec<_>, _>>()
|
||||
.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()
|
||||
|
||||
@@ -255,13 +255,6 @@ pub struct PublicMessage {
|
||||
|
||||
pub type InstructionData = Vec<u32>;
|
||||
|
||||
#[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<AccountWithMetadata>,
|
||||
pub public_diffs: Vec<PublicDiff>,
|
||||
pub nonces: Vec<Nonce>,
|
||||
pub private_actions: Vec<PrivateAction>,
|
||||
|
||||
@@ -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]),
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user