mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-03-24 03:03:09 +00:00
fix: lint fix
This commit is contained in:
parent
5ab7d40727
commit
a0ab6ad92d
@ -29,7 +29,7 @@ pub struct ClientConfig {
|
||||
pub struct IndexerConfig {
|
||||
/// Home dir of sequencer storage.
|
||||
pub home: PathBuf,
|
||||
/// Sequencers signing key
|
||||
/// Sequencers signing key.
|
||||
pub signing_key: [u8; 32],
|
||||
#[serde(with = "humantime_serde")]
|
||||
pub consensus_info_polling_interval: Duration,
|
||||
|
||||
@ -142,11 +142,11 @@ impl InitialData {
|
||||
})
|
||||
.chain(self.private_accounts.iter().map(|(key_chain, account)| {
|
||||
let account_id = AccountId::from(&key_chain.nullifer_public_key);
|
||||
InitialAccountData::Private(PrivateAccountPrivateInitialData {
|
||||
InitialAccountData::Private(Box::new(PrivateAccountPrivateInitialData {
|
||||
account_id,
|
||||
account: account.clone(),
|
||||
key_chain: key_chain.clone(),
|
||||
})
|
||||
}))
|
||||
}))
|
||||
.collect()
|
||||
}
|
||||
|
||||
@ -101,6 +101,7 @@ pub struct PrivateAccountPrivateInitialData {
|
||||
pub key_chain: KeyChain,
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn initial_pub_accounts_private_keys() -> Vec<PublicAccountPrivateInitialData> {
|
||||
let acc1_pub_sign_key = PrivateKey::try_new(PRIVATE_KEY_PUB_ACC_A).unwrap();
|
||||
|
||||
@ -118,6 +119,7 @@ pub fn initial_pub_accounts_private_keys() -> Vec<PublicAccountPrivateInitialDat
|
||||
]
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn initial_priv_accounts_private_keys() -> Vec<PrivateAccountPrivateInitialData> {
|
||||
let key_chain_1 = KeyChain {
|
||||
secret_spending_key: SecretSpendingKey(SSK_PRIV_ACC_A),
|
||||
@ -163,16 +165,18 @@ pub fn initial_priv_accounts_private_keys() -> Vec<PrivateAccountPrivateInitialD
|
||||
]
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn initial_commitments() -> Vec<PrivateAccountPublicInitialData> {
|
||||
initial_priv_accounts_private_keys()
|
||||
.into_iter()
|
||||
.map(|data| PrivateAccountPublicInitialData {
|
||||
npk: data.key_chain.nullifer_public_key.clone(),
|
||||
account: data.account.clone(),
|
||||
account: data.account,
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn initial_accounts() -> Vec<PublicAccountPublicInitialData> {
|
||||
let initial_account_ids = initial_pub_accounts_private_keys()
|
||||
.into_iter()
|
||||
@ -191,6 +195,7 @@ pub fn initial_accounts() -> Vec<PublicAccountPublicInitialData> {
|
||||
]
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn initial_state() -> V02State {
|
||||
let initial_commitments: Vec<nssa_core::Commitment> = initial_commitments()
|
||||
.iter()
|
||||
@ -213,6 +218,7 @@ pub fn initial_state() -> V02State {
|
||||
nssa::V02State::new_with_genesis_accounts(&init_accs, &initial_commitments)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn initial_state_testnet() -> V02State {
|
||||
let mut state = initial_state();
|
||||
|
||||
@ -223,7 +229,7 @@ pub fn initial_state_testnet() -> V02State {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::str::FromStr;
|
||||
use std::str::FromStr as _;
|
||||
|
||||
use super::*;
|
||||
|
||||
@ -234,7 +240,7 @@ mod tests {
|
||||
const PRIV_ACC_B_TEXT_ADDR: &str = "E8HwiTyQe4H9HK7icTvn95HQMnzx49mP9A2ddtMLpNaN";
|
||||
|
||||
#[test]
|
||||
fn test_pub_state_consistency() {
|
||||
fn pub_state_consistency() {
|
||||
let init_accs_private_data = initial_pub_accounts_private_keys();
|
||||
let init_accs_pub_data = initial_accounts();
|
||||
|
||||
@ -262,11 +268,11 @@ mod tests {
|
||||
account_id: AccountId::from_str(PUB_ACC_B_TEXT_ADDR).unwrap(),
|
||||
balance: PUB_ACC_B_INITIAL_BALANCE,
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_private_state_consistency() {
|
||||
fn private_state_consistency() {
|
||||
let init_private_accs_keys = initial_priv_accounts_private_keys();
|
||||
let init_comms = initial_commitments();
|
||||
|
||||
@ -386,6 +392,6 @@ mod tests {
|
||||
nonce: 0,
|
||||
},
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ pub struct SequencerConfig {
|
||||
pub retry_pending_blocks_timeout: Duration,
|
||||
/// Port to listen.
|
||||
pub port: u16,
|
||||
/// Sequencer own signing key
|
||||
/// Sequencer own signing key.
|
||||
pub signing_key: [u8; 32],
|
||||
/// Bedrock configuration options.
|
||||
pub bedrock_config: BedrockConfig,
|
||||
|
||||
@ -94,53 +94,50 @@ impl<BC: BlockSettlementClientTrait, IC: IndexerClientTrait> SequencerCore<BC, I
|
||||
.expect("Failed to read latest block meta from store");
|
||||
|
||||
#[cfg_attr(not(feature = "testnet"), allow(unused_mut))]
|
||||
let mut state = match store.get_nssa_state() {
|
||||
Some(state) => {
|
||||
info!("Found local database. Loading state and pending blocks from it.");
|
||||
state
|
||||
}
|
||||
None => {
|
||||
info!(
|
||||
"No database found when starting the sequencer. Creating a fresh new with the initial data"
|
||||
);
|
||||
let mut state = if let Some(state) = store.get_nssa_state() {
|
||||
info!("Found local database. Loading state and pending blocks from it.");
|
||||
state
|
||||
} else {
|
||||
info!(
|
||||
"No database found when starting the sequencer. Creating a fresh new with the initial data"
|
||||
);
|
||||
|
||||
let initial_commitments: Option<Vec<nssa_core::Commitment>> = config
|
||||
.initial_commitments
|
||||
.clone()
|
||||
.map(|initial_commitments| {
|
||||
initial_commitments
|
||||
.iter()
|
||||
.map(|init_comm_data| {
|
||||
let npk = &init_comm_data.npk;
|
||||
let initial_commitments: Option<Vec<nssa_core::Commitment>> = config
|
||||
.initial_commitments
|
||||
.clone()
|
||||
.map(|initial_commitments| {
|
||||
initial_commitments
|
||||
.iter()
|
||||
.map(|init_comm_data| {
|
||||
let npk = &init_comm_data.npk;
|
||||
|
||||
let mut acc = init_comm_data.account.clone();
|
||||
let mut acc = init_comm_data.account.clone();
|
||||
|
||||
acc.program_owner =
|
||||
nssa::program::Program::authenticated_transfer_program().id();
|
||||
acc.program_owner =
|
||||
nssa::program::Program::authenticated_transfer_program().id();
|
||||
|
||||
nssa_core::Commitment::new(npk, &acc)
|
||||
})
|
||||
.collect()
|
||||
});
|
||||
nssa_core::Commitment::new(npk, &acc)
|
||||
})
|
||||
.collect()
|
||||
});
|
||||
|
||||
let init_accs: Option<Vec<(nssa::AccountId, u128)>> =
|
||||
config.initial_accounts.clone().map(|initial_accounts| {
|
||||
initial_accounts
|
||||
.iter()
|
||||
.map(|acc_data| (acc_data.account_id, acc_data.balance))
|
||||
.collect()
|
||||
});
|
||||
let init_accs: Option<Vec<(nssa::AccountId, u128)>> =
|
||||
config.initial_accounts.clone().map(|initial_accounts| {
|
||||
initial_accounts
|
||||
.iter()
|
||||
.map(|acc_data| (acc_data.account_id, acc_data.balance))
|
||||
.collect()
|
||||
});
|
||||
|
||||
// If initial commitments or accounts are present in config, need to construct state
|
||||
// from them
|
||||
if initial_commitments.is_some() || init_accs.is_some() {
|
||||
V02State::new_with_genesis_accounts(
|
||||
&init_accs.unwrap_or_default(),
|
||||
&initial_commitments.unwrap_or_default(),
|
||||
)
|
||||
} else {
|
||||
initial_state()
|
||||
}
|
||||
// If initial commitments or accounts are present in config, need to construct state
|
||||
// from them
|
||||
if initial_commitments.is_some() || init_accs.is_some() {
|
||||
V02State::new_with_genesis_accounts(
|
||||
&init_accs.unwrap_or_default(),
|
||||
&initial_commitments.unwrap_or_default(),
|
||||
)
|
||||
} else {
|
||||
initial_state()
|
||||
}
|
||||
};
|
||||
|
||||
@ -485,7 +482,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_transaction_pre_check_native_transfer_valid() {
|
||||
async fn transaction_pre_check_native_transfer_valid() {
|
||||
let (_sequencer, _mempool_handle) = common_setup().await;
|
||||
|
||||
let acc1 = initial_accounts()[0].account_id;
|
||||
|
||||
@ -197,7 +197,8 @@ impl<BC: BlockSettlementClientTrait, IC: IndexerClientTrait> JsonHandler<BC, IC>
|
||||
|
||||
/// Returns the initial accounts for testnet.
|
||||
/// `ToDo`: Useful only for testnet and needs to be removed later.
|
||||
async fn get_initial_testnet_accounts(&self, request: Request) -> Result<Value, RpcErr> {
|
||||
#[expect(clippy::unused_self, reason = "Let all methods be uniform")]
|
||||
fn get_initial_testnet_accounts(&self, request: Request) -> Result<Value, RpcErr> {
|
||||
let _get_initial_testnet_accounts_request =
|
||||
GetInitialTestnetAccountsRequest::parse(Some(request.params))?;
|
||||
|
||||
@ -320,7 +321,7 @@ impl<BC: BlockSettlementClientTrait, IC: IndexerClientTrait> JsonHandler<BC, IC>
|
||||
GET_BLOCK_RANGE => self.process_get_block_range_data(request).await,
|
||||
GET_GENESIS => self.process_get_genesis(request).await,
|
||||
GET_LAST_BLOCK => self.process_get_last_block(request).await,
|
||||
GET_INITIAL_TESTNET_ACCOUNTS => self.get_initial_testnet_accounts(request).await,
|
||||
GET_INITIAL_TESTNET_ACCOUNTS => self.get_initial_testnet_accounts(request),
|
||||
GET_ACCOUNT_BALANCE => self.process_get_account_balance(request).await,
|
||||
GET_ACCOUNTS_NONCES => self.process_get_accounts_nonces(request).await,
|
||||
GET_ACCOUNT => self.process_get_account(request).await,
|
||||
|
||||
@ -41,10 +41,18 @@ pub struct PersistentAccountDataPrivate {
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub enum InitialAccountData {
|
||||
Public(PublicAccountPrivateInitialData),
|
||||
Private(PrivateAccountPrivateInitialData),
|
||||
Private(Box<PrivateAccountPrivateInitialData>),
|
||||
}
|
||||
|
||||
impl InitialAccountData {
|
||||
#[must_use]
|
||||
pub const fn account_id(&self) -> nssa::AccountId {
|
||||
match &self {
|
||||
Self::Public(acc) => acc.account_id,
|
||||
Self::Private(acc) => acc.account_id,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn create_initial_accounts_data() -> Vec<Self> {
|
||||
let pub_data = initial_pub_accounts_private_keys();
|
||||
let priv_data = initial_priv_accounts_private_keys();
|
||||
@ -117,16 +125,6 @@ impl PersistentStorage {
|
||||
}
|
||||
}
|
||||
|
||||
impl InitialAccountData {
|
||||
#[must_use]
|
||||
pub fn account_id(&self) -> nssa::AccountId {
|
||||
match &self {
|
||||
Self::Public(acc) => acc.account_id,
|
||||
Self::Private(acc) => acc.account_id,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl PersistentAccountData {
|
||||
#[must_use]
|
||||
pub fn account_id(&self) -> nssa::AccountId {
|
||||
@ -146,7 +144,7 @@ impl From<PublicAccountPrivateInitialData> for InitialAccountData {
|
||||
|
||||
impl From<PrivateAccountPrivateInitialData> for InitialAccountData {
|
||||
fn from(value: PrivateAccountPrivateInitialData) -> Self {
|
||||
Self::Private(value)
|
||||
Self::Private(Box::new(value))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
use std::{collections::HashMap, path::PathBuf, str::FromStr as _};
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use base58::ToBase58;
|
||||
use anyhow::{Context as _, Result};
|
||||
use base58::ToBase58 as _;
|
||||
use key_protocol::{
|
||||
initial_state::{PrivateAccountPrivateInitialData, PublicAccountPrivateInitialData},
|
||||
key_protocol_core::NSSAUserData,
|
||||
@ -132,11 +132,11 @@ pub fn produce_data_for_storage(
|
||||
|
||||
for (account_id, (key_chain, account)) in &user_data.default_user_private_accounts {
|
||||
vec_for_storage.push(
|
||||
InitialAccountData::Private(PrivateAccountPrivateInitialData {
|
||||
InitialAccountData::Private(Box::new(PrivateAccountPrivateInitialData {
|
||||
account_id: *account_id,
|
||||
account: account.clone(),
|
||||
key_chain: key_chain.clone(),
|
||||
})
|
||||
}))
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user