Skip to content

Commit 7938a43

Browse files
committed
Rename VList to List and use Vector
1 parent 20f53e7 commit 7938a43

File tree

22 files changed

+83
-94
lines changed

22 files changed

+83
-94
lines changed

beacon_node/beacon_chain/src/eth1_chain.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ mod test {
10211021

10221022
mod collect_valid_votes {
10231023
use super::*;
1024-
use types::VList;
1024+
use types::List;
10251025

10261026
fn get_eth1_data_vec(n: u64, block_number_offset: u64) -> Vec<(Eth1Data, BlockNumber)> {
10271027
(0..n)
@@ -1069,7 +1069,7 @@ mod test {
10691069

10701070
let votes_to_consider = get_eth1_data_vec(slots, 0);
10711071

1072-
*state.eth1_data_votes_mut() = VList::new(
1072+
*state.eth1_data_votes_mut() = List::new(
10731073
votes_to_consider[0..slots as usize / 4]
10741074
.iter()
10751075
.map(|(eth1_data, _)| eth1_data)
@@ -1100,7 +1100,7 @@ mod test {
11001100
.expect("should have some eth1 data")
11011101
.clone();
11021102

1103-
*state.eth1_data_votes_mut() = VList::new(
1103+
*state.eth1_data_votes_mut() = List::new(
11041104
vec![duplicate_eth1_data.clone(); 4]
11051105
.iter()
11061106
.map(|(eth1_data, _)| eth1_data)

beacon_node/store/src/hdiff.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use ssz::{Decode, Encode};
66
use ssz_derive::{Decode, Encode};
77
use std::io::{Read, Write};
88
use std::str::FromStr;
9-
use types::{BeaconState, ChainSpec, EthSpec, Slot, VList};
9+
use types::{BeaconState, ChainSpec, EthSpec, List, Slot};
1010
use zstd::{Decoder, Encoder};
1111

1212
#[derive(Debug)]
@@ -91,7 +91,7 @@ impl HDiffBuffer {
9191

9292
pub fn into_state<E: EthSpec>(self, spec: &ChainSpec) -> Result<BeaconState<E>, Error> {
9393
let mut state = BeaconState::from_ssz_bytes(&self.state, spec).unwrap();
94-
*state.balances_mut() = VList::new(self.balances).unwrap();
94+
*state.balances_mut() = List::new(self.balances).unwrap();
9595
Ok(state)
9696
}
9797
}

consensus/state_processing/src/per_epoch_processing/altair/participation_flag_updates.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ use crate::EpochProcessingError;
22
use types::beacon_state::BeaconState;
33
use types::eth_spec::EthSpec;
44
use types::participation_flags::ParticipationFlags;
5-
use types::VList;
5+
use types::List;
66

77
pub fn process_participation_flag_updates<T: EthSpec>(
88
state: &mut BeaconState<T>,
99
) -> Result<(), EpochProcessingError> {
1010
*state.previous_epoch_participation_mut()? =
1111
std::mem::take(state.current_epoch_participation_mut()?);
1212
*state.current_epoch_participation_mut()? =
13-
VList::repeat(ParticipationFlags::default(), state.validators().len())?;
13+
List::repeat(ParticipationFlags::default(), state.validators().len())?;
1414
Ok(())
1515
}

consensus/state_processing/src/per_epoch_processing/epoch_processing_summary.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use crate::metrics;
33
use std::sync::Arc;
44
use types::{
55
consts::altair::{TIMELY_HEAD_FLAG_INDEX, TIMELY_SOURCE_FLAG_INDEX, TIMELY_TARGET_FLAG_INDEX},
6-
BeaconStateError, Epoch, EthSpec, ParticipationFlags, ProgressiveBalancesCache, SyncCommittee,
7-
VList, Validator,
6+
BeaconStateError, Epoch, EthSpec, List, ParticipationFlags, ProgressiveBalancesCache,
7+
SyncCommittee, Validator,
88
};
99

1010
/// Provides a summary of validator participation during the epoch.
@@ -25,20 +25,20 @@ pub enum EpochProcessingSummary<T: EthSpec> {
2525
#[derive(PartialEq, Debug)]
2626
pub struct ParticipationEpochSummary<T: EthSpec> {
2727
/// Copy of the validator registry prior to mutation.
28-
validators: VList<Validator, T::ValidatorRegistryLimit>,
28+
validators: List<Validator, T::ValidatorRegistryLimit>,
2929
/// Copy of the participation flags for the previous epoch.
30-
previous_epoch_participation: VList<ParticipationFlags, T::ValidatorRegistryLimit>,
30+
previous_epoch_participation: List<ParticipationFlags, T::ValidatorRegistryLimit>,
3131
/// Copy of the participation flags for the current epoch.
32-
current_epoch_participation: VList<ParticipationFlags, T::ValidatorRegistryLimit>,
32+
current_epoch_participation: List<ParticipationFlags, T::ValidatorRegistryLimit>,
3333
previous_epoch: Epoch,
3434
current_epoch: Epoch,
3535
}
3636

3737
impl<T: EthSpec> ParticipationEpochSummary<T> {
3838
pub fn new(
39-
validators: VList<Validator, T::ValidatorRegistryLimit>,
40-
previous_epoch_participation: VList<ParticipationFlags, T::ValidatorRegistryLimit>,
41-
current_epoch_participation: VList<ParticipationFlags, T::ValidatorRegistryLimit>,
39+
validators: List<Validator, T::ValidatorRegistryLimit>,
40+
previous_epoch_participation: List<ParticipationFlags, T::ValidatorRegistryLimit>,
41+
current_epoch_participation: List<ParticipationFlags, T::ValidatorRegistryLimit>,
4242
previous_epoch: Epoch,
4343
current_epoch: Epoch,
4444
) -> Self {

consensus/state_processing/src/per_epoch_processing/resets.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use super::errors::EpochProcessingError;
22
use safe_arith::SafeArith;
33
use types::beacon_state::BeaconState;
44
use types::eth_spec::EthSpec;
5-
use types::{Unsigned, VList};
5+
use types::{List, Unsigned};
66

77
pub fn process_eth1_data_reset<T: EthSpec>(
88
state: &mut BeaconState<T>,
@@ -13,7 +13,7 @@ pub fn process_eth1_data_reset<T: EthSpec>(
1313
.safe_rem(T::SlotsPerEth1VotingPeriod::to_u64())?
1414
== 0
1515
{
16-
*state.eth1_data_votes_mut() = VList::empty();
16+
*state.eth1_data_votes_mut() = List::empty();
1717
}
1818
Ok(())
1919
}

consensus/state_processing/src/upgrade/altair.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ use std::mem;
44
use std::sync::Arc;
55
use types::{
66
BeaconState, BeaconStateAltair, BeaconStateError as Error, ChainSpec, EpochCache, EthSpec,
7-
Fork, ParticipationFlags, PendingAttestation, RelativeEpoch, SyncCommittee, VList,
7+
Fork, List, ParticipationFlags, PendingAttestation, RelativeEpoch, SyncCommittee,
88
};
99

1010
/// Translate the participation information from the epoch prior to the fork into Altair's format.
1111
pub fn translate_participation<E: EthSpec>(
1212
state: &mut BeaconState<E>,
13-
pending_attestations: &VList<PendingAttestation<E>, E::MaxPendingAttestations>,
13+
pending_attestations: &List<PendingAttestation<E>, E::MaxPendingAttestations>,
1414
spec: &ChainSpec,
1515
) -> Result<(), Error> {
1616
// Previous epoch committee cache is required for `get_attesting_indices`.
@@ -51,8 +51,8 @@ pub fn upgrade_to_altair<E: EthSpec>(
5151
let pre = pre_state.as_base_mut()?;
5252

5353
let default_epoch_participation =
54-
VList::new(vec![ParticipationFlags::default(); pre.validators.len()])?;
55-
let inactivity_scores = VList::new(vec![0; pre.validators.len()])?;
54+
List::new(vec![ParticipationFlags::default(); pre.validators.len()])?;
55+
let inactivity_scores = List::new(vec![0; pre.validators.len()])?;
5656

5757
let temp_sync_committee = Arc::new(SyncCommittee::temporary());
5858

consensus/state_processing/src/upgrade/capella.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::mem;
22
use types::{
33
BeaconState, BeaconStateCapella, BeaconStateError as Error, ChainSpec, EpochCache, EthSpec,
4-
Fork, VList,
4+
Fork, List,
55
};
66

77
/// Transform a `Merge` state into an `Capella` state.
@@ -61,7 +61,7 @@ pub fn upgrade_to_capella<E: EthSpec>(
6161
// Capella
6262
next_withdrawal_index: 0,
6363
next_withdrawal_validator_index: 0,
64-
historical_summaries: VList::default(),
64+
historical_summaries: List::default(),
6565
// Caches
6666
total_active_balance: pre.total_active_balance,
6767
progressive_balances_cache: mem::take(&mut pre.progressive_balances_cache),

consensus/types/src/beacon_block_body.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use derivative::Derivative;
44
use merkle_proof::{MerkleTree, MerkleTreeError};
55
use serde::{Deserialize, Serialize};
66
use ssz_derive::{Decode, Encode};
7-
use ssz_types::{FixedVector, VariableList};
87
use std::marker::PhantomData;
98
use superstruct::superstruct;
109
use test_random_derive::TestRandom;

consensus/types/src/beacon_state.rs

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use crate::epoch_cache::EpochCache;
3535
use crate::historical_summary::HistoricalSummary;
3636
pub use eth_spec::*;
3737
pub use iter::BlockRootsIter;
38-
pub use milhouse::{interface::Interface, List as VList, List, Vector as FixedVector};
38+
pub use milhouse::{interface::Interface, List, Vector};
3939

4040
#[macro_use]
4141
mod committee_cache;
@@ -51,8 +51,8 @@ mod tests;
5151
pub const CACHED_EPOCHS: usize = 3;
5252
const MAX_RANDOM_BYTE: u64 = (1 << 8) - 1;
5353

54-
pub type Validators<T> = VList<Validator, <T as EthSpec>::ValidatorRegistryLimit>;
55-
pub type Balances<T> = VList<u64, <T as EthSpec>::ValidatorRegistryLimit>;
54+
pub type Validators<T> = List<Validator, <T as EthSpec>::ValidatorRegistryLimit>;
55+
pub type Balances<T> = List<u64, <T as EthSpec>::ValidatorRegistryLimit>;
5656

5757
#[derive(Debug, PartialEq, Clone)]
5858
pub enum Error {
@@ -328,60 +328,60 @@ where
328328
#[metastruct(exclude_from(tree_lists))]
329329
pub latest_block_header: BeaconBlockHeader,
330330
#[test_random(default)]
331-
pub block_roots: FixedVector<Hash256, T::SlotsPerHistoricalRoot>,
331+
pub block_roots: Vector<Hash256, T::SlotsPerHistoricalRoot>,
332332
#[test_random(default)]
333-
pub state_roots: FixedVector<Hash256, T::SlotsPerHistoricalRoot>,
333+
pub state_roots: Vector<Hash256, T::SlotsPerHistoricalRoot>,
334334
// Frozen in Capella, replaced by historical_summaries
335335
#[test_random(default)]
336-
pub historical_roots: VList<Hash256, T::HistoricalRootsLimit>,
336+
pub historical_roots: List<Hash256, T::HistoricalRootsLimit>,
337337

338338
// Ethereum 1.0 chain data
339339
#[metastruct(exclude_from(tree_lists))]
340340
pub eth1_data: Eth1Data,
341341
#[test_random(default)]
342342
// FIXME(sproul): excluded due to `rebase_on` issue
343343
#[metastruct(exclude_from(tree_lists))]
344-
pub eth1_data_votes: VList<Eth1Data, T::SlotsPerEth1VotingPeriod>,
344+
pub eth1_data_votes: List<Eth1Data, T::SlotsPerEth1VotingPeriod>,
345345
#[superstruct(getter(copy))]
346346
#[metastruct(exclude_from(tree_lists))]
347347
#[serde(with = "serde_utils::quoted_u64")]
348348
pub eth1_deposit_index: u64,
349349

350350
// Registry
351351
#[test_random(default)]
352-
pub validators: VList<GenericValidator, T::ValidatorRegistryLimit>,
352+
pub validators: List<GenericValidator, T::ValidatorRegistryLimit>,
353353
#[serde(with = "ssz_types::serde_utils::quoted_u64_var_list")]
354354
#[compare_fields(as_iter)]
355355
#[test_random(default)]
356-
pub balances: VList<u64, T::ValidatorRegistryLimit>,
356+
pub balances: List<u64, T::ValidatorRegistryLimit>,
357357

358358
// Randomness
359359
#[test_random(default)]
360-
pub randao_mixes: FixedVector<Hash256, T::EpochsPerHistoricalVector>,
360+
pub randao_mixes: Vector<Hash256, T::EpochsPerHistoricalVector>,
361361

362362
// Slashings
363363
#[test_random(default)]
364364
#[serde(with = "ssz_types::serde_utils::quoted_u64_fixed_vec")]
365-
pub slashings: FixedVector<u64, T::EpochsPerSlashingsVector>,
365+
pub slashings: Vector<u64, T::EpochsPerSlashingsVector>,
366366

367367
// Attestations (genesis fork only)
368368
// FIXME(sproul): excluded from tree lists due to ResetListDiff
369369
#[superstruct(only(Base))]
370370
#[test_random(default)]
371371
#[metastruct(exclude_from(tree_lists))]
372-
pub previous_epoch_attestations: VList<PendingAttestation<T>, T::MaxPendingAttestations>,
372+
pub previous_epoch_attestations: List<PendingAttestation<T>, T::MaxPendingAttestations>,
373373
#[superstruct(only(Base))]
374374
#[test_random(default)]
375375
#[metastruct(exclude_from(tree_lists))]
376-
pub current_epoch_attestations: VList<PendingAttestation<T>, T::MaxPendingAttestations>,
376+
pub current_epoch_attestations: List<PendingAttestation<T>, T::MaxPendingAttestations>,
377377

378378
// Participation (Altair and later)
379379
#[superstruct(only(Altair, Merge, Capella, Deneb))]
380380
#[test_random(default)]
381-
pub previous_epoch_participation: VList<ParticipationFlags, T::ValidatorRegistryLimit>,
381+
pub previous_epoch_participation: List<ParticipationFlags, T::ValidatorRegistryLimit>,
382382
#[superstruct(only(Altair, Merge, Capella, Deneb))]
383383
#[test_random(default)]
384-
pub current_epoch_participation: VList<ParticipationFlags, T::ValidatorRegistryLimit>,
384+
pub current_epoch_participation: List<ParticipationFlags, T::ValidatorRegistryLimit>,
385385

386386
// Finality
387387
#[test_random(default)]
@@ -401,7 +401,7 @@ where
401401
#[serde(with = "ssz_types::serde_utils::quoted_u64_var_list")]
402402
#[superstruct(only(Altair, Merge, Capella, Deneb))]
403403
#[test_random(default)]
404-
pub inactivity_scores: VList<u64, T::ValidatorRegistryLimit>,
404+
pub inactivity_scores: List<u64, T::ValidatorRegistryLimit>,
405405

406406
// Light-client sync committees
407407
#[superstruct(only(Altair, Merge, Capella, Deneb))]
@@ -443,7 +443,7 @@ where
443443
// Deep history valid from Capella onwards.
444444
#[superstruct(only(Capella, Deneb))]
445445
#[test_random(default)]
446-
pub historical_summaries: VList<HistoricalSummary, T::HistoricalRootsLimit>,
446+
pub historical_summaries: List<HistoricalSummary, T::HistoricalRootsLimit>,
447447

448448
// Caching (not in the spec)
449449
#[serde(skip_serializing, skip_deserializing)]
@@ -510,28 +510,28 @@ impl<T: EthSpec> BeaconState<T> {
510510

511511
// History
512512
latest_block_header: BeaconBlock::<T>::empty(spec).temporary_block_header(),
513-
block_roots: FixedVector::default(),
514-
state_roots: FixedVector::default(),
515-
historical_roots: VList::default(),
513+
block_roots: Vector::default(),
514+
state_roots: Vector::default(),
515+
historical_roots: List::default(),
516516

517517
// Eth1
518518
eth1_data,
519-
eth1_data_votes: VList::default(),
519+
eth1_data_votes: List::default(),
520520
eth1_deposit_index: 0,
521521

522522
// Validator registry
523-
validators: VList::default(), // Set later.
524-
balances: VList::default(), // Set later.
523+
validators: List::default(), // Set later.
524+
balances: List::default(), // Set later.
525525

526526
// Randomness
527-
randao_mixes: FixedVector::default(),
527+
randao_mixes: Vector::default(),
528528

529529
// Slashings
530-
slashings: FixedVector::default(),
530+
slashings: Vector::default(),
531531

532532
// Attestations
533-
previous_epoch_attestations: VList::default(),
534-
current_epoch_attestations: VList::default(),
533+
previous_epoch_attestations: List::default(),
534+
current_epoch_attestations: List::default(),
535535

536536
// Finality
537537
justification_bits: BitVector::new(),
@@ -1169,7 +1169,7 @@ impl<T: EthSpec> BeaconState<T> {
11691169

11701170
/// Fill `randao_mixes` with
11711171
pub fn fill_randao_mixes_with(&mut self, index_root: Hash256) -> Result<(), Error> {
1172-
*self.randao_mixes_mut() = FixedVector::from_elem(index_root)?;
1172+
*self.randao_mixes_mut() = Vector::from_elem(index_root)?;
11731173
Ok(())
11741174
}
11751175

@@ -1303,7 +1303,7 @@ impl<T: EthSpec> BeaconState<T> {
13031303
}
13041304

13051305
/// Get a reference to the entire `slashings` vector.
1306-
pub fn get_all_slashings(&self) -> &FixedVector<u64, T::EpochsPerSlashingsVector> {
1306+
pub fn get_all_slashings(&self) -> &Vector<u64, T::EpochsPerSlashingsVector> {
13071307
self.slashings()
13081308
}
13091309

@@ -1370,9 +1370,9 @@ impl<T: EthSpec> BeaconState<T> {
13701370
(
13711371
&mut Validators<T>,
13721372
&mut Balances<T>,
1373-
&VList<ParticipationFlags, T::ValidatorRegistryLimit>,
1374-
&VList<ParticipationFlags, T::ValidatorRegistryLimit>,
1375-
&mut VList<u64, T::ValidatorRegistryLimit>,
1373+
&List<ParticipationFlags, T::ValidatorRegistryLimit>,
1374+
&List<ParticipationFlags, T::ValidatorRegistryLimit>,
1375+
&mut List<u64, T::ValidatorRegistryLimit>,
13761376
&mut ProgressiveBalancesCache,
13771377
&mut ExitCache,
13781378
&mut EpochCache,
@@ -1677,7 +1677,7 @@ impl<T: EthSpec> BeaconState<T> {
16771677
epoch: Epoch,
16781678
previous_epoch: Epoch,
16791679
current_epoch: Epoch,
1680-
) -> Result<&mut VList<ParticipationFlags, T::ValidatorRegistryLimit>, Error> {
1680+
) -> Result<&mut List<ParticipationFlags, T::ValidatorRegistryLimit>, Error> {
16811681
if epoch == current_epoch {
16821682
match self {
16831683
BeaconState::Base(_) => Err(BeaconStateError::IncorrectStateVariant),
@@ -1928,19 +1928,19 @@ impl<T: EthSpec> BeaconState<T> {
19281928
|| self.slashings().has_pending_updates()
19291929
|| self
19301930
.previous_epoch_attestations()
1931-
.map_or(false, VList::has_pending_updates)
1931+
.map_or(false, List::has_pending_updates)
19321932
|| self
19331933
.current_epoch_attestations()
1934-
.map_or(false, VList::has_pending_updates)
1934+
.map_or(false, List::has_pending_updates)
19351935
|| self
19361936
.previous_epoch_participation()
1937-
.map_or(false, VList::has_pending_updates)
1937+
.map_or(false, List::has_pending_updates)
19381938
|| self
19391939
.current_epoch_participation()
1940-
.map_or(false, VList::has_pending_updates)
1940+
.map_or(false, List::has_pending_updates)
19411941
|| self
19421942
.inactivity_scores()
1943-
.map_or(false, VList::has_pending_updates)
1943+
.map_or(false, List::has_pending_updates)
19441944
}
19451945

19461946
/// Completely drops the `progressive_balances_cache` cache, replacing it with a new, empty cache.

consensus/types/src/beacon_state/committee_cache/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ async fn shuffles_for_the_right_epoch() {
9292
.map(|i| Hash256::from_low_u64_be(i as u64))
9393
.collect();
9494

95-
*state.randao_mixes_mut() = FixedVector::try_from_iter(distinct_hashes).unwrap();
95+
*state.randao_mixes_mut() = Vector::try_from_iter(distinct_hashes).unwrap();
9696

9797
let previous_seed = state
9898
.get_seed(state.previous_epoch(), Domain::BeaconAttester, spec)

0 commit comments

Comments
 (0)