mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-04-12 06:03:08 +00:00
lint fixes
This commit is contained in:
parent
455bda3fbf
commit
c54bd0a048
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.
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.
@ -185,11 +185,11 @@ mod tests {
|
||||
}
|
||||
|
||||
fn acc1() -> AccountId {
|
||||
AccountId::public_account_id(&PublicKey::new_from_private_key(&acc1_sign_key()), None)
|
||||
AccountId::public_account_id(&PublicKey::new_from_private_key(&acc1_sign_key()))
|
||||
}
|
||||
|
||||
fn acc2() -> AccountId {
|
||||
AccountId::public_account_id(&PublicKey::new_from_private_key(&acc2_sign_key()), None)
|
||||
AccountId::public_account_id(&PublicKey::new_from_private_key(&acc2_sign_key()))
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@ -12,6 +12,7 @@ use logos_blockchain_core::mantle::{
|
||||
ops::channel::{ChannelId, inscribe::InscriptionOp},
|
||||
};
|
||||
use nssa::{AccountId, V03State};
|
||||
use nssa_core::account::Identifier;
|
||||
use testnet_initial_state::initial_state_testnet;
|
||||
|
||||
use crate::{block_store::IndexerStore, config::IndexerConfig};
|
||||
@ -71,7 +72,7 @@ impl IndexerCore {
|
||||
acc.program_owner =
|
||||
nssa::program::Program::authenticated_transfer_program().id();
|
||||
|
||||
nssa_core::Commitment::new(&AccountId::private_account_id(npk, None), &acc)
|
||||
nssa_core::Commitment::new(&AccountId::private_account_id(npk, Identifier(0_u128)), &acc)
|
||||
})
|
||||
.collect()
|
||||
});
|
||||
|
||||
@ -5,7 +5,7 @@ use bytesize::ByteSize;
|
||||
use indexer_service::{BackoffConfig, ChannelId, ClientConfig, IndexerConfig};
|
||||
use key_protocol::key_management::KeyChain;
|
||||
use nssa::{Account, AccountId};
|
||||
use nssa_core::{PrivateKey, PublicKey, account::Data, program::DEFAULT_PROGRAM_ID};
|
||||
use nssa_core::{PrivateKey, PublicKey, account::{Data, Identifier}, program::DEFAULT_PROGRAM_ID};
|
||||
use sequencer_core::config::{BedrockConfig, SequencerConfig};
|
||||
use testnet_initial_state::{
|
||||
PrivateAccountPrivateInitialData, PrivateAccountPublicInitialData,
|
||||
@ -46,11 +46,11 @@ impl InitialData {
|
||||
let mut public_alice_public_key =
|
||||
PublicKey::new_from_private_key(&public_alice_private_key);
|
||||
let mut public_alice_account_id =
|
||||
AccountId::public_account_id(&public_alice_public_key, None);
|
||||
AccountId::public_account_id(&public_alice_public_key);
|
||||
|
||||
let mut public_bob_private_key = PrivateKey::new_os_random();
|
||||
let mut public_bob_public_key = PublicKey::new_from_private_key(&public_bob_private_key);
|
||||
let mut public_bob_account_id = AccountId::public_account_id(&public_bob_public_key, None);
|
||||
let mut public_bob_account_id = AccountId::public_account_id(&public_bob_public_key);
|
||||
|
||||
// Ensure consistent ordering
|
||||
if public_alice_account_id > public_bob_account_id {
|
||||
@ -61,11 +61,11 @@ impl InitialData {
|
||||
|
||||
let mut private_charlie_key_chain = KeyChain::new_os_random();
|
||||
let mut private_charlie_account_id =
|
||||
AccountId::private_account_id(&private_charlie_key_chain.nullifier_public_key, None);
|
||||
AccountId::private_account_id(&private_charlie_key_chain.nullifier_public_key, Identifier(0_u128));
|
||||
|
||||
let mut private_david_key_chain = KeyChain::new_os_random();
|
||||
let mut private_david_account_id =
|
||||
AccountId::private_account_id(&private_david_key_chain.nullifier_public_key, None);
|
||||
AccountId::private_account_id(&private_david_key_chain.nullifier_public_key, Identifier(0_u128));
|
||||
|
||||
// Ensure consistent ordering
|
||||
if private_charlie_account_id > private_david_account_id {
|
||||
@ -109,7 +109,7 @@ impl InitialData {
|
||||
.iter()
|
||||
.map(|(priv_key, balance)| {
|
||||
let pub_key = PublicKey::new_from_private_key(priv_key);
|
||||
let account_id = AccountId::public_account_id(&pub_key, None);
|
||||
let account_id = AccountId::public_account_id(&pub_key);
|
||||
PublicAccountPublicInitialData {
|
||||
account_id,
|
||||
balance: *balance,
|
||||
@ -133,7 +133,7 @@ impl InitialData {
|
||||
.iter()
|
||||
.map(|(priv_key, _)| {
|
||||
let pub_key = PublicKey::new_from_private_key(priv_key);
|
||||
let account_id = AccountId::public_account_id(&pub_key, None);
|
||||
let account_id = AccountId::public_account_id(&pub_key);
|
||||
InitialAccountData::Public(PublicAccountPrivateInitialData {
|
||||
account_id,
|
||||
pub_sign_key: priv_key.clone(),
|
||||
@ -141,7 +141,7 @@ impl InitialData {
|
||||
})
|
||||
.chain(self.private_accounts.iter().map(|(key_chain, account)| {
|
||||
let account_id =
|
||||
AccountId::private_account_id(&key_chain.nullifier_public_key, None);
|
||||
AccountId::private_account_id(&key_chain.nullifier_public_key, Identifier(0_u128));
|
||||
InitialAccountData::Private(Box::new(PrivateAccountPrivateInitialData {
|
||||
account_id,
|
||||
account: account.clone(),
|
||||
|
||||
@ -28,7 +28,7 @@ use nssa::{
|
||||
};
|
||||
use nssa_core::{
|
||||
MembershipProof, NullifierPublicKey, PrivateKey, PublicKey,
|
||||
account::{AccountWithMetadata, Nonce, data::Data},
|
||||
account::{AccountWithMetadata, Identifier, Nonce, data::Data},
|
||||
encryption::ViewingPublicKey,
|
||||
};
|
||||
use sequencer_service_rpc::RpcClient as _;
|
||||
@ -49,7 +49,7 @@ impl TpsTestManager {
|
||||
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::public_account_id(&public_key, None);
|
||||
let account_id = AccountId::public_account_id(&public_key);
|
||||
(private_key, account_id)
|
||||
})
|
||||
.collect();
|
||||
@ -212,7 +212,7 @@ fn build_privacy_transaction() -> PrivacyPreservingTransaction {
|
||||
let sender_vsk = [99; 32];
|
||||
let sender_vpk = ViewingPublicKey::from_scalar(sender_vsk);
|
||||
let sender_npk = NullifierPublicKey::from(&sender_nsk);
|
||||
let sender_id = AccountId::private_account_id(&sender_npk, None);
|
||||
let sender_id = AccountId::private_account_id(&sender_npk, Identifier(0_u128));
|
||||
let sender_pre = AccountWithMetadata::new(
|
||||
Account {
|
||||
balance: 100,
|
||||
@ -221,17 +221,17 @@ fn build_privacy_transaction() -> PrivacyPreservingTransaction {
|
||||
data: Data::default(),
|
||||
},
|
||||
true,
|
||||
AccountId::private_account_id(&sender_npk, None),
|
||||
AccountId::private_account_id(&sender_npk, Identifier(0_u128)),
|
||||
);
|
||||
let recipient_nsk = [2; 32];
|
||||
let recipient_vsk = [99; 32];
|
||||
let recipient_vpk = ViewingPublicKey::from_scalar(recipient_vsk);
|
||||
let recipient_npk = NullifierPublicKey::from(&recipient_nsk);
|
||||
let recipient_id = AccountId::private_account_id(&recipient_npk, None);
|
||||
let recipient_id = AccountId::private_account_id(&recipient_npk, Identifier(0_u128));
|
||||
let recipient_pre = AccountWithMetadata::new(
|
||||
Account::default(),
|
||||
false,
|
||||
AccountId::private_account_id(&recipient_npk, None),
|
||||
AccountId::private_account_id(&recipient_npk, Identifier(0_u128)),
|
||||
);
|
||||
|
||||
let eph_holder_from = EphemeralKeyHolder::new(&sender_npk);
|
||||
|
||||
@ -22,7 +22,7 @@ use anyhow::Result;
|
||||
use integration_tests::{BlockingTestContext, TIME_TO_WAIT_FOR_BLOCK_SECONDS};
|
||||
use log::info;
|
||||
use nssa::{Account, AccountId, program::Program};
|
||||
use nssa_core::{PrivateKey, PublicKey, program::DEFAULT_PROGRAM_ID};
|
||||
use nssa_core::{PrivateKey, PublicKey, account::Identifier, program::DEFAULT_PROGRAM_ID};
|
||||
use tempfile::tempdir;
|
||||
use wallet_ffi::{
|
||||
FfiAccount, FfiAccountList, FfiBytes32, FfiPrivateAccountKeys, FfiPublicAccountKey,
|
||||
@ -332,7 +332,7 @@ fn wallet_ffi_save_and_load_persistent_storage() -> Result<()> {
|
||||
};
|
||||
|
||||
assert_eq!(
|
||||
nssa::AccountId::private_account_id(&private_account_keys.npk(), None),
|
||||
nssa::AccountId::private_account_id(&private_account_keys.npk(), Identifier(0_u128)),
|
||||
out_private_account_id.into()
|
||||
);
|
||||
|
||||
@ -607,7 +607,7 @@ fn test_wallet_ffi_get_private_account_keys() -> Result<()> {
|
||||
fn test_wallet_ffi_account_id_to_base58() -> Result<()> {
|
||||
let private_key = PrivateKey::new_os_random();
|
||||
let public_key = PublicKey::new_from_private_key(&private_key);
|
||||
let account_id = AccountId::public_account_id(&public_key, None);
|
||||
let account_id = AccountId::public_account_id(&public_key);
|
||||
let ffi_bytes: FfiBytes32 = (&account_id).into();
|
||||
let ptr = unsafe { wallet_ffi_account_id_to_base58(&raw const ffi_bytes) };
|
||||
|
||||
@ -626,7 +626,7 @@ fn test_wallet_ffi_account_id_to_base58() -> Result<()> {
|
||||
fn wallet_ffi_base58_to_account_id() -> Result<()> {
|
||||
let private_key = PrivateKey::new_os_random();
|
||||
let public_key = PublicKey::new_from_private_key(&private_key);
|
||||
let account_id = AccountId::public_account_id(&public_key, None);
|
||||
let account_id = AccountId::public_account_id(&public_key);
|
||||
let account_id_str = account_id.to_string();
|
||||
let account_id_c_str = CString::new(account_id_str.clone())?;
|
||||
let account_id: AccountId = unsafe {
|
||||
|
||||
@ -74,7 +74,8 @@ impl Signature {
|
||||
}
|
||||
|
||||
#[cfg(feature = "test-utils")]
|
||||
pub fn new_for_tests(value: [u8; 64]) -> Self {
|
||||
#[must_use]
|
||||
pub const fn new_for_tests(value: [u8; 64]) -> Self {
|
||||
Self { value }
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,7 +15,6 @@ pub use privacy_preserving_transaction::{
|
||||
pub use program_deployment_transaction::ProgramDeploymentTransaction;
|
||||
pub use program_methods::PRIVACY_PRESERVING_CIRCUIT_ID;
|
||||
pub use public_transaction::PublicTransaction;
|
||||
pub use signature::{PrivateKey, PublicKey, Signature};
|
||||
pub use state::{
|
||||
CLOCK_01_PROGRAM_ACCOUNT_ID, CLOCK_10_PROGRAM_ACCOUNT_ID, CLOCK_50_PROGRAM_ACCOUNT_ID,
|
||||
CLOCK_PROGRAM_ACCOUNT_IDS, V03State,
|
||||
|
||||
@ -61,7 +61,7 @@ impl PublicTransaction {
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use nssa_core::{PrivateKey, PublicKey, Signature};
|
||||
use nssa_core::{PrivateKey, PublicKey};
|
||||
use sha2::{Digest as _, digest::FixedOutput as _};
|
||||
|
||||
use crate::{
|
||||
@ -205,6 +205,8 @@ pub mod tests {
|
||||
#[cfg(feature = "test-utils")]
|
||||
#[test]
|
||||
fn all_signatures_must_be_valid() {
|
||||
use nssa_core::Signature;
|
||||
|
||||
let (key1, key2, addr1, addr2) = keys_for_tests();
|
||||
let state = state_for_tests();
|
||||
let nonces = vec![0_u128.into(), 0_u128.into()];
|
||||
|
||||
@ -357,7 +357,6 @@ pub mod tests {
|
||||
use std::collections::HashMap;
|
||||
|
||||
use nssa_core::account::Identifier;
|
||||
#[allow(unused_imports)]
|
||||
use nssa_core::{
|
||||
BlockId, Commitment, Nullifier, NullifierPublicKey, NullifierSecretKey, PrivateKey,
|
||||
PublicKey, SharedSecretKey, Timestamp,
|
||||
@ -378,7 +377,6 @@ pub mod tests {
|
||||
},
|
||||
program::Program,
|
||||
public_transaction,
|
||||
signature::PrivateKey,
|
||||
state::{
|
||||
CLOCK_01_PROGRAM_ACCOUNT_ID, CLOCK_10_PROGRAM_ACCOUNT_ID, CLOCK_50_PROGRAM_ACCOUNT_ID,
|
||||
CLOCK_PROGRAM_ACCOUNT_IDS, MAX_NUMBER_CHAINED_CALLS,
|
||||
@ -2595,7 +2593,7 @@ pub mod tests {
|
||||
fn unauthorized_public_account_claiming_fails() {
|
||||
let program = Program::authenticated_transfer_program();
|
||||
let account_key = PrivateKey::try_new([9; 32]).unwrap();
|
||||
let account_id = AccountId::from(&PublicKey::new_from_private_key(&account_key));
|
||||
let account_id = AccountId::public_account_id(&PublicKey::new_from_private_key(&account_key));
|
||||
let mut state = V03State::new_with_genesis_accounts(&[], &[], 0);
|
||||
|
||||
assert_eq!(state.get_account_by_id(account_id), Account::default());
|
||||
@ -2616,7 +2614,7 @@ pub mod tests {
|
||||
fn authorized_public_account_claiming_succeeds() {
|
||||
let program = Program::authenticated_transfer_program();
|
||||
let account_key = PrivateKey::try_new([10; 32]).unwrap();
|
||||
let account_id = AccountId::from(&PublicKey::new_from_private_key(&account_key));
|
||||
let account_id = AccountId::public_account_id(&PublicKey::new_from_private_key(&account_key));
|
||||
let mut state = V03State::new_with_genesis_accounts(&[], &[], 0);
|
||||
|
||||
assert_eq!(state.get_account_by_id(account_id), Account::default());
|
||||
@ -2912,7 +2910,6 @@ pub mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
// TODO: Marvin check this
|
||||
#[test_case::test_case(1; "single call")]
|
||||
#[test_case::test_case(2; "two calls")]
|
||||
fn private_chained_call(number_of_calls: u32) {
|
||||
@ -3839,7 +3836,7 @@ pub mod tests {
|
||||
V03State::new_with_genesis_accounts(&[(recipient_id, 0)], &[], genesis_timestamp)
|
||||
.with_test_programs();
|
||||
let key1 = PrivateKey::try_new([1; 32]).unwrap();
|
||||
let sender_id = AccountId::from(&PublicKey::new_from_private_key(&key1));
|
||||
let sender_id = AccountId::public_account_id(&PublicKey::new_from_private_key(&key1));
|
||||
state.force_insert_account(
|
||||
sender_id,
|
||||
Account {
|
||||
@ -3882,7 +3879,7 @@ pub mod tests {
|
||||
V03State::new_with_genesis_accounts(&[(recipient_id, 0)], &[], genesis_timestamp)
|
||||
.with_test_programs();
|
||||
let key1 = PrivateKey::try_new([1; 32]).unwrap();
|
||||
let sender_id = AccountId::from(&PublicKey::new_from_private_key(&key1));
|
||||
let sender_id = AccountId::public_account_id(&PublicKey::new_from_private_key(&key1));
|
||||
state.force_insert_account(
|
||||
sender_id,
|
||||
Account {
|
||||
|
||||
@ -16,6 +16,7 @@ use mempool::{MemPool, MemPoolHandle};
|
||||
#[cfg(feature = "mock")]
|
||||
pub use mock::SequencerCoreWithMockClients;
|
||||
use nssa::{AccountId, V03State};
|
||||
use nssa_core::account::Identifier;
|
||||
pub use storage::error::DbError;
|
||||
use testnet_initial_state::initial_state;
|
||||
|
||||
@ -113,7 +114,7 @@ impl<BC: BlockSettlementClientTrait, IC: IndexerClientTrait> SequencerCore<BC, I
|
||||
let npk = &init_comm_data.npk;
|
||||
|
||||
let mut acc = init_comm_data.account.clone();
|
||||
let acc_id = &AccountId::private_account_id(npk, None);
|
||||
let acc_id = &AccountId::private_account_id(npk, Identifier(0_u128));
|
||||
acc.program_owner =
|
||||
nssa::program::Program::authenticated_transfer_program().id();
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ use nssa::{
|
||||
},
|
||||
};
|
||||
use nssa_core::{
|
||||
Commitment, MembershipProof, SharedSecretKey, account::Nonce, program::InstructionData,
|
||||
Commitment, MembershipProof, SharedSecretKey, account::{Identifier, Nonce}, program::InstructionData,
|
||||
};
|
||||
pub use privacy_preserving_tx::PrivacyPreservingAccount;
|
||||
use sequencer_service_rpc::{RpcClient as _, SequencerClient, SequencerClientBuilder};
|
||||
|
||||
@ -3,7 +3,7 @@ use key_protocol::key_management::ephemeral_key_holder::EphemeralKeyHolder;
|
||||
use nssa::AccountId;
|
||||
use nssa_core::{
|
||||
MembershipProof, NullifierPublicKey, NullifierSecretKey, PrivateKey, SharedSecretKey,
|
||||
account::{AccountWithMetadata, Nonce},
|
||||
account::{AccountWithMetadata, Identifier, Nonce},
|
||||
encryption::{EphemeralPublicKey, ViewingPublicKey},
|
||||
};
|
||||
|
||||
@ -82,7 +82,7 @@ impl AccountManager {
|
||||
(State::Private(pre), mask)
|
||||
}
|
||||
PrivacyPreservingAccount::PrivateForeign { npk, vpk } => {
|
||||
let account_id = AccountId::private_account_id(&npk, None);
|
||||
let account_id = AccountId::private_account_id(&npk, Identifier(0_u128));
|
||||
let acc = nssa_core::account::Account::default();
|
||||
let auth_acc = AccountWithMetadata::new(acc, false, account_id);
|
||||
let pre = AccountPreparedData {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user