Update all dependencies.

This commit is contained in:
parazyd
2022-04-20 11:57:33 +02:00
parent f6d36a15e1
commit 0299b45de3
19 changed files with 227 additions and 614 deletions

556
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -35,7 +35,7 @@ members = [
[dependencies]
# Hard dependencies
libc = "0.2.123"
libc = "0.2.124"
log = "0.4.16"
thiserror = "1.0.30"
@@ -86,7 +86,7 @@ regex = {version = "1.1.9", optional = true}
# Misc
termion = {version = "1.5.6", optional = true}
simplelog = {version = "0.12.0-alpha1", optional = true}
simplelog = {version = "0.12.0", optional = true}
# Websockets
tungstenite = {version = "0.17.2", optional = true}
@@ -116,14 +116,14 @@ wasmer-compiler-singlepass = {version = "2.2.1", optional = true}
wasmer-middlewares = {version = "2.2.1", optional = true}
# Wallet management
sqlx = {version = "0.5.12", features = ["runtime-async-std-native-tls", "sqlite"], optional = true}
sqlx = {version = "0.5.13", features = ["runtime-async-std-native-tls", "sqlite"], optional = true}
libsqlite3-sys = {version = "0.24.2", features = ["bundled-sqlcipher"], optional = true }
# Blockchain store
sled = {version = "0.34.7", optional = true}
[dev-dependencies]
clap = {version = "3.1.8", features = ["derive"]}
clap = {version = "3.1.10", features = ["derive"]}
[features]
async-runtime = [
@@ -259,9 +259,6 @@ wasm-runtime = [
node = [
"url",
"bytes",
"zeromq",
"signal-hook",
"signal-hook-async-std",
"lazy-init",
"async-runtime",

View File

@@ -21,10 +21,10 @@ easy-parallel = "3.2.0"
rand = "0.8.5"
# Misc
clap = {version = "3.1.8", features = ["derive"]}
clap = {version = "3.1.10", features = ["derive"]}
log = "0.4.16"
num_cpus = "1.13.1"
simplelog = "0.12.0-alpha1"
simplelog = "0.12.0"
thiserror = "1.0.30"
url = "2.2.2"
fxhash = "0.2.1"
@@ -49,8 +49,8 @@ num-bigint = {version = "0.4.3", features = ["rand", "serde"], optional = true}
# Solana bridge dependencies
native-tls = {version = "0.2.10", optional = true}
async-native-tls = {version = "0.4.0", optional = true}
solana-client = {version = "1.10.3", optional = true}
solana-sdk = {version = "1.10.3", optional = true}
solana-client = {version = "1.10.9", optional = true}
solana-sdk = {version = "1.10.9", optional = true}
spl-associated-token-account = {version = "1.0.3", features = ["no-entrypoint"], optional = true}
spl-token = {version = "3.2.0", features = ["no-entrypoint"], optional = true}
tungstenite = {version = "0.17.2", optional = true}

View File

@@ -18,10 +18,10 @@ async-executor = "1.4.1"
easy-parallel = "3.2.0"
# Misc
clap = {version = "3.1.8", features = ["derive"]}
clap = {version = "3.1.10", features = ["derive"]}
log = "0.4.16"
num_cpus = "1.13.1"
simplelog = "0.12.0-alpha1"
simplelog = "0.12.0"
url = "2.2.2"
# Encoding and parsing

View File

@@ -20,7 +20,7 @@ easy-parallel = "3.2.0"
# Misc
log = "0.4.16"
num_cpus = "1.13.1"
simplelog = "0.12.0-alpha1"
simplelog = "0.12.0"
# Encoding and parsing
serde_json = "1.0.79"

View File

@@ -17,11 +17,11 @@ async-executor = "1.4.1"
easy-parallel = "3.2.0"
# Misc
clap = {version = "3.1.8", features = ["derive"]}
clap = {version = "3.1.10", features = ["derive"]}
url = "2.2.2"
log = "0.4.16"
num_cpus = "1.13.1"
simplelog = "0.12.0-alpha1"
simplelog = "0.12.0"
fxhash = "0.2.1"
# Encoding and parsing

View File

@@ -15,14 +15,14 @@ async-std = "1.11.0"
async-trait = "0.1.53"
chrono = "0.4.19"
ctrlc-async = {version = "3.2.2", default-features = false, features = ["async-std", "termination"]}
darkfi = {path = "../../", features = ["blockchain2", "wallet", "rpc", "net"]}
darkfi = {path = "../../", features = ["blockchain", "wallet", "rpc", "net", "node"]}
easy-parallel = "3.2.0"
futures-lite = "1.12.0"
lazy-init = "0.5.0"
log = "0.4.16"
rand = "0.8.5"
serde_json = "1.0.79"
simplelog = "0.12.0-alpha1"
simplelog = "0.12.0"
sled = "0.34.7"
url = "2.2.2"

View File

@@ -1,75 +0,0 @@
use async_std::sync::Mutex;
use lazy_init::Lazy;
use log::info;
use darkfi::{
crypto::{
address::Address,
keypair::{Keypair, PublicKey},
proof::ProvingKey,
},
wallet::walletdb::WalletPtr,
Result,
};
pub struct Client {
main_keypair: Mutex<Keypair>,
wallet: WalletPtr,
mint_pk: Lazy<ProvingKey>,
burn_pk: Lazy<ProvingKey>,
}
impl Client {
pub async fn new(wallet: WalletPtr) -> Result<Self> {
// Initialize or load the wallet
wallet.init_db().await?;
// Check if there is a default keypair and generate one in
// case we don't have any.
if wallet.get_default_keypair().await.is_err() {
// TODO: Clean this up with Option<T> to have less calls.
if wallet.get_keypairs().await?.is_empty() {
wallet.keygen().await?;
}
wallet.set_default_keypair(&wallet.get_keypairs().await?[0].public).await?;
}
// Generate Merkle Tree if we don't have one.
// if wallet.get_tree().await.is_err() {
// wallet.tree_gen().await?;
// }
let main_keypair = wallet.get_default_keypair().await?;
info!(target: "CLIENT", "Main keypair: {}", Address::from(main_keypair.public));
Ok(Self {
main_keypair: Mutex::new(main_keypair),
wallet,
mint_pk: Lazy::new(),
burn_pk: Lazy::new(),
})
}
pub async fn keygen(&self) -> Result<Address> {
let kp = self.wallet.keygen().await?;
Ok(Address::from(kp.public))
}
pub async fn get_keypairs(&self) -> Result<Vec<Keypair>> {
self.wallet.get_keypairs().await
}
pub async fn put_keypair(&self, keypair: &Keypair) -> Result<()> {
self.wallet.put_keypair(keypair).await
}
pub async fn set_default_keypair(&self, public: &PublicKey) -> Result<()> {
self.wallet.set_default_keypair(public).await?;
let kp = self.wallet.get_default_keypair().await?;
let mut mk = self.main_keypair.lock().await;
*mk = kp;
drop(mk);
Ok(())
}
}

View File

@@ -5,6 +5,7 @@ use async_std::sync::{Arc, Mutex};
use async_trait::async_trait;
use easy_parallel::Parallel;
use futures_lite::future;
use lazy_init::Lazy;
use log::{error, info};
use rand::Rng;
use serde_derive::Deserialize;
@@ -15,6 +16,8 @@ use structopt_toml::StructOptToml;
use url::Url;
use darkfi::{
async_daemonize,
blockchain2::{NullifierStore, RootStore},
cli_desc,
consensus2::{
proto::{ProtocolParticipant, ProtocolProposal, ProtocolTx, ProtocolVote},
@@ -28,6 +31,7 @@ use darkfi::{
},
net,
net::P2pPtr,
node::{Client, State},
rpc::{
jsonrpc,
jsonrpc::{
@@ -45,9 +49,6 @@ use darkfi::{
Error, Result,
};
mod client;
use client::Client;
mod error;
use error::{server_error, RpcError};
@@ -116,9 +117,9 @@ struct Args {
pub struct Darkfid {
client: Client,
state: ValidatorStatePtr,
p2p: P2pPtr,
synced: Mutex<bool>,
validator_state: ValidatorStatePtr,
state: Arc<Mutex<State>>,
}
#[async_trait]
@@ -137,16 +138,36 @@ impl RequestHandler for Darkfid {
Some("export_keypair") => return self.export_keypair(req.id, params).await,
Some("import_keypair") => return self.import_keypair(req.id, params).await,
Some("set_default_address") => return self.set_default_address(req.id, params).await,
Some("tx") => return self.receive_tx(req.id, params).await,
Some(_) | None => return jsonrpc::error(MethodNotFound, None, req.id).into(),
}
}
}
impl Darkfid {
pub async fn new(wallet: WalletPtr, state: ValidatorStatePtr, p2p: P2pPtr) -> Result<Self> {
pub async fn new(
db: &sled::Db,
wallet: WalletPtr,
validator_state: ValidatorStatePtr,
p2p: P2pPtr,
) -> Result<Self> {
// Initialize Client
let client = Client::new(wallet).await?;
Ok(Self { client, state, p2p, synced: Mutex::new(false) })
let tree = client.get_tree().await?;
let merkle_roots = RootStore::new(db)?;
let nullifiers = NullifierStore::new(db)?;
// Initialize State
let state = Arc::new(Mutex::new(State {
tree,
merkle_roots,
nullifiers,
cashier_pubkeys: vec![],
faucet_pubkeys: vec![],
mint_vk: Lazy::new(),
burn_vk: Lazy::new(),
}));
Ok(Self { client, p2p, validator_state, state })
}
// RPCAPI:
@@ -326,23 +347,6 @@ impl Darkfid {
jsonrpc::response(json!(true), id).into()
}
async fn receive_tx(&self, id: Value, params: &[Value]) -> JsonResult {
if params.len() != 1 || !params[0].is_string() {
return jsonrpc::error(InvalidParams, None, id).into()
}
let payload = String::from(params[0].as_str().unwrap());
let tx = Tx { payload };
self.state.write().await.append_tx(tx.clone());
let result = self.p2p.broadcast(tx).await;
match result {
Ok(()) => jsonrpc::response(json!(true), id).into(),
Err(_) => jsonrpc::error(InternalError, None, id).into(),
}
}
}
async fn init_wallet(wallet_path: &str, wallet_pass: &str) -> Result<WalletPtr> {
@@ -352,6 +356,7 @@ async fn init_wallet(wallet_path: &str, wallet_pass: &str) -> Result<WalletPtr>
Ok(wallet)
}
async_daemonize!(realmain);
async fn realmain(args: Args, ex: Arc<Executor<'_>>) -> Result<()> {
// We use this handler to block this function after detaching all
// tasks, and to catch a shutdown signal, where we can clean up and
@@ -383,6 +388,8 @@ async fn realmain(args: Args, ex: Arc<Executor<'_>>) -> Result<()> {
// TODO: Is this ok?
let mut rng = rand::thread_rng();
let id: u64 = rng.gen();
// Initialize validator state
let state = ValidatorState::new(&sled_db, id, genesis_ts, genesis_data)?;
// P2P network
@@ -398,6 +405,7 @@ async fn realmain(args: Args, ex: Arc<Executor<'_>>) -> Result<()> {
let p2p = net::P2p::new(network_settings).await;
let registry = p2p.protocol_registry();
info!("Registering P2P protocols...");
let _state = state.clone();
registry
.register(!net::SESSION_SEED, move |channel, p2p| {
@@ -407,33 +415,33 @@ async fn realmain(args: Args, ex: Arc<Executor<'_>>) -> Result<()> {
.await;
// Activate these protocols only if we're participating in consensus.
if args.consensus {
info!("Registering consensus P2P protocols...");
//if args.consensus {
info!("Registering consensus P2P protocols...");
let _state = state.clone();
registry
.register(!net::SESSION_SEED, move |channel, p2p| {
let state = _state.clone();
async move { ProtocolVote::init(channel, state, p2p).await.unwrap() }
})
.await;
let _state = state.clone();
registry
.register(!net::SESSION_SEED, move |channel, p2p| {
let state = _state.clone();
async move { ProtocolVote::init(channel, state, p2p).await.unwrap() }
})
.await;
let _state = state.clone();
registry
.register(!net::SESSION_SEED, move |channel, p2p| {
let state = _state.clone();
async move { ProtocolProposal::init(channel, state, p2p).await.unwrap() }
})
.await;
let _state = state.clone();
registry
.register(!net::SESSION_SEED, move |channel, p2p| {
let state = _state.clone();
async move { ProtocolProposal::init(channel, state, p2p).await.unwrap() }
})
.await;
let _state = state.clone();
registry
.register(!net::SESSION_SEED, move |channel, p2p| {
let state = _state.clone();
async move { ProtocolParticipant::init(channel, state, p2p).await.unwrap() }
})
.await;
}
let _state = state.clone();
registry
.register(!net::SESSION_SEED, move |channel, p2p| {
let state = _state.clone();
async move { ProtocolParticipant::init(channel, state, p2p).await.unwrap() }
})
.await;
//}
info!("Starting P2P networking");
p2p.clone().start(ex.clone()).await?;
@@ -447,7 +455,7 @@ async fn realmain(args: Args, ex: Arc<Executor<'_>>) -> Result<()> {
.detach();
// Initialize program state
let darkfid = Darkfid::new(wallet, state.clone(), p2p.clone()).await?;
let darkfid = Darkfid::new(&sled_db, wallet, state.clone(), p2p.clone()).await?;
let darkfid = Arc::new(darkfid);
// JSON-RPC server
@@ -455,10 +463,10 @@ async fn realmain(args: Args, ex: Arc<Executor<'_>>) -> Result<()> {
ex.spawn(listen_and_serve(args.rpc_listen, darkfid)).detach();
// Consensus protocol
if args.consensus {
info!("Starting consensus protocol task");
ex.spawn(proposal_task(p2p, state)).detach();
}
//if args.consensus {
info!("Starting consensus protocol task");
ex.spawn(proposal_task(p2p, state)).detach();
//}
// Wait for SIGINT
shutdown.recv().await?;
@@ -471,30 +479,3 @@ async fn realmain(args: Args, ex: Arc<Executor<'_>>) -> Result<()> {
Ok(())
}
fn main() -> Result<()> {
let args = Args::from_args_with_toml("").unwrap();
let cfg_path = get_config_path(args.config, CONFIG_FILE)?;
spawn_config(&cfg_path, CONFIG_FILE_CONTENTS.as_bytes())?;
let args = Args::from_args_with_toml(&std::fs::read_to_string(cfg_path)?).unwrap();
let (lvl, conf) = log_config(args.verbose.into())?;
TermLogger::init(lvl, conf, TerminalMode::Mixed, ColorChoice::Auto)?;
// https://docs.rs/smol/latest/smol/struct.Executor.html#examples
let ex = Arc::new(Executor::new());
let (signal, shutdown) = async_channel::unbounded::<()>();
let (_, result) = Parallel::new()
// Run four executor threads
.each(0..4, |_| future::block_on(ex.run(shutdown.recv())))
// Run the main future on the current thread.
.finish(|| {
future::block_on(async {
realmain(args, ex.clone()).await?;
drop(signal);
Ok::<(), darkfi::Error>(())
})
});
result
}

View File

@@ -19,9 +19,9 @@ easy-parallel = "3.2.0"
async-channel = "1.6.1"
# Misc
clap = "3.1.8"
clap = "3.1.10"
rand = "0.8.5"
simplelog = "0.12.0-alpha1"
simplelog = "0.12.0"
log = "0.4.16"
num_cpus = "1.13.1"
url = "2.2.2"

View File

@@ -12,9 +12,9 @@ features = ["rpc"]
async-std = {version = "1.11.0", features = ["attributes"]}
# Misc
clap = {version = "3.1.8", features = ["derive"]}
clap = {version = "3.1.10", features = ["derive"]}
log = "0.4.16"
simplelog = "0.12.0-alpha1"
simplelog = "0.12.0"
prettytable-rs = "0.8.0"
url = "2.2.2"

View File

@@ -25,7 +25,7 @@ log = "0.4.16"
num-bigint = "0.4.3"
rand = "0.8.5"
serde_json = "1.0.79"
simplelog = "0.12.0-alpha1"
simplelog = "0.12.0"
sled = "0.34.7"
url = "2.2.2"

View File

@@ -16,10 +16,10 @@ async-executor = "1.4.1"
easy-parallel = "3.2.0"
# Misc
clap = {version = "3.1.8", features = ["derive"]}
clap = {version = "3.1.10", features = ["derive"]}
log = "0.4.16"
num_cpus = "1.13.1"
simplelog = "0.12.0-alpha1"
simplelog = "0.12.0"
# Encoding and parsing
serde = {version = "1.0.136", features = ["derive"]}

View File

@@ -23,9 +23,9 @@ easy-parallel = "3.2.0"
rand = "0.8.5"
# Misc
clap = {version = "3.1.8", features = ["derive"]}
clap = {version = "3.1.10", features = ["derive"]}
log = "0.4.16"
simplelog = "0.12.0-alpha1"
simplelog = "0.12.0"
fxhash = "0.2.1"
# Encoding and parsing

View File

@@ -16,10 +16,10 @@ async-executor = "1.4.1"
easy-parallel = "3.2.0"
# Misc
clap = {version = "3.1.8", features = ["derive"]}
clap = {version = "3.1.10", features = ["derive"]}
log = "0.4.16"
num_cpus = "1.13.1"
simplelog = "0.12.0-alpha1"
simplelog = "0.12.0"
url = "2.2.2"
chrono = "0.4.19"
prettytable-rs = "0.8.0"

View File

@@ -18,10 +18,10 @@ async-executor = "1.4.1"
easy-parallel = "3.2.0"
# Misc
clap = {version = "3.1.8", features = ["derive"]}
clap = {version = "3.1.10", features = ["derive"]}
log = "0.4.16"
num_cpus = "1.13.1"
simplelog = "0.12.0-alpha1"
simplelog = "0.12.0"
rand = "0.8.5"
chrono = "0.4.19"
thiserror = "1.0.30"

View File

@@ -10,7 +10,7 @@ edition = "2021"
[dependencies]
bs58 = "0.4.0"
clap = {version = "3.1.8", features = ["derive"]}
clap = {version = "3.1.10", features = ["derive"]}
ctrlc = "3.2.1"
darkfi = {path = "../../", features = ["crypto"]}
indicatif = "0.17.0-rc.10"

View File

@@ -9,5 +9,5 @@ license = "AGPL-3.0-only"
edition = "2021"
[dependencies]
clap = {version = "3.1.8", features = ["derive"]}
clap = {version = "3.1.10", features = ["derive"]}
darkfi = {path = "../../", features = ["zkas"]}

View File

@@ -23,9 +23,9 @@ easy-parallel = "3.2.0"
rand = "0.8.5"
# Misc
clap = {version = "3.1.8", features = ["derive"]}
clap = {version = "3.1.10", features = ["derive"]}
log = "0.4.16"
simplelog = "0.12.0-alpha1"
simplelog = "0.12.0"
fxhash = "0.2.1"
url = "2.2.2"