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

@@ -295,10 +295,13 @@ where
pub latest_execution_payload_header: ExecutionPayloadHeaderEip4844<T>,
// Withdrawals
#[cfg(feature = "withdrawals")]
#[superstruct(only(Capella, Eip4844))]
pub withdrawal_queue: VariableList<Withdrawal, T::WithdrawalQueueLimit>,
#[cfg(feature = "withdrawals")]
#[superstruct(only(Capella, Eip4844))]
pub next_withdrawal_index: u64,
#[cfg(feature = "withdrawals")]
#[superstruct(only(Capella, Eip4844))]
pub next_partial_withdrawal_validator_index: u64,

View File

@@ -80,6 +80,7 @@ pub struct ExecutionPayload<T: EthSpec> {
pub block_hash: ExecutionBlockHash,
#[serde(with = "ssz_types::serde_utils::list_of_hex_var_list")]
pub transactions: Transactions<T>,
#[cfg(feature = "withdrawals")]
#[superstruct(only(Capella, Eip4844))]
pub withdrawals: VariableList<Withdrawal, T::MaxWithdrawalsPerPayload>,
}

View File

@@ -74,6 +74,7 @@ pub struct ExecutionPayloadHeader<T: EthSpec> {
pub block_hash: ExecutionBlockHash,
#[superstruct(getter(copy))]
pub transactions_root: Hash256,
#[cfg(feature = "withdrawals")]
#[superstruct(only(Capella, Eip4844))]
#[superstruct(getter(copy))]
pub withdrawals_root: Hash256,
@@ -104,6 +105,7 @@ impl<'a, T: EthSpec> ExecutionPayloadHeaderRef<'a, T> {
impl<T: EthSpec> ExecutionPayloadHeaderMerge<T> {
pub fn upgrade_to_capella(&self) -> ExecutionPayloadHeaderCapella<T> {
#[cfg(feature = "withdrawals")]
// TODO: if this is correct we should calculate and hardcode this..
let empty_withdrawals_root =
VariableList::<Withdrawal, T::MaxWithdrawalsPerPayload>::empty().tree_hash_root();
@@ -122,6 +124,7 @@ impl<T: EthSpec> ExecutionPayloadHeaderMerge<T> {
base_fee_per_gas: self.base_fee_per_gas,
block_hash: self.block_hash,
transactions_root: self.transactions_root,
#[cfg(feature = "withdrawals")]
// FIXME: the spec doesn't seem to define what to do here..
withdrawals_root: empty_withdrawals_root,
}
@@ -147,6 +150,7 @@ impl<T: EthSpec> ExecutionPayloadHeaderCapella<T> {
excess_blobs: 0,
block_hash: self.block_hash,
transactions_root: self.transactions_root,
#[cfg(feature = "withdrawals")]
withdrawals_root: self.withdrawals_root,
}
}
@@ -189,6 +193,7 @@ impl<T: EthSpec> From<ExecutionPayloadCapella<T>> for ExecutionPayloadHeaderCape
base_fee_per_gas: payload.base_fee_per_gas,
block_hash: payload.block_hash,
transactions_root: payload.transactions.tree_hash_root(),
#[cfg(feature = "withdrawals")]
withdrawals_root: payload.withdrawals.tree_hash_root(),
}
}
@@ -211,6 +216,7 @@ impl<T: EthSpec> From<ExecutionPayloadEip4844<T>> for ExecutionPayloadHeaderEip4
excess_blobs: payload.excess_blobs,
block_hash: payload.block_hash,
transactions_root: payload.transactions.tree_hash_root(),
#[cfg(feature = "withdrawals")]
withdrawals_root: payload.withdrawals.tree_hash_root(),
}
}