This commit is contained in:
Boog900 2025-03-06 21:52:18 +00:00
parent d71c5aaf7f
commit 435c6b717f
No known key found for this signature in database
GPG key ID: 42AB1287CB0041C2
7 changed files with 19 additions and 16 deletions
binaries/cuprated/src/blockchain
consensus/fast-sync/src
p2p/p2p/src/block_downloader
storage/blockchain/src/service

View file

@ -5,6 +5,8 @@ use cuprate_helper::network::Network;
/// The hashes of the compiled in fast sync file.
static FAST_SYNC_HASHES: &[[u8; 32]] = unsafe {
let bytes = include_bytes!("./fast_sync/fast_sync_hashes.bin");
#[expect(clippy::manual_assert, reason = "assert is not const")]
if bytes.len() % 32 != 0 {
panic!()
}

View file

@ -116,7 +116,7 @@ impl BlockchainManager {
batch,
).await;
drop(permit)
drop(permit);
}
Some(incoming_command) = command_rx.recv() => {
self.handle_command(incoming_command).await;

View file

@ -30,6 +30,7 @@ pub enum SyncerError {
/// The syncer tasks that makes sure we are fully synchronised with our connected peers.
#[instrument(level = "debug", skip_all)]
#[expect(clippy::significant_drop_tightening)]
pub async fn syncer<CN>(
mut context_svc: BlockchainContextService,
our_chain: CN,
@ -56,7 +57,7 @@ where
let semaphore = Arc::new(Semaphore::new(1));
let mut sync_permit = Arc::new(semaphore.clone().acquire_owned().await.unwrap());
let mut sync_permit = Arc::new(Arc::clone(&semaphore).acquire_owned().await.unwrap());
loop {
check_sync_interval.tick().await;
@ -80,7 +81,7 @@ where
tracing::info!("Received stop signal, stopping block downloader");
drop(sync_permit);
sync_permit = Arc::new(semaphore.clone().acquire_owned().await.unwrap());
sync_permit = Arc::new(Arc::clone(&semaphore).acquire_owned().await.unwrap());
break;
}
@ -89,7 +90,7 @@ where
// Wait for all references to the permit have been dropped (which means all blocks in the queue
// have been handled before checking if we are synced.
drop(sync_permit);
sync_permit = Arc::new(semaphore.clone().acquire_owned().await.unwrap());
sync_permit = Arc::new(Arc::clone(&semaphore).acquire_owned().await.unwrap());
let blockchain_context = context_svc.blockchain_context();

View file

@ -29,9 +29,8 @@ async fn read_batch(
let response_channel = handle.ready().await?.call(request);
let response = response_channel.await?;
let block_ids = match response {
BlockchainResponse::BlockHashInRange(block_id) => block_id,
_ => unreachable!(),
let BlockchainResponse::BlockHashInRange(block_ids) = response else {
unreachable!()
};
Ok(block_ids)
@ -67,7 +66,7 @@ async fn main() {
}
height += BATCH_SIZE;
println!("height: {}", height);
println!("height: {height}");
}
drop(read_handle);

View file

@ -112,7 +112,7 @@ pub async fn validate_entries<N: NetworkZone>(
.ids
.drain((back.ids.len() - hashes_stop_diff_last_height)..)
.collect(),
peer: back.peer.clone(),
peer: back.peer,
handle: back.handle.clone(),
});
@ -169,7 +169,7 @@ pub async fn validate_entries<N: NetworkZone>(
}
/// Get the index of the hash that contains this block in the fast sync hashes.
fn get_hash_index_for_height(height: usize) -> usize {
const fn get_hash_index_for_height(height: usize) -> usize {
height / FAST_SYNC_BATCH_LEN
}
@ -191,9 +191,10 @@ pub fn block_to_verified_block_information(
panic!("fast sync block invalid");
};
if *height != blockchin_ctx.chain_height {
panic!("fast sync block invalid");
}
assert_eq!(
*height, blockchin_ctx.chain_height,
"fast sync block invalid"
);
let mut txs = txs
.into_iter()

View file

@ -50,7 +50,7 @@ pub(crate) enum ChainTrackerError {
NewEntryIsEmpty,
/// The new chain entry does not follow from the top of our chain tracker.
NewEntryDoesNotFollowChain,
#[allow(dead_code)] // This is used for logging
#[expect(dead_code)] // This is used for logging
ChainSvcError(tower::BoxError),
}

View file

@ -285,12 +285,12 @@ fn block_hash_in_range(env: &ConcreteEnv, range: Range<usize>, chain: Chain) ->
.map(|block_height| {
let tx_ro = tx_ro.get_or_try(|| env_inner.tx_ro())?;
let table_block_infos = env_inner.open_db_ro::<BlockInfos>(&tx_ro)?;
let table_block_infos = env_inner.open_db_ro::<BlockInfos>(tx_ro)?;
let block_hash = match chain {
Chain::Main => get_block_info(&block_height, &table_block_infos)?.block_hash,
Chain::Alt(chain) => {
get_alt_block_hash(&block_height, chain, &env_inner.open_tables(&tx_ro)?)?
get_alt_block_hash(&block_height, chain, &env_inner.open_tables(tx_ro)?)?
}
};