mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
Shuffling for 32 bit platforms (#7725)
- In shuffling, a the raw_pivot (u64) is cast to a usize which will break on 32 bit systems. Now it is modulo'ed with the list_size first then cast to a usize. - ruint doesn't implement shifting with u64's on 32-bit arch. Since `prefix_bits` is u8 and NODE_ID_BITS = 256, we use them as u32's instead. See: https://docs.rs/ruint/latest/src/ruint/bits.rs.html#711
This commit is contained in:
@@ -96,8 +96,7 @@ pub fn shuffle_list(
|
||||
loop {
|
||||
buf.set_round(r);
|
||||
|
||||
let pivot = buf.raw_pivot() as usize % list_size;
|
||||
|
||||
let pivot = (buf.raw_pivot() % list_size as u64) as usize;
|
||||
let mirror = (pivot + 1) >> 1;
|
||||
|
||||
buf.mix_in_position(pivot >> 8);
|
||||
|
||||
@@ -11,7 +11,7 @@ const MAX_SUBNET_ID: usize = 64;
|
||||
|
||||
/// The number of bits in a Discovery `NodeId`. This is used for binary operations on the node-id
|
||||
/// data.
|
||||
const NODE_ID_BITS: u64 = 256;
|
||||
const NODE_ID_BITS: u32 = 256;
|
||||
|
||||
static SUBNET_ID_TO_STRING: LazyLock<Vec<String>> = LazyLock::new(|| {
|
||||
let mut v = Vec::with_capacity(MAX_SUBNET_ID);
|
||||
@@ -102,7 +102,7 @@ impl SubnetId {
|
||||
spec: &ChainSpec,
|
||||
) -> impl Iterator<Item = SubnetId> {
|
||||
// The bits of the node-id we are using to define the subnets.
|
||||
let prefix_bits = spec.attestation_subnet_prefix_bits as u64;
|
||||
let prefix_bits = spec.attestation_subnet_prefix_bits as u32;
|
||||
|
||||
let node_id = U256::from_be_slice(&raw_node_id);
|
||||
// calculate the prefixes used to compute the subnet and shuffling
|
||||
|
||||
Reference in New Issue
Block a user