mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
Feature gate withdrawals (#3684)
* start feature gating * feature gate withdrawals
This commit is contained in:
@@ -4,6 +4,9 @@ version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
[features]
|
||||
withdrawals = ["state_processing/withdrawals", "types/withdrawals"]
|
||||
withdrawals-processing = ["state_processing/withdrawals-processing"]
|
||||
|
||||
[dependencies]
|
||||
types = { path = "../../consensus/types"}
|
||||
|
||||
@@ -155,6 +155,7 @@ pub struct ExecutionBlockWithTransactions<T: EthSpec> {
|
||||
#[serde(rename = "hash")]
|
||||
pub block_hash: ExecutionBlockHash,
|
||||
pub transactions: Vec<Transaction>,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
#[superstruct(only(Capella, Eip4844))]
|
||||
pub withdrawals: Vec<Withdrawal>,
|
||||
}
|
||||
@@ -204,6 +205,7 @@ impl<T: EthSpec> From<ExecutionPayload<T>> for ExecutionBlockWithTransactions<T>
|
||||
.map(|tx| Transaction::decode(&Rlp::new(tx)))
|
||||
.collect::<Result<Vec<_>, _>>()
|
||||
.unwrap_or_else(|_| Vec::new()),
|
||||
#[cfg(feature = "withdrawals")]
|
||||
withdrawals: block.withdrawals.into(),
|
||||
})
|
||||
}
|
||||
@@ -229,6 +231,7 @@ impl<T: EthSpec> From<ExecutionPayload<T>> for ExecutionBlockWithTransactions<T>
|
||||
.map(|tx| Transaction::decode(&Rlp::new(tx)))
|
||||
.collect::<Result<Vec<_>, _>>()
|
||||
.unwrap_or_else(|_| Vec::new()),
|
||||
#[cfg(feature = "withdrawals")]
|
||||
withdrawals: block.withdrawals.into(),
|
||||
})
|
||||
}
|
||||
@@ -236,17 +239,6 @@ impl<T: EthSpec> From<ExecutionPayload<T>> for ExecutionBlockWithTransactions<T>
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
impl<T: EthSpec> From<ExecutionBlockWithTransactions<T>> for ExecutionPayload<T> {
|
||||
fn from(block: ExecutionBlockWithTransactions<T>) -> Self {
|
||||
map_execution_block_with_transactions!(block, |inner, cons| {
|
||||
let block = inner.into();
|
||||
cons(block)
|
||||
})
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
#[superstruct(
|
||||
variants(V1, V2),
|
||||
variant_attributes(derive(Clone, Debug, PartialEq),),
|
||||
@@ -261,6 +253,7 @@ pub struct PayloadAttributes {
|
||||
pub prev_randao: Hash256,
|
||||
#[superstruct(getter(copy))]
|
||||
pub suggested_fee_recipient: Address,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
#[superstruct(only(V2))]
|
||||
pub withdrawals: Vec<Withdrawal>,
|
||||
}
|
||||
|
||||
@@ -99,6 +99,7 @@ pub struct JsonExecutionPayloadHeader<T: EthSpec> {
|
||||
pub excess_blobs: u64,
|
||||
pub block_hash: ExecutionBlockHash,
|
||||
pub transactions_root: Hash256,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
#[superstruct(only(V2, V3))]
|
||||
pub withdrawals_root: Hash256,
|
||||
}
|
||||
@@ -137,6 +138,7 @@ impl<T: EthSpec> From<JsonExecutionPayloadHeader<T>> for ExecutionPayloadHeader<
|
||||
base_fee_per_gas: v2.base_fee_per_gas,
|
||||
block_hash: v2.block_hash,
|
||||
transactions_root: v2.transactions_root,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
withdrawals_root: v2.withdrawals_root,
|
||||
}),
|
||||
JsonExecutionPayloadHeader::V3(v3) => Self::Eip4844(ExecutionPayloadHeaderEip4844 {
|
||||
@@ -155,6 +157,7 @@ impl<T: EthSpec> From<JsonExecutionPayloadHeader<T>> for ExecutionPayloadHeader<
|
||||
excess_blobs: v3.excess_blobs,
|
||||
block_hash: v3.block_hash,
|
||||
transactions_root: v3.transactions_root,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
withdrawals_root: v3.withdrawals_root,
|
||||
}),
|
||||
}
|
||||
@@ -195,6 +198,7 @@ impl<T: EthSpec> From<ExecutionPayloadHeader<T>> for JsonExecutionPayloadHeader<
|
||||
base_fee_per_gas: capella.base_fee_per_gas,
|
||||
block_hash: capella.block_hash,
|
||||
transactions_root: capella.transactions_root,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
withdrawals_root: capella.withdrawals_root,
|
||||
}),
|
||||
ExecutionPayloadHeader::Eip4844(eip4844) => Self::V3(JsonExecutionPayloadHeaderV3 {
|
||||
@@ -213,6 +217,7 @@ impl<T: EthSpec> From<ExecutionPayloadHeader<T>> for JsonExecutionPayloadHeader<
|
||||
excess_blobs: eip4844.excess_blobs,
|
||||
block_hash: eip4844.block_hash,
|
||||
transactions_root: eip4844.transactions_root,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
withdrawals_root: eip4844.withdrawals_root,
|
||||
}),
|
||||
}
|
||||
@@ -258,6 +263,7 @@ pub struct JsonExecutionPayload<T: EthSpec> {
|
||||
#[serde(with = "ssz_types::serde_utils::list_of_hex_var_list")]
|
||||
pub transactions:
|
||||
VariableList<Transaction<T::MaxBytesPerTransaction>, T::MaxTransactionsPerPayload>,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
#[superstruct(only(V2, V3))]
|
||||
pub withdrawals: VariableList<Withdrawal, T::MaxWithdrawalsPerPayload>,
|
||||
}
|
||||
@@ -296,6 +302,7 @@ impl<T: EthSpec> From<JsonExecutionPayload<T>> for ExecutionPayload<T> {
|
||||
base_fee_per_gas: v2.base_fee_per_gas,
|
||||
block_hash: v2.block_hash,
|
||||
transactions: v2.transactions,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
withdrawals: v2.withdrawals,
|
||||
}),
|
||||
JsonExecutionPayload::V3(v3) => Self::Eip4844(ExecutionPayloadEip4844 {
|
||||
@@ -314,6 +321,7 @@ impl<T: EthSpec> From<JsonExecutionPayload<T>> for ExecutionPayload<T> {
|
||||
excess_blobs: v3.excess_blobs,
|
||||
block_hash: v3.block_hash,
|
||||
transactions: v3.transactions,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
withdrawals: v3.withdrawals,
|
||||
}),
|
||||
}
|
||||
@@ -354,6 +362,7 @@ impl<T: EthSpec> From<ExecutionPayload<T>> for JsonExecutionPayload<T> {
|
||||
base_fee_per_gas: capella.base_fee_per_gas,
|
||||
block_hash: capella.block_hash,
|
||||
transactions: capella.transactions,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
withdrawals: capella.withdrawals,
|
||||
}),
|
||||
ExecutionPayload::Eip4844(eip4844) => Self::V3(JsonExecutionPayloadV3 {
|
||||
@@ -372,6 +381,7 @@ impl<T: EthSpec> From<ExecutionPayload<T>> for JsonExecutionPayload<T> {
|
||||
excess_blobs: eip4844.excess_blobs,
|
||||
block_hash: eip4844.block_hash,
|
||||
transactions: eip4844.transactions,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
withdrawals: eip4844.withdrawals,
|
||||
}),
|
||||
}
|
||||
@@ -425,6 +435,7 @@ pub struct JsonPayloadAttributes {
|
||||
pub timestamp: u64,
|
||||
pub prev_randao: Hash256,
|
||||
pub suggested_fee_recipient: Address,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
#[superstruct(only(V2))]
|
||||
pub withdrawals: Vec<JsonWithdrawal>,
|
||||
}
|
||||
@@ -441,6 +452,7 @@ impl From<PayloadAttributes> for JsonPayloadAttributes {
|
||||
timestamp: pa.timestamp,
|
||||
prev_randao: pa.prev_randao,
|
||||
suggested_fee_recipient: pa.suggested_fee_recipient,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
withdrawals: pa.withdrawals.into_iter().map(Into::into).collect(),
|
||||
}),
|
||||
}
|
||||
@@ -459,6 +471,7 @@ impl From<JsonPayloadAttributes> for PayloadAttributes {
|
||||
timestamp: jpa.timestamp,
|
||||
prev_randao: jpa.prev_randao,
|
||||
suggested_fee_recipient: jpa.suggested_fee_recipient,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
withdrawals: jpa.withdrawals.into_iter().map(Into::into).collect(),
|
||||
}),
|
||||
}
|
||||
|
||||
@@ -1499,6 +1499,7 @@ impl<T: EthSpec> ExecutionLayer<T> {
|
||||
})
|
||||
}
|
||||
ExecutionBlockWithTransactions::Capella(capella_block) => {
|
||||
#[cfg(feature = "withdrawals")]
|
||||
let withdrawals = VariableList::new(capella_block.withdrawals.clone())
|
||||
.map_err(ApiError::DeserializeWithdrawals)?;
|
||||
|
||||
@@ -1517,10 +1518,12 @@ impl<T: EthSpec> ExecutionLayer<T> {
|
||||
base_fee_per_gas: capella_block.base_fee_per_gas,
|
||||
block_hash: capella_block.block_hash,
|
||||
transactions,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
withdrawals,
|
||||
})
|
||||
}
|
||||
ExecutionBlockWithTransactions::Eip4844(eip4844_block) => {
|
||||
#[cfg(feature = "withdrawals")]
|
||||
let withdrawals = VariableList::new(eip4844_block.withdrawals.clone())
|
||||
.map_err(ApiError::DeserializeWithdrawals)?;
|
||||
|
||||
@@ -1540,6 +1543,7 @@ impl<T: EthSpec> ExecutionLayer<T> {
|
||||
excess_blobs: eip4844_block.excess_blobs,
|
||||
block_hash: eip4844_block.block_hash,
|
||||
transactions,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
withdrawals,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -403,6 +403,7 @@ impl<T: EthSpec> ExecutionBlockGenerator<T> {
|
||||
base_fee_per_gas: Uint256::one(),
|
||||
block_hash: ExecutionBlockHash::zero(),
|
||||
transactions: vec![].into(),
|
||||
#[cfg(feature = "withdrawals")]
|
||||
withdrawals: pa
|
||||
.withdrawals
|
||||
.iter()
|
||||
|
||||
@@ -113,6 +113,7 @@ impl<T: EthSpec> MockExecutionLayer<T> {
|
||||
prev_randao,
|
||||
suggested_fee_recipient: Address::repeat_byte(42),
|
||||
// FIXME: think about adding withdrawals here..
|
||||
#[cfg(feature = "withdrawals")]
|
||||
withdrawals: vec![],
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user