mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-07-25 23:23:11 +00:00
Merge branch 'Pravdyvy/node-wallet-rewrite' into schouhy/implement-nssa-v0.1-public-state-tmp
This commit is contained in:
@@ -30,14 +30,8 @@ path = "../sequencer_core"
|
||||
[dependencies.sequencer_runner]
|
||||
path = "../sequencer_runner"
|
||||
|
||||
[dependencies.node_rpc]
|
||||
path = "../node_rpc"
|
||||
|
||||
[dependencies.node_core]
|
||||
path = "../node_core"
|
||||
|
||||
[dependencies.node_runner]
|
||||
path = "../node_runner"
|
||||
[dependencies.wallet]
|
||||
path = "../wallet"
|
||||
|
||||
[dependencies.common]
|
||||
path = "../common"
|
||||
|
||||
@@ -1,253 +1,45 @@
|
||||
{
|
||||
"home": "./node",
|
||||
"override_rust_log": null,
|
||||
"sequencer_addr": "http://127.0.0.1:3040",
|
||||
"seq_poll_timeout_secs": 10,
|
||||
"port": 3041,
|
||||
"gas_config": {
|
||||
"gas_fee_per_byte_deploy": 100,
|
||||
"gas_fee_per_input_buffer_runtime": 1000,
|
||||
"gas_fee_per_byte_runtime": 10,
|
||||
"gas_cost_runtime": 100,
|
||||
"gas_cost_deploy": 1000,
|
||||
"gas_limit_deploy": 30000000,
|
||||
"gas_limit_runtime": 30000000
|
||||
},
|
||||
"shapshot_frequency_in_blocks": 10,
|
||||
"initial_accounts": [
|
||||
{
|
||||
"address": [
|
||||
13,
|
||||
150,
|
||||
223,
|
||||
204,
|
||||
65,
|
||||
64,
|
||||
25,
|
||||
56,
|
||||
12,
|
||||
157,
|
||||
222,
|
||||
12,
|
||||
211,
|
||||
220,
|
||||
229,
|
||||
170,
|
||||
201,
|
||||
15,
|
||||
181,
|
||||
68,
|
||||
59,
|
||||
248,
|
||||
113,
|
||||
16,
|
||||
135,
|
||||
65,
|
||||
174,
|
||||
175,
|
||||
222,
|
||||
85,
|
||||
42,
|
||||
215
|
||||
],
|
||||
"balance": 10000,
|
||||
"key_holder": {
|
||||
"address": [
|
||||
13,
|
||||
150,
|
||||
223,
|
||||
204,
|
||||
65,
|
||||
64,
|
||||
25,
|
||||
56,
|
||||
12,
|
||||
157,
|
||||
222,
|
||||
12,
|
||||
211,
|
||||
220,
|
||||
229,
|
||||
170,
|
||||
201,
|
||||
15,
|
||||
181,
|
||||
68,
|
||||
59,
|
||||
248,
|
||||
113,
|
||||
16,
|
||||
135,
|
||||
65,
|
||||
174,
|
||||
175,
|
||||
222,
|
||||
85,
|
||||
42,
|
||||
215
|
||||
],
|
||||
"nullifer_public_key": "03A340BECA9FAAB444CED0140681D72EA1318B5C611704FEE017DA9836B17DB718",
|
||||
"pub_account_signing_key": [
|
||||
133,
|
||||
143,
|
||||
177,
|
||||
187,
|
||||
252,
|
||||
66,
|
||||
237,
|
||||
236,
|
||||
234,
|
||||
252,
|
||||
244,
|
||||
138,
|
||||
5,
|
||||
151,
|
||||
3,
|
||||
99,
|
||||
217,
|
||||
231,
|
||||
112,
|
||||
217,
|
||||
77,
|
||||
211,
|
||||
58,
|
||||
218,
|
||||
176,
|
||||
68,
|
||||
99,
|
||||
53,
|
||||
152,
|
||||
228,
|
||||
198,
|
||||
190
|
||||
],
|
||||
"top_secret_key_holder": {
|
||||
"secret_spending_key": "7BC46784DB1BC67825D8F029436846712BFDF9B5D79EA3AB11D39A52B9B229D4"
|
||||
},
|
||||
"utxo_secret_key_holder": {
|
||||
"nullifier_secret_key": "BB54A8D3C9C51B82C431082D1845A74677B0EF829A11B517E1D9885DE3139506",
|
||||
"viewing_secret_key": "AD923E92F6A5683E30140CEAB2702AFB665330C1EE4EFA70FAF29767B6B52BAF"
|
||||
},
|
||||
"viewing_public_key": "0361220C5D277E7A1709340FD31A52600C1432B9C45B9BCF88A43581D58824A8B6"
|
||||
},
|
||||
"utxos": {}
|
||||
"home": "./node",
|
||||
"override_rust_log": null,
|
||||
"sequencer_addr": "http://127.0.0.1:3040",
|
||||
"seq_poll_timeout_secs": 10,
|
||||
"initial_accounts": [
|
||||
{
|
||||
"address": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
|
||||
"balance": 10000,
|
||||
"key_holder": {
|
||||
"address": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
|
||||
"nullifer_public_key": "03A340BECA9FAAB444CED0140681D72EA1318B5C611704FEE017DA9836B17DB718",
|
||||
"pub_account_signing_key": 1,
|
||||
"top_secret_key_holder": {
|
||||
"secret_spending_key": "7BC46784DB1BC67825D8F029436846712BFDF9B5D79EA3AB11D39A52B9B229D4"
|
||||
},
|
||||
{
|
||||
"address": [
|
||||
151,
|
||||
72,
|
||||
112,
|
||||
233,
|
||||
190,
|
||||
141,
|
||||
10,
|
||||
192,
|
||||
138,
|
||||
168,
|
||||
59,
|
||||
63,
|
||||
199,
|
||||
167,
|
||||
166,
|
||||
134,
|
||||
41,
|
||||
29,
|
||||
135,
|
||||
50,
|
||||
80,
|
||||
138,
|
||||
186,
|
||||
152,
|
||||
179,
|
||||
96,
|
||||
128,
|
||||
243,
|
||||
156,
|
||||
44,
|
||||
243,
|
||||
100
|
||||
],
|
||||
"balance": 20000,
|
||||
"key_holder": {
|
||||
"address": [
|
||||
151,
|
||||
72,
|
||||
112,
|
||||
233,
|
||||
190,
|
||||
141,
|
||||
10,
|
||||
192,
|
||||
138,
|
||||
168,
|
||||
59,
|
||||
63,
|
||||
199,
|
||||
167,
|
||||
166,
|
||||
134,
|
||||
41,
|
||||
29,
|
||||
135,
|
||||
50,
|
||||
80,
|
||||
138,
|
||||
186,
|
||||
152,
|
||||
179,
|
||||
96,
|
||||
128,
|
||||
243,
|
||||
156,
|
||||
44,
|
||||
243,
|
||||
100
|
||||
],
|
||||
"nullifer_public_key": "02172F50274DE67C4087C344F5D58E11DF761D90285B095060E0994FAA6BCDE271",
|
||||
"pub_account_signing_key": [
|
||||
54,
|
||||
90,
|
||||
62,
|
||||
225,
|
||||
71,
|
||||
225,
|
||||
228,
|
||||
148,
|
||||
143,
|
||||
53,
|
||||
210,
|
||||
23,
|
||||
137,
|
||||
158,
|
||||
171,
|
||||
156,
|
||||
48,
|
||||
7,
|
||||
139,
|
||||
52,
|
||||
117,
|
||||
242,
|
||||
214,
|
||||
7,
|
||||
99,
|
||||
29,
|
||||
122,
|
||||
184,
|
||||
59,
|
||||
116,
|
||||
144,
|
||||
107
|
||||
],
|
||||
"top_secret_key_holder": {
|
||||
"secret_spending_key": "80A186737C8D38B4288A03F0F589957D9C040D79C19F3E0CC4BA80F8494E5179"
|
||||
},
|
||||
"utxo_secret_key_holder": {
|
||||
"nullifier_secret_key": "746928E63F0984F6F4818933493CE9C067562D9CB932FDC06D82C86CDF6D7122",
|
||||
"viewing_secret_key": "89176CF4BC9E673807643FD52110EF99D4894335AFB10D881AC0B5041FE1FCB7"
|
||||
},
|
||||
"viewing_public_key": "026072A8F83FEC3472E30CDD4767683F30B91661D25B1040AD9A5FC2E01D659F99"
|
||||
},
|
||||
"utxos": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
"utxo_secret_key_holder": {
|
||||
"nullifier_secret_key": "BB54A8D3C9C51B82C431082D1845A74677B0EF829A11B517E1D9885DE3139506",
|
||||
"viewing_secret_key": "AD923E92F6A5683E30140CEAB2702AFB665330C1EE4EFA70FAF29767B6B52BAF"
|
||||
},
|
||||
"viewing_public_key": "0361220C5D277E7A1709340FD31A52600C1432B9C45B9BCF88A43581D58824A8B6"
|
||||
},
|
||||
"utxos": {}
|
||||
},
|
||||
{
|
||||
"address": [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],
|
||||
"balance": 20000,
|
||||
"key_holder": {
|
||||
"address": [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],
|
||||
"nullifer_public_key": "02172F50274DE67C4087C344F5D58E11DF761D90285B095060E0994FAA6BCDE271",
|
||||
"pub_account_signing_key": 2,
|
||||
"top_secret_key_holder": {
|
||||
"secret_spending_key": "80A186737C8D38B4288A03F0F589957D9C040D79C19F3E0CC4BA80F8494E5179"
|
||||
},
|
||||
"utxo_secret_key_holder": {
|
||||
"nullifier_secret_key": "746928E63F0984F6F4818933493CE9C067562D9CB932FDC06D82C86CDF6D7122",
|
||||
"viewing_secret_key": "89176CF4BC9E673807643FD52110EF99D4894335AFB10D881AC0B5041FE1FCB7"
|
||||
},
|
||||
"viewing_public_key": "026072A8F83FEC3472E30CDD4767683F30B91661D25B1040AD9A5FC2E01D659F99"
|
||||
},
|
||||
"utxos": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
"port": 3040,
|
||||
"initial_accounts": [
|
||||
{
|
||||
"addr": "0d96dfcc414019380c9dde0cd3dce5aac90fb5443bf871108741aeafde552ad7",
|
||||
"addr": "0101010101010101010101010101010101010101010101010101010101010101",
|
||||
"balance": 10000
|
||||
},
|
||||
{
|
||||
"addr": "974870e9be8d0ac08aa83b3fc7a7a686291d8732508aba98b36080f39c2cf364",
|
||||
"addr": "0202020202020202020202020202020202020202020202020202020202020202",
|
||||
"balance": 20000
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
use std::{path::PathBuf, sync::Arc, time::Duration};
|
||||
use std::{path::PathBuf, time::Duration};
|
||||
|
||||
use actix_web::dev::ServerHandle;
|
||||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
use common::rpc_primitives::RpcConfig;
|
||||
use common::sequencer_client::SequencerClient;
|
||||
use log::info;
|
||||
use node_core::{NodeCore, config::NodeConfig};
|
||||
use sequencer_core::config::SequencerConfig;
|
||||
use sequencer_runner::startup_sequencer;
|
||||
use tempfile::TempDir;
|
||||
use tokio::{sync::Mutex, task::JoinHandle};
|
||||
use tokio::task::JoinHandle;
|
||||
use wallet::{Command, helperfunctions::fetch_config};
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[clap(version)]
|
||||
@@ -20,92 +20,49 @@ struct Args {
|
||||
test_name: String,
|
||||
}
|
||||
|
||||
pub const ACC_SENDER: &str = "0d96dfcc414019380c9dde0cd3dce5aac90fb5443bf871108741aeafde552ad7";
|
||||
pub const ACC_RECEIVER: &str = "974870e9be8d0ac08aa83b3fc7a7a686291d8732508aba98b36080f39c2cf364";
|
||||
pub const ACC_SENDER: &str = "0101010101010101010101010101010101010101010101010101010101010101";
|
||||
pub const ACC_RECEIVER: &str = "0202020202020202020202020202020202020202020202020202020202020202";
|
||||
|
||||
pub const TIME_TO_WAIT_FOR_BLOCK_SECONDS: u64 = 12;
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
pub async fn pre_test(
|
||||
home_dir: PathBuf,
|
||||
) -> Result<(
|
||||
ServerHandle,
|
||||
JoinHandle<Result<()>>,
|
||||
ServerHandle,
|
||||
TempDir,
|
||||
TempDir,
|
||||
Arc<Mutex<NodeCore>>,
|
||||
)> {
|
||||
) -> Result<(ServerHandle, JoinHandle<Result<()>>, TempDir)> {
|
||||
let home_dir_sequencer = home_dir.join("sequencer");
|
||||
let home_dir_node = home_dir.join("node");
|
||||
|
||||
let mut sequencer_config =
|
||||
sequencer_runner::config::from_file(home_dir_sequencer.join("sequencer_config.json"))
|
||||
.unwrap();
|
||||
let mut node_config =
|
||||
node_runner::config::from_file(home_dir_node.join("node_config.json")).unwrap();
|
||||
|
||||
let (temp_dir_node, temp_dir_sequencer) =
|
||||
replace_home_dir_with_temp_dir_in_configs(&mut node_config, &mut sequencer_config);
|
||||
let temp_dir_sequencer = replace_home_dir_with_temp_dir_in_configs(&mut sequencer_config);
|
||||
|
||||
let (seq_http_server_handle, sequencer_loop_handle) =
|
||||
startup_sequencer(sequencer_config).await?;
|
||||
|
||||
let node_port = node_config.port;
|
||||
|
||||
let node_core = NodeCore::start_from_config_update_chain(node_config.clone()).await?;
|
||||
|
||||
let wrapped_node_core = Arc::new(Mutex::new(node_core));
|
||||
|
||||
let http_server = node_rpc::new_http_server(
|
||||
RpcConfig::with_port(node_port),
|
||||
node_config.clone(),
|
||||
wrapped_node_core.clone(),
|
||||
)?;
|
||||
info!("HTTP server started");
|
||||
let node_http_server_handle = http_server.handle();
|
||||
tokio::spawn(http_server);
|
||||
|
||||
Ok((
|
||||
seq_http_server_handle,
|
||||
sequencer_loop_handle,
|
||||
node_http_server_handle,
|
||||
temp_dir_node,
|
||||
temp_dir_sequencer,
|
||||
wrapped_node_core,
|
||||
))
|
||||
}
|
||||
|
||||
pub fn replace_home_dir_with_temp_dir_in_configs(
|
||||
node_config: &mut NodeConfig,
|
||||
sequencer_config: &mut SequencerConfig,
|
||||
) -> (TempDir, TempDir) {
|
||||
let temp_dir_node = tempfile::tempdir().unwrap();
|
||||
) -> TempDir {
|
||||
let temp_dir_sequencer = tempfile::tempdir().unwrap();
|
||||
|
||||
node_config.home = temp_dir_node.path().to_path_buf();
|
||||
sequencer_config.home = temp_dir_sequencer.path().to_path_buf();
|
||||
|
||||
(temp_dir_node, temp_dir_sequencer)
|
||||
temp_dir_sequencer
|
||||
}
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
pub async fn post_test(
|
||||
residual: (
|
||||
ServerHandle,
|
||||
JoinHandle<Result<()>>,
|
||||
ServerHandle,
|
||||
TempDir,
|
||||
TempDir,
|
||||
Arc<Mutex<NodeCore>>,
|
||||
),
|
||||
) {
|
||||
let (seq_http_server_handle, sequencer_loop_handle, node_http_server_handle, _, _, _) =
|
||||
residual;
|
||||
pub async fn post_test(residual: (ServerHandle, JoinHandle<Result<()>>, TempDir)) {
|
||||
let (seq_http_server_handle, sequencer_loop_handle, _) = residual;
|
||||
|
||||
info!("Cleanup");
|
||||
|
||||
node_http_server_handle.stop(true).await;
|
||||
sequencer_loop_handle.abort();
|
||||
seq_http_server_handle.stop(true).await;
|
||||
|
||||
@@ -113,28 +70,28 @@ pub async fn post_test(
|
||||
//So they are dropped and tempdirs will be dropped too,
|
||||
}
|
||||
|
||||
pub async fn test_success(wrapped_node_core: Arc<Mutex<NodeCore>>) {
|
||||
let acc_sender = hex::decode(ACC_SENDER).unwrap().try_into().unwrap();
|
||||
let acc_receiver = hex::decode(ACC_RECEIVER).unwrap().try_into().unwrap();
|
||||
pub async fn test_success() {
|
||||
let command = Command::SendNativeTokenTransfer {
|
||||
from: ACC_SENDER.to_string(),
|
||||
to: ACC_RECEIVER.to_string(),
|
||||
amount: 100,
|
||||
};
|
||||
|
||||
let guard = wrapped_node_core.lock().await;
|
||||
let node_config = fetch_config().unwrap();
|
||||
|
||||
let _res = guard
|
||||
.send_public_native_token_transfer(acc_sender, 0, acc_receiver, 100)
|
||||
.await
|
||||
.unwrap();
|
||||
let seq_client = SequencerClient::new(node_config.sequencer_addr.clone()).unwrap();
|
||||
|
||||
wallet::execute_subcommand(command).await.unwrap();
|
||||
|
||||
info!("Waiting for next block creation");
|
||||
tokio::time::sleep(Duration::from_secs(TIME_TO_WAIT_FOR_BLOCK_SECONDS)).await;
|
||||
|
||||
info!("Checking correct balance move");
|
||||
let acc_1_balance = guard
|
||||
.sequencer_client
|
||||
let acc_1_balance = seq_client
|
||||
.get_account_balance(ACC_SENDER.to_string())
|
||||
.await
|
||||
.unwrap();
|
||||
let acc_2_balance = guard
|
||||
.sequencer_client
|
||||
let acc_2_balance = seq_client
|
||||
.get_account_balance(ACC_RECEIVER.to_string())
|
||||
.await
|
||||
.unwrap();
|
||||
@@ -148,30 +105,30 @@ pub async fn test_success(wrapped_node_core: Arc<Mutex<NodeCore>>) {
|
||||
info!("Success!");
|
||||
}
|
||||
|
||||
pub async fn test_success_move_to_another_account(wrapped_node_core: Arc<Mutex<NodeCore>>) {
|
||||
let acc_sender = hex::decode(ACC_SENDER).unwrap().try_into().unwrap();
|
||||
let acc_receiver_new_acc = [42; 32];
|
||||
pub async fn test_success_move_to_another_account() {
|
||||
let hex_acc_receiver_new_acc = hex::encode([42; 32]);
|
||||
|
||||
let hex_acc_receiver_new_acc = hex::encode(acc_receiver_new_acc);
|
||||
let command = Command::SendNativeTokenTransfer {
|
||||
from: ACC_SENDER.to_string(),
|
||||
to: hex_acc_receiver_new_acc.clone(),
|
||||
amount: 100,
|
||||
};
|
||||
|
||||
let guard = wrapped_node_core.lock().await;
|
||||
let node_config = fetch_config().unwrap();
|
||||
|
||||
let _res = guard
|
||||
.send_public_native_token_transfer(acc_sender, 0, acc_receiver_new_acc, 100)
|
||||
.await
|
||||
.unwrap();
|
||||
let seq_client = SequencerClient::new(node_config.sequencer_addr.clone()).unwrap();
|
||||
|
||||
wallet::execute_subcommand(command).await.unwrap();
|
||||
|
||||
info!("Waiting for next block creation");
|
||||
tokio::time::sleep(Duration::from_secs(TIME_TO_WAIT_FOR_BLOCK_SECONDS)).await;
|
||||
|
||||
info!("Checking correct balance move");
|
||||
let acc_1_balance = guard
|
||||
.sequencer_client
|
||||
let acc_1_balance = seq_client
|
||||
.get_account_balance(ACC_SENDER.to_string())
|
||||
.await
|
||||
.unwrap();
|
||||
let acc_2_balance = guard
|
||||
.sequencer_client
|
||||
let acc_2_balance = seq_client
|
||||
.get_account_balance(hex_acc_receiver_new_acc)
|
||||
.await
|
||||
.unwrap();
|
||||
@@ -185,28 +142,28 @@ pub async fn test_success_move_to_another_account(wrapped_node_core: Arc<Mutex<N
|
||||
info!("Success!");
|
||||
}
|
||||
|
||||
pub async fn test_failure(wrapped_node_core: Arc<Mutex<NodeCore>>) {
|
||||
let acc_sender = hex::decode(ACC_SENDER).unwrap().try_into().unwrap();
|
||||
let acc_receiver = hex::decode(ACC_RECEIVER).unwrap().try_into().unwrap();
|
||||
pub async fn test_failure() {
|
||||
let command = Command::SendNativeTokenTransfer {
|
||||
from: ACC_SENDER.to_string(),
|
||||
to: ACC_RECEIVER.to_string(),
|
||||
amount: 1000000,
|
||||
};
|
||||
|
||||
let guard = wrapped_node_core.lock().await;
|
||||
let node_config = fetch_config().unwrap();
|
||||
|
||||
let _res = guard
|
||||
.send_public_native_token_transfer(acc_sender, 0, acc_receiver, 100000)
|
||||
.await
|
||||
.unwrap();
|
||||
let seq_client = SequencerClient::new(node_config.sequencer_addr.clone()).unwrap();
|
||||
|
||||
wallet::execute_subcommand(command).await.unwrap();
|
||||
|
||||
info!("Waiting for next block creation");
|
||||
tokio::time::sleep(Duration::from_secs(TIME_TO_WAIT_FOR_BLOCK_SECONDS)).await;
|
||||
|
||||
info!("Checking correct balance move");
|
||||
let acc_1_balance = guard
|
||||
.sequencer_client
|
||||
let acc_1_balance = seq_client
|
||||
.get_account_balance(ACC_SENDER.to_string())
|
||||
.await
|
||||
.unwrap();
|
||||
let acc_2_balance = guard
|
||||
.sequencer_client
|
||||
let acc_2_balance = seq_client
|
||||
.get_account_balance(ACC_RECEIVER.to_string())
|
||||
.await
|
||||
.unwrap();
|
||||
@@ -224,12 +181,10 @@ macro_rules! test_cleanup_wrap {
|
||||
($home_dir:ident, $test_func:ident) => {{
|
||||
let res = pre_test($home_dir.clone()).await.unwrap();
|
||||
|
||||
let wrapped_node_core = res.5.clone();
|
||||
|
||||
info!("Waiting for first block creation");
|
||||
tokio::time::sleep(Duration::from_secs(TIME_TO_WAIT_FOR_BLOCK_SECONDS)).await;
|
||||
|
||||
$test_func(wrapped_node_core.clone()).await;
|
||||
$test_func().await;
|
||||
|
||||
post_test(res).await;
|
||||
}};
|
||||
|
||||
Reference in New Issue
Block a user