Просмотр исходного кода

daod/proof: add less_than or equal to checks + bool_check

lunar-mining 3 лет назад
Родитель
Сommit
3b6a51678d

+ 4 - 5
bin/daod/proof/dao-exec.zk

@@ -134,11 +134,10 @@ circuit "DaoExec" {
     constrain_instance(user_spend_hook);
     constrain_instance(user_data);
 
-    # total_votes >= dao_quorum
-    # TODO: waiting on this opcode in zkas
-    #
-    #     greater_than_or_equal(total_votes, dao_quorum)
-    #
+    # Check that dao_quorum is less than or equal to all_votes_value
+    one = witness_base(1);
+    all_votes_value_1 = base_add(all_votes_value, one);
+    less_than(dao_quorum, all_votes_value_1);
 
     # win_votes / total_votes >= approval_ratio_quot / approval_ratio_base
     #

+ 4 - 4
bin/daod/proof/dao-propose-main.zk

@@ -69,10 +69,10 @@ circuit "DaoProposeMain" {
     less_than(zero, proposal_amount);
 
     # This is the main check
-    # TODO: check total_funds >= proposer_limit
-    #
-    #     greater_than_or_equal(total_funds, proposer_limit)
-    #
+    # We check that dao_proposer_limit <= total_funds
+    one = witness_base(1);
+    total_funds_1 = base_add(total_funds, one);
+    less_than(dao_proposer_limit, total_funds_1);
 
 	# Pedersen commitment for coin's value
 	vcv = ec_mul_short(total_funds, VALUE_COMMIT_VALUE);

+ 2 - 5
bin/daod/proof/dao-vote-main.zk

@@ -91,11 +91,8 @@ circuit "DaoVoteMain" {
 	constrain_instance(all_votes_commit_x);
 	constrain_instance(all_votes_commit_y);
 
-    # This is the main check
-    # TODO: vote option should be 0 or 1
-    #
-    # assert!(vote_option == 0 || vote_option == 1)
-    #
+    # Vote option should be 0 or 1
+    bool_check(vote_option);
 }
 
 

+ 1 - 0
bin/daod/src/demo.rs

@@ -315,6 +315,7 @@ pub async fn demo() -> Result<()> {
     // DAO parameters
     let dao_proposer_limit = 110;
     let dao_quorum = 110;
+    // TODO: should be 2:1
     let dao_approval_ratio = 2;
 
     // Lookup table for smart contract states