mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-03-24 03:03:09 +00:00
fix: suggestions fix 2
This commit is contained in:
parent
2c9361c6b5
commit
afa0a63c95
16
Cargo.lock
generated
16
Cargo.lock
generated
@ -3716,6 +3716,7 @@ dependencies = [
|
||||
"serde_json",
|
||||
"storage",
|
||||
"tempfile",
|
||||
"testnet_initial_state",
|
||||
"tokio",
|
||||
"url",
|
||||
]
|
||||
@ -3844,6 +3845,7 @@ dependencies = [
|
||||
"serde_json",
|
||||
"tempfile",
|
||||
"testcontainers",
|
||||
"testnet_initial_state",
|
||||
"token_core",
|
||||
"tokio",
|
||||
"url",
|
||||
@ -7449,6 +7451,7 @@ dependencies = [
|
||||
"serde_json",
|
||||
"storage",
|
||||
"tempfile",
|
||||
"testnet_initial_state",
|
||||
"tokio",
|
||||
"url",
|
||||
]
|
||||
@ -7476,6 +7479,7 @@ dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tempfile",
|
||||
"testnet_initial_state",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
@ -8179,6 +8183,17 @@ dependencies = [
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "testnet_initial_state"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"common",
|
||||
"key_protocol",
|
||||
"nssa",
|
||||
"nssa_core",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.69"
|
||||
@ -8976,6 +8991,7 @@ dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2",
|
||||
"testnet_initial_state",
|
||||
"token_core",
|
||||
"tokio",
|
||||
"url",
|
||||
|
||||
@ -33,6 +33,7 @@ members = [
|
||||
"examples/program_deployment/methods",
|
||||
"examples/program_deployment/methods/guest",
|
||||
"bedrock_client",
|
||||
"testnet_initial_state",
|
||||
]
|
||||
|
||||
[workspace.dependencies]
|
||||
@ -57,6 +58,7 @@ amm_core = { path = "programs/amm/core" }
|
||||
amm_program = { path = "programs/amm" }
|
||||
test_program_methods = { path = "test_program_methods" }
|
||||
bedrock_client = { path = "bedrock_client" }
|
||||
testnet_initial_state = { path = "testnet_initial_state" }
|
||||
|
||||
tokio = { version = "1.50", features = [
|
||||
"net",
|
||||
|
||||
@ -14,6 +14,7 @@ nssa.workspace = true
|
||||
nssa_core.workspace = true
|
||||
storage.workspace = true
|
||||
key_protocol.workspace = true
|
||||
testnet_initial_state.workspace = true
|
||||
|
||||
anyhow.workspace = true
|
||||
log.workspace = true
|
||||
@ -29,4 +30,3 @@ async-stream.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
tempfile.workspace = true
|
||||
|
||||
|
||||
@ -9,11 +9,9 @@ use anyhow::{Context as _, Result};
|
||||
pub use bedrock_client::BackoffConfig;
|
||||
use common::config::BasicAuth;
|
||||
use humantime_serde;
|
||||
use key_protocol::initial_state::{
|
||||
PrivateAccountPublicInitialData, PublicAccountPublicInitialData,
|
||||
};
|
||||
pub use logos_blockchain_core::mantle::ops::channel::ChannelId;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use testnet_initial_state::{PrivateAccountPublicInitialData, PublicAccountPublicInitialData};
|
||||
use url::Url;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
|
||||
@ -6,13 +6,13 @@ use common::{
|
||||
HashType, PINATA_BASE58,
|
||||
block::{Block, HashableBlockData},
|
||||
};
|
||||
use key_protocol::initial_state::initial_state_testnet;
|
||||
use log::{debug, error, info};
|
||||
use logos_blockchain_core::mantle::{
|
||||
Op, SignedMantleTx,
|
||||
ops::channel::{ChannelId, inscribe::InscriptionOp},
|
||||
};
|
||||
use nssa::V02State;
|
||||
use testnet_initial_state::initial_state_testnet;
|
||||
|
||||
use crate::{block_store::IndexerStore, config::IndexerConfig};
|
||||
|
||||
@ -59,7 +59,7 @@ impl IndexerCore {
|
||||
|
||||
let initial_commitments: Option<Vec<nssa_core::Commitment>> = config
|
||||
.initial_private_accounts
|
||||
.clone()
|
||||
.as_ref()
|
||||
.map(|initial_commitments| {
|
||||
initial_commitments
|
||||
.iter()
|
||||
@ -78,7 +78,7 @@ impl IndexerCore {
|
||||
|
||||
let init_accs: Option<Vec<(nssa::AccountId, u128)>> = config
|
||||
.initial_public_accounts
|
||||
.clone()
|
||||
.as_ref()
|
||||
.map(|initial_accounts| {
|
||||
initial_accounts
|
||||
.iter()
|
||||
|
||||
@ -20,6 +20,7 @@ serde_json.workspace = true
|
||||
token_core.workspace = true
|
||||
indexer_service_rpc.workspace = true
|
||||
wallet-ffi.workspace = true
|
||||
testnet_initial_state.workspace = true
|
||||
|
||||
url.workspace = true
|
||||
|
||||
|
||||
@ -3,16 +3,14 @@ use std::{net::SocketAddr, path::PathBuf, time::Duration};
|
||||
use anyhow::{Context as _, Result};
|
||||
use bytesize::ByteSize;
|
||||
use indexer_service::{BackoffConfig, ChannelId, ClientConfig, IndexerConfig};
|
||||
use key_protocol::{
|
||||
initial_state::{
|
||||
PrivateAccountPrivateInitialData, PrivateAccountPublicInitialData,
|
||||
PublicAccountPrivateInitialData, PublicAccountPublicInitialData,
|
||||
},
|
||||
key_management::KeyChain,
|
||||
};
|
||||
use key_protocol::key_management::KeyChain;
|
||||
use nssa::{Account, AccountId, PrivateKey, PublicKey};
|
||||
use nssa_core::{account::Data, program::DEFAULT_PROGRAM_ID};
|
||||
use sequencer_core::config::{BedrockConfig, SequencerConfig};
|
||||
use testnet_initial_state::{
|
||||
PrivateAccountPrivateInitialData, PrivateAccountPublicInitialData,
|
||||
PublicAccountPrivateInitialData, PublicAccountPublicInitialData,
|
||||
};
|
||||
use url::Url;
|
||||
use wallet::config::{InitialAccountData, WalletConfig};
|
||||
|
||||
|
||||
@ -20,17 +20,16 @@ pub struct SeedHolder {
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
|
||||
/// Secret spending key object. Can produce `PrivateKeyHolder` objects.
|
||||
pub struct SecretSpendingKey(pub(crate) [u8; 32]);
|
||||
pub struct SecretSpendingKey(pub [u8; 32]);
|
||||
|
||||
pub type ViewingSecretKey = Scalar;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
/// Private key holder. Produces public keys. Can produce `account_id`. Can produce shared secret
|
||||
/// for recepient.
|
||||
#[expect(clippy::partial_pub_fields, reason = "TODO: fix later")]
|
||||
pub struct PrivateKeyHolder {
|
||||
pub nullifier_secret_key: NullifierSecretKey,
|
||||
pub(crate) viewing_secret_key: ViewingSecretKey,
|
||||
pub viewing_secret_key: ViewingSecretKey,
|
||||
}
|
||||
|
||||
impl SeedHolder {
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
#![expect(clippy::print_stdout, reason = "TODO: fix later")]
|
||||
|
||||
pub mod initial_state;
|
||||
pub mod key_management;
|
||||
pub mod key_protocol_core;
|
||||
|
||||
@ -37,4 +37,4 @@ test-case = "3.3.1"
|
||||
[features]
|
||||
default = []
|
||||
prove = ["risc0-zkvm/prove"]
|
||||
test-utils = []
|
||||
test-utils = []
|
||||
|
||||
@ -8,10 +8,12 @@ license = { workspace = true }
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
nssa = { workspace = true, optional = true, features = ["test-utils"], default-features = true }
|
||||
nssa = { workspace = true, optional = true, features = [
|
||||
"test-utils",
|
||||
], default-features = true }
|
||||
nssa_core.workspace = true
|
||||
token_core.workspace = true
|
||||
amm_core.workspace = true
|
||||
|
||||
[features]
|
||||
nssa = ["dep:nssa"]
|
||||
nssa = ["dep:nssa"]
|
||||
|
||||
@ -15,6 +15,7 @@ storage.workspace = true
|
||||
mempool.workspace = true
|
||||
bedrock_client.workspace = true
|
||||
key_protocol.workspace = true
|
||||
testnet_initial_state.workspace = true
|
||||
|
||||
anyhow.workspace = true
|
||||
serde.workspace = true
|
||||
|
||||
@ -10,11 +10,9 @@ use bedrock_client::BackoffConfig;
|
||||
use bytesize::ByteSize;
|
||||
use common::config::BasicAuth;
|
||||
use humantime_serde;
|
||||
use key_protocol::initial_state::{
|
||||
PrivateAccountPublicInitialData, PublicAccountPublicInitialData,
|
||||
};
|
||||
use logos_blockchain_core::mantle::ops::channel::ChannelId;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use testnet_initial_state::{PrivateAccountPublicInitialData, PublicAccountPublicInitialData};
|
||||
use url::Url;
|
||||
|
||||
// TODO: Provide default values
|
||||
|
||||
@ -10,13 +10,13 @@ use common::{
|
||||
transaction::NSSATransaction,
|
||||
};
|
||||
use config::SequencerConfig;
|
||||
use key_protocol::initial_state::initial_state;
|
||||
use log::{error, info, warn};
|
||||
use logos_blockchain_key_management_system_service::keys::{ED25519_SECRET_KEY_SIZE, Ed25519Key};
|
||||
use mempool::{MemPool, MemPoolHandle};
|
||||
#[cfg(feature = "mock")]
|
||||
pub use mock::SequencerCoreWithMockClients;
|
||||
use nssa::V02State;
|
||||
use testnet_initial_state::initial_state;
|
||||
|
||||
use crate::{
|
||||
block_settlement_client::{BlockSettlementClient, BlockSettlementClientTrait, MsgId},
|
||||
@ -386,9 +386,9 @@ mod tests {
|
||||
|
||||
use bedrock_client::BackoffConfig;
|
||||
use common::{test_utils::sequencer_sign_key_for_testing, transaction::NSSATransaction};
|
||||
use key_protocol::initial_state::{initial_accounts, initial_pub_accounts_private_keys};
|
||||
use logos_blockchain_core::mantle::ops::channel::ChannelId;
|
||||
use mempool::MemPoolHandle;
|
||||
use testnet_initial_state::{initial_accounts, initial_pub_accounts_private_keys};
|
||||
|
||||
use crate::{
|
||||
config::{BedrockConfig, SequencerConfig},
|
||||
|
||||
@ -14,6 +14,7 @@ mempool.workspace = true
|
||||
sequencer_core = { workspace = true }
|
||||
bedrock_client.workspace = true
|
||||
key_protocol.workspace = true
|
||||
testnet_initial_state.workspace = true
|
||||
|
||||
anyhow.workspace = true
|
||||
serde_json.workspace = true
|
||||
|
||||
@ -23,13 +23,13 @@ use common::{
|
||||
transaction::{NSSATransaction, TransactionMalformationError},
|
||||
};
|
||||
use itertools::Itertools as _;
|
||||
use key_protocol::initial_state::initial_accounts;
|
||||
use log::warn;
|
||||
use nssa::{self, program::Program};
|
||||
use sequencer_core::{
|
||||
block_settlement_client::BlockSettlementClientTrait, indexer_client::IndexerClientTrait,
|
||||
};
|
||||
use serde_json::Value;
|
||||
use testnet_initial_state::initial_accounts;
|
||||
|
||||
use super::{JsonHandler, respond, types::err_rpc::RpcErr};
|
||||
|
||||
@ -342,13 +342,13 @@ mod tests {
|
||||
use common::{
|
||||
config::BasicAuth, test_utils::sequencer_sign_key_for_testing, transaction::NSSATransaction,
|
||||
};
|
||||
use key_protocol::initial_state::{initial_accounts, initial_pub_accounts_private_keys};
|
||||
use sequencer_core::{
|
||||
config::{BedrockConfig, SequencerConfig},
|
||||
mock::{MockBlockSettlementClient, MockIndexerClient, SequencerCoreWithMockClients},
|
||||
};
|
||||
use serde_json::Value;
|
||||
use tempfile::tempdir;
|
||||
use testnet_initial_state::{initial_accounts, initial_pub_accounts_private_keys};
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
use crate::rpc_handler;
|
||||
|
||||
16
testnet_initial_state/Cargo.toml
Normal file
16
testnet_initial_state/Cargo.toml
Normal file
@ -0,0 +1,16 @@
|
||||
[package]
|
||||
name = "testnet_initial_state"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
license.workspace = true
|
||||
|
||||
[dependencies]
|
||||
key_protocol.workspace = true
|
||||
nssa.workspace = true
|
||||
nssa_core.workspace = true
|
||||
common.workspace = true
|
||||
|
||||
serde.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
@ -1,12 +1,11 @@
|
||||
use common::PINATA_BASE58;
|
||||
use nssa::{Account, AccountId, Data, PrivateKey, PublicKey, V02State};
|
||||
use nssa_core::{NullifierPublicKey, encryption::shared_key_derivation::Secp256k1Point};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::key_management::{
|
||||
use key_protocol::key_management::{
|
||||
KeyChain,
|
||||
secret_holders::{PrivateKeyHolder, SecretSpendingKey},
|
||||
};
|
||||
use nssa::{Account, AccountId, Data, PrivateKey, PublicKey, V02State};
|
||||
use nssa_core::{NullifierPublicKey, encryption::shared_key_derivation::Secp256k1Point};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
const PRIVATE_KEY_PUB_ACC_A: [u8; 32] = [
|
||||
16, 162, 106, 154, 236, 125, 52, 184, 35, 100, 238, 174, 69, 197, 41, 77, 187, 10, 118, 75, 0,
|
||||
@ -14,6 +14,7 @@ common.workspace = true
|
||||
key_protocol.workspace = true
|
||||
token_core.workspace = true
|
||||
amm_core.workspace = true
|
||||
testnet_initial_state.workspace = true
|
||||
|
||||
anyhow.workspace = true
|
||||
serde_json.workspace = true
|
||||
|
||||
@ -99,39 +99,24 @@ impl WalletChainStore {
|
||||
let mut public_init_acc_map = BTreeMap::new();
|
||||
let mut private_init_acc_map = BTreeMap::new();
|
||||
|
||||
// If initial accounts are present in config, need to construct state from them
|
||||
if let Some(initial_accounts) = config.initial_accounts.clone() {
|
||||
for init_acc_data in initial_accounts {
|
||||
match init_acc_data {
|
||||
InitialAccountData::Public(data) => {
|
||||
public_init_acc_map.insert(data.account_id, data.pub_sign_key);
|
||||
}
|
||||
InitialAccountData::Private(data) => {
|
||||
let mut account = data.account;
|
||||
// TODO: Program owner is only known after code is compiled and can't be set
|
||||
// in the config. Therefore we overwrite it here on
|
||||
// startup. Fix this when program id can be fetched
|
||||
// from the node and queried from the wallet.
|
||||
account.program_owner = Program::authenticated_transfer_program().id();
|
||||
private_init_acc_map.insert(data.account_id, (data.key_chain, account));
|
||||
}
|
||||
let initial_accounts = config
|
||||
.initial_accounts
|
||||
.clone()
|
||||
.unwrap_or_else(InitialAccountData::create_initial_accounts_data);
|
||||
|
||||
for init_acc_data in initial_accounts {
|
||||
match init_acc_data {
|
||||
InitialAccountData::Public(data) => {
|
||||
public_init_acc_map.insert(data.account_id, data.pub_sign_key);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for init_acc_data in InitialAccountData::create_initial_accounts_data() {
|
||||
match init_acc_data {
|
||||
InitialAccountData::Public(data) => {
|
||||
public_init_acc_map.insert(data.account_id, data.pub_sign_key);
|
||||
}
|
||||
InitialAccountData::Private(data) => {
|
||||
let mut account = data.account;
|
||||
// TODO: Program owner is only known after code is compiled and can't be set
|
||||
// in the config. Therefore we overwrite it here on
|
||||
// startup. Fix this when program id can be fetched
|
||||
// from the node and queried from the wallet.
|
||||
account.program_owner = Program::authenticated_transfer_program().id();
|
||||
private_init_acc_map.insert(data.account_id, (data.key_chain, account));
|
||||
}
|
||||
InitialAccountData::Private(data) => {
|
||||
let mut account = data.account;
|
||||
// TODO: Program owner is only known after code is compiled and can't be set
|
||||
// in the config. Therefore we overwrite it here on
|
||||
// startup. Fix this when program id can be fetched
|
||||
// from the node and queried from the wallet.
|
||||
account.program_owner = Program::authenticated_transfer_program().id();
|
||||
private_init_acc_map.insert(data.account_id, (data.key_chain, account));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,7 +69,17 @@ impl WalletSubcommand for ConfigSubcommand {
|
||||
);
|
||||
}
|
||||
"initial_accounts" => {
|
||||
println!("{:#?}", InitialAccountData::create_initial_accounts_data());
|
||||
println!(
|
||||
"{:#?}",
|
||||
wallet_core
|
||||
.storage
|
||||
.wallet_config
|
||||
.initial_accounts
|
||||
.clone()
|
||||
.unwrap_or_else(
|
||||
InitialAccountData::create_initial_accounts_data
|
||||
)
|
||||
);
|
||||
}
|
||||
"basic_auth" => {
|
||||
if let Some(basic_auth) = &wallet_core.storage.wallet_config.basic_auth
|
||||
|
||||
@ -8,17 +8,15 @@ use std::{
|
||||
use anyhow::{Context as _, Result};
|
||||
use common::config::BasicAuth;
|
||||
use humantime_serde;
|
||||
use key_protocol::{
|
||||
initial_state::{
|
||||
PrivateAccountPrivateInitialData, PublicAccountPrivateInitialData,
|
||||
initial_priv_accounts_private_keys, initial_pub_accounts_private_keys,
|
||||
},
|
||||
key_management::key_tree::{
|
||||
chain_index::ChainIndex, keys_private::ChildKeysPrivate, keys_public::ChildKeysPublic,
|
||||
},
|
||||
use key_protocol::key_management::key_tree::{
|
||||
chain_index::ChainIndex, keys_private::ChildKeysPrivate, keys_public::ChildKeysPublic,
|
||||
};
|
||||
use log::warn;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use testnet_initial_state::{
|
||||
PrivateAccountPrivateInitialData, PublicAccountPrivateInitialData,
|
||||
initial_priv_accounts_private_keys, initial_pub_accounts_private_keys,
|
||||
};
|
||||
use url::Url;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
|
||||
@ -2,14 +2,12 @@ use std::{collections::HashMap, path::PathBuf, str::FromStr as _};
|
||||
|
||||
use anyhow::{Context as _, Result};
|
||||
use base58::ToBase58 as _;
|
||||
use key_protocol::{
|
||||
initial_state::{PrivateAccountPrivateInitialData, PublicAccountPrivateInitialData},
|
||||
key_protocol_core::NSSAUserData,
|
||||
};
|
||||
use key_protocol::key_protocol_core::NSSAUserData;
|
||||
use nssa::Account;
|
||||
use nssa_core::account::Nonce;
|
||||
use rand::{RngCore as _, rngs::OsRng};
|
||||
use serde::Serialize;
|
||||
use testnet_initial_state::{PrivateAccountPrivateInitialData, PublicAccountPrivateInitialData};
|
||||
|
||||
use crate::{
|
||||
HOME_DIR_ENV_VAR,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user