فهرست منبع

dao/spec: rename all mentions of slot to blockheight

zero 2 سال پیش
والد
کامیت
50522bd7db

+ 2 - 2
doc/src/spec/contract/dao/model.md

@@ -97,11 +97,11 @@ guarantee which block they get into, we therefore must modulo the block height
 a certain number which we use in the proofs.
 a certain number which we use in the proofs.
 
 
 ```rust
 ```rust
-{{#include ../../../../../src/contract/dao/src/lib.rs:dao-slot_to_day}}
+{{#include ../../../../../src/contract/dao/src/lib.rs:dao-blockheight_to_day}}
 ```
 ```
 
 
 which can be used like this
 which can be used like this
 ```rust
 ```rust
-{{#include ../../../../../src/contract/dao/src/entrypoint/propose.rs:dao-slot_to_day-example-usage}}
+{{#include ../../../../../src/contract/dao/src/entrypoint/propose.rs:dao-blockheight_to_day-example-usage}}
 ```
 ```
 
 

+ 5 - 4
src/contract/dao/src/entrypoint/propose.rs

@@ -33,9 +33,10 @@ use darkfi_sdk::{
 use darkfi_serial::{deserialize, serialize, Encodable, WriteExt};
 use darkfi_serial::{deserialize, serialize, Encodable, WriteExt};
 
 
 use crate::{
 use crate::{
+    blockheight_to_day,
     error::DaoError,
     error::DaoError,
     model::{DaoBlindAggregateVote, DaoProposalMetadata, DaoProposeParams, DaoProposeUpdate},
     model::{DaoBlindAggregateVote, DaoProposalMetadata, DaoProposeParams, DaoProposeUpdate},
-    slot_to_day, DaoFunction, DAO_CONTRACT_DB_DAO_MERKLE_ROOTS, DAO_CONTRACT_DB_PROPOSAL_BULLAS,
+    DaoFunction, DAO_CONTRACT_DB_DAO_MERKLE_ROOTS, DAO_CONTRACT_DB_PROPOSAL_BULLAS,
     DAO_CONTRACT_ZKAS_DAO_PROPOSE_BURN_NS, DAO_CONTRACT_ZKAS_DAO_PROPOSE_MAIN_NS,
     DAO_CONTRACT_ZKAS_DAO_PROPOSE_BURN_NS, DAO_CONTRACT_ZKAS_DAO_PROPOSE_MAIN_NS,
 };
 };
 
 
@@ -83,9 +84,9 @@ pub(crate) fn dao_propose_get_metadata(
         ));
         ));
     }
     }
 
 
-    // ANCHOR: dao-slot_to_day-example-usage
-    let current_day = slot_to_day(get_verifying_slot());
-    // ANCHOR_END: dao-slot_to_day-example-usage
+    // ANCHOR: dao-blockheight_to_day-example-usage
+    let current_day = blockheight_to_day(get_verifying_slot());
+    // ANCHOR_END: dao-blockheight_to_day-example-usage
 
 
     let total_funds_coords = total_funds_commit.to_affine().coordinates().unwrap();
     let total_funds_coords = total_funds_commit.to_affine().coordinates().unwrap();
     zk_public_inputs.push((
     zk_public_inputs.push((

+ 3 - 2
src/contract/dao/src/entrypoint/vote.rs

@@ -30,9 +30,10 @@ use darkfi_sdk::{
 use darkfi_serial::{deserialize, serialize, Encodable, WriteExt};
 use darkfi_serial::{deserialize, serialize, Encodable, WriteExt};
 
 
 use crate::{
 use crate::{
+    blockheight_to_day,
     error::DaoError,
     error::DaoError,
     model::{DaoProposalMetadata, DaoVoteParams, DaoVoteUpdate},
     model::{DaoProposalMetadata, DaoVoteParams, DaoVoteUpdate},
-    slot_to_day, DaoFunction, DAO_CONTRACT_DB_PROPOSAL_BULLAS, DAO_CONTRACT_DB_VOTE_NULLIFIERS,
+    DaoFunction, DAO_CONTRACT_DB_PROPOSAL_BULLAS, DAO_CONTRACT_DB_VOTE_NULLIFIERS,
     DAO_CONTRACT_ZKAS_DAO_VOTE_BURN_NS, DAO_CONTRACT_ZKAS_DAO_VOTE_MAIN_NS,
     DAO_CONTRACT_ZKAS_DAO_VOTE_BURN_NS, DAO_CONTRACT_ZKAS_DAO_VOTE_MAIN_NS,
 };
 };
 
 
@@ -80,7 +81,7 @@ pub(crate) fn dao_vote_get_metadata(
         ));
         ));
     }
     }
 
 
-    let current_day = slot_to_day(get_verifying_slot());
+    let current_day = blockheight_to_day(get_verifying_slot());
 
 
     let yes_vote_commit_coords = params.yes_vote_commit.to_affine().coordinates().unwrap();
     let yes_vote_commit_coords = params.yes_vote_commit.to_affine().coordinates().unwrap();
     let all_vote_commit_coords = all_vote_commit.to_affine().coordinates().unwrap();
     let all_vote_commit_coords = all_vote_commit.to_affine().coordinates().unwrap();

+ 5 - 5
src/contract/dao/src/lib.rs

@@ -90,13 +90,13 @@ pub const DAO_CONTRACT_ZKAS_DAO_AUTH_MONEY_TRANSFER_NS: &str = "DaoAuthMoneyTran
 pub const DAO_CONTRACT_ZKAS_DAO_AUTH_MONEY_TRANSFER_ENC_COIN_NS: &str =
 pub const DAO_CONTRACT_ZKAS_DAO_AUTH_MONEY_TRANSFER_ENC_COIN_NS: &str =
     "DaoAuthMoneyTransferEncCoin";
     "DaoAuthMoneyTransferEncCoin";
 
 
-// ANCHOR: dao-slot_to_day
-const SLOT_TIME: u64 = 90;
+// ANCHOR: dao-blockheight_to_day
+const BLOCK_TIME: u64 = 90;
 const SECS_IN_DAY: u64 = 24 * 60 * 60;
 const SECS_IN_DAY: u64 = 24 * 60 * 60;
 
 
 /// Days since genesis block. Used for time limit on DAO proposals.
 /// Days since genesis block. Used for time limit on DAO proposals.
-pub fn slot_to_day(slot: u64) -> u64 {
-    let timestamp_secs = slot * SLOT_TIME;
+pub fn blockheight_to_day(height: u64) -> u64 {
+    let timestamp_secs = height * BLOCK_TIME;
     timestamp_secs / SECS_IN_DAY
     timestamp_secs / SECS_IN_DAY
 }
 }
-// ANCHOR_END: dao-slot_to_day
+// ANCHOR_END: dao-blockheight_to_day