fix merge

This commit is contained in:
Boog900 2024-08-01 21:05:15 +01:00
parent 2b8bc4d67f
commit 5709111144
No known key found for this signature in database
GPG key ID: 42AB1287CB0041C2
11 changed files with 19 additions and 37 deletions

View file

@ -35,9 +35,9 @@ prop_compose! {
fn arb_full_hf_votes()
(
// we can't use HardFork as for some reason it overflows the stack, so we use u8.
votes in any::<[u8; TEST_WINDOW_SIZE as usize]>()
votes in any::<[u8; TEST_WINDOW_SIZE]>()
) -> HFVotes {
let mut vote_count = HFVotes::new(TEST_WINDOW_SIZE as usize);
let mut vote_count = HFVotes::new(TEST_WINDOW_SIZE);
for vote in votes {
vote_count.add_vote_for_hf(&HardFork::from_vote(vote % 17));
}

View file

@ -130,10 +130,10 @@ pub(crate) fn ring_ct_semantic_checks(
let rct_type = proofs.rct_type();
check_rct_type(&rct_type, *hf, tx_hash)?;
check_output_range_proofs(&proofs, verifier)?;
check_output_range_proofs(proofs, verifier)?;
if rct_type != RctType::AggregateMlsagBorromean {
simple_type_balances(&proofs)?;
simple_type_balances(proofs)?;
}
Ok(())

View file

@ -135,11 +135,7 @@ impl DifficultyCache {
numb_blocks: usize,
database: D,
) -> Result<(), ExtendedConsensusError> {
let Some(retained_blocks) = self
.timestamps
.len()
.checked_sub(usize::try_from(numb_blocks).unwrap())
else {
let Some(retained_blocks) = self.timestamps.len().checked_sub(numb_blocks) else {
// More blocks to pop than we have in the cache, so just restart a new cache.
*self = Self::init_from_chain_height(
self.last_accounted_height - numb_blocks + 1,

View file

@ -79,12 +79,8 @@ impl HardForkState {
let block_start = chain_height.saturating_sub(config.window);
let votes = get_votes_in_range(
database.clone(),
block_start..chain_height,
usize::try_from(config.window).unwrap(),
)
.await?;
let votes =
get_votes_in_range(database.clone(), block_start..chain_height, config.window).await?;
if chain_height > config.window {
debug_assert_eq!(votes.total_votes(), config.window)

View file

@ -101,17 +101,11 @@ impl BlockWeightsCache {
Ok(BlockWeightsCache {
short_term_block_weights: rayon_spawn_async(move || {
RollingMedian::from_vec(
short_term_block_weights,
usize::try_from(config.short_term_window).unwrap(),
)
RollingMedian::from_vec(short_term_block_weights, config.short_term_window)
})
.await,
long_term_weights: rayon_spawn_async(move || {
RollingMedian::from_vec(
long_term_weights,
usize::try_from(config.long_term_window).unwrap(),
)
RollingMedian::from_vec(long_term_weights, config.long_term_window)
})
.await,
tip_height: chain_height - 1,

View file

@ -65,7 +65,7 @@ async fn calculate_diff_3000000_3002000() -> Result<(), tower::BoxError> {
let mut db_builder = DummyDatabaseBuilder::default();
for (cum_dif, timestamp) in DIF_3000000_3002000
.iter()
.take(cfg.total_block_count() as usize)
.take(cfg.total_block_count())
{
db_builder.add_block(
DummyBlockExtendedHeader::default().with_difficulty_info(*timestamp, *cum_dif),

View file

@ -173,8 +173,8 @@ impl Service<BCReadRequest> for DummyDatabase {
BCResponse::BlockHash(hash)
}
BCReadRequest::BlockExtendedHeaderInRange(range, _) => {
let mut end = usize::try_from(range.end).unwrap();
let mut start = usize::try_from(range.start).unwrap();
let mut end = range.end;
let mut start = range.start;
if let Some(dummy_height) = dummy_height {
let block_len = blocks.read().unwrap().len();

View file

@ -130,13 +130,10 @@ impl TransactionVerificationData {
match &tx {
Transaction::V1 { prefix, .. } => {
for input in &prefix.inputs {
match input {
Input::ToKey { amount, .. } => {
fee = fee
.checked_add(amount.unwrap_or(0))
.ok_or(TransactionError::InputsOverflow)?;
}
_ => (),
if let Input::ToKey { amount, .. } = input {
fee = fee
.checked_add(amount.unwrap_or(0))
.ok_or(TransactionError::InputsOverflow)?;
}
}

View file

@ -131,7 +131,7 @@ mod tests {
start_height,
block_batch: BlockBatch {
blocks: vec![],
size: start_height as usize,
size: start_height,
peer_handle,
},
}

View file

@ -171,15 +171,12 @@ impl<N: NetworkZone> ChainTracker<N> {
// - index of the next pruned block for this seed
let end_idx = min(
min(entry.ids.len(), max_blocks),
usize::try_from(
pruning_seed
.get_next_pruned_block(self.first_height, CRYPTONOTE_MAX_BLOCK_HEIGHT)
.expect("We use local values to calculate height which should be below the sanity limit")
// Use a big value as a fallback if the seed does no pruning.
.unwrap_or(CRYPTONOTE_MAX_BLOCK_HEIGHT)
- self.first_height,
)
.unwrap(),
);
if end_idx == 0 {

View file

@ -25,6 +25,7 @@ use crate::{
pub fn chain_height(
table_block_heights: &impl DatabaseRo<BlockHeights>,
) -> Result<BlockHeight, RuntimeError> {
#[allow(clippy::cast_possible_truncation)] // we enforce 64-bit
table_block_heights.len().map(|height| height as usize)
}
@ -47,6 +48,7 @@ pub fn top_block_height(
) -> Result<BlockHeight, RuntimeError> {
match table_block_heights.len()? {
0 => Err(RuntimeError::KeyNotFound),
#[allow(clippy::cast_possible_truncation)] // we enforce 64-bit
height => Ok(height as usize - 1),
}
}