From 4c3561dcaf8ddeb7cef86f329a386615adfad9eb Mon Sep 17 00:00:00 2001 From: realbigsean Date: Mon, 13 Feb 2023 16:50:33 -0500 Subject: [PATCH] make batch size check compile time panic --- beacon_node/network/src/sync/network_context.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/beacon_node/network/src/sync/network_context.rs b/beacon_node/network/src/sync/network_context.rs index beeba9e9b..2e8becb9c 100644 --- a/beacon_node/network/src/sync/network_context.rs +++ b/beacon_node/network/src/sync/network_context.rs @@ -562,13 +562,12 @@ impl SyncNetworkContext { /// blocks and blobs. #[allow(unused)] pub fn batch_type(&self, epoch: types::Epoch) -> ByRangeRequestType { - if super::backfill_sync::BACKFILL_EPOCHS_PER_BATCH * super::range_sync::EPOCHS_PER_BATCH - != 1 - { - panic!( - "To deal with alignment with 4844 boundaries, batches need to be of just one epoch" - ); - } + const _: () = assert!( + super::backfill_sync::BACKFILL_EPOCHS_PER_BATCH == 1 + && super::range_sync::EPOCHS_PER_BATCH == 1, + "To deal with alignment with 4844 boundaries, batches need to be of just one epoch" + ); + #[cfg(test)] { // Keep tests only for blocks.