Fix todos

This commit is contained in:
Pawan Dhananjay
2024-05-08 13:42:29 -07:00
parent 3ef7c9078e
commit 683de56f6e
3 changed files with 36 additions and 6 deletions

View File

@@ -41,6 +41,8 @@ pub use new_payload_request::{
NewPayloadRequestDeneb, NewPayloadRequestElectra, NewPayloadRequestDeneb, NewPayloadRequestElectra,
}; };
use self::json_structures::{JsonDepositRequest, JsonWithdrawalRequest};
pub const LATEST_TAG: &str = "latest"; pub const LATEST_TAG: &str = "latest";
pub type PayloadId = [u8; 8]; pub type PayloadId = [u8; 8];
@@ -64,6 +66,8 @@ pub enum Error {
TransitionConfigurationMismatch, TransitionConfigurationMismatch,
SszError(ssz_types::Error), SszError(ssz_types::Error),
DeserializeWithdrawals(ssz_types::Error), DeserializeWithdrawals(ssz_types::Error),
DeserializeDepositReceipts(ssz_types::Error),
DeserializeWithdrawalRequests(ssz_types::Error),
BuilderApi(builder_client::Error), BuilderApi(builder_client::Error),
IncorrectStateVariant, IncorrectStateVariant,
RequiredMethodUnsupported(&'static str), RequiredMethodUnsupported(&'static str),
@@ -198,6 +202,10 @@ pub struct ExecutionBlockWithTransactions<E: EthSpec> {
#[superstruct(only(Deneb, Electra))] #[superstruct(only(Deneb, Electra))]
#[serde(with = "serde_utils::u64_hex_be")] #[serde(with = "serde_utils::u64_hex_be")]
pub excess_blob_gas: u64, pub excess_blob_gas: u64,
#[superstruct(only(Electra))]
pub deposit_receipts: Vec<JsonDepositRequest>,
#[superstruct(only(Electra))]
pub withdrawal_requests: Vec<JsonWithdrawalRequest>,
} }
impl<E: EthSpec> TryFrom<ExecutionPayload<E>> for ExecutionBlockWithTransactions<E> { impl<E: EthSpec> TryFrom<ExecutionPayload<E>> for ExecutionBlockWithTransactions<E> {
@@ -305,6 +313,16 @@ impl<E: EthSpec> TryFrom<ExecutionPayload<E>> for ExecutionBlockWithTransactions
.collect(), .collect(),
blob_gas_used: block.blob_gas_used, blob_gas_used: block.blob_gas_used,
excess_blob_gas: block.excess_blob_gas, excess_blob_gas: block.excess_blob_gas,
deposit_receipts: block
.deposit_receipts
.into_iter()
.map(|deposit| deposit.into())
.collect(),
withdrawal_requests: block
.withdrawal_requests
.into_iter()
.map(|withdrawal| withdrawal.into())
.collect(),
}) })
} }
}; };

View File

@@ -1985,6 +1985,22 @@ impl<E: EthSpec> ExecutionLayer<E> {
.collect(), .collect(),
) )
.map_err(ApiError::DeserializeWithdrawals)?; .map_err(ApiError::DeserializeWithdrawals)?;
let deposit_receipts = VariableList::new(
electra_block
.deposit_receipts
.into_iter()
.map(Into::into)
.collect(),
)
.map_err(ApiError::DeserializeDepositReceipts)?;
let withdrawal_requests = VariableList::new(
electra_block
.withdrawal_requests
.into_iter()
.map(Into::into)
.collect(),
)
.map_err(ApiError::DeserializeWithdrawalRequests)?;
ExecutionPayload::Electra(ExecutionPayloadElectra { ExecutionPayload::Electra(ExecutionPayloadElectra {
parent_hash: electra_block.parent_hash, parent_hash: electra_block.parent_hash,
fee_recipient: electra_block.fee_recipient, fee_recipient: electra_block.fee_recipient,
@@ -2003,11 +2019,8 @@ impl<E: EthSpec> ExecutionLayer<E> {
withdrawals, withdrawals,
blob_gas_used: electra_block.blob_gas_used, blob_gas_used: electra_block.blob_gas_used,
excess_blob_gas: electra_block.excess_blob_gas, excess_blob_gas: electra_block.excess_blob_gas,
// TODO(electra) deposit_receipts,
// deposit_receipts: electra_block.deposit_receipts, withdrawal_requests,
// withdrawal_requests: electra_block.withdrawal_requests,
deposit_receipts: <_>::default(),
withdrawal_requests: <_>::default(),
}) })
} }
}; };

View File

@@ -117,7 +117,6 @@ impl<E: EthSpec> ExecutionPayloadHeader<E> {
#[allow(clippy::arithmetic_side_effects)] #[allow(clippy::arithmetic_side_effects)]
pub fn ssz_max_var_len_for_fork(fork_name: ForkName) -> usize { pub fn ssz_max_var_len_for_fork(fork_name: ForkName) -> usize {
// Matching here in case variable fields are added in future forks. // Matching here in case variable fields are added in future forks.
// TODO(electra): review electra changes
match fork_name { match fork_name {
ForkName::Base ForkName::Base
| ForkName::Altair | ForkName::Altair