mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-06 18:21:45 +00:00
merge with capella
This commit is contained in:
@@ -165,7 +165,6 @@ 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<JsonWithdrawal>,
|
||||
}
|
||||
@@ -215,7 +214,6 @@ impl<T: EthSpec> TryFrom<ExecutionPayload<T>> for ExecutionBlockWithTransactions
|
||||
.iter()
|
||||
.map(|tx| Transaction::decode(&Rlp::new(tx)))
|
||||
.collect::<Result<Vec<_>, _>>()?,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
withdrawals: Vec::from(block.withdrawals)
|
||||
.into_iter()
|
||||
.map(|withdrawal| withdrawal.into())
|
||||
@@ -243,7 +241,6 @@ impl<T: EthSpec> TryFrom<ExecutionPayload<T>> for ExecutionBlockWithTransactions
|
||||
.iter()
|
||||
.map(|tx| Transaction::decode(&Rlp::new(tx)))
|
||||
.collect::<Result<Vec<_>, _>>()?,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
withdrawals: Vec::from(block.withdrawals)
|
||||
.into_iter()
|
||||
.map(|withdrawal| withdrawal.into())
|
||||
|
||||
@@ -779,7 +779,7 @@ impl HttpJsonRpc {
|
||||
) -> Result<ExecutionPayload<T>, Error> {
|
||||
let params = json!([JsonPayloadIdRequest::from(payload_id)]);
|
||||
|
||||
let payload_v2: JsonExecutionPayloadV2<T> = self
|
||||
let response: JsonGetPayloadResponse<T> = self
|
||||
.rpc_request(
|
||||
ENGINE_GET_PAYLOAD_V2,
|
||||
params,
|
||||
@@ -787,7 +787,7 @@ impl HttpJsonRpc {
|
||||
)
|
||||
.await?;
|
||||
|
||||
JsonExecutionPayload::V2(payload_v2).try_into_execution_payload(fork_name)
|
||||
JsonExecutionPayload::V2(response.execution_payload).try_into_execution_payload(fork_name)
|
||||
}
|
||||
|
||||
pub async fn get_payload_v3<T: EthSpec>(
|
||||
@@ -889,11 +889,11 @@ impl HttpJsonRpc {
|
||||
pub async fn supported_apis_v1(&self) -> Result<SupportedApis, Error> {
|
||||
Ok(SupportedApis {
|
||||
new_payload_v1: true,
|
||||
new_payload_v2: cfg!(all(feature = "withdrawals", not(test))),
|
||||
new_payload_v2: cfg!(not(test)),
|
||||
forkchoice_updated_v1: true,
|
||||
forkchoice_updated_v2: cfg!(all(feature = "withdrawals", not(test))),
|
||||
forkchoice_updated_v2: cfg!(not(test)),
|
||||
get_payload_v1: true,
|
||||
get_payload_v2: cfg!(all(feature = "withdrawals", not(test))),
|
||||
get_payload_v2: cfg!(not(test)),
|
||||
exchange_transition_configuration_v1: true,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -164,7 +164,6 @@ impl<T: EthSpec> JsonExecutionPayload<T> {
|
||||
base_fee_per_gas: v2.base_fee_per_gas,
|
||||
block_hash: v2.block_hash,
|
||||
transactions: v2.transactions,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
withdrawals: v2
|
||||
.withdrawals
|
||||
.map(|v| {
|
||||
@@ -192,7 +191,6 @@ impl<T: EthSpec> JsonExecutionPayload<T> {
|
||||
excess_data_gas: v2.excess_data_gas.ok_or_else(|| Error::BadConversion("Null `excess_data_gas` field converting JsonExecutionPayloadV2 -> ExecutionPayloadEip4844".to_string()))?,
|
||||
block_hash: v2.block_hash,
|
||||
transactions: v2.transactions,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
withdrawals: v2
|
||||
.withdrawals
|
||||
.map(|v| {
|
||||
@@ -280,7 +278,6 @@ impl<T: EthSpec> TryFrom<ExecutionPayload<T>> for JsonExecutionPayloadV2<T> {
|
||||
excess_data_gas: None,
|
||||
block_hash: capella.block_hash,
|
||||
transactions: capella.transactions,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
withdrawals: Some(
|
||||
Vec::from(capella.withdrawals)
|
||||
.into_iter()
|
||||
@@ -288,8 +285,6 @@ impl<T: EthSpec> TryFrom<ExecutionPayload<T>> for JsonExecutionPayloadV2<T> {
|
||||
.collect::<Vec<_>>()
|
||||
.into(),
|
||||
),
|
||||
#[cfg(not(feature = "withdrawals"))]
|
||||
withdrawals: None,
|
||||
}),
|
||||
ExecutionPayload::Eip4844(eip4844) => Ok(JsonExecutionPayloadV2 {
|
||||
parent_hash: eip4844.parent_hash,
|
||||
@@ -307,7 +302,6 @@ impl<T: EthSpec> TryFrom<ExecutionPayload<T>> for JsonExecutionPayloadV2<T> {
|
||||
excess_data_gas: Some(eip4844.excess_data_gas),
|
||||
block_hash: eip4844.block_hash,
|
||||
transactions: eip4844.transactions,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
withdrawals: Some(
|
||||
Vec::from(eip4844.withdrawals)
|
||||
.into_iter()
|
||||
@@ -315,13 +309,20 @@ impl<T: EthSpec> TryFrom<ExecutionPayload<T>> for JsonExecutionPayloadV2<T> {
|
||||
.collect::<Vec<_>>()
|
||||
.into(),
|
||||
),
|
||||
#[cfg(not(feature = "withdrawals"))]
|
||||
withdrawals: None,
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(bound = "T: EthSpec", rename_all = "camelCase")]
|
||||
pub struct JsonGetPayloadResponse<T: EthSpec> {
|
||||
pub execution_payload: JsonExecutionPayloadV2<T>,
|
||||
// uncomment this when geth fixes its serialization
|
||||
//#[serde(with = "eth2_serde_utils::u256_hex_be")]
|
||||
//pub block_value: Uint256,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct JsonWithdrawal {
|
||||
|
||||
@@ -1642,7 +1642,6 @@ impl<T: EthSpec> ExecutionLayer<T> {
|
||||
})
|
||||
}
|
||||
ExecutionBlockWithTransactions::Capella(capella_block) => {
|
||||
#[cfg(feature = "withdrawals")]
|
||||
let withdrawals = VariableList::new(
|
||||
capella_block
|
||||
.withdrawals
|
||||
@@ -1651,7 +1650,6 @@ impl<T: EthSpec> ExecutionLayer<T> {
|
||||
.collect(),
|
||||
)
|
||||
.map_err(ApiError::DeserializeWithdrawals)?;
|
||||
|
||||
ExecutionPayload::Capella(ExecutionPayloadCapella {
|
||||
parent_hash: capella_block.parent_hash,
|
||||
fee_recipient: capella_block.fee_recipient,
|
||||
@@ -1667,12 +1665,10 @@ 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
|
||||
@@ -1681,7 +1677,6 @@ impl<T: EthSpec> ExecutionLayer<T> {
|
||||
.collect(),
|
||||
)
|
||||
.map_err(ApiError::DeserializeWithdrawals)?;
|
||||
|
||||
ExecutionPayload::Eip4844(ExecutionPayloadEip4844 {
|
||||
parent_hash: eip4844_block.parent_hash,
|
||||
fee_recipient: eip4844_block.fee_recipient,
|
||||
@@ -1698,7 +1693,6 @@ impl<T: EthSpec> ExecutionLayer<T> {
|
||||
excess_data_gas: eip4844_block.excess_data_gas,
|
||||
block_hash: eip4844_block.block_hash,
|
||||
transactions,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
withdrawals,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -103,10 +103,7 @@ impl<T: EthSpec> MockExecutionLayer<T> {
|
||||
prev_randao,
|
||||
Address::repeat_byte(42),
|
||||
// FIXME: think about how to handle different forks / withdrawals here..
|
||||
#[cfg(feature = "withdrawals")]
|
||||
Some(vec![]),
|
||||
#[cfg(not(feature = "withdrawals"))]
|
||||
None,
|
||||
);
|
||||
|
||||
// Insert a proposer to ensure the fork choice updated command works.
|
||||
|
||||
Reference in New Issue
Block a user