Skip to content

Commit

Permalink
Change type of Config::blob_sidecar_subnet_count to NonZeroU64
Browse files Browse the repository at this point in the history
  • Loading branch information
Tumas committed Nov 11, 2024
1 parent da3bd32 commit c42dcaa
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion eth2_libp2p
2 changes: 1 addition & 1 deletion helper_functions/src/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ pub fn compute_subnet_for_attestation<P: Preset>(

/// [`compute_subnet_for_blob_sidecar`](https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/validator.md#sidecar)
#[must_use]
pub const fn compute_subnet_for_blob_sidecar(config: &Config, blob_index: BlobIndex) -> SubnetId {
pub fn compute_subnet_for_blob_sidecar(config: &Config, blob_index: BlobIndex) -> SubnetId {
blob_index % config.blob_sidecar_subnet_count
}

Expand Down
3 changes: 1 addition & 2 deletions types/src/combined.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1248,9 +1248,8 @@ impl<P: Preset> SszWrite for LightClientUpdate<P> {
fn write_variable(&self, bytes: &mut Vec<u8>) -> Result<(), WriteError> {
match self {
Self::Altair(update) => {
let size = AltairLightClientUpdate::<P>::SIZE.get();
let length_before = bytes.len();
let length_after = length_before + size;
let length_after = length_before + AltairLightClientUpdate::<P>::SIZE.get();

bytes.resize(length_after, 0);
update.write_fixed(&mut bytes[length_before..]);
Expand Down
4 changes: 2 additions & 2 deletions types/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ pub struct Config {
#[serde(with = "serde_utils::string_or_native")]
pub min_epochs_for_blob_sidecars_requests: u64,
#[serde(with = "serde_utils::string_or_native")]
pub blob_sidecar_subnet_count: u64,
pub blob_sidecar_subnet_count: NonZeroU64,
#[serde(with = "serde_utils::string_or_native")]
pub data_column_sidecar_subnet_count: u64,

Expand Down Expand Up @@ -232,7 +232,7 @@ impl Default for Config {
max_request_blocks_deneb: 128,
max_request_blob_sidecars: 768,
min_epochs_for_blob_sidecars_requests: 4096,
blob_sidecar_subnet_count: 6,
blob_sidecar_subnet_count: nonzero!(6_u64),
data_column_sidecar_subnet_count: 64,

// Transition
Expand Down

0 comments on commit c42dcaa

Please sign in to comment.