317 lines
12 KiB
Rust
Raw Normal View History

2026-03-04 18:42:33 +03:00
#![expect(
clippy::arithmetic_side_effects,
clippy::float_arithmetic,
clippy::missing_asserts_for_indexing,
clippy::as_conversions,
clippy::tests_outside_test_module,
clippy::integer_division,
clippy::integer_division_remainder_used,
reason = "We don't care about these in tests"
)]
use std::time::{Duration, Instant};
2025-10-23 16:23:47 -03:00
feat(wallet): add keycard support for public tx for auth-transfer (#451) * feat: add basic commands for communicating with keycard * initialize changes * reorganization * add script file for easier wallet access * update commands * fixes * fixed load for non continuous run * Updates for signatures with keycard * fix BIP-340 signatures for fixed sized messages * fmt * refactor and add pin support to program facades * fix unit test * fixes * Revert "fixes" This reverts commit 41f34f4ff4145b7abb60fd9bec168ae4b60f23b4. * fixes * fixes * Removed privacy keycard calls * Revert "Removed privacy keycard calls" This reverts commit d70ef505a1f40b87159099761f5fce5a31e3f17b. * Add domain separators * Removed privacy txs for keycard * CI fixes * CI fixes * addressed some comments * fix ci * ci fixes * fix integration test issue and updated keycard firmware * addressed more comments * fixed deny * remove keycard-py * fixed from earlier merge * add hash_message tests * add test * fix deny * CI fixes * fixed integration tests * Update public.rs * update artifacts * ci and comments * addressed comments * comment fixes * fixes from merging main * first round of comments * Revert "Merge branch 'main' into marvin/keycard-commands" This reverts commit 3fce53f663a3996938dddf77680854570063ca21, reversing changes made to e7b42a5177641455a8917bd2e29db20afd9690e5. * python comments * addressed comments * compile error fixed * fix artifacts * fix main merge error * adjust signer logic workflow * fmt * merge main and shift keycard tests * deny fix * artifacts fix * remove keycard scripts from root * tps fix * fmt
2026-05-21 20:46:13 -04:00
use anyhow::{Context as _, Result};
2026-02-24 19:41:01 +03:00
use bytesize::ByteSize;
use common::transaction::LeeTransaction;
use integration_tests::{TestContext, config::SequencerPartialConfig};
use lee::{
Account, AccountId, PrivacyPreservingTransaction, PrivateKey, PublicKey, PublicTransaction,
2025-10-23 16:23:47 -03:00
privacy_preserving_transaction::{self as pptx, circuit},
program::Program,
public_transaction as putx,
};
use lee_core::{
DUMMY_COMMITMENT_HASH, InputAccountIdentity, MembershipProof, NullifierPublicKey,
2026-03-18 10:28:52 -04:00
account::{AccountWithMetadata, Nonce, data::Data},
2026-01-21 17:27:23 -05:00
encryption::ViewingPublicKey,
2025-10-23 16:23:47 -03:00
};
use log::info;
use sequencer_core::config::GenesisAction;
use sequencer_service_rpc::RpcClient as _;
use tokio::test;
2025-10-23 16:23:47 -03:00
pub(crate) struct TpsTestManager {
public_keypairs: Vec<(PrivateKey, AccountId)>,
2025-10-23 16:23:47 -03:00
target_tps: u64,
}
impl TpsTestManager {
2025-11-26 00:27:20 +03:00
/// Generates public account keypairs. These are used to populate the config and to generate
/// valid public transactions for the tps test.
2025-10-23 16:23:47 -03:00
pub(crate) fn new(target_tps: u64, number_transactions: usize) -> Self {
let public_keypairs = (1..(number_transactions + 2))
.map(|i| {
2026-03-04 18:42:33 +03:00
let mut private_key_bytes = [0_u8; 32];
2025-10-23 16:23:47 -03:00
private_key_bytes[..8].copy_from_slice(&i.to_le_bytes());
let private_key = PrivateKey::try_new(private_key_bytes).unwrap();
let public_key = PublicKey::new_from_private_key(&private_key);
let account_id = AccountId::from(&public_key);
(private_key, account_id)
2025-10-23 16:23:47 -03:00
})
.collect();
2025-10-23 16:23:47 -03:00
Self {
public_keypairs,
target_tps,
}
}
2026-03-03 23:21:08 +03:00
#[expect(
clippy::cast_precision_loss,
reason = "This is just for testing purposes, we don't care about precision loss here"
)]
2025-10-23 16:23:47 -03:00
pub(crate) fn target_time(&self) -> Duration {
let number_transactions = (self.public_keypairs.len() - 1) as u64;
Duration::from_secs_f64(number_transactions as f64 / self.target_tps as f64)
}
feat(wallet): add keycard support for public tx for auth-transfer (#451) * feat: add basic commands for communicating with keycard * initialize changes * reorganization * add script file for easier wallet access * update commands * fixes * fixed load for non continuous run * Updates for signatures with keycard * fix BIP-340 signatures for fixed sized messages * fmt * refactor and add pin support to program facades * fix unit test * fixes * Revert "fixes" This reverts commit 41f34f4ff4145b7abb60fd9bec168ae4b60f23b4. * fixes * fixes * Removed privacy keycard calls * Revert "Removed privacy keycard calls" This reverts commit d70ef505a1f40b87159099761f5fce5a31e3f17b. * Add domain separators * Removed privacy txs for keycard * CI fixes * CI fixes * addressed some comments * fix ci * ci fixes * fix integration test issue and updated keycard firmware * addressed more comments * fixed deny * remove keycard-py * fixed from earlier merge * add hash_message tests * add test * fix deny * CI fixes * fixed integration tests * Update public.rs * update artifacts * ci and comments * addressed comments * comment fixes * fixes from merging main * first round of comments * Revert "Merge branch 'main' into marvin/keycard-commands" This reverts commit 3fce53f663a3996938dddf77680854570063ca21, reversing changes made to e7b42a5177641455a8917bd2e29db20afd9690e5. * python comments * addressed comments * compile error fixed * fix artifacts * fix main merge error * adjust signer logic workflow * fmt * merge main and shift keycard tests * deny fix * artifacts fix * remove keycard scripts from root * tps fix * fmt
2026-05-21 20:46:13 -04:00
/// Claim funds from each account's vault PDA into the account itself.
///
/// `GenesisAction::SupplyAccount` funds vault PDAs (not accounts directly), so this step is
/// required before sending `authenticated_transfer` transactions from these accounts.
/// All claim transactions are submitted at once and then confirmed sequentially.
/// After this call every account has nonce 1, so `build_public_txs` must be called after it.
pub async fn claim_vault_funds(
&self,
sequencer_client: &sequencer_service_rpc::SequencerClient,
) -> Result<()> {
let vault_program_id = programs::vault().id();
feat(wallet): add keycard support for public tx for auth-transfer (#451) * feat: add basic commands for communicating with keycard * initialize changes * reorganization * add script file for easier wallet access * update commands * fixes * fixed load for non continuous run * Updates for signatures with keycard * fix BIP-340 signatures for fixed sized messages * fmt * refactor and add pin support to program facades * fix unit test * fixes * Revert "fixes" This reverts commit 41f34f4ff4145b7abb60fd9bec168ae4b60f23b4. * fixes * fixes * Removed privacy keycard calls * Revert "Removed privacy keycard calls" This reverts commit d70ef505a1f40b87159099761f5fce5a31e3f17b. * Add domain separators * Removed privacy txs for keycard * CI fixes * CI fixes * addressed some comments * fix ci * ci fixes * fix integration test issue and updated keycard firmware * addressed more comments * fixed deny * remove keycard-py * fixed from earlier merge * add hash_message tests * add test * fix deny * CI fixes * fixed integration tests * Update public.rs * update artifacts * ci and comments * addressed comments * comment fixes * fixes from merging main * first round of comments * Revert "Merge branch 'main' into marvin/keycard-commands" This reverts commit 3fce53f663a3996938dddf77680854570063ca21, reversing changes made to e7b42a5177641455a8917bd2e29db20afd9690e5. * python comments * addressed comments * compile error fixed * fix artifacts * fix main merge error * adjust signer logic workflow * fmt * merge main and shift keycard tests * deny fix * artifacts fix * remove keycard scripts from root * tps fix * fmt
2026-05-21 20:46:13 -04:00
let mut tx_hashes = Vec::with_capacity(self.public_keypairs.len());
for (private_key, account_id) in &self.public_keypairs {
let owner_vault_id =
vault_core::compute_vault_account_id(vault_program_id, *account_id);
let message = putx::Message::try_new(
vault_program_id,
vec![*account_id, owner_vault_id],
vec![Nonce(0_u128)],
vault_core::Instruction::Claim { amount: 10 },
)
.context("Failed to build vault claim message")?;
let witness_set =
lee::public_transaction::WitnessSet::for_message(&message, &[private_key]);
feat(wallet): add keycard support for public tx for auth-transfer (#451) * feat: add basic commands for communicating with keycard * initialize changes * reorganization * add script file for easier wallet access * update commands * fixes * fixed load for non continuous run * Updates for signatures with keycard * fix BIP-340 signatures for fixed sized messages * fmt * refactor and add pin support to program facades * fix unit test * fixes * Revert "fixes" This reverts commit 41f34f4ff4145b7abb60fd9bec168ae4b60f23b4. * fixes * fixes * Removed privacy keycard calls * Revert "Removed privacy keycard calls" This reverts commit d70ef505a1f40b87159099761f5fce5a31e3f17b. * Add domain separators * Removed privacy txs for keycard * CI fixes * CI fixes * addressed some comments * fix ci * ci fixes * fix integration test issue and updated keycard firmware * addressed more comments * fixed deny * remove keycard-py * fixed from earlier merge * add hash_message tests * add test * fix deny * CI fixes * fixed integration tests * Update public.rs * update artifacts * ci and comments * addressed comments * comment fixes * fixes from merging main * first round of comments * Revert "Merge branch 'main' into marvin/keycard-commands" This reverts commit 3fce53f663a3996938dddf77680854570063ca21, reversing changes made to e7b42a5177641455a8917bd2e29db20afd9690e5. * python comments * addressed comments * compile error fixed * fix artifacts * fix main merge error * adjust signer logic workflow * fmt * merge main and shift keycard tests * deny fix * artifacts fix * remove keycard scripts from root * tps fix * fmt
2026-05-21 20:46:13 -04:00
let tx = PublicTransaction::new(message, witness_set);
let hash = sequencer_client
.send_transaction(LeeTransaction::Public(tx))
feat(wallet): add keycard support for public tx for auth-transfer (#451) * feat: add basic commands for communicating with keycard * initialize changes * reorganization * add script file for easier wallet access * update commands * fixes * fixed load for non continuous run * Updates for signatures with keycard * fix BIP-340 signatures for fixed sized messages * fmt * refactor and add pin support to program facades * fix unit test * fixes * Revert "fixes" This reverts commit 41f34f4ff4145b7abb60fd9bec168ae4b60f23b4. * fixes * fixes * Removed privacy keycard calls * Revert "Removed privacy keycard calls" This reverts commit d70ef505a1f40b87159099761f5fce5a31e3f17b. * Add domain separators * Removed privacy txs for keycard * CI fixes * CI fixes * addressed some comments * fix ci * ci fixes * fix integration test issue and updated keycard firmware * addressed more comments * fixed deny * remove keycard-py * fixed from earlier merge * add hash_message tests * add test * fix deny * CI fixes * fixed integration tests * Update public.rs * update artifacts * ci and comments * addressed comments * comment fixes * fixes from merging main * first round of comments * Revert "Merge branch 'main' into marvin/keycard-commands" This reverts commit 3fce53f663a3996938dddf77680854570063ca21, reversing changes made to e7b42a5177641455a8917bd2e29db20afd9690e5. * python comments * addressed comments * compile error fixed * fix artifacts * fix main merge error * adjust signer logic workflow * fmt * merge main and shift keycard tests * deny fix * artifacts fix * remove keycard scripts from root * tps fix * fmt
2026-05-21 20:46:13 -04:00
.await
.context("Failed to submit vault claim")?;
tx_hashes.push(hash);
}
let deadline = Instant::now() + Duration::from_mins(5);
feat(wallet): add keycard support for public tx for auth-transfer (#451) * feat: add basic commands for communicating with keycard * initialize changes * reorganization * add script file for easier wallet access * update commands * fixes * fixed load for non continuous run * Updates for signatures with keycard * fix BIP-340 signatures for fixed sized messages * fmt * refactor and add pin support to program facades * fix unit test * fixes * Revert "fixes" This reverts commit 41f34f4ff4145b7abb60fd9bec168ae4b60f23b4. * fixes * fixes * Removed privacy keycard calls * Revert "Removed privacy keycard calls" This reverts commit d70ef505a1f40b87159099761f5fce5a31e3f17b. * Add domain separators * Removed privacy txs for keycard * CI fixes * CI fixes * addressed some comments * fix ci * ci fixes * fix integration test issue and updated keycard firmware * addressed more comments * fixed deny * remove keycard-py * fixed from earlier merge * add hash_message tests * add test * fix deny * CI fixes * fixed integration tests * Update public.rs * update artifacts * ci and comments * addressed comments * comment fixes * fixes from merging main * first round of comments * Revert "Merge branch 'main' into marvin/keycard-commands" This reverts commit 3fce53f663a3996938dddf77680854570063ca21, reversing changes made to e7b42a5177641455a8917bd2e29db20afd9690e5. * python comments * addressed comments * compile error fixed * fix artifacts * fix main merge error * adjust signer logic workflow * fmt * merge main and shift keycard tests * deny fix * artifacts fix * remove keycard scripts from root * tps fix * fmt
2026-05-21 20:46:13 -04:00
for (i, tx_hash) in tx_hashes.iter().enumerate() {
loop {
anyhow::ensure!(
Instant::now() < deadline,
"Vault claims timed out after 5 minutes ({i}/{} confirmed)",
tx_hashes.len()
);
let found = sequencer_client
.get_transaction(*tx_hash)
.await
.ok()
.flatten()
.is_some();
if found {
break;
}
}
}
Ok(())
}
2025-10-23 16:23:47 -03:00
/// Build a batch of public transactions to submit to the node.
feat(wallet): add keycard support for public tx for auth-transfer (#451) * feat: add basic commands for communicating with keycard * initialize changes * reorganization * add script file for easier wallet access * update commands * fixes * fixed load for non continuous run * Updates for signatures with keycard * fix BIP-340 signatures for fixed sized messages * fmt * refactor and add pin support to program facades * fix unit test * fixes * Revert "fixes" This reverts commit 41f34f4ff4145b7abb60fd9bec168ae4b60f23b4. * fixes * fixes * Removed privacy keycard calls * Revert "Removed privacy keycard calls" This reverts commit d70ef505a1f40b87159099761f5fce5a31e3f17b. * Add domain separators * Removed privacy txs for keycard * CI fixes * CI fixes * addressed some comments * fix ci * ci fixes * fix integration test issue and updated keycard firmware * addressed more comments * fixed deny * remove keycard-py * fixed from earlier merge * add hash_message tests * add test * fix deny * CI fixes * fixed integration tests * Update public.rs * update artifacts * ci and comments * addressed comments * comment fixes * fixes from merging main * first round of comments * Revert "Merge branch 'main' into marvin/keycard-commands" This reverts commit 3fce53f663a3996938dddf77680854570063ca21, reversing changes made to e7b42a5177641455a8917bd2e29db20afd9690e5. * python comments * addressed comments * compile error fixed * fix artifacts * fix main merge error * adjust signer logic workflow * fmt * merge main and shift keycard tests * deny fix * artifacts fix * remove keycard scripts from root * tps fix * fmt
2026-05-21 20:46:13 -04:00
///
/// Must be called after `claim_vault_funds`, which sets each account's nonce to 1.
2025-10-23 16:23:47 -03:00
pub fn build_public_txs(&self) -> Vec<PublicTransaction> {
// Create valid public transactions
let program = programs::authenticated_transfer();
2025-10-23 16:23:47 -03:00
let public_txs: Vec<PublicTransaction> = self
.public_keypairs
.windows(2)
.map(|pair| {
let amount: u128 = 1;
let message = putx::Message::try_new(
program.id(),
[pair[0].1, pair[1].1].to_vec(),
feat(wallet): add keycard support for public tx for auth-transfer (#451) * feat: add basic commands for communicating with keycard * initialize changes * reorganization * add script file for easier wallet access * update commands * fixes * fixed load for non continuous run * Updates for signatures with keycard * fix BIP-340 signatures for fixed sized messages * fmt * refactor and add pin support to program facades * fix unit test * fixes * Revert "fixes" This reverts commit 41f34f4ff4145b7abb60fd9bec168ae4b60f23b4. * fixes * fixes * Removed privacy keycard calls * Revert "Removed privacy keycard calls" This reverts commit d70ef505a1f40b87159099761f5fce5a31e3f17b. * Add domain separators * Removed privacy txs for keycard * CI fixes * CI fixes * addressed some comments * fix ci * ci fixes * fix integration test issue and updated keycard firmware * addressed more comments * fixed deny * remove keycard-py * fixed from earlier merge * add hash_message tests * add test * fix deny * CI fixes * fixed integration tests * Update public.rs * update artifacts * ci and comments * addressed comments * comment fixes * fixes from merging main * first round of comments * Revert "Merge branch 'main' into marvin/keycard-commands" This reverts commit 3fce53f663a3996938dddf77680854570063ca21, reversing changes made to e7b42a5177641455a8917bd2e29db20afd9690e5. * python comments * addressed comments * compile error fixed * fix artifacts * fix main merge error * adjust signer logic workflow * fmt * merge main and shift keycard tests * deny fix * artifacts fix * remove keycard scripts from root * tps fix * fmt
2026-05-21 20:46:13 -04:00
[Nonce(1_u128)].to_vec(),
authenticated_transfer_core::Instruction::Transfer { amount },
2025-10-23 16:23:47 -03:00
)
.unwrap();
let witness_set =
lee::public_transaction::WitnessSet::for_message(&message, &[&pair[0].0]);
2025-10-23 16:23:47 -03:00
PublicTransaction::new(message, witness_set)
})
.collect();
public_txs
}
/// Generates a sequencer configuration with initial balance in a number of public accounts.
2025-11-26 00:27:20 +03:00
/// The transactions generated with the function `build_public_txs` will be valid in a node
/// started with the config from this method.
fn generate_genesis(&self) -> Vec<GenesisAction> {
self.public_keypairs
2025-10-23 16:23:47 -03:00
.iter()
.map(|(_, account_id)| GenesisAction::SupplyAccount {
account_id: *account_id,
balance: 10,
})
.collect()
}
2026-03-09 18:27:56 +03:00
const fn generate_sequencer_partial_config() -> SequencerPartialConfig {
SequencerPartialConfig {
2025-10-23 16:23:47 -03:00
max_num_tx_in_block: 300,
2026-02-24 19:41:01 +03:00
max_block_size: ByteSize::mb(500),
mempool_max_size: 10_000,
block_create_timeout: Duration::from_secs(12),
2025-10-23 16:23:47 -03:00
}
}
}
2026-03-04 18:42:33 +03:00
// TODO: Make a proper benchmark instead of an ad-hoc test
#[test]
pub async fn tps_test() -> Result<()> {
let num_transactions = 300 * 5;
let target_tps = 8;
let tps_test = TpsTestManager::new(target_tps, num_transactions);
let ctx = TestContext::builder()
.with_sequencer_partial_config(TpsTestManager::generate_sequencer_partial_config())
.with_genesis(tps_test.generate_genesis())
2026-03-04 18:42:33 +03:00
.build()
.await?;
feat(wallet): add keycard support for public tx for auth-transfer (#451) * feat: add basic commands for communicating with keycard * initialize changes * reorganization * add script file for easier wallet access * update commands * fixes * fixed load for non continuous run * Updates for signatures with keycard * fix BIP-340 signatures for fixed sized messages * fmt * refactor and add pin support to program facades * fix unit test * fixes * Revert "fixes" This reverts commit 41f34f4ff4145b7abb60fd9bec168ae4b60f23b4. * fixes * fixes * Removed privacy keycard calls * Revert "Removed privacy keycard calls" This reverts commit d70ef505a1f40b87159099761f5fce5a31e3f17b. * Add domain separators * Removed privacy txs for keycard * CI fixes * CI fixes * addressed some comments * fix ci * ci fixes * fix integration test issue and updated keycard firmware * addressed more comments * fixed deny * remove keycard-py * fixed from earlier merge * add hash_message tests * add test * fix deny * CI fixes * fixed integration tests * Update public.rs * update artifacts * ci and comments * addressed comments * comment fixes * fixes from merging main * first round of comments * Revert "Merge branch 'main' into marvin/keycard-commands" This reverts commit 3fce53f663a3996938dddf77680854570063ca21, reversing changes made to e7b42a5177641455a8917bd2e29db20afd9690e5. * python comments * addressed comments * compile error fixed * fix artifacts * fix main merge error * adjust signer logic workflow * fmt * merge main and shift keycard tests * deny fix * artifacts fix * remove keycard scripts from root * tps fix * fmt
2026-05-21 20:46:13 -04:00
// Genesis funds vault PDAs, not accounts directly. Claim into accounts before measuring.
tps_test
.claim_vault_funds(ctx.sequencer_client())
.await
.context("Failed to claim vault funds for TPS accounts")?;
2026-03-04 18:42:33 +03:00
let target_time = tps_test.target_time();
info!(
"TPS test begin. Target time is {target_time:?} for {num_transactions} transactions ({target_tps} TPS)"
);
let txs = tps_test.build_public_txs();
let now = Instant::now();
let mut tx_hashes = vec![];
for (i, tx) in txs.into_iter().enumerate() {
let tx_hash = ctx
.sequencer_client()
.send_transaction(LeeTransaction::Public(tx))
2026-03-04 18:42:33 +03:00
.await
.unwrap();
2026-03-04 18:42:33 +03:00
info!("Sent tx {i}");
tx_hashes.push(tx_hash);
}
for (i, tx_hash) in tx_hashes.iter().enumerate() {
loop {
assert!(
now.elapsed().as_millis() <= target_time.as_millis(),
"TPS test failed by timeout, transactions processed {i}/{num_transactions}"
2026-03-04 18:42:33 +03:00
);
let tx_obj = ctx
.sequencer_client()
.get_transaction(*tx_hash)
2026-03-04 18:42:33 +03:00
.await
.inspect_err(|err| {
log::warn!("Failed to get transaction by hash {tx_hash} with error: {err:#?}");
});
if tx_obj.is_ok_and(|opt| opt.is_some()) {
2026-03-04 18:42:33 +03:00
info!("Found tx {i} with hash {tx_hash}");
break;
}
}
}
let time_elapsed = now.elapsed().as_secs();
let tx_processed = tx_hashes.len();
let actual_tps = tx_processed as u64 / time_elapsed;
info!("Processed {tx_processed} transactions in {time_elapsed:?} ({actual_tps} TPS)",);
assert_eq!(tx_processed, num_transactions);
assert!(
time_elapsed <= target_time.as_secs(),
"Elapsed time {time_elapsed:?} exceeded target time {target_time:?}"
);
info!("TPS test finished successfully");
Ok(())
}
2025-10-23 16:23:47 -03:00
/// Builds a single privacy transaction to use in stress tests. This involves generating a proof so
/// it may take a while to run. In normal execution of the node this transaction will be accepted
/// only once. Disabling the node's nullifier uniqueness check allows to submit this transaction
/// multiple times with the purpose of testing the node's processing performance.
#[expect(dead_code, reason = "No idea if we need this, should we remove it?")]
2025-10-23 16:23:47 -03:00
fn build_privacy_transaction() -> PrivacyPreservingTransaction {
let program = programs::authenticated_transfer();
2025-10-23 16:23:47 -03:00
let sender_nsk = [1; 32];
let sender_vpk = ViewingPublicKey::from_seed(&[99_u8; 32], &[100_u8; 32]);
2025-10-23 16:23:47 -03:00
let sender_npk = NullifierPublicKey::from(&sender_nsk);
let sender_pre = AccountWithMetadata::new(
Account {
balance: 100,
2026-03-18 10:28:52 -04:00
nonce: Nonce(0xdead_beef),
2025-10-23 16:23:47 -03:00
program_owner: program.id(),
data: Data::default(),
2025-10-23 16:23:47 -03:00
},
true,
2026-06-19 22:37:36 +04:00
AccountId::for_regular_private_account(&sender_npk, &sender_vpk, 0),
2025-10-23 16:23:47 -03:00
);
let recipient_nsk = [2; 32];
let recipient_vpk = ViewingPublicKey::from_seed(&[101_u8; 32], &[102_u8; 32]);
2025-10-23 16:23:47 -03:00
let recipient_npk = NullifierPublicKey::from(&recipient_nsk);
2026-04-19 23:13:51 -03:00
let recipient_pre = AccountWithMetadata::new(
Account::default(),
refactor: `PrivateUnauthorized` authorization changed to true (#621) * refactor: rename PrivateUnauthorized to PrivateForeignInit The account_identity's is_authorized flag no longer determines authorization for this variant, so keep the name tied to what actually distinguishes it: no nsk, only npk (a foreign account init). * chore: rebuild guest artifacts and bump spin to clear yanked advisory Regenerate ELF artifacts after the PrivateForeignInit rename in lee_core (compiled into every guest program), and update spin 0.9.8 -> 0.9.9 since 0.9.8 was yanked from crates.io, per cargo deny check advisories. * test: align is_authorized with PrivateForeignInit's flipped semantics Recipient pre-states built for PrivateForeignInit now need is_authorized: true to match the assertion in output.rs. Also rewrites the boundary test that checked the old invalid case to check the new one, and updates stale "unauthorized" wording left over from the PrivateUnauthorized name. * chore: rebuild guest artifacts Reproducible across repeated local builds; likely toolchain drift since the prior artifact commit rather than a source change, since no guest-relevant source or Cargo.lock changed in between. * fix(tests): align integration tests with PrivateForeignInit and regenerate fixture prove_init_with_commitment_root (private.rs) and build_privacy_transaction (tps.rs) still built PrivateForeignInit recipients with is_authorized: false, same stale-semantics bug fixed earlier in the lee crate's own tests. The prebuilt sequencer DB dump embeds program IDs derived from guest ELF bytes, which shifted once the PrivateForeignInit rename changed lee_core (compiled into every guest program). The stale dump caused widespread "Unknown program" failures across integration test suites that exercise deployed programs (wallet_ffi, auth_transfer, bridge, amm, token, pinata, ata, indexer state-consistency checks). Regenerated via `just regenerate-test-fixture`. * fix(tests): rename leftover PrivateUnauthorized to PrivateForeignInit and regenerate fixture * test: align is_authorized with PrivateForeignInit's flipped semantics * chore: regenerate test fixture after rebase onto dev * chore: regenerate test fixture after rebase onto dev Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-23 17:32:01 -04:00
true,
2026-06-19 22:37:36 +04:00
AccountId::for_regular_private_account(&recipient_npk, &recipient_vpk, 0),
2026-04-19 23:13:51 -03:00
);
2025-10-23 16:23:47 -03:00
let balance_to_move: u128 = 1;
let proof: MembershipProof = (
1,
vec![[
170, 10, 217, 228, 20, 35, 189, 177, 238, 235, 97, 129, 132, 89, 96, 247, 86, 91, 222,
214, 38, 194, 216, 67, 56, 251, 208, 226, 0, 117, 149, 39,
]],
);
let (output, proof) = circuit::execute_and_prove(
vec![sender_pre, recipient_pre],
Program::serialize_instruction(authenticated_transfer_core::Instruction::Transfer {
amount: balance_to_move,
})
.unwrap(),
vec![
InputAccountIdentity::PrivateAuthorizedUpdate {
2026-06-19 22:37:36 +04:00
vpk: sender_vpk,
random_seed: [0; 32],
view_tag: 0,
nsk: sender_nsk,
membership_proof: proof,
identifier: 0,
},
refactor: `PrivateUnauthorized` authorization changed to true (#621) * refactor: rename PrivateUnauthorized to PrivateForeignInit The account_identity's is_authorized flag no longer determines authorization for this variant, so keep the name tied to what actually distinguishes it: no nsk, only npk (a foreign account init). * chore: rebuild guest artifacts and bump spin to clear yanked advisory Regenerate ELF artifacts after the PrivateForeignInit rename in lee_core (compiled into every guest program), and update spin 0.9.8 -> 0.9.9 since 0.9.8 was yanked from crates.io, per cargo deny check advisories. * test: align is_authorized with PrivateForeignInit's flipped semantics Recipient pre-states built for PrivateForeignInit now need is_authorized: true to match the assertion in output.rs. Also rewrites the boundary test that checked the old invalid case to check the new one, and updates stale "unauthorized" wording left over from the PrivateUnauthorized name. * chore: rebuild guest artifacts Reproducible across repeated local builds; likely toolchain drift since the prior artifact commit rather than a source change, since no guest-relevant source or Cargo.lock changed in between. * fix(tests): align integration tests with PrivateForeignInit and regenerate fixture prove_init_with_commitment_root (private.rs) and build_privacy_transaction (tps.rs) still built PrivateForeignInit recipients with is_authorized: false, same stale-semantics bug fixed earlier in the lee crate's own tests. The prebuilt sequencer DB dump embeds program IDs derived from guest ELF bytes, which shifted once the PrivateForeignInit rename changed lee_core (compiled into every guest program). The stale dump caused widespread "Unknown program" failures across integration test suites that exercise deployed programs (wallet_ffi, auth_transfer, bridge, amm, token, pinata, ata, indexer state-consistency checks). Regenerated via `just regenerate-test-fixture`. * fix(tests): rename leftover PrivateUnauthorized to PrivateForeignInit and regenerate fixture * test: align is_authorized with PrivateForeignInit's flipped semantics * chore: regenerate test fixture after rebase onto dev * chore: regenerate test fixture after rebase onto dev Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-23 17:32:01 -04:00
InputAccountIdentity::PrivateForeignInit {
2026-06-19 22:37:36 +04:00
vpk: recipient_vpk,
random_seed: [0; 32],
npk: recipient_npk,
identifier: 0,
refactor(privacy_preserving_circuit): introduce helper functions to shorten long functions (#545) * refactor(privacy_preserving_circuit): extract functions for readability * refactor(privacy_preserving_circuit): address PR review comments Bundle shared handle_* arguments into PrivateOutputHandler struct in output.rs and fix misplaced docstring on resolve_external_seed in execution_state.rs. * feat: update commitment mechanism for new private account (#546) * refactor(privacy_preserving_circuit): extract functions for readability * feat: update commitment mechanism for new private accounts Allow init accounts to optionally use a real membership proof for DUMMY_COMMITMENT instead of hardcoding DUMMY_COMMITMENT_HASH as the CommitmentSetDigest. The wallet fetches the proof from the sequencer and passes it through the circuit. * fix: address clippy lints and fix integration test visibility * add tests * refactor: removed duplicated code * refactor: simplify init nullifier mechanism Replace Option<MembershipProof> with Option<CommitmentSetDigest> on init variants (PrivateAuthorizedInit, PrivateUnauthorized, PrivatePdaInit). The circuit now receives the commitment tree root directly instead of recomputing it from a Merkle proof. * refactor: use CommitmentSetDigest directly instead of Option for init commitment root Address PR #546 review feedback: the circuit now accepts CommitmentSetDigest directly on init variants (PrivateAuthorizedInit, PrivateUnauthorized, PrivatePdaInit), with callers providing DUMMY_COMMITMENT_HASH as the default. Also fixes duplicate resolve_external_seed from rebase and rebuilds artifacts. * style: run cargo +nightly fmt
2026-07-01 10:14:32 -04:00
commitment_root: DUMMY_COMMITMENT_HASH,
},
],
2025-11-20 19:25:56 -03:00
&program.into(),
2025-10-23 16:23:47 -03:00
)
.unwrap();
2026-06-10 22:14:09 +04:00
let message = pptx::message::Message::try_from_circuit_output(vec![], vec![], output).unwrap();
2025-10-23 16:23:47 -03:00
let witness_set = pptx::witness_set::WitnessSet::for_message(&message, proof, &[]);
pptx::PrivacyPreservingTransaction::new(message, witness_set)
}