mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-09 19:51:47 +00:00
merge with upstream
This commit is contained in:
@@ -11,7 +11,7 @@ use engine_api::Error as ApiError;
|
||||
pub use engine_api::*;
|
||||
pub use engine_api::{http, http::deposit_methods, http::HttpJsonRpc};
|
||||
use engines::{Engine, EngineError};
|
||||
pub use engines::{EngineState, ForkChoiceState};
|
||||
pub use engines::{EngineState, ForkchoiceState};
|
||||
use fork_choice::ForkchoiceUpdateParameters;
|
||||
use lru::LruCache;
|
||||
use payload_status::process_payload_status;
|
||||
@@ -32,6 +32,8 @@ use tokio::{
|
||||
time::sleep,
|
||||
};
|
||||
use tokio_stream::wrappers::WatchStream;
|
||||
#[cfg(feature = "withdrawals")]
|
||||
use types::Withdrawal;
|
||||
use types::{AbstractExecPayload, Blob, ExecPayload, ExecutionPayloadEip4844, KzgCommitment};
|
||||
use types::{
|
||||
BlindedPayload, BlockType, ChainSpec, Epoch, ExecutionBlockHash, ForkName,
|
||||
@@ -623,6 +625,8 @@ impl<T: EthSpec> ExecutionLayer<T> {
|
||||
proposer_index: u64,
|
||||
forkchoice_update_params: ForkchoiceUpdateParameters,
|
||||
builder_params: BuilderParams,
|
||||
current_fork: ForkName,
|
||||
#[cfg(feature = "withdrawals")] withdrawals: Option<Vec<Withdrawal>>,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<BlockProposalContents<T, Payload>, Error> {
|
||||
let suggested_fee_recipient = self.get_suggested_fee_recipient(proposer_index).await;
|
||||
@@ -640,6 +644,9 @@ impl<T: EthSpec> ExecutionLayer<T> {
|
||||
suggested_fee_recipient,
|
||||
forkchoice_update_params,
|
||||
builder_params,
|
||||
current_fork,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
withdrawals,
|
||||
spec,
|
||||
)
|
||||
.await
|
||||
@@ -655,6 +662,9 @@ impl<T: EthSpec> ExecutionLayer<T> {
|
||||
prev_randao,
|
||||
suggested_fee_recipient,
|
||||
forkchoice_update_params,
|
||||
current_fork,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
withdrawals,
|
||||
)
|
||||
.await
|
||||
}
|
||||
@@ -670,6 +680,8 @@ impl<T: EthSpec> ExecutionLayer<T> {
|
||||
suggested_fee_recipient: Address,
|
||||
forkchoice_update_params: ForkchoiceUpdateParameters,
|
||||
builder_params: BuilderParams,
|
||||
current_fork: ForkName,
|
||||
#[cfg(feature = "withdrawals")] withdrawals: Option<Vec<Withdrawal>>,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<BlockProposalContents<T, Payload>, Error> {
|
||||
if let Some(builder) = self.builder() {
|
||||
@@ -693,6 +705,9 @@ impl<T: EthSpec> ExecutionLayer<T> {
|
||||
prev_randao,
|
||||
suggested_fee_recipient,
|
||||
forkchoice_update_params,
|
||||
current_fork,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
withdrawals,
|
||||
)
|
||||
);
|
||||
|
||||
@@ -822,6 +837,9 @@ impl<T: EthSpec> ExecutionLayer<T> {
|
||||
prev_randao,
|
||||
suggested_fee_recipient,
|
||||
forkchoice_update_params,
|
||||
current_fork,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
withdrawals,
|
||||
)
|
||||
.await
|
||||
}
|
||||
@@ -834,6 +852,8 @@ impl<T: EthSpec> ExecutionLayer<T> {
|
||||
prev_randao: Hash256,
|
||||
suggested_fee_recipient: Address,
|
||||
forkchoice_update_params: ForkchoiceUpdateParameters,
|
||||
current_fork: ForkName,
|
||||
#[cfg(feature = "withdrawals")] withdrawals: Option<Vec<Withdrawal>>,
|
||||
) -> Result<BlockProposalContents<T, Payload>, Error> {
|
||||
self.get_full_payload_with(
|
||||
parent_hash,
|
||||
@@ -841,6 +861,9 @@ impl<T: EthSpec> ExecutionLayer<T> {
|
||||
prev_randao,
|
||||
suggested_fee_recipient,
|
||||
forkchoice_update_params,
|
||||
current_fork,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
withdrawals,
|
||||
noop,
|
||||
)
|
||||
.await
|
||||
@@ -854,6 +877,8 @@ impl<T: EthSpec> ExecutionLayer<T> {
|
||||
prev_randao: Hash256,
|
||||
suggested_fee_recipient: Address,
|
||||
forkchoice_update_params: ForkchoiceUpdateParameters,
|
||||
current_fork: ForkName,
|
||||
#[cfg(feature = "withdrawals")] withdrawals: Option<Vec<Withdrawal>>,
|
||||
) -> Result<BlockProposalContents<T, Payload>, Error> {
|
||||
self.get_full_payload_with(
|
||||
parent_hash,
|
||||
@@ -861,6 +886,9 @@ impl<T: EthSpec> ExecutionLayer<T> {
|
||||
prev_randao,
|
||||
suggested_fee_recipient,
|
||||
forkchoice_update_params,
|
||||
current_fork,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
withdrawals,
|
||||
Self::cache_payload,
|
||||
)
|
||||
.await
|
||||
@@ -873,10 +901,14 @@ impl<T: EthSpec> ExecutionLayer<T> {
|
||||
prev_randao: Hash256,
|
||||
suggested_fee_recipient: Address,
|
||||
forkchoice_update_params: ForkchoiceUpdateParameters,
|
||||
current_fork: ForkName,
|
||||
#[cfg(feature = "withdrawals")] withdrawals: Option<Vec<Withdrawal>>,
|
||||
f: fn(&ExecutionLayer<T>, &ExecutionPayload<T>) -> Option<ExecutionPayload<T>>,
|
||||
) -> Result<BlockProposalContents<T, Payload>, Error> {
|
||||
#[cfg(feature = "withdrawals")]
|
||||
let withdrawals_ref = &withdrawals;
|
||||
self.engine()
|
||||
.request(|engine| async move {
|
||||
.request(move |engine| async move {
|
||||
let payload_id = if let Some(id) = engine
|
||||
.get_payload_id(parent_hash, timestamp, prev_randao, suggested_fee_recipient)
|
||||
.await
|
||||
@@ -894,7 +926,7 @@ impl<T: EthSpec> ExecutionLayer<T> {
|
||||
&metrics::EXECUTION_LAYER_PRE_PREPARED_PAYLOAD_ID,
|
||||
&[metrics::MISS],
|
||||
);
|
||||
let fork_choice_state = ForkChoiceState {
|
||||
let fork_choice_state = ForkchoiceState {
|
||||
head_block_hash: parent_hash,
|
||||
safe_block_hash: forkchoice_update_params
|
||||
.justified_hash
|
||||
@@ -903,12 +935,14 @@ impl<T: EthSpec> ExecutionLayer<T> {
|
||||
.finalized_hash
|
||||
.unwrap_or_else(ExecutionBlockHash::zero),
|
||||
};
|
||||
// FIXME: This will have to properly handle forks. To do that,
|
||||
// withdrawals will need to be passed into this function
|
||||
let payload_attributes = PayloadAttributes::V1(PayloadAttributesV1 {
|
||||
// This must always be the latest PayloadAttributes
|
||||
// FIXME: How to non-capella EIP4844 testnets handle this?
|
||||
let payload_attributes = PayloadAttributes::V2(PayloadAttributesV2 {
|
||||
timestamp,
|
||||
prev_randao,
|
||||
suggested_fee_recipient,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
withdrawals: withdrawals_ref.clone(),
|
||||
});
|
||||
|
||||
let response = engine
|
||||
@@ -935,16 +969,22 @@ impl<T: EthSpec> ExecutionLayer<T> {
|
||||
};
|
||||
|
||||
let blob_fut = async {
|
||||
//FIXME(sean) do a fork check here and return None otherwise
|
||||
debug!(
|
||||
self.log(),
|
||||
"Issuing engine_getBlobsBundle";
|
||||
"suggested_fee_recipient" => ?suggested_fee_recipient,
|
||||
"prev_randao" => ?prev_randao,
|
||||
"timestamp" => timestamp,
|
||||
"parent_hash" => ?parent_hash,
|
||||
);
|
||||
Some(engine.api.get_blobs_bundle_v1::<T>(payload_id).await)
|
||||
match current_fork {
|
||||
ForkName::Base | ForkName::Altair | ForkName::Merge | ForkName::Capella => {
|
||||
None
|
||||
}
|
||||
ForkName::Eip4844 => {
|
||||
debug!(
|
||||
self.log(),
|
||||
"Issuing engine_getBlobsBundle";
|
||||
"suggested_fee_recipient" => ?suggested_fee_recipient,
|
||||
"prev_randao" => ?prev_randao,
|
||||
"timestamp" => timestamp,
|
||||
"parent_hash" => ?parent_hash,
|
||||
);
|
||||
Some(engine.api.get_blobs_bundle_v1::<T>(payload_id).await)
|
||||
}
|
||||
}
|
||||
};
|
||||
let payload_fut = async {
|
||||
debug!(
|
||||
@@ -955,9 +995,8 @@ impl<T: EthSpec> ExecutionLayer<T> {
|
||||
"timestamp" => timestamp,
|
||||
"parent_hash" => ?parent_hash,
|
||||
);
|
||||
engine.api.get_payload_v1::<T>(payload_id).await
|
||||
engine.api.get_payload::<T>(current_fork, payload_id).await
|
||||
};
|
||||
|
||||
let (blob, payload) = tokio::join!(blob_fut, payload_fut);
|
||||
let payload = payload.map(|full_payload| {
|
||||
if full_payload.fee_recipient() != suggested_fee_recipient {
|
||||
@@ -1030,7 +1069,7 @@ impl<T: EthSpec> ExecutionLayer<T> {
|
||||
|
||||
let result = self
|
||||
.engine()
|
||||
.request(|engine| engine.api.new_payload_v1(execution_payload.clone()))
|
||||
.request(|engine| engine.api.new_payload(execution_payload.clone()))
|
||||
.await;
|
||||
|
||||
if let Ok(status) = &result {
|
||||
@@ -1160,7 +1199,7 @@ impl<T: EthSpec> ExecutionLayer<T> {
|
||||
}
|
||||
}
|
||||
|
||||
let forkchoice_state = ForkChoiceState {
|
||||
let forkchoice_state = ForkchoiceState {
|
||||
head_block_hash,
|
||||
safe_block_hash: justified_block_hash,
|
||||
finalized_block_hash,
|
||||
|
||||
Reference in New Issue
Block a user