Răsfoiți Sursa

example/dao: running the example through makefile

Dastan-glitch 3 ani în urmă
părinte
comite
8e381ad43c

+ 33 - 0
Cargo.lock

@@ -1147,6 +1147,39 @@ dependencies = [
  "url",
 ]
 
+[[package]]
+name = "dao-example"
+version = "0.3.0"
+dependencies = [
+ "async-channel",
+ "async-executor",
+ "async-std",
+ "async-trait",
+ "bs58",
+ "chacha20poly1305",
+ "darkfi",
+ "darkfi-sdk",
+ "darkfi-serial",
+ "easy-parallel",
+ "env_logger",
+ "futures",
+ "fxhash",
+ "group",
+ "halo2_gadgets",
+ "halo2_proofs",
+ "incrementalmerkletree",
+ "lazy_static",
+ "log",
+ "num_cpus",
+ "pasta_curves",
+ "rand",
+ "serde_json",
+ "simplelog",
+ "smol",
+ "thiserror",
+ "url",
+]
+
 [[package]]
 name = "daod"
 version = "0.3.0"

+ 1 - 0
Cargo.toml

@@ -44,6 +44,7 @@ members = [
     "src/serial/derive-internal",
 
     "example/dchat",
+    "example/dao",
 ]
 
 [dependencies]

+ 1 - 1
Makefile

@@ -66,7 +66,7 @@ test-tx: zkas
 	RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) run --release --features=node,zkas --example tx
 
 test-dao: zkas
-	RUSTFLAGS="$(RUSTFLAGS)" RUST_LOG=debug $(CARGO) run --release --features=crypto,rpc --example dao
+	$(MAKE) -C example/dao
 
 cleanbin:
 	rm -f $(BINS)

+ 4 - 2
example/dao/Cargo.toml

@@ -1,5 +1,5 @@
 [package]
-name = "dao"
+name = "dao-example"
 version = "0.3.0"
 edition = "2021"
 authors = ["Dyne.org foundation <foundation@dyne.org>"]
@@ -8,6 +8,7 @@ license = "AGPL-3.0-only"
 [dependencies]
 darkfi = {path = "../../", features = ["rpc", "crypto", "tx", "node"]}
 darkfi-serial = {path = "../../src/serial"}
+darkfi-sdk = {path = "../../src/sdk"}
 
 # Async
 smol = "1.2.5"
@@ -30,7 +31,7 @@ pasta_curves = "0.4.0"
 halo2_gadgets = "0.2.0"
 halo2_proofs = "0.2.0"
 rand = "0.8.5"
-crypto_api_chachapoly = "0.5.0"
+chacha20poly1305 = "0.10.1"
 group = "0.12.0"
 
 # Encoding and parsing
@@ -41,3 +42,4 @@ fxhash = "0.2.1"
 # Utilities
 lazy_static = "1.4.0"
 url = "2.3.1"
+env_logger = "0.9.1"

+ 3 - 0
example/dao/Makefile

@@ -0,0 +1,3 @@
+# 
+dao:
+	RUST_LOG=debug cargo run --release

+ 1 - 1
example/dao/src/contract/dao/state.rs

@@ -28,7 +28,7 @@ use crate::util::HashableBase;
 #[derive(Clone, SerialEncodable, SerialDecodable)]
 pub struct DaoBulla(pub pallas::Base);
 
-type MerkleTree = BridgeTree<MerkleNode, MERKLE_DEPTH>;
+type MerkleTree = BridgeTree<MerkleNode, { MERKLE_DEPTH }>;
 
 pub struct ProposalVotes {
     // TODO: might be more logical to have 'yes_votes_commit' and 'no_votes_commit'

+ 1 - 1
example/dao/src/contract/money/state.rs

@@ -20,7 +20,7 @@ use darkfi::crypto::keypair::PublicKey;
 use darkfi_sdk::crypto::{constants::MERKLE_DEPTH, MerkleNode, Nullifier};
 use incrementalmerkletree::bridgetree::BridgeTree;
 
-type MerkleTree = BridgeTree<MerkleNode, MERKLE_DEPTH>;
+type MerkleTree = BridgeTree<MerkleNode, { MERKLE_DEPTH }>;
 
 /// The state machine, held in memory.
 pub struct State {

+ 1 - 1
example/dao/src/main.rs

@@ -54,7 +54,7 @@ use crate::{
     util::{sign, StateRegistry, Transaction, ZkContractTable},
 };
 
-type MerkleTree = BridgeTree<MerkleNode, MERKLE_DEPTH>;
+type MerkleTree = BridgeTree<MerkleNode, { MERKLE_DEPTH }>;
 
 pub struct OwnCoin {
     pub coin: Coin,