From 569b296c168b1fa9394b9d203bfa66df02348894 Mon Sep 17 00:00:00 2001 From: parazyd Date: Wed, 16 Nov 2022 14:19:39 +0100 Subject: [PATCH] darkfid: Get compiling with most of RPC functionality disabled. --- Makefile | 8 +++--- bin/dao/daod/Cargo.toml | 2 +- bin/darkfid/Cargo.toml | 2 +- bin/darkfid/src/internal.rs | 7 +---- bin/darkfid/src/main.rs | 56 +++++++++++++++---------------------- bin/darkfid/src/rpc_tx.rs | 2 +- bin/faucetd/Cargo.toml | 2 +- example/dao/Cargo.toml | 2 +- src/contract/money/Makefile | 6 ++-- 9 files changed, 35 insertions(+), 52 deletions(-) diff --git a/Makefile b/Makefile index ecc8e7aec..4b6cf3938 100644 --- a/Makefile +++ b/Makefile @@ -32,13 +32,13 @@ PROOFS_BIN = $(PROOFS:=.bin) all: zkas $(PROOFS_BIN) $(BINS) -contracts: zkas - $(MAKE) -C src/contract/money - zkas: $(BINDEPS) RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) build --all-features --release --package $@ cp -f target/release/$@ $@ +contracts: zkas + $(MAKE) -C src/contract/money + $(PROOFS_BIN): $(PROOFS) zkas ./zkas $(basename $@) -o $@ @@ -96,4 +96,4 @@ uninstall: rm -f $(DESTDIR)$(PREFIX)/bin/$$i; \ done; -.PHONY: all check fix clippy rustdoc test test-tx clean cleanbin install uninstall +.PHONY: all contracts check fix clippy rustdoc test test-tx clean cleanbin install uninstall diff --git a/bin/dao/daod/Cargo.toml b/bin/dao/daod/Cargo.toml index ac21a2102..0d9a284aa 100644 --- a/bin/dao/daod/Cargo.toml +++ b/bin/dao/daod/Cargo.toml @@ -9,7 +9,7 @@ license = "AGPL-3.0-only" edition = "2021" [dependencies] -darkfi = {path = "../../../", features = ["rpc", "crypto", "tx", "node"]} +darkfi = {path = "../../../", features = ["rpc", "crypto", "tx"]} darkfi-sdk = {path = "../../../src/sdk"} darkfi-serial = {path = "../../../src/serial"} diff --git a/bin/darkfid/Cargo.toml b/bin/darkfid/Cargo.toml index f2a04eaba..a5c90fc8d 100644 --- a/bin/darkfid/Cargo.toml +++ b/bin/darkfid/Cargo.toml @@ -15,7 +15,7 @@ blake3 = "1.3.1" bs58 = "0.4.0" chrono = "0.4.22" ctrlc = { version = "3.2.3", features = ["termination"] } -darkfi = {path = "../../", features = ["blockchain", "wallet", "rpc", "net", "node"]} +darkfi = {path = "../../", features = ["blockchain", "wallet", "rpc", "net"]} darkfi-sdk = {path = "../../src/sdk"} darkfi-serial = {path = "../../src/serial"} easy-parallel = "3.2.0" diff --git a/bin/darkfid/src/internal.rs b/bin/darkfid/src/internal.rs index 02a2b4457..5c44d61fc 100644 --- a/bin/darkfid/src/internal.rs +++ b/bin/darkfid/src/internal.rs @@ -16,12 +16,7 @@ * along with this program. If not, see . */ -use darkfi::{ - consensus::ValidatorState, - node::{state::StateUpdate, MemoryState}, - tx::Transaction, - Result, -}; +use darkfi::{tx2::Transaction, Result}; use super::Darkfid; diff --git a/bin/darkfid/src/main.rs b/bin/darkfid/src/main.rs index eb73be835..0cdbd81a8 100644 --- a/bin/darkfid/src/main.rs +++ b/bin/darkfid/src/main.rs @@ -20,25 +20,27 @@ use std::str::FromStr; use async_std::sync::{Arc, Mutex}; use async_trait::async_trait; -use darkfi_sdk::crypto::{Address, PublicKey}; -use log::{debug, error, info}; +use darkfi_sdk::crypto::PublicKey; +use log::{error, info}; use structopt_toml::{serde::Deserialize, structopt::StructOpt, StructOptToml}; use url::Url; use darkfi::{ async_daemonize, cli_desc, consensus::{ + constants::{ + MAINNET_GENESIS_HASH_BYTES, MAINNET_GENESIS_TIMESTAMP, TESTNET_GENESIS_HASH_BYTES, + TESTNET_GENESIS_TIMESTAMP, + }, proto::{ ProtocolParticipant, ProtocolProposal, ProtocolSync, ProtocolSyncConsensus, ProtocolTx, }, state::ValidatorStatePtr, task::{block_sync_task, proposal_task}, - ValidatorState, MAINNET_GENESIS_HASH_BYTES, MAINNET_GENESIS_TIMESTAMP, - TESTNET_GENESIS_HASH_BYTES, TESTNET_GENESIS_TIMESTAMP, + ValidatorState, }, net, net::P2pPtr, - node::Client, rpc::{ clock_sync::check_clock, jsonrpc::{ @@ -155,11 +157,11 @@ struct Args { channel_log: bool, #[structopt(long)] - /// Whitelisted cashier address (repeatable flag) + /// Whitelisted cashier public key (repeatable flag) cashier_pub: Vec, #[structopt(long)] - /// Whitelisted faucet address (repeatable flag) + /// Whitelisted faucet public key (repeatable flag) faucet_pub: Vec, #[structopt(long)] @@ -175,18 +177,17 @@ pub struct Darkfid { synced: Mutex, // AtomicBool is weird in Arc _consensus_p2p: Option, sync_p2p: Option, - client: Arc, validator_state: ValidatorStatePtr, } // JSON-RPC methods mod rpc_blockchain; mod rpc_misc; -mod rpc_tx; -mod rpc_wallet; +//mod rpc_tx; +//mod rpc_wallet; // Internal methods -mod internal; +//mod internal; #[async_trait] impl RequestHandler for Darkfid { @@ -215,12 +216,15 @@ impl RequestHandler for Darkfid { // =================== // Transaction methods // =================== + /* Some("tx.transfer") => return self.tx_transfer(req.id, params).await, Some("tx.broadcast") => return self.tx_broadcast(req.id, params).await, + */ // ============== // Wallet methods // ============== + /* Some("wallet.keygen") => return self.wallet_keygen(req.id, params).await, Some("wallet.get_addrs") => return self.wallet_get_addrs(req.id, params).await, Some("wallet.export_keypair") => { @@ -240,7 +244,7 @@ impl RequestHandler for Darkfid { return self.wallet_get_merkle_path(req.id, params).await } Some("wallet.decrypt_note") => return self.wallet_decrypt_note(req.id, params).await, - + */ // ============== // Invalid method // ============== @@ -254,18 +258,8 @@ impl Darkfid { validator_state: ValidatorStatePtr, consensus_p2p: Option, sync_p2p: Option, - ) -> Result { - debug!("Waiting for validator state lock"); - let client = validator_state.read().await.client.clone(); - debug!("Released validator state lock"); - - Ok(Self { - synced: Mutex::new(false), - _consensus_p2p: consensus_p2p, - sync_p2p, - client, - validator_state, - }) + ) -> Self { + Self { synced: Mutex::new(false), _consensus_p2p: consensus_p2p, sync_p2p, validator_state } } } @@ -318,23 +312,17 @@ async fn realmain(args: Args, ex: Arc>) -> Result<()> { } }; - // TODO: sqldb init cleanup - // Initialize Client - let client = Arc::new(Client::new(wallet).await?); - // Parse cashier addresses let mut cashier_pubkeys = vec![]; for i in args.cashier_pub { - let addr = Address::from_str(&i)?; - let pk = PublicKey::try_from(addr)?; + let pk = PublicKey::from_str(&i)?; cashier_pubkeys.push(pk); } // Parse fauced addresses let mut faucet_pubkeys = vec![]; for i in args.faucet_pub { - let addr = Address::from_str(&i)?; - let pk = PublicKey::try_from(addr)?; + let pk = PublicKey::from_str(&i)?; faucet_pubkeys.push(pk); } @@ -343,7 +331,7 @@ async fn realmain(args: Args, ex: Arc>) -> Result<()> { &sled_db, genesis_ts, genesis_data, - client, + wallet, cashier_pubkeys, faucet_pubkeys, ) @@ -440,7 +428,7 @@ async fn realmain(args: Args, ex: Arc>) -> Result<()> { }; // Initialize program state - let darkfid = Darkfid::new(state.clone(), consensus_p2p.clone(), sync_p2p.clone()).await?; + let darkfid = Darkfid::new(state.clone(), consensus_p2p.clone(), sync_p2p.clone()).await; let darkfid = Arc::new(darkfid); // JSON-RPC server diff --git a/bin/darkfid/src/rpc_tx.rs b/bin/darkfid/src/rpc_tx.rs index 5f680d237..27b781478 100644 --- a/bin/darkfid/src/rpc_tx.rs +++ b/bin/darkfid/src/rpc_tx.rs @@ -25,7 +25,7 @@ use serde_json::{json, Value}; use darkfi::{ rpc::jsonrpc::{ErrorCode::InvalidParams, JsonError, JsonResponse, JsonResult}, - tx::Transaction, + tx2::Transaction, }; use super::Darkfid; diff --git a/bin/faucetd/Cargo.toml b/bin/faucetd/Cargo.toml index 1cf36d03b..8bfef8f63 100644 --- a/bin/faucetd/Cargo.toml +++ b/bin/faucetd/Cargo.toml @@ -15,7 +15,7 @@ blake3 = "1.3.1" bs58 = "0.4.0" chrono = "0.4.22" ctrlc = { version = "3.2.3", features = ["termination"] } -darkfi = {path = "../../", features = ["blockchain", "wallet", "rpc", "net", "node"]} +darkfi = {path = "../../", features = ["blockchain", "wallet", "rpc", "net"]} darkfi-serial = {path = "../../src/serial"} darkfi-sdk = {path = "../../src/sdk"} easy-parallel = "3.2.0" diff --git a/example/dao/Cargo.toml b/example/dao/Cargo.toml index c5080e08d..378ada311 100644 --- a/example/dao/Cargo.toml +++ b/example/dao/Cargo.toml @@ -6,7 +6,7 @@ authors = ["Dyne.org foundation "] license = "AGPL-3.0-only" [dependencies] -darkfi = {path = "../../", features = ["rpc", "crypto", "tx", "node"]} +darkfi = {path = "../../", features = ["rpc", "crypto", "tx"]} darkfi-serial = {path = "../../src/serial"} darkfi-sdk = {path = "../../src/sdk"} diff --git a/src/contract/money/Makefile b/src/contract/money/Makefile index 96c1fd3d1..117c5689d 100644 --- a/src/contract/money/Makefile +++ b/src/contract/money/Makefile @@ -10,8 +10,8 @@ ZKAS_SRC = $(shell find proof -type f -name '*.zk') # wasm source files WASM_SRC = \ $(shell find src -type f) \ - $(shell find ../../sdk/src -type f) \ - $(shell find ../../serial/src -type f) + $(shell find ../../sdk -type f) \ + $(shell find ../../serial -type f) # zkas circuit bin files ZKAS_BIN = $(ZKAS_SRC:=.bin) @@ -34,4 +34,4 @@ clean: rm -f $(ZKAS_BIN) $(WASM_BIN) # We always rebuild the wasm no matter what -.PHONY: $(WASM_BIN) all test clean +.PHONY: all test clean