Feature gate withdrawals (#3684)
* start feature gating * feature gate withdrawals
This commit is contained in:
parent
1aec17b09c
commit
fc0b06a039
@ -13,6 +13,8 @@ node_test_rig = { path = "../testing/node_test_rig" }
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
write_ssz_files = ["beacon_chain/write_ssz_files"] # Writes debugging .ssz files to /tmp during block processing.
|
write_ssz_files = ["beacon_chain/write_ssz_files"] # Writes debugging .ssz files to /tmp during block processing.
|
||||||
|
withdrawals = ["beacon_chain/withdrawals", "types/withdrawals", "store/withdrawals", "execution_layer/withdrawals"]
|
||||||
|
withdrawals-processing = ["beacon_chain/withdrawals-processing", "store/withdrawals-processing", "execution_layer/withdrawals-processing"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
eth2_config = { path = "../common/eth2_config" }
|
eth2_config = { path = "../common/eth2_config" }
|
||||||
|
@ -10,6 +10,8 @@ default = ["participation_metrics"]
|
|||||||
write_ssz_files = [] # Writes debugging .ssz files to /tmp during block processing.
|
write_ssz_files = [] # Writes debugging .ssz files to /tmp during block processing.
|
||||||
participation_metrics = [] # Exposes validator participation metrics to Prometheus.
|
participation_metrics = [] # Exposes validator participation metrics to Prometheus.
|
||||||
fork_from_env = [] # Initialise the harness chain spec from the FORK_NAME env variable
|
fork_from_env = [] # Initialise the harness chain spec from the FORK_NAME env variable
|
||||||
|
withdrawals = ["state_processing/withdrawals", "types/withdrawals", "store/withdrawals", "execution_layer/withdrawals"]
|
||||||
|
withdrawals-processing = ["state_processing/withdrawals-processing", "store/withdrawals-processing", "execution_layer/withdrawals-processing"]
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
maplit = "1.0.2"
|
maplit = "1.0.2"
|
||||||
|
@ -4117,6 +4117,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
.get_suggested_fee_recipient(proposer as u64)
|
.get_suggested_fee_recipient(proposer as u64)
|
||||||
.await,
|
.await,
|
||||||
//FIXME(sean)
|
//FIXME(sean)
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
withdrawals: vec![],
|
withdrawals: vec![],
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
@ -4,6 +4,9 @@ version = "0.1.0"
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# 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]
|
[dependencies]
|
||||||
types = { path = "../../consensus/types"}
|
types = { path = "../../consensus/types"}
|
||||||
|
@ -155,6 +155,7 @@ pub struct ExecutionBlockWithTransactions<T: EthSpec> {
|
|||||||
#[serde(rename = "hash")]
|
#[serde(rename = "hash")]
|
||||||
pub block_hash: ExecutionBlockHash,
|
pub block_hash: ExecutionBlockHash,
|
||||||
pub transactions: Vec<Transaction>,
|
pub transactions: Vec<Transaction>,
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
#[superstruct(only(Capella, Eip4844))]
|
#[superstruct(only(Capella, Eip4844))]
|
||||||
pub withdrawals: Vec<Withdrawal>,
|
pub withdrawals: Vec<Withdrawal>,
|
||||||
}
|
}
|
||||||
@ -204,6 +205,7 @@ impl<T: EthSpec> From<ExecutionPayload<T>> for ExecutionBlockWithTransactions<T>
|
|||||||
.map(|tx| Transaction::decode(&Rlp::new(tx)))
|
.map(|tx| Transaction::decode(&Rlp::new(tx)))
|
||||||
.collect::<Result<Vec<_>, _>>()
|
.collect::<Result<Vec<_>, _>>()
|
||||||
.unwrap_or_else(|_| Vec::new()),
|
.unwrap_or_else(|_| Vec::new()),
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
withdrawals: block.withdrawals.into(),
|
withdrawals: block.withdrawals.into(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -229,6 +231,7 @@ impl<T: EthSpec> From<ExecutionPayload<T>> for ExecutionBlockWithTransactions<T>
|
|||||||
.map(|tx| Transaction::decode(&Rlp::new(tx)))
|
.map(|tx| Transaction::decode(&Rlp::new(tx)))
|
||||||
.collect::<Result<Vec<_>, _>>()
|
.collect::<Result<Vec<_>, _>>()
|
||||||
.unwrap_or_else(|_| Vec::new()),
|
.unwrap_or_else(|_| Vec::new()),
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
withdrawals: block.withdrawals.into(),
|
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(
|
#[superstruct(
|
||||||
variants(V1, V2),
|
variants(V1, V2),
|
||||||
variant_attributes(derive(Clone, Debug, PartialEq),),
|
variant_attributes(derive(Clone, Debug, PartialEq),),
|
||||||
@ -261,6 +253,7 @@ pub struct PayloadAttributes {
|
|||||||
pub prev_randao: Hash256,
|
pub prev_randao: Hash256,
|
||||||
#[superstruct(getter(copy))]
|
#[superstruct(getter(copy))]
|
||||||
pub suggested_fee_recipient: Address,
|
pub suggested_fee_recipient: Address,
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
#[superstruct(only(V2))]
|
#[superstruct(only(V2))]
|
||||||
pub withdrawals: Vec<Withdrawal>,
|
pub withdrawals: Vec<Withdrawal>,
|
||||||
}
|
}
|
||||||
|
@ -99,6 +99,7 @@ pub struct JsonExecutionPayloadHeader<T: EthSpec> {
|
|||||||
pub excess_blobs: u64,
|
pub excess_blobs: u64,
|
||||||
pub block_hash: ExecutionBlockHash,
|
pub block_hash: ExecutionBlockHash,
|
||||||
pub transactions_root: Hash256,
|
pub transactions_root: Hash256,
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
#[superstruct(only(V2, V3))]
|
#[superstruct(only(V2, V3))]
|
||||||
pub withdrawals_root: Hash256,
|
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,
|
base_fee_per_gas: v2.base_fee_per_gas,
|
||||||
block_hash: v2.block_hash,
|
block_hash: v2.block_hash,
|
||||||
transactions_root: v2.transactions_root,
|
transactions_root: v2.transactions_root,
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
withdrawals_root: v2.withdrawals_root,
|
withdrawals_root: v2.withdrawals_root,
|
||||||
}),
|
}),
|
||||||
JsonExecutionPayloadHeader::V3(v3) => Self::Eip4844(ExecutionPayloadHeaderEip4844 {
|
JsonExecutionPayloadHeader::V3(v3) => Self::Eip4844(ExecutionPayloadHeaderEip4844 {
|
||||||
@ -155,6 +157,7 @@ impl<T: EthSpec> From<JsonExecutionPayloadHeader<T>> for ExecutionPayloadHeader<
|
|||||||
excess_blobs: v3.excess_blobs,
|
excess_blobs: v3.excess_blobs,
|
||||||
block_hash: v3.block_hash,
|
block_hash: v3.block_hash,
|
||||||
transactions_root: v3.transactions_root,
|
transactions_root: v3.transactions_root,
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
withdrawals_root: v3.withdrawals_root,
|
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,
|
base_fee_per_gas: capella.base_fee_per_gas,
|
||||||
block_hash: capella.block_hash,
|
block_hash: capella.block_hash,
|
||||||
transactions_root: capella.transactions_root,
|
transactions_root: capella.transactions_root,
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
withdrawals_root: capella.withdrawals_root,
|
withdrawals_root: capella.withdrawals_root,
|
||||||
}),
|
}),
|
||||||
ExecutionPayloadHeader::Eip4844(eip4844) => Self::V3(JsonExecutionPayloadHeaderV3 {
|
ExecutionPayloadHeader::Eip4844(eip4844) => Self::V3(JsonExecutionPayloadHeaderV3 {
|
||||||
@ -213,6 +217,7 @@ impl<T: EthSpec> From<ExecutionPayloadHeader<T>> for JsonExecutionPayloadHeader<
|
|||||||
excess_blobs: eip4844.excess_blobs,
|
excess_blobs: eip4844.excess_blobs,
|
||||||
block_hash: eip4844.block_hash,
|
block_hash: eip4844.block_hash,
|
||||||
transactions_root: eip4844.transactions_root,
|
transactions_root: eip4844.transactions_root,
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
withdrawals_root: eip4844.withdrawals_root,
|
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")]
|
#[serde(with = "ssz_types::serde_utils::list_of_hex_var_list")]
|
||||||
pub transactions:
|
pub transactions:
|
||||||
VariableList<Transaction<T::MaxBytesPerTransaction>, T::MaxTransactionsPerPayload>,
|
VariableList<Transaction<T::MaxBytesPerTransaction>, T::MaxTransactionsPerPayload>,
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
#[superstruct(only(V2, V3))]
|
#[superstruct(only(V2, V3))]
|
||||||
pub withdrawals: VariableList<Withdrawal, T::MaxWithdrawalsPerPayload>,
|
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,
|
base_fee_per_gas: v2.base_fee_per_gas,
|
||||||
block_hash: v2.block_hash,
|
block_hash: v2.block_hash,
|
||||||
transactions: v2.transactions,
|
transactions: v2.transactions,
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
withdrawals: v2.withdrawals,
|
withdrawals: v2.withdrawals,
|
||||||
}),
|
}),
|
||||||
JsonExecutionPayload::V3(v3) => Self::Eip4844(ExecutionPayloadEip4844 {
|
JsonExecutionPayload::V3(v3) => Self::Eip4844(ExecutionPayloadEip4844 {
|
||||||
@ -314,6 +321,7 @@ impl<T: EthSpec> From<JsonExecutionPayload<T>> for ExecutionPayload<T> {
|
|||||||
excess_blobs: v3.excess_blobs,
|
excess_blobs: v3.excess_blobs,
|
||||||
block_hash: v3.block_hash,
|
block_hash: v3.block_hash,
|
||||||
transactions: v3.transactions,
|
transactions: v3.transactions,
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
withdrawals: v3.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,
|
base_fee_per_gas: capella.base_fee_per_gas,
|
||||||
block_hash: capella.block_hash,
|
block_hash: capella.block_hash,
|
||||||
transactions: capella.transactions,
|
transactions: capella.transactions,
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
withdrawals: capella.withdrawals,
|
withdrawals: capella.withdrawals,
|
||||||
}),
|
}),
|
||||||
ExecutionPayload::Eip4844(eip4844) => Self::V3(JsonExecutionPayloadV3 {
|
ExecutionPayload::Eip4844(eip4844) => Self::V3(JsonExecutionPayloadV3 {
|
||||||
@ -372,6 +381,7 @@ impl<T: EthSpec> From<ExecutionPayload<T>> for JsonExecutionPayload<T> {
|
|||||||
excess_blobs: eip4844.excess_blobs,
|
excess_blobs: eip4844.excess_blobs,
|
||||||
block_hash: eip4844.block_hash,
|
block_hash: eip4844.block_hash,
|
||||||
transactions: eip4844.transactions,
|
transactions: eip4844.transactions,
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
withdrawals: eip4844.withdrawals,
|
withdrawals: eip4844.withdrawals,
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
@ -425,6 +435,7 @@ pub struct JsonPayloadAttributes {
|
|||||||
pub timestamp: u64,
|
pub timestamp: u64,
|
||||||
pub prev_randao: Hash256,
|
pub prev_randao: Hash256,
|
||||||
pub suggested_fee_recipient: Address,
|
pub suggested_fee_recipient: Address,
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
#[superstruct(only(V2))]
|
#[superstruct(only(V2))]
|
||||||
pub withdrawals: Vec<JsonWithdrawal>,
|
pub withdrawals: Vec<JsonWithdrawal>,
|
||||||
}
|
}
|
||||||
@ -441,6 +452,7 @@ impl From<PayloadAttributes> for JsonPayloadAttributes {
|
|||||||
timestamp: pa.timestamp,
|
timestamp: pa.timestamp,
|
||||||
prev_randao: pa.prev_randao,
|
prev_randao: pa.prev_randao,
|
||||||
suggested_fee_recipient: pa.suggested_fee_recipient,
|
suggested_fee_recipient: pa.suggested_fee_recipient,
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
withdrawals: pa.withdrawals.into_iter().map(Into::into).collect(),
|
withdrawals: pa.withdrawals.into_iter().map(Into::into).collect(),
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
@ -459,6 +471,7 @@ impl From<JsonPayloadAttributes> for PayloadAttributes {
|
|||||||
timestamp: jpa.timestamp,
|
timestamp: jpa.timestamp,
|
||||||
prev_randao: jpa.prev_randao,
|
prev_randao: jpa.prev_randao,
|
||||||
suggested_fee_recipient: jpa.suggested_fee_recipient,
|
suggested_fee_recipient: jpa.suggested_fee_recipient,
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
withdrawals: jpa.withdrawals.into_iter().map(Into::into).collect(),
|
withdrawals: jpa.withdrawals.into_iter().map(Into::into).collect(),
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
@ -1499,6 +1499,7 @@ impl<T: EthSpec> ExecutionLayer<T> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
ExecutionBlockWithTransactions::Capella(capella_block) => {
|
ExecutionBlockWithTransactions::Capella(capella_block) => {
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
let withdrawals = VariableList::new(capella_block.withdrawals.clone())
|
let withdrawals = VariableList::new(capella_block.withdrawals.clone())
|
||||||
.map_err(ApiError::DeserializeWithdrawals)?;
|
.map_err(ApiError::DeserializeWithdrawals)?;
|
||||||
|
|
||||||
@ -1517,10 +1518,12 @@ impl<T: EthSpec> ExecutionLayer<T> {
|
|||||||
base_fee_per_gas: capella_block.base_fee_per_gas,
|
base_fee_per_gas: capella_block.base_fee_per_gas,
|
||||||
block_hash: capella_block.block_hash,
|
block_hash: capella_block.block_hash,
|
||||||
transactions,
|
transactions,
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
withdrawals,
|
withdrawals,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
ExecutionBlockWithTransactions::Eip4844(eip4844_block) => {
|
ExecutionBlockWithTransactions::Eip4844(eip4844_block) => {
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
let withdrawals = VariableList::new(eip4844_block.withdrawals.clone())
|
let withdrawals = VariableList::new(eip4844_block.withdrawals.clone())
|
||||||
.map_err(ApiError::DeserializeWithdrawals)?;
|
.map_err(ApiError::DeserializeWithdrawals)?;
|
||||||
|
|
||||||
@ -1540,6 +1543,7 @@ impl<T: EthSpec> ExecutionLayer<T> {
|
|||||||
excess_blobs: eip4844_block.excess_blobs,
|
excess_blobs: eip4844_block.excess_blobs,
|
||||||
block_hash: eip4844_block.block_hash,
|
block_hash: eip4844_block.block_hash,
|
||||||
transactions,
|
transactions,
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
withdrawals,
|
withdrawals,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -403,6 +403,7 @@ impl<T: EthSpec> ExecutionBlockGenerator<T> {
|
|||||||
base_fee_per_gas: Uint256::one(),
|
base_fee_per_gas: Uint256::one(),
|
||||||
block_hash: ExecutionBlockHash::zero(),
|
block_hash: ExecutionBlockHash::zero(),
|
||||||
transactions: vec![].into(),
|
transactions: vec![].into(),
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
withdrawals: pa
|
withdrawals: pa
|
||||||
.withdrawals
|
.withdrawals
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -113,6 +113,7 @@ impl<T: EthSpec> MockExecutionLayer<T> {
|
|||||||
prev_randao,
|
prev_randao,
|
||||||
suggested_fee_recipient: Address::repeat_byte(42),
|
suggested_fee_recipient: Address::repeat_byte(42),
|
||||||
// FIXME: think about adding withdrawals here..
|
// FIXME: think about adding withdrawals here..
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
withdrawals: vec![],
|
withdrawals: vec![],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -26,3 +26,7 @@ lru = "0.7.1"
|
|||||||
sloggers = { version = "2.1.1", features = ["json"] }
|
sloggers = { version = "2.1.1", features = ["json"] }
|
||||||
directory = { path = "../../common/directory" }
|
directory = { path = "../../common/directory" }
|
||||||
strum = { version = "0.24.0", features = ["derive"] }
|
strum = { version = "0.24.0", features = ["derive"] }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
withdrawals = ["state_processing/withdrawals", "types/withdrawals"]
|
||||||
|
withdrawals-processing = ["state_processing/withdrawals-processing"]
|
@ -105,10 +105,13 @@ where
|
|||||||
pub latest_execution_payload_header: ExecutionPayloadHeaderEip4844<T>,
|
pub latest_execution_payload_header: ExecutionPayloadHeaderEip4844<T>,
|
||||||
|
|
||||||
// Withdrawals
|
// Withdrawals
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
#[superstruct(only(Capella, Eip4844))]
|
#[superstruct(only(Capella, Eip4844))]
|
||||||
pub withdrawal_queue: VariableList<Withdrawal, T::WithdrawalQueueLimit>,
|
pub withdrawal_queue: VariableList<Withdrawal, T::WithdrawalQueueLimit>,
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
#[superstruct(only(Capella, Eip4844))]
|
#[superstruct(only(Capella, Eip4844))]
|
||||||
pub next_withdrawal_index: u64,
|
pub next_withdrawal_index: u64,
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
#[superstruct(only(Capella, Eip4844))]
|
#[superstruct(only(Capella, Eip4844))]
|
||||||
pub next_partial_withdrawal_validator_index: u64,
|
pub next_partial_withdrawal_validator_index: u64,
|
||||||
}
|
}
|
||||||
@ -199,6 +202,7 @@ impl<T: EthSpec> PartialBeaconState<T> {
|
|||||||
latest_execution_payload_header
|
latest_execution_payload_header
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
BeaconState::Capella(s) => impl_from_state_forgetful!(
|
BeaconState::Capella(s) => impl_from_state_forgetful!(
|
||||||
s,
|
s,
|
||||||
outer,
|
outer,
|
||||||
@ -216,6 +220,22 @@ impl<T: EthSpec> PartialBeaconState<T> {
|
|||||||
next_partial_withdrawal_validator_index
|
next_partial_withdrawal_validator_index
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
|
#[cfg(not(feature = "withdrawals"))]
|
||||||
|
BeaconState::Capella(s) => impl_from_state_forgetful!(
|
||||||
|
s,
|
||||||
|
outer,
|
||||||
|
Capella,
|
||||||
|
PartialBeaconStateCapella,
|
||||||
|
[
|
||||||
|
previous_epoch_participation,
|
||||||
|
current_epoch_participation,
|
||||||
|
current_sync_committee,
|
||||||
|
next_sync_committee,
|
||||||
|
inactivity_scores,
|
||||||
|
latest_execution_payload_header
|
||||||
|
]
|
||||||
|
),
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
BeaconState::Eip4844(s) => impl_from_state_forgetful!(
|
BeaconState::Eip4844(s) => impl_from_state_forgetful!(
|
||||||
s,
|
s,
|
||||||
outer,
|
outer,
|
||||||
@ -233,6 +253,21 @@ impl<T: EthSpec> PartialBeaconState<T> {
|
|||||||
next_partial_withdrawal_validator_index
|
next_partial_withdrawal_validator_index
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
|
#[cfg(not(feature = "withdrawals"))]
|
||||||
|
BeaconState::Eip4844(s) => impl_from_state_forgetful!(
|
||||||
|
s,
|
||||||
|
outer,
|
||||||
|
Eip4844,
|
||||||
|
PartialBeaconStateEip4844,
|
||||||
|
[
|
||||||
|
previous_epoch_participation,
|
||||||
|
current_epoch_participation,
|
||||||
|
current_sync_committee,
|
||||||
|
next_sync_committee,
|
||||||
|
inactivity_scores,
|
||||||
|
latest_execution_payload_header
|
||||||
|
]
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -420,6 +455,7 @@ impl<E: EthSpec> TryInto<BeaconState<E>> for PartialBeaconState<E> {
|
|||||||
latest_execution_payload_header
|
latest_execution_payload_header
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
PartialBeaconState::Capella(inner) => impl_try_into_beacon_state!(
|
PartialBeaconState::Capella(inner) => impl_try_into_beacon_state!(
|
||||||
inner,
|
inner,
|
||||||
Capella,
|
Capella,
|
||||||
@ -436,6 +472,21 @@ impl<E: EthSpec> TryInto<BeaconState<E>> for PartialBeaconState<E> {
|
|||||||
next_partial_withdrawal_validator_index
|
next_partial_withdrawal_validator_index
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
|
#[cfg(not(feature = "withdrawals"))]
|
||||||
|
PartialBeaconState::Capella(inner) => impl_try_into_beacon_state!(
|
||||||
|
inner,
|
||||||
|
Capella,
|
||||||
|
BeaconStateCapella,
|
||||||
|
[
|
||||||
|
previous_epoch_participation,
|
||||||
|
current_epoch_participation,
|
||||||
|
current_sync_committee,
|
||||||
|
next_sync_committee,
|
||||||
|
inactivity_scores,
|
||||||
|
latest_execution_payload_header
|
||||||
|
]
|
||||||
|
),
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
PartialBeaconState::Eip4844(inner) => impl_try_into_beacon_state!(
|
PartialBeaconState::Eip4844(inner) => impl_try_into_beacon_state!(
|
||||||
inner,
|
inner,
|
||||||
Eip4844,
|
Eip4844,
|
||||||
@ -452,6 +503,20 @@ impl<E: EthSpec> TryInto<BeaconState<E>> for PartialBeaconState<E> {
|
|||||||
next_partial_withdrawal_validator_index
|
next_partial_withdrawal_validator_index
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
|
#[cfg(not(feature = "withdrawals"))]
|
||||||
|
PartialBeaconState::Eip4844(inner) => impl_try_into_beacon_state!(
|
||||||
|
inner,
|
||||||
|
Eip4844,
|
||||||
|
BeaconStateEip4844,
|
||||||
|
[
|
||||||
|
previous_epoch_participation,
|
||||||
|
current_epoch_participation,
|
||||||
|
current_sync_committee,
|
||||||
|
next_sync_committee,
|
||||||
|
inactivity_scores,
|
||||||
|
latest_execution_payload_header
|
||||||
|
]
|
||||||
|
),
|
||||||
};
|
};
|
||||||
Ok(state)
|
Ok(state)
|
||||||
}
|
}
|
||||||
|
@ -43,3 +43,5 @@ arbitrary-fuzz = [
|
|||||||
"eth2_ssz_types/arbitrary",
|
"eth2_ssz_types/arbitrary",
|
||||||
"tree_hash/arbitrary",
|
"tree_hash/arbitrary",
|
||||||
]
|
]
|
||||||
|
withdrawals = ["types/withdrawals"]
|
||||||
|
withdrawals-processing = []
|
||||||
|
@ -15,6 +15,7 @@ pub use get_attesting_indices::{get_attesting_indices, get_attesting_indices_fro
|
|||||||
pub use get_indexed_attestation::get_indexed_attestation;
|
pub use get_indexed_attestation::get_indexed_attestation;
|
||||||
pub use initiate_validator_exit::initiate_validator_exit;
|
pub use initiate_validator_exit::initiate_validator_exit;
|
||||||
pub use slash_validator::slash_validator;
|
pub use slash_validator::slash_validator;
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
pub use withdraw_balance::withdraw_balance;
|
pub use withdraw_balance::withdraw_balance;
|
||||||
|
|
||||||
use safe_arith::SafeArith;
|
use safe_arith::SafeArith;
|
||||||
|
@ -2,6 +2,7 @@ use crate::common::decrease_balance;
|
|||||||
use safe_arith::SafeArith;
|
use safe_arith::SafeArith;
|
||||||
use types::{BeaconStateError as Error, *};
|
use types::{BeaconStateError as Error, *};
|
||||||
|
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
pub fn withdraw_balance<T: EthSpec>(
|
pub fn withdraw_balance<T: EthSpec>(
|
||||||
state: &mut BeaconState<T>,
|
state: &mut BeaconState<T>,
|
||||||
validator_index: usize,
|
validator_index: usize,
|
||||||
|
@ -5,11 +5,15 @@ use crate::per_epoch_processing::{
|
|||||||
historical_roots_update::process_historical_roots_update,
|
historical_roots_update::process_historical_roots_update,
|
||||||
resets::{process_eth1_data_reset, process_randao_mixes_reset, process_slashings_reset},
|
resets::{process_eth1_data_reset, process_randao_mixes_reset, process_slashings_reset},
|
||||||
};
|
};
|
||||||
|
#[cfg(all(feature = "withdrawals", feature = "withdrawals-processing"))]
|
||||||
pub use full_withdrawals::process_full_withdrawals;
|
pub use full_withdrawals::process_full_withdrawals;
|
||||||
|
#[cfg(all(feature = "withdrawals", feature = "withdrawals-processing"))]
|
||||||
pub use partial_withdrawals::process_partial_withdrawals;
|
pub use partial_withdrawals::process_partial_withdrawals;
|
||||||
use types::{BeaconState, ChainSpec, EthSpec, RelativeEpoch};
|
use types::{BeaconState, ChainSpec, EthSpec, RelativeEpoch};
|
||||||
|
|
||||||
|
#[cfg(all(feature = "withdrawals", feature = "withdrawals-processing"))]
|
||||||
pub mod full_withdrawals;
|
pub mod full_withdrawals;
|
||||||
|
#[cfg(all(feature = "withdrawals", feature = "withdrawals-processing"))]
|
||||||
pub mod partial_withdrawals;
|
pub mod partial_withdrawals;
|
||||||
|
|
||||||
pub fn process_epoch<T: EthSpec>(
|
pub fn process_epoch<T: EthSpec>(
|
||||||
@ -66,8 +70,10 @@ pub fn process_epoch<T: EthSpec>(
|
|||||||
altair::process_sync_committee_updates(state, spec)?;
|
altair::process_sync_committee_updates(state, spec)?;
|
||||||
|
|
||||||
// Withdrawals
|
// Withdrawals
|
||||||
|
#[cfg(all(feature = "withdrawals", feature = "withdrawals-processing"))]
|
||||||
process_full_withdrawals(state, spec)?;
|
process_full_withdrawals(state, spec)?;
|
||||||
|
|
||||||
|
#[cfg(all(feature = "withdrawals", feature = "withdrawals-processing"))]
|
||||||
process_partial_withdrawals(state, spec)?;
|
process_partial_withdrawals(state, spec)?;
|
||||||
|
|
||||||
// Rotate the epoch caches to suit the epoch transition.
|
// Rotate the epoch caches to suit the epoch transition.
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
|
#[cfg(all(feature = "withdrawals", feature = "withdrawals-processing"))]
|
||||||
use crate::common::withdraw_balance;
|
use crate::common::withdraw_balance;
|
||||||
use crate::EpochProcessingError;
|
use crate::EpochProcessingError;
|
||||||
use types::{beacon_state::BeaconState, eth_spec::EthSpec, ChainSpec};
|
use types::{beacon_state::BeaconState, eth_spec::EthSpec, ChainSpec};
|
||||||
|
|
||||||
|
#[cfg(all(feature = "withdrawals", feature = "withdrawals-processing"))]
|
||||||
pub fn process_full_withdrawals<T: EthSpec>(
|
pub fn process_full_withdrawals<T: EthSpec>(
|
||||||
state: &mut BeaconState<T>,
|
state: &mut BeaconState<T>,
|
||||||
spec: &ChainSpec,
|
spec: &ChainSpec,
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
|
#[cfg(all(feature = "withdrawals", feature = "withdrawals-processing"))]
|
||||||
use crate::common::withdraw_balance;
|
use crate::common::withdraw_balance;
|
||||||
use crate::EpochProcessingError;
|
use crate::EpochProcessingError;
|
||||||
use safe_arith::SafeArith;
|
use safe_arith::SafeArith;
|
||||||
use types::{beacon_state::BeaconState, eth_spec::EthSpec, ChainSpec};
|
use types::{beacon_state::BeaconState, eth_spec::EthSpec, ChainSpec};
|
||||||
|
|
||||||
|
#[cfg(all(feature = "withdrawals", feature = "withdrawals-processing"))]
|
||||||
pub fn process_partial_withdrawals<T: EthSpec>(
|
pub fn process_partial_withdrawals<T: EthSpec>(
|
||||||
state: &mut BeaconState<T>,
|
state: &mut BeaconState<T>,
|
||||||
spec: &ChainSpec,
|
spec: &ChainSpec,
|
||||||
|
@ -57,8 +57,11 @@ pub fn upgrade_to_capella<E: EthSpec>(
|
|||||||
// Execution
|
// Execution
|
||||||
latest_execution_payload_header: pre.latest_execution_payload_header.upgrade_to_capella(),
|
latest_execution_payload_header: pre.latest_execution_payload_header.upgrade_to_capella(),
|
||||||
// Withdrawals
|
// Withdrawals
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
withdrawal_queue: VariableList::empty(),
|
withdrawal_queue: VariableList::empty(),
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
next_withdrawal_index: 0,
|
next_withdrawal_index: 0,
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
next_partial_withdrawal_validator_index: 0,
|
next_partial_withdrawal_validator_index: 0,
|
||||||
// Caches
|
// Caches
|
||||||
total_active_balance: pre.total_active_balance,
|
total_active_balance: pre.total_active_balance,
|
||||||
|
@ -9,6 +9,14 @@ pub fn upgrade_to_eip4844<E: EthSpec>(
|
|||||||
let epoch = pre_state.current_epoch();
|
let epoch = pre_state.current_epoch();
|
||||||
let pre = pre_state.as_capella_mut()?;
|
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
|
// 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`.
|
// 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,
|
genesis_validators_root: pre.genesis_validators_root,
|
||||||
slot: pre.slot,
|
slot: pre.slot,
|
||||||
fork: Fork {
|
fork: Fork {
|
||||||
previous_version: pre.fork.current_version,
|
previous_version: previous_fork_version,
|
||||||
current_version: spec.eip4844_fork_version,
|
current_version: spec.eip4844_fork_version,
|
||||||
epoch,
|
epoch,
|
||||||
},
|
},
|
||||||
@ -56,8 +64,11 @@ pub fn upgrade_to_eip4844<E: EthSpec>(
|
|||||||
// Execution
|
// Execution
|
||||||
latest_execution_payload_header: pre.latest_execution_payload_header.upgrade_to_eip4844(),
|
latest_execution_payload_header: pre.latest_execution_payload_header.upgrade_to_eip4844(),
|
||||||
// Withdrawals
|
// Withdrawals
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
withdrawal_queue: mem::take(&mut pre.withdrawal_queue),
|
withdrawal_queue: mem::take(&mut pre.withdrawal_queue),
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
next_withdrawal_index: pre.next_withdrawal_index,
|
next_withdrawal_index: pre.next_withdrawal_index,
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
next_partial_withdrawal_validator_index: pre.next_partial_withdrawal_validator_index,
|
next_partial_withdrawal_validator_index: pre.next_partial_withdrawal_validator_index,
|
||||||
// Caches
|
// Caches
|
||||||
total_active_balance: pre.total_active_balance,
|
total_active_balance: pre.total_active_balance,
|
||||||
|
@ -71,3 +71,4 @@ arbitrary-fuzz = [
|
|||||||
"swap_or_not_shuffle/arbitrary",
|
"swap_or_not_shuffle/arbitrary",
|
||||||
"tree_hash/arbitrary",
|
"tree_hash/arbitrary",
|
||||||
]
|
]
|
||||||
|
withdrawals = []
|
||||||
|
@ -295,10 +295,13 @@ where
|
|||||||
pub latest_execution_payload_header: ExecutionPayloadHeaderEip4844<T>,
|
pub latest_execution_payload_header: ExecutionPayloadHeaderEip4844<T>,
|
||||||
|
|
||||||
// Withdrawals
|
// Withdrawals
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
#[superstruct(only(Capella, Eip4844))]
|
#[superstruct(only(Capella, Eip4844))]
|
||||||
pub withdrawal_queue: VariableList<Withdrawal, T::WithdrawalQueueLimit>,
|
pub withdrawal_queue: VariableList<Withdrawal, T::WithdrawalQueueLimit>,
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
#[superstruct(only(Capella, Eip4844))]
|
#[superstruct(only(Capella, Eip4844))]
|
||||||
pub next_withdrawal_index: u64,
|
pub next_withdrawal_index: u64,
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
#[superstruct(only(Capella, Eip4844))]
|
#[superstruct(only(Capella, Eip4844))]
|
||||||
pub next_partial_withdrawal_validator_index: u64,
|
pub next_partial_withdrawal_validator_index: u64,
|
||||||
|
|
||||||
|
@ -80,6 +80,7 @@ pub struct ExecutionPayload<T: EthSpec> {
|
|||||||
pub block_hash: ExecutionBlockHash,
|
pub block_hash: ExecutionBlockHash,
|
||||||
#[serde(with = "ssz_types::serde_utils::list_of_hex_var_list")]
|
#[serde(with = "ssz_types::serde_utils::list_of_hex_var_list")]
|
||||||
pub transactions: Transactions<T>,
|
pub transactions: Transactions<T>,
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
#[superstruct(only(Capella, Eip4844))]
|
#[superstruct(only(Capella, Eip4844))]
|
||||||
pub withdrawals: VariableList<Withdrawal, T::MaxWithdrawalsPerPayload>,
|
pub withdrawals: VariableList<Withdrawal, T::MaxWithdrawalsPerPayload>,
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,7 @@ pub struct ExecutionPayloadHeader<T: EthSpec> {
|
|||||||
pub block_hash: ExecutionBlockHash,
|
pub block_hash: ExecutionBlockHash,
|
||||||
#[superstruct(getter(copy))]
|
#[superstruct(getter(copy))]
|
||||||
pub transactions_root: Hash256,
|
pub transactions_root: Hash256,
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
#[superstruct(only(Capella, Eip4844))]
|
#[superstruct(only(Capella, Eip4844))]
|
||||||
#[superstruct(getter(copy))]
|
#[superstruct(getter(copy))]
|
||||||
pub withdrawals_root: Hash256,
|
pub withdrawals_root: Hash256,
|
||||||
@ -104,6 +105,7 @@ impl<'a, T: EthSpec> ExecutionPayloadHeaderRef<'a, T> {
|
|||||||
|
|
||||||
impl<T: EthSpec> ExecutionPayloadHeaderMerge<T> {
|
impl<T: EthSpec> ExecutionPayloadHeaderMerge<T> {
|
||||||
pub fn upgrade_to_capella(&self) -> ExecutionPayloadHeaderCapella<T> {
|
pub fn upgrade_to_capella(&self) -> ExecutionPayloadHeaderCapella<T> {
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
// TODO: if this is correct we should calculate and hardcode this..
|
// TODO: if this is correct we should calculate and hardcode this..
|
||||||
let empty_withdrawals_root =
|
let empty_withdrawals_root =
|
||||||
VariableList::<Withdrawal, T::MaxWithdrawalsPerPayload>::empty().tree_hash_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,
|
base_fee_per_gas: self.base_fee_per_gas,
|
||||||
block_hash: self.block_hash,
|
block_hash: self.block_hash,
|
||||||
transactions_root: self.transactions_root,
|
transactions_root: self.transactions_root,
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
// FIXME: the spec doesn't seem to define what to do here..
|
// FIXME: the spec doesn't seem to define what to do here..
|
||||||
withdrawals_root: empty_withdrawals_root,
|
withdrawals_root: empty_withdrawals_root,
|
||||||
}
|
}
|
||||||
@ -147,6 +150,7 @@ impl<T: EthSpec> ExecutionPayloadHeaderCapella<T> {
|
|||||||
excess_blobs: 0,
|
excess_blobs: 0,
|
||||||
block_hash: self.block_hash,
|
block_hash: self.block_hash,
|
||||||
transactions_root: self.transactions_root,
|
transactions_root: self.transactions_root,
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
withdrawals_root: self.withdrawals_root,
|
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,
|
base_fee_per_gas: payload.base_fee_per_gas,
|
||||||
block_hash: payload.block_hash,
|
block_hash: payload.block_hash,
|
||||||
transactions_root: payload.transactions.tree_hash_root(),
|
transactions_root: payload.transactions.tree_hash_root(),
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
withdrawals_root: payload.withdrawals.tree_hash_root(),
|
withdrawals_root: payload.withdrawals.tree_hash_root(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -211,6 +216,7 @@ impl<T: EthSpec> From<ExecutionPayloadEip4844<T>> for ExecutionPayloadHeaderEip4
|
|||||||
excess_blobs: payload.excess_blobs,
|
excess_blobs: payload.excess_blobs,
|
||||||
block_hash: payload.block_hash,
|
block_hash: payload.block_hash,
|
||||||
transactions_root: payload.transactions.tree_hash_root(),
|
transactions_root: payload.transactions.tree_hash_root(),
|
||||||
|
#[cfg(feature = "withdrawals")]
|
||||||
withdrawals_root: payload.withdrawals.tree_hash_root(),
|
withdrawals_root: payload.withdrawals.tree_hash_root(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,10 @@ gnosis = []
|
|||||||
slasher-mdbx = ["slasher/mdbx"]
|
slasher-mdbx = ["slasher/mdbx"]
|
||||||
# Support slasher LMDB backend.
|
# Support slasher LMDB backend.
|
||||||
slasher-lmdb = ["slasher/lmdb"]
|
slasher-lmdb = ["slasher/lmdb"]
|
||||||
|
# Support for inclusion of withdrawals fields in all capella consensus types in all APIs.
|
||||||
|
withdrawals = ["types/withdrawals", "beacon_node/withdrawals"]
|
||||||
|
# Support for withdrawals consensus processing logic.
|
||||||
|
withdrawals-processing = ["beacon_node/withdrawals-processing"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
beacon_node = { "path" = "../beacon_node" }
|
beacon_node = { "path" = "../beacon_node" }
|
||||||
|
Loading…
Reference in New Issue
Block a user