mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 18:32:42 +00:00
* Consensus changes
* EF tests
* lcli
* common and watch
* account manager
* cargo
* fork choice
* promise cache
* beacon chain
* interop genesis
* http api
* lighthouse
* op pool
* beacon chain misc
* parallel state cache
* store
* fix issues in store
* IT COMPILES
* Remove some unnecessary module qualification
* Revert Arced pubkey optimization (#5536)
* Merge remote-tracking branch 'origin/unstable' into tree-states-memory
* Fix caching, rebasing and some tests
* Remove unused deps
* Merge remote-tracking branch 'origin/unstable' into tree-states-memory
* Small cleanups
* Revert shuffling cache/promise cache changes
* Fix state advance bugs
* Fix shuffling tests
* Remove some resolved FIXMEs
* Remove StateProcessingStrategy
* Optimise withdrawals calculation
* Don't reorg if state cache is missed
* Remove inconsistent state func
* Fix beta compiler
* Rebase early, rebase often
* Fix state caching behaviour
* Update to milhouse release
* Fix on-disk consensus context format
* Merge remote-tracking branch 'origin/unstable' into tree-states-memory
* Squashed commit of the following:
commit 3a16649023
Author: Michael Sproul <michael@sigmaprime.io>
Date: Thu Apr 18 14:26:09 2024 +1000
Fix on-disk consensus context format
* Keep indexed attestations, thanks Sean
* Merge branch 'on-disk-consensus-context' into tree-states-memory
* Merge branch 'unstable' into tree-states-memory
* Address half of Sean's review
* More simplifications from Sean's review
* Cache state after get_advanced_hot_state
80 lines
3.2 KiB
Rust
80 lines
3.2 KiB
Rust
use std::mem;
|
|
use types::{
|
|
BeaconState, BeaconStateDeneb, BeaconStateError as Error, ChainSpec, EpochCache, EthSpec, Fork,
|
|
};
|
|
|
|
/// Transform a `Capella` state into an `Deneb` state.
|
|
pub fn upgrade_to_deneb<E: EthSpec>(
|
|
pre_state: &mut BeaconState<E>,
|
|
spec: &ChainSpec,
|
|
) -> Result<(), Error> {
|
|
let epoch = pre_state.current_epoch();
|
|
let pre = pre_state.as_capella_mut()?;
|
|
|
|
let previous_fork_version = pre.fork.current_version;
|
|
|
|
// Where possible, use something like `mem::take` to move fields from behind the &mut
|
|
// reference. For other fields that don't have a good default value, use `clone`.
|
|
//
|
|
// Fixed size vectors get cloned because replacing them would require the same size
|
|
// allocation as cloning.
|
|
let post = BeaconState::Deneb(BeaconStateDeneb {
|
|
// Versioning
|
|
genesis_time: pre.genesis_time,
|
|
genesis_validators_root: pre.genesis_validators_root,
|
|
slot: pre.slot,
|
|
fork: Fork {
|
|
previous_version: previous_fork_version,
|
|
current_version: spec.deneb_fork_version,
|
|
epoch,
|
|
},
|
|
// History
|
|
latest_block_header: pre.latest_block_header.clone(),
|
|
block_roots: pre.block_roots.clone(),
|
|
state_roots: pre.state_roots.clone(),
|
|
historical_roots: mem::take(&mut pre.historical_roots),
|
|
// Eth1
|
|
eth1_data: pre.eth1_data.clone(),
|
|
eth1_data_votes: mem::take(&mut pre.eth1_data_votes),
|
|
eth1_deposit_index: pre.eth1_deposit_index,
|
|
// Registry
|
|
validators: mem::take(&mut pre.validators),
|
|
balances: mem::take(&mut pre.balances),
|
|
// Randomness
|
|
randao_mixes: pre.randao_mixes.clone(),
|
|
// Slashings
|
|
slashings: pre.slashings.clone(),
|
|
// `Participation
|
|
previous_epoch_participation: mem::take(&mut pre.previous_epoch_participation),
|
|
current_epoch_participation: mem::take(&mut pre.current_epoch_participation),
|
|
// Finality
|
|
justification_bits: pre.justification_bits.clone(),
|
|
previous_justified_checkpoint: pre.previous_justified_checkpoint,
|
|
current_justified_checkpoint: pre.current_justified_checkpoint,
|
|
finalized_checkpoint: pre.finalized_checkpoint,
|
|
// Inactivity
|
|
inactivity_scores: mem::take(&mut pre.inactivity_scores),
|
|
// Sync committees
|
|
current_sync_committee: pre.current_sync_committee.clone(),
|
|
next_sync_committee: pre.next_sync_committee.clone(),
|
|
// Execution
|
|
latest_execution_payload_header: pre.latest_execution_payload_header.upgrade_to_deneb(),
|
|
// Capella
|
|
next_withdrawal_index: pre.next_withdrawal_index,
|
|
next_withdrawal_validator_index: pre.next_withdrawal_validator_index,
|
|
historical_summaries: pre.historical_summaries.clone(),
|
|
// Caches
|
|
total_active_balance: pre.total_active_balance,
|
|
progressive_balances_cache: mem::take(&mut pre.progressive_balances_cache),
|
|
committee_caches: mem::take(&mut pre.committee_caches),
|
|
pubkey_cache: mem::take(&mut pre.pubkey_cache),
|
|
exit_cache: mem::take(&mut pre.exit_cache),
|
|
slashings_cache: mem::take(&mut pre.slashings_cache),
|
|
epoch_cache: EpochCache::default(),
|
|
});
|
|
|
|
*pre_state = post;
|
|
|
|
Ok(())
|
|
}
|