Przeglądaj źródła

speling: cummulative --> cumulative

darkfi 1 rok temu
rodzic
commit
af4d31870c

+ 9 - 9
script/research/pow/src/main.rs

@@ -173,20 +173,20 @@ fn check_block_timestamp(block: &Block, timestamps: &mut Vec<u64>) -> bool {
 
 /// Calculate the next mining difficulty.
 ///
-/// Takes a `RingBuffer` of timestamps, a `RingBuffer` of cummulative
+/// Takes a `RingBuffer` of timestamps, a `RingBuffer` of cumulative
 /// difficulties, and a target block time in seconds.
 /// **NOTE**: `timestamps` get sorted in this function.
 ///
 /// Panics if:
-/// * `timestamps.len() != cummulative_difficulties.len()`
+/// * `timestamps.len() != cumulative_difficulties.len()`
 /// * `timestamps.len() > DIFFICULTY_WINDOW`
 fn next_difficulty(
     timestamps: &mut Vec<u64>,
-    cummulative_difficulties: &[BigUint],
+    cumulative_difficulties: &[BigUint],
     target_seconds: usize,
 ) -> BigUint {
     let length = timestamps.len();
-    assert!(length == cummulative_difficulties.len() && length <= DIFFICULTY_WINDOW);
+    assert!(length == cumulative_difficulties.len() && length <= DIFFICULTY_WINDOW);
 
     if length <= 1 {
         return BigUint::one()
@@ -213,7 +213,7 @@ fn next_difficulty(
         time_span = 1;
     }
 
-    let total_work = &cummulative_difficulties[cut_end - 1] - &cummulative_difficulties[cut_begin];
+    let total_work = &cumulative_difficulties[cut_end - 1] - &cumulative_difficulties[cut_begin];
     assert!(total_work > BigUint::zero());
 
     (total_work * target_seconds + time_span - BigUint::one()) / time_span
@@ -239,10 +239,10 @@ fn main() -> Result<()> {
 
     // This represents the blocks in our blockchain
     let mut blockchain: Vec<Block> = vec![genesis_block.clone()];
-    // The cummulative difficulties track difficulty through time.
+    // The cumulative difficulties track difficulty through time.
     // The genesis block (block 0) is ignored. Blocks 1 and 2 must have difficulty 1.
     let mut difficulties = vec![];
-    let mut cummulative_difficulty = BigUint::zero();
+    let mut cumlative_difficulty = BigUint::zero();
     // We also track block timestamps this way.
     let mut timestamps = vec![];
 
@@ -374,7 +374,7 @@ fn main() -> Result<()> {
         // The new block appends to the blockchain
         timestamps.push(miner_block.header.timestamp);
         blockchain.push(miner_block);
-        cummulative_difficulty += difficulty;
-        difficulties.push(cummulative_difficulty.clone());
+        cumulative_difficulty += difficulty;
+        difficulties.push(cumulative_difficulty.clone());
     }
 }

+ 5 - 5
script/research/pow/src/tests.rs

@@ -32,8 +32,8 @@ const DEFAULT_TEST_DIFFICULTY_TARGET: usize = 120;
 #[test]
 fn test_wide_difficulty() {
     let mut timestamps: Vec<u64> = vec![];
-    let mut cummulative_difficulties: Vec<BigUint> = vec![];
-    let mut cummulative_difficulty = BigUint::zero();
+    let mut cumulative_difficulties: Vec<BigUint> = vec![];
+    let mut cumulative_difficulty = BigUint::zero();
 
     let output = Command::new("./gen_wide_data.py").output().unwrap();
     let reader = Cursor::new(output.stdout);
@@ -57,7 +57,7 @@ fn test_wide_difficulty() {
         }
 
         let mut timestamps_cut = timestamps[begin..end].to_vec();
-        let difficulty_cut = &cummulative_difficulties[begin..end];
+        let difficulty_cut = &cumulative_difficulties[begin..end];
         let res =
             next_difficulty(&mut timestamps_cut, difficulty_cut, DEFAULT_TEST_DIFFICULTY_TARGET);
 
@@ -69,7 +69,7 @@ fn test_wide_difficulty() {
         }
 
         timestamps.push(timestamp);
-        cummulative_difficulty += difficulty;
-        cummulative_difficulties.push(cummulative_difficulty.clone());
+        cumulative_difficulty += difficulty;
+        cumulative_difficulties.push(cumulative_difficulty.clone());
     }
 }

+ 8 - 8
src/blockchain/block_store.rs

@@ -167,18 +167,18 @@ pub struct BlockOrder {
 
 /// Auxiliary structure used to keep track of block ranking information.
 ///
-/// Note: we only need height cummulative ranks, but we also keep its actual
+/// Note: we only need height cumulative ranks, but we also keep its actual
 /// ranks, so we can verify the sequence and/or know specific block height
 /// ranks, if ever needed.
 #[derive(Clone, Debug, SerialEncodable, SerialDecodable)]
 pub struct BlockRanks {
     /// Block target rank
     pub target_rank: BigUint,
-    /// Height cummulative targets rank
+    /// Height cumulative targets rank
     pub targets_rank: BigUint,
     /// Block hash rank
     pub hash_rank: BigUint,
-    /// Height cummulative hashes rank
+    /// Height cumulative hashes rank
     pub hashes_rank: BigUint,
 }
 
@@ -195,7 +195,7 @@ impl BlockRanks {
 
 /// Auxiliary structure used to keep track of block PoW difficulty information.
 ///
-/// Note: we only need height cummulative difficulty, but we also keep its actual
+/// Note: we only need height cumulative difficulty, but we also keep its actual
 /// difficulty, so we can verify the sequence and/or know specific block height
 /// difficulty, if ever needed.
 #[derive(Clone, Debug, SerialEncodable, SerialDecodable)]
@@ -206,8 +206,8 @@ pub struct BlockDifficulty {
     pub timestamp: Timestamp,
     /// Height difficulty
     pub difficulty: BigUint,
-    /// Height cummulative difficulty (total + height difficulty)
-    pub cummulative_difficulty: BigUint,
+    /// Height cumulative difficulty (total + height difficulty)
+    pub cumulative_difficulty: BigUint,
     /// Block ranks
     pub ranks: BlockRanks,
 }
@@ -217,10 +217,10 @@ impl BlockDifficulty {
         height: u32,
         timestamp: Timestamp,
         difficulty: BigUint,
-        cummulative_difficulty: BigUint,
+        cumulative_difficulty: BigUint,
         ranks: BlockRanks,
     ) -> Self {
-        Self { height, timestamp, difficulty, cummulative_difficulty, ranks }
+        Self { height, timestamp, difficulty, cumulative_difficulty, ranks }
     }
 
     /// Represents the genesis block difficulty

+ 1 - 1
src/contract/money/src/entrypoint/pow_reward_v1.rs

@@ -172,7 +172,7 @@ pub(crate) fn money_pow_reward_process_update_v1(
     let fees_db = wasm::db::db_lookup(cid, MONEY_CONTRACT_FEES_TREE)?;
 
     // Generate the accumulator for the next height
-    msg!("[PowRewardV1] Creating next height fees acummulator");
+    msg!("[PowRewardV1] Creating next height fees accumulator");
     wasm::db::db_set(fees_db, &serialize(&(update.height + 1)), &serialize(&0_u64))?;
 
     // This will just make a snapshot to match the coins one

+ 3 - 3
src/validator/consensus.rs

@@ -720,8 +720,8 @@ impl Fork {
         self.hashes_rank += hash_distance_sq.clone();
 
         // Generate block difficulty and update PoW module
-        let cummulative_difficulty =
-            self.module.cummulative_difficulty.clone() + next_difficulty.clone();
+        let cumulative_difficulty =
+            self.module.cumulative_difficulty.clone() + next_difficulty.clone();
         let ranks = BlockRanks::new(
             target_distance_sq,
             self.targets_rank.clone(),
@@ -732,7 +732,7 @@ impl Fork {
             proposal.block.header.height,
             proposal.block.header.timestamp,
             next_difficulty,
-            cummulative_difficulty,
+            cumulative_difficulty,
             ranks,
         );
         self.module.append_difficulty(&self.overlay, block_difficulty)?;

+ 6 - 6
src/validator/mod.rs

@@ -470,8 +470,8 @@ impl Validator {
             current_hashes_rank += hash_distance_sq.clone();
 
             // Generate block difficulty and update PoW module
-            let cummulative_difficulty =
-                module.cummulative_difficulty.clone() + next_difficulty.clone();
+            let cumulative_difficulty =
+                module.cumulative_difficulty.clone() + next_difficulty.clone();
             let ranks = BlockRanks::new(
                 target_distance_sq,
                 current_targets_rank.clone(),
@@ -482,7 +482,7 @@ impl Validator {
                 block.header.height,
                 block.header.timestamp,
                 next_difficulty,
-                cummulative_difficulty,
+                cumulative_difficulty,
                 ranks,
             );
             module.append_difficulty(&overlay, block_difficulty)?;
@@ -572,8 +572,8 @@ impl Validator {
             current_hashes_rank += hash_distance_sq.clone();
 
             // Generate block difficulty and update PoW module
-            let cummulative_difficulty =
-                module.cummulative_difficulty.clone() + next_difficulty.clone();
+            let cumulative_difficulty =
+                module.cumulative_difficulty.clone() + next_difficulty.clone();
             let ranks = BlockRanks::new(
                 target_distance_sq,
                 current_targets_rank.clone(),
@@ -584,7 +584,7 @@ impl Validator {
                 block.header.height,
                 block.header.timestamp,
                 next_difficulty,
-                cummulative_difficulty,
+                cumulative_difficulty,
                 ranks,
             );
             module.append_difficulty(&overlay, block_difficulty)?;

+ 10 - 10
src/validator/pow.rs

@@ -82,13 +82,13 @@ pub struct PoWModule {
     pub fixed_difficulty: Option<BigUint>,
     /// Latest block timestamps ringbuffer
     pub timestamps: RingBuffer<Timestamp, BUF_SIZE>,
-    /// Latest block cummulative difficulties ringbuffer
+    /// Latest block cumulative difficulties ringbuffer
     pub difficulties: RingBuffer<BigUint, BUF_SIZE>,
-    /// Total blocks cummulative difficulty
+    /// Total blocks cumulative difficulty
     /// Note: we keep this as a struct field for faster
     /// access(optimization), since its always same as
     /// difficulties buffer last.
-    pub cummulative_difficulty: BigUint,
+    pub cumulative_difficulty: BigUint,
 }
 
 impl PoWModule {
@@ -106,15 +106,15 @@ impl PoWModule {
         // Retrieving last BUF_SIZE difficulties from blockchain to build the buffers
         let mut timestamps = RingBuffer::<Timestamp, BUF_SIZE>::new();
         let mut difficulties = RingBuffer::<BigUint, BUF_SIZE>::new();
-        let mut cummulative_difficulty = BigUint::zero();
+        let mut cumulative_difficulty = BigUint::zero();
         let last_n = match height {
             Some(h) => blockchain.blocks.get_difficulties_before(h, BUF_SIZE)?,
             None => blockchain.blocks.get_last_n_difficulties(BUF_SIZE)?,
         };
         for difficulty in last_n {
             timestamps.push(difficulty.timestamp);
-            difficulties.push(difficulty.cummulative_difficulty.clone());
-            cummulative_difficulty = difficulty.cummulative_difficulty;
+            difficulties.push(difficulty.cumulative_difficulty.clone());
+            cumulative_difficulty = difficulty.cumulative_difficulty;
         }
 
         // If a fixed difficulty has been set, assert its greater than zero
@@ -128,7 +128,7 @@ impl PoWModule {
             fixed_difficulty,
             timestamps,
             difficulties,
-            cummulative_difficulty,
+            cumulative_difficulty,
         })
     }
 
@@ -295,8 +295,8 @@ impl PoWModule {
     /// Append provided timestamp and difficulty to the ring buffers.
     pub fn append(&mut self, timestamp: Timestamp, difficulty: &BigUint) {
         self.timestamps.push(timestamp);
-        self.cummulative_difficulty += difficulty;
-        self.difficulties.push(self.cummulative_difficulty.clone());
+        self.cumulative_difficulty += difficulty;
+        self.difficulties.push(self.cumulative_difficulty.clone());
     }
 
     /// Append provided block difficulty to the ring buffers and insert
@@ -330,7 +330,7 @@ impl std::fmt::Display for PoWModule {
         write!(f, "\ttarget: {}", self.target)?;
         write!(f, "\ttimestamps: {:?}", self.timestamps)?;
         write!(f, "\tdifficulties: {:?}", self.difficulties)?;
-        write!(f, "\tcummulative_difficulty: {}", self.cummulative_difficulty)
+        write!(f, "\tcumulative_difficulty: {}", self.cumulative_difficulty)
     }
 }