diff --git a/src/mine_loop.rs b/src/mine_loop.rs index 84133a99..622999f4 100644 --- a/src/mine_loop.rs +++ b/src/mine_loop.rs @@ -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; diff --git a/src/models/blockchain/block/difficulty_control.rs b/src/models/blockchain/block/difficulty_control.rs index 73554f60..3854a4d7 100644 --- a/src/models/blockchain/block/difficulty_control.rs +++ b/src/models/blockchain/block/difficulty_control.rs @@ -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. @@ -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 { diff --git a/src/models/blockchain/block/validity/appendix_witness.rs b/src/models/blockchain/block/validity/appendix_witness.rs index bfbc367a..0eec92f9 100644 --- a/src/models/blockchain/block/validity/appendix_witness.rs +++ b/src/models/blockchain/block/validity/appendix_witness.rs @@ -39,7 +39,8 @@ 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(), @@ -47,7 +48,8 @@ impl AppendixWitness { } } - 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); @@ -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 { 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 @@ -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)) } } diff --git a/src/models/blockchain/block/validity/block_primitive_witness.rs b/src/models/blockchain/block/validity/block_primitive_witness.rs index 46fd1040..5dca89f3 100644 --- a/src/models/blockchain/block/validity/block_primitive_witness.rs +++ b/src/models/blockchain/block/validity/block_primitive_witness.rs @@ -1,4 +1,5 @@ use std::sync::OnceLock; + use tasm_lib::twenty_first::prelude::Mmr; use crate::models::blockchain::block::block_body::BlockBody; diff --git a/src/models/blockchain/block/validity/block_program.rs b/src/models/blockchain/block/validity/block_program.rs index c997f937..af23f86e 100644 --- a/src/models/blockchain/block/validity/block_program.rs +++ b/src/models/blockchain/block/validity/block_program.rs @@ -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(); diff --git a/src/models/blockchain/block/validity/transaction_is_valid.rs b/src/models/blockchain/block/validity/transaction_is_valid.rs index 0de7a7fe..6aa69791 100644 --- a/src/models/blockchain/block/validity/transaction_is_valid.rs +++ b/src/models/blockchain/block/validity/transaction_is_valid.rs @@ -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)