Feature gate withdrawals (#3684)

* start feature gating

* feature gate withdrawals
This commit is contained in:
realbigsean
2022-11-04 16:50:26 -04:00
committed by GitHub
parent 1aec17b09c
commit fc0b06a039
24 changed files with 144 additions and 12 deletions

View File

@@ -57,8 +57,11 @@ pub fn upgrade_to_capella<E: EthSpec>(
// Execution
latest_execution_payload_header: pre.latest_execution_payload_header.upgrade_to_capella(),
// Withdrawals
#[cfg(feature = "withdrawals")]
withdrawal_queue: VariableList::empty(),
#[cfg(feature = "withdrawals")]
next_withdrawal_index: 0,
#[cfg(feature = "withdrawals")]
next_partial_withdrawal_validator_index: 0,
// Caches
total_active_balance: pre.total_active_balance,

View File

@@ -9,6 +9,14 @@ pub fn upgrade_to_eip4844<E: EthSpec>(
let epoch = pre_state.current_epoch();
let pre = pre_state.as_capella_mut()?;
// FIXME(sean) This is a hack to let us participate in testnets where capella doesn't exist.
// if we are disabling withdrawals, assume we should fork off of bellatrix.
let previous_fork_version = if cfg!(feature ="withdrawals") {
pre.fork.current_version
} else {
spec.bellatrix_fork_epoch
};
// 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`.
//
@@ -20,7 +28,7 @@ pub fn upgrade_to_eip4844<E: EthSpec>(
genesis_validators_root: pre.genesis_validators_root,
slot: pre.slot,
fork: Fork {
previous_version: pre.fork.current_version,
previous_version: previous_fork_version,
current_version: spec.eip4844_fork_version,
epoch,
},
@@ -56,8 +64,11 @@ pub fn upgrade_to_eip4844<E: EthSpec>(
// Execution
latest_execution_payload_header: pre.latest_execution_payload_header.upgrade_to_eip4844(),
// Withdrawals
#[cfg(feature = "withdrawals")]
withdrawal_queue: mem::take(&mut pre.withdrawal_queue),
#[cfg(feature = "withdrawals")]
next_withdrawal_index: pre.next_withdrawal_index,
#[cfg(feature = "withdrawals")]
next_partial_withdrawal_validator_index: pre.next_partial_withdrawal_validator_index,
// Caches
total_active_balance: pre.total_active_balance,