Skip to content

Commit fc0b06a

Browse files
authored
Feature gate withdrawals (#3684)
* start feature gating * feature gate withdrawals
1 parent 1aec17b commit fc0b06a

File tree

24 files changed

+144
-12
lines changed

24 files changed

+144
-12
lines changed

beacon_node/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ node_test_rig = { path = "../testing/node_test_rig" }
1313

1414
[features]
1515
write_ssz_files = ["beacon_chain/write_ssz_files"] # Writes debugging .ssz files to /tmp during block processing.
16+
withdrawals = ["beacon_chain/withdrawals", "types/withdrawals", "store/withdrawals", "execution_layer/withdrawals"]
17+
withdrawals-processing = ["beacon_chain/withdrawals-processing", "store/withdrawals-processing", "execution_layer/withdrawals-processing"]
1618

1719
[dependencies]
1820
eth2_config = { path = "../common/eth2_config" }

beacon_node/beacon_chain/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ default = ["participation_metrics"]
1010
write_ssz_files = [] # Writes debugging .ssz files to /tmp during block processing.
1111
participation_metrics = [] # Exposes validator participation metrics to Prometheus.
1212
fork_from_env = [] # Initialise the harness chain spec from the FORK_NAME env variable
13+
withdrawals = ["state_processing/withdrawals", "types/withdrawals", "store/withdrawals", "execution_layer/withdrawals"]
14+
withdrawals-processing = ["state_processing/withdrawals-processing", "store/withdrawals-processing", "execution_layer/withdrawals-processing"]
1315

1416
[dev-dependencies]
1517
maplit = "1.0.2"

beacon_node/beacon_chain/src/beacon_chain.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4117,6 +4117,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
41174117
.get_suggested_fee_recipient(proposer as u64)
41184118
.await,
41194119
//FIXME(sean)
4120+
#[cfg(feature = "withdrawals")]
41204121
withdrawals: vec![],
41214122
}),
41224123
};

beacon_node/execution_layer/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ version = "0.1.0"
44
edition = "2021"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
[features]
8+
withdrawals = ["state_processing/withdrawals", "types/withdrawals"]
9+
withdrawals-processing = ["state_processing/withdrawals-processing"]
710

811
[dependencies]
912
types = { path = "../../consensus/types"}

beacon_node/execution_layer/src/engine_api.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ pub struct ExecutionBlockWithTransactions<T: EthSpec> {
155155
#[serde(rename = "hash")]
156156
pub block_hash: ExecutionBlockHash,
157157
pub transactions: Vec<Transaction>,
158+
#[cfg(feature = "withdrawals")]
158159
#[superstruct(only(Capella, Eip4844))]
159160
pub withdrawals: Vec<Withdrawal>,
160161
}
@@ -204,6 +205,7 @@ impl<T: EthSpec> From<ExecutionPayload<T>> for ExecutionBlockWithTransactions<T>
204205
.map(|tx| Transaction::decode(&Rlp::new(tx)))
205206
.collect::<Result<Vec<_>, _>>()
206207
.unwrap_or_else(|_| Vec::new()),
208+
#[cfg(feature = "withdrawals")]
207209
withdrawals: block.withdrawals.into(),
208210
})
209211
}
@@ -229,24 +231,14 @@ impl<T: EthSpec> From<ExecutionPayload<T>> for ExecutionBlockWithTransactions<T>
229231
.map(|tx| Transaction::decode(&Rlp::new(tx)))
230232
.collect::<Result<Vec<_>, _>>()
231233
.unwrap_or_else(|_| Vec::new()),
234+
#[cfg(feature = "withdrawals")]
232235
withdrawals: block.withdrawals.into(),
233236
})
234237
}
235238
}
236239
}
237240
}
238241

239-
/*
240-
impl<T: EthSpec> From<ExecutionBlockWithTransactions<T>> for ExecutionPayload<T> {
241-
fn from(block: ExecutionBlockWithTransactions<T>) -> Self {
242-
map_execution_block_with_transactions!(block, |inner, cons| {
243-
let block = inner.into();
244-
cons(block)
245-
})
246-
}
247-
}
248-
*/
249-
250242
#[superstruct(
251243
variants(V1, V2),
252244
variant_attributes(derive(Clone, Debug, PartialEq),),
@@ -261,6 +253,7 @@ pub struct PayloadAttributes {
261253
pub prev_randao: Hash256,
262254
#[superstruct(getter(copy))]
263255
pub suggested_fee_recipient: Address,
256+
#[cfg(feature = "withdrawals")]
264257
#[superstruct(only(V2))]
265258
pub withdrawals: Vec<Withdrawal>,
266259
}

beacon_node/execution_layer/src/engine_api/json_structures.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ pub struct JsonExecutionPayloadHeader<T: EthSpec> {
9999
pub excess_blobs: u64,
100100
pub block_hash: ExecutionBlockHash,
101101
pub transactions_root: Hash256,
102+
#[cfg(feature = "withdrawals")]
102103
#[superstruct(only(V2, V3))]
103104
pub withdrawals_root: Hash256,
104105
}
@@ -137,6 +138,7 @@ impl<T: EthSpec> From<JsonExecutionPayloadHeader<T>> for ExecutionPayloadHeader<
137138
base_fee_per_gas: v2.base_fee_per_gas,
138139
block_hash: v2.block_hash,
139140
transactions_root: v2.transactions_root,
141+
#[cfg(feature = "withdrawals")]
140142
withdrawals_root: v2.withdrawals_root,
141143
}),
142144
JsonExecutionPayloadHeader::V3(v3) => Self::Eip4844(ExecutionPayloadHeaderEip4844 {
@@ -155,6 +157,7 @@ impl<T: EthSpec> From<JsonExecutionPayloadHeader<T>> for ExecutionPayloadHeader<
155157
excess_blobs: v3.excess_blobs,
156158
block_hash: v3.block_hash,
157159
transactions_root: v3.transactions_root,
160+
#[cfg(feature = "withdrawals")]
158161
withdrawals_root: v3.withdrawals_root,
159162
}),
160163
}
@@ -195,6 +198,7 @@ impl<T: EthSpec> From<ExecutionPayloadHeader<T>> for JsonExecutionPayloadHeader<
195198
base_fee_per_gas: capella.base_fee_per_gas,
196199
block_hash: capella.block_hash,
197200
transactions_root: capella.transactions_root,
201+
#[cfg(feature = "withdrawals")]
198202
withdrawals_root: capella.withdrawals_root,
199203
}),
200204
ExecutionPayloadHeader::Eip4844(eip4844) => Self::V3(JsonExecutionPayloadHeaderV3 {
@@ -213,6 +217,7 @@ impl<T: EthSpec> From<ExecutionPayloadHeader<T>> for JsonExecutionPayloadHeader<
213217
excess_blobs: eip4844.excess_blobs,
214218
block_hash: eip4844.block_hash,
215219
transactions_root: eip4844.transactions_root,
220+
#[cfg(feature = "withdrawals")]
216221
withdrawals_root: eip4844.withdrawals_root,
217222
}),
218223
}
@@ -258,6 +263,7 @@ pub struct JsonExecutionPayload<T: EthSpec> {
258263
#[serde(with = "ssz_types::serde_utils::list_of_hex_var_list")]
259264
pub transactions:
260265
VariableList<Transaction<T::MaxBytesPerTransaction>, T::MaxTransactionsPerPayload>,
266+
#[cfg(feature = "withdrawals")]
261267
#[superstruct(only(V2, V3))]
262268
pub withdrawals: VariableList<Withdrawal, T::MaxWithdrawalsPerPayload>,
263269
}
@@ -296,6 +302,7 @@ impl<T: EthSpec> From<JsonExecutionPayload<T>> for ExecutionPayload<T> {
296302
base_fee_per_gas: v2.base_fee_per_gas,
297303
block_hash: v2.block_hash,
298304
transactions: v2.transactions,
305+
#[cfg(feature = "withdrawals")]
299306
withdrawals: v2.withdrawals,
300307
}),
301308
JsonExecutionPayload::V3(v3) => Self::Eip4844(ExecutionPayloadEip4844 {
@@ -314,6 +321,7 @@ impl<T: EthSpec> From<JsonExecutionPayload<T>> for ExecutionPayload<T> {
314321
excess_blobs: v3.excess_blobs,
315322
block_hash: v3.block_hash,
316323
transactions: v3.transactions,
324+
#[cfg(feature = "withdrawals")]
317325
withdrawals: v3.withdrawals,
318326
}),
319327
}
@@ -354,6 +362,7 @@ impl<T: EthSpec> From<ExecutionPayload<T>> for JsonExecutionPayload<T> {
354362
base_fee_per_gas: capella.base_fee_per_gas,
355363
block_hash: capella.block_hash,
356364
transactions: capella.transactions,
365+
#[cfg(feature = "withdrawals")]
357366
withdrawals: capella.withdrawals,
358367
}),
359368
ExecutionPayload::Eip4844(eip4844) => Self::V3(JsonExecutionPayloadV3 {
@@ -372,6 +381,7 @@ impl<T: EthSpec> From<ExecutionPayload<T>> for JsonExecutionPayload<T> {
372381
excess_blobs: eip4844.excess_blobs,
373382
block_hash: eip4844.block_hash,
374383
transactions: eip4844.transactions,
384+
#[cfg(feature = "withdrawals")]
375385
withdrawals: eip4844.withdrawals,
376386
}),
377387
}
@@ -425,6 +435,7 @@ pub struct JsonPayloadAttributes {
425435
pub timestamp: u64,
426436
pub prev_randao: Hash256,
427437
pub suggested_fee_recipient: Address,
438+
#[cfg(feature = "withdrawals")]
428439
#[superstruct(only(V2))]
429440
pub withdrawals: Vec<JsonWithdrawal>,
430441
}
@@ -441,6 +452,7 @@ impl From<PayloadAttributes> for JsonPayloadAttributes {
441452
timestamp: pa.timestamp,
442453
prev_randao: pa.prev_randao,
443454
suggested_fee_recipient: pa.suggested_fee_recipient,
455+
#[cfg(feature = "withdrawals")]
444456
withdrawals: pa.withdrawals.into_iter().map(Into::into).collect(),
445457
}),
446458
}
@@ -459,6 +471,7 @@ impl From<JsonPayloadAttributes> for PayloadAttributes {
459471
timestamp: jpa.timestamp,
460472
prev_randao: jpa.prev_randao,
461473
suggested_fee_recipient: jpa.suggested_fee_recipient,
474+
#[cfg(feature = "withdrawals")]
462475
withdrawals: jpa.withdrawals.into_iter().map(Into::into).collect(),
463476
}),
464477
}

beacon_node/execution_layer/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,6 +1499,7 @@ impl<T: EthSpec> ExecutionLayer<T> {
14991499
})
15001500
}
15011501
ExecutionBlockWithTransactions::Capella(capella_block) => {
1502+
#[cfg(feature = "withdrawals")]
15021503
let withdrawals = VariableList::new(capella_block.withdrawals.clone())
15031504
.map_err(ApiError::DeserializeWithdrawals)?;
15041505

@@ -1517,10 +1518,12 @@ impl<T: EthSpec> ExecutionLayer<T> {
15171518
base_fee_per_gas: capella_block.base_fee_per_gas,
15181519
block_hash: capella_block.block_hash,
15191520
transactions,
1521+
#[cfg(feature = "withdrawals")]
15201522
withdrawals,
15211523
})
15221524
}
15231525
ExecutionBlockWithTransactions::Eip4844(eip4844_block) => {
1526+
#[cfg(feature = "withdrawals")]
15241527
let withdrawals = VariableList::new(eip4844_block.withdrawals.clone())
15251528
.map_err(ApiError::DeserializeWithdrawals)?;
15261529

@@ -1540,6 +1543,7 @@ impl<T: EthSpec> ExecutionLayer<T> {
15401543
excess_blobs: eip4844_block.excess_blobs,
15411544
block_hash: eip4844_block.block_hash,
15421545
transactions,
1546+
#[cfg(feature = "withdrawals")]
15431547
withdrawals,
15441548
})
15451549
}

beacon_node/execution_layer/src/test_utils/execution_block_generator.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ impl<T: EthSpec> ExecutionBlockGenerator<T> {
403403
base_fee_per_gas: Uint256::one(),
404404
block_hash: ExecutionBlockHash::zero(),
405405
transactions: vec![].into(),
406+
#[cfg(feature = "withdrawals")]
406407
withdrawals: pa
407408
.withdrawals
408409
.iter()

beacon_node/execution_layer/src/test_utils/mock_execution_layer.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ impl<T: EthSpec> MockExecutionLayer<T> {
113113
prev_randao,
114114
suggested_fee_recipient: Address::repeat_byte(42),
115115
// FIXME: think about adding withdrawals here..
116+
#[cfg(feature = "withdrawals")]
116117
withdrawals: vec![],
117118
})
118119
}

beacon_node/store/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,7 @@ lru = "0.7.1"
2626
sloggers = { version = "2.1.1", features = ["json"] }
2727
directory = { path = "../../common/directory" }
2828
strum = { version = "0.24.0", features = ["derive"] }
29+
30+
[features]
31+
withdrawals = ["state_processing/withdrawals", "types/withdrawals"]
32+
withdrawals-processing = ["state_processing/withdrawals-processing"]

0 commit comments

Comments
 (0)