Skip to content

Commit

Permalink
chore: Make linter happy
Browse files Browse the repository at this point in the history
Prepend `_` to some function names since they're currently only in use
in tests. They will be used to generate the block proofs. I wanted to
use the #expect annotation but I got errors when I did.

Also some formatting of import statement.
  • Loading branch information
Sword-Smith committed Oct 28, 2024
1 parent ae5a635 commit 926650f
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 13 deletions.
3 changes: 2 additions & 1 deletion src/mine_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,10 +581,11 @@ pub async fn mine(

#[cfg(test)]
pub(crate) mod mine_loop_tests {
use std::hint::black_box;

use block_header::block_header_tests::random_block_header;
use num_bigint::BigUint;
use num_traits::Pow;
use std::hint::black_box;
use tracing_test::traced_test;
use transaction_output::TxOutput;
use transaction_output::UtxoNotificationMedium;
Expand Down
6 changes: 2 additions & 4 deletions src/models/blockchain/block/difficulty_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ use tasm_lib::triton_vm::prelude::BFieldCodec;
use tasm_lib::triton_vm::prelude::BFieldElement;
use tasm_lib::triton_vm::prelude::Digest;

use super::block_height::BlockHeight;
use crate::models::blockchain::block::block_header::ADVANCE_DIFFICULTY_CORRECTION_FACTOR;
use crate::models::blockchain::block::block_header::ADVANCE_DIFFICULTY_CORRECTION_WAIT;
use crate::models::blockchain::block::block_header::TARGET_BLOCK_INTERVAL;
use crate::models::proof_abstractions::timestamp::Timestamp;

use super::block_height::BlockHeight;

const DIFFICULTY_NUM_LIMBS: usize = 5;

/// Estimated number of hashes required to find a block.
Expand Down Expand Up @@ -447,14 +446,13 @@ mod test {
use rand_distr::Geometric;
use test_strategy::proptest;

use super::difficulty_control;
use crate::models::blockchain::block::block_header::ADVANCE_DIFFICULTY_CORRECTION_FACTOR;
use crate::models::blockchain::block::block_header::ADVANCE_DIFFICULTY_CORRECTION_WAIT;
use crate::models::blockchain::block::block_height::BlockHeight;
use crate::models::blockchain::block::difficulty_control::Difficulty;
use crate::models::proof_abstractions::timestamp::Timestamp;

use super::difficulty_control;

impl Difficulty {
pub(crate) fn from_biguint(bi: BigUint) -> Self {
if bi.iter_u32_digits().count() > Self::NUM_LIMBS {
Expand Down
15 changes: 9 additions & 6 deletions src/models/blockchain/block/validity/appendix_witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,17 @@ pub(crate) struct AppendixWitness {
}

impl AppendixWitness {
fn new(block_body: &BlockBody) -> Self {
// TODO: Rename when used
fn _new(block_body: &BlockBody) -> Self {
Self {
block_body_hash: block_body.mast_hash(),
claims: Vec::default(),
proofs: Vec::default(),
}
}

fn with_claim(mut self, claim: Claim, proof: Proof) -> Self {
// TODO: Rename when used
fn _with_claim(mut self, claim: Claim, proof: Proof) -> Self {
assert!(triton_vm::verify(Stark::default(), &claim, &proof));
self.claims.push(claim);
self.proofs.push(proof);
Expand All @@ -59,13 +61,14 @@ impl AppendixWitness {
self.claims.clone()
}

pub(crate) async fn produce(
// TODO: Rename when used
pub(crate) async fn _produce(
block_primitive_witness: BlockPrimitiveWitness,
sync_device: &TritonProverSync,
) -> Result<AppendixWitness, TryLockError> {
let block_mast_hash = block_primitive_witness.body().mast_hash();

let tx_is_valid_claim = TransactionIsValid::claim(block_mast_hash);
let tx_is_valid_claim = TransactionIsValid::_claim(block_mast_hash);
let tx_is_valid_witness = TransactionIsValidWitness::from(block_primitive_witness.clone());
let tx_is_valid_nondeterminism = tx_is_valid_witness.nondeterminism();
let tx_is_valid_proof = TransactionIsValid
Expand All @@ -75,8 +78,8 @@ impl AppendixWitness {
// todo: add other claims and proofs

// construct `AppendixWitness` object
Ok(Self::new(block_primitive_witness.body())
.with_claim(tx_is_valid_claim, tx_is_valid_proof))
Ok(Self::_new(block_primitive_witness.body())
._with_claim(tx_is_valid_claim, tx_is_valid_proof))
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::sync::OnceLock;

use tasm_lib::twenty_first::prelude::Mmr;

use crate::models::blockchain::block::block_body::BlockBody;
Expand Down
2 changes: 1 addition & 1 deletion src/models/blockchain/block/validity/block_program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ pub(crate) mod test {
);

let appendix_witness =
AppendixWitness::produce(block_primitive_witness, &TritonProverSync::dummy())
AppendixWitness::_produce(block_primitive_witness, &TritonProverSync::dummy())
.await
.unwrap();
let block_program_nondeterminism = appendix_witness.nondeterminism();
Expand Down
3 changes: 2 additions & 1 deletion src/models/blockchain/block/validity/transaction_is_valid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ impl SecretWitness for TransactionIsValidWitness {
pub(crate) struct TransactionIsValid;

impl TransactionIsValid {
pub(crate) fn claim(block_mast_hash: Digest) -> Claim {
// TODO: Rename when used
pub(crate) fn _claim(block_mast_hash: Digest) -> Claim {
let input = block_mast_hash.reversed().values().to_vec();

Claim::new(Self.hash()).with_input(input)
Expand Down

0 comments on commit 926650f

Please sign in to comment.