Procházet zdrojové kódy

darkfid: Get compiling with most of RPC functionality disabled.

parazyd před 3 roky
rodič
revize
569b296c16

+ 4 - 4
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

+ 1 - 1
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"}
 

+ 1 - 1
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"

+ 1 - 6
bin/darkfid/src/internal.rs

@@ -16,12 +16,7 @@
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-use darkfi::{
-    consensus::ValidatorState,
-    node::{state::StateUpdate, MemoryState},
-    tx::Transaction,
-    Result,
-};
+use darkfi::{tx2::Transaction, Result};
 
 use super::Darkfid;
 

+ 22 - 34
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<String>,
 
     #[structopt(long)]
-    /// Whitelisted faucet address (repeatable flag)
+    /// Whitelisted faucet public key (repeatable flag)
     faucet_pub: Vec<String>,
 
     #[structopt(long)]
@@ -175,18 +177,17 @@ pub struct Darkfid {
     synced: Mutex<bool>, // AtomicBool is weird in Arc
     _consensus_p2p: Option<P2pPtr>,
     sync_p2p: Option<P2pPtr>,
-    client: Arc<Client>,
     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<P2pPtr>,
         sync_p2p: Option<P2pPtr>,
-    ) -> Result<Self> {
-        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<smol::Executor<'_>>) -> 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<smol::Executor<'_>>) -> Result<()> {
         &sled_db,
         genesis_ts,
         genesis_data,
-        client,
+        wallet,
         cashier_pubkeys,
         faucet_pubkeys,
     )
@@ -440,7 +428,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'_>>) -> 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

+ 1 - 1
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;

+ 1 - 1
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"

+ 1 - 1
example/dao/Cargo.toml

@@ -6,7 +6,7 @@ authors = ["Dyne.org foundation <foundation@dyne.org>"]
 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"}
 

+ 3 - 3
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