Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement EIP 6110 #5532

Closed
wants to merge 62 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
51a07b0
add `deposit_receipts`
kevinbogner Mar 16, 2023
a0157f4
modify `ExecutionPayloadHeader`& `BeaconState`
kevinbogner Mar 16, 2023
57afc5e
add `process_deposit_receipt`&`process_operations`
kevinbogner Mar 17, 2023
b20fa95
update `process_deposit_receipt`
kevinbogner Mar 19, 2023
541ff94
finish `process_deposit_receipt`
kevinbogner Mar 20, 2023
37adbf0
mod. `process_operations` and `payload.rs`
kevinbogner Mar 20, 2023
81b0db6
modify `initialize_beacon_state_from_eth1`
kevinbogner Mar 20, 2023
ef699e3
fix `consensus-spec-tests`
kevinbogner Mar 23, 2023
cf6aefb
cargo fmt
kevinbogner Mar 23, 2023
824d40d
Decouple `Eip6110` and `Eip4844`
kevinbogner Mar 28, 2023
bb983bb
minor fixes
kevinbogner Mar 28, 2023
30c8cea
minor fixes
kevinbogner Mar 29, 2023
1369a29
remove tests for `Eip6110` for now
kevinbogner Mar 29, 2023
ffd03f8
clippy
kevinbogner Mar 30, 2023
d255634
fix Makefile
kevinbogner Mar 30, 2023
38f8b54
`V4` -> `V6110`
kevinbogner Apr 3, 2023
f733a23
Fix `JsonPayloadAttributes`
kevinbogner Apr 10, 2023
6bc054b
add consensus-spec-tests of `deposit_receipt`
kevinbogner Apr 11, 2023
850988c
fmt and clippy :<
kevinbogner Apr 11, 2023
d2731f0
minor fix
kevinbogner Apr 12, 2023
f5c97fd
cargo fmt
kevinbogner Apr 12, 2023
c5e5e85
fix `operations_deposit_receipt` test
kevinbogner Apr 12, 2023
5db79a9
cleanup
kevinbogner Apr 14, 2023
8c3f0d3
cargo fmt
kevinbogner Apr 14, 2023
5070add
add `apply_deposit()`
kevinbogner Apr 14, 2023
732326e
minor fix
kevinbogner Apr 14, 2023
d77f51b
clippy
kevinbogner Apr 14, 2023
96a4f36
fmt...
kevinbogner Apr 14, 2023
042e660
cleanup
kevinbogner Apr 16, 2023
40f5897
clippy
kevinbogner Apr 16, 2023
c96d79d
add `upgrade_to_eip6110`
kevinbogner Apr 24, 2023
c6a8c07
Merge remote-tracking branch 'upstream/eip4844' into eip6110-deneb
kevinbogner May 1, 2023
e534391
minor fix
kevinbogner May 1, 2023
8068c14
fix `config.yaml`
kevinbogner May 2, 2023
8cb5ce7
add `$h:block`
kevinbogner May 3, 2023
875d834
add `deposit_receipts` to `ExecutionPayloadBodyV1`
kevinbogner May 3, 2023
b9ea79a
fix `process_operations`
kevinbogner May 3, 2023
a6782af
`deposit_receipts` -> `deposit_receipts_root`
kevinbogner May 4, 2023
b451305
`deposit_receipts_root` -> `deposit_receipts`
kevinbogner May 8, 2023
8f3e8f5
minor fixes
kevinbogner May 15, 2023
b0ae043
Merged `deneb-free-blobs` into `eip6110-deneb`
kevinbogner May 18, 2023
6495fc1
Merge deneb-free-blobs into eip6110-deneb
kevinbogner May 18, 2023
61e5be8
Various bug fixes and improvements
kevinbogner May 19, 2023
197f82f
activate `process_deposit_receipt` at 6110
kevinbogner May 25, 2023
33cd27a
fix to call `newPayloadV6110`
kevinbogner May 29, 2023
be3f310
add `new_payload_v6110`
kevinbogner Jun 1, 2023
c3e4edd
Merge branch deneb-free-blobs into eip6110-deneb
kevinbogner Jun 3, 2023
8d00bac
Refactor: Swap quoted_u64 source
kevinbogner Jun 3, 2023
9e26fd7
more refactoring
kevinbogner Jun 3, 2023
9b99c9e
clippy
kevinbogner Jun 3, 2023
40dc77d
add 6110 to topics, remove `apply_deposit`
kevinbogner Jun 5, 2023
701e534
Fixed `process_operations` for EIP-6110
kevinbogner Jun 7, 2023
886df78
fix clippy
kevinbogner Jun 22, 2023
2c8984a
fix `apply_deposit`
kevinbogner Jun 23, 2023
35fa50e
fix `single_block_lookup_request` disable Eth1Data
kevinbogner Jul 3, 2023
d1e4891
Merge branch 'unstable' into eip6110-deneb
pawanjay176 Apr 5, 2024
bf5b720
Fix issues from merge
pawanjay176 Apr 6, 2024
ce0e4f0
Merge branch 'unstable' into eip6110
pawanjay176 Apr 15, 2024
3a61bd3
Remove more instances of 6110
pawanjay176 Apr 17, 2024
699ea14
Fix superstruct issues
pawanjay176 Apr 17, 2024
1e55276
More compilation fixes
pawanjay176 Apr 17, 2024
07bee4a
Fix ef tests compilation
pawanjay176 Apr 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
766 changes: 416 additions & 350 deletions Cargo.lock

Large diffs are not rendered by default.

80 changes: 49 additions & 31 deletions beacon_node/execution_layer/src/engine_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use crate::engines::ForkchoiceState;
use crate::http::{
ENGINE_FORKCHOICE_UPDATED_V1, ENGINE_FORKCHOICE_UPDATED_V2, ENGINE_FORKCHOICE_UPDATED_V3,
ENGINE_GET_PAYLOAD_BODIES_BY_HASH_V1, ENGINE_GET_PAYLOAD_BODIES_BY_RANGE_V1,
ENGINE_GET_PAYLOAD_V1, ENGINE_GET_PAYLOAD_V2, ENGINE_GET_PAYLOAD_V3, ENGINE_NEW_PAYLOAD_V1,
ENGINE_NEW_PAYLOAD_V2, ENGINE_NEW_PAYLOAD_V3,
ENGINE_GET_PAYLOAD_V1, ENGINE_GET_PAYLOAD_V2, ENGINE_GET_PAYLOAD_V3, ENGINE_GET_PAYLOAD_V4,
ENGINE_NEW_PAYLOAD_V1, ENGINE_NEW_PAYLOAD_V2, ENGINE_NEW_PAYLOAD_V3, ENGINE_NEW_PAYLOAD_V4,
};
use eth2::types::{
BlobsBundle, SsePayloadAttributes, SsePayloadAttributesV1, SsePayloadAttributesV2,
Expand All @@ -13,16 +13,16 @@ use ethers_core::types::Transaction;
use ethers_core::utils::rlp;
use ethers_core::utils::rlp::{Decodable, Rlp};
use http::deposit_methods::RpcError;
pub use json_structures::{JsonWithdrawal, TransitionConfigurationV1};
pub use json_structures::{JsonDepositReceipt, JsonWithdrawal, TransitionConfigurationV1};
use pretty_reqwest_error::PrettyReqwestError;
use reqwest::StatusCode;
use serde::{Deserialize, Serialize};
use strum::IntoStaticStr;
use superstruct::superstruct;
pub use types::{
Address, BeaconBlockRef, EthSpec, ExecutionBlockHash, ExecutionPayload, ExecutionPayloadHeader,
ExecutionPayloadRef, FixedVector, ForkName, Hash256, Transactions, Uint256, VariableList,
Withdrawal, Withdrawals,
Address, BeaconBlockRef, DepositReceipts, EthSpec, ExecutionBlockHash, ExecutionPayload,
ExecutionPayloadHeader, ExecutionPayloadRef, FixedVector, ForkName, Hash256, Transactions,
Uint256, VariableList, Withdrawal, Withdrawals,
};

use types::{
Expand Down Expand Up @@ -64,6 +64,7 @@ pub enum Error {
PayloadConversionLogicFlaw,
SszError(ssz_types::Error),
DeserializeWithdrawals(ssz_types::Error),
DeserializeDepositReceipts(ssz_types::Error),
BuilderApi(builder_client::Error),
IncorrectStateVariant,
RequiredMethodUnsupported(&'static str),
Expand Down Expand Up @@ -197,6 +198,8 @@ pub struct ExecutionBlockWithTransactions<E: EthSpec> {
#[superstruct(only(Deneb, Electra))]
#[serde(with = "serde_utils::u64_hex_be")]
pub excess_blob_gas: u64,
#[superstruct(only(Electra))]
pub deposit_receipts: Vec<JsonDepositReceipt>,
}

impl<E: EthSpec> TryFrom<ExecutionPayload<E>> for ExecutionBlockWithTransactions<E> {
Expand Down Expand Up @@ -302,6 +305,10 @@ impl<E: EthSpec> TryFrom<ExecutionPayload<E>> for ExecutionBlockWithTransactions
.collect(),
blob_gas_used: block.blob_gas_used,
excess_blob_gas: block.excess_blob_gas,
deposit_receipts: Vec::from(block.deposit_receipts)
.into_iter()
.map(|deposit_receipt| deposit_receipt.into())
.collect(),
})
}
};
Expand Down Expand Up @@ -521,6 +528,7 @@ impl<E: EthSpec> GetPayloadResponse<E> {
pub struct ExecutionPayloadBodyV1<E: EthSpec> {
pub transactions: Transactions<E>,
pub withdrawals: Option<Withdrawals<E>>,
pub deposit_receipts: Option<DepositReceipts<E>>,
}

impl<E: EthSpec> ExecutionPayloadBodyV1<E> {
Expand Down Expand Up @@ -608,32 +616,34 @@ impl<E: EthSpec> ExecutionPayloadBodyV1<E> {
}
}
ExecutionPayloadHeader::Electra(header) => {
if let Some(withdrawals) = self.withdrawals {
Ok(ExecutionPayload::Electra(ExecutionPayloadElectra {
parent_hash: header.parent_hash,
fee_recipient: header.fee_recipient,
state_root: header.state_root,
receipts_root: header.receipts_root,
logs_bloom: header.logs_bloom,
prev_randao: header.prev_randao,
block_number: header.block_number,
gas_limit: header.gas_limit,
gas_used: header.gas_used,
timestamp: header.timestamp,
extra_data: header.extra_data,
base_fee_per_gas: header.base_fee_per_gas,
block_hash: header.block_hash,
transactions: self.transactions,
withdrawals,
blob_gas_used: header.blob_gas_used,
excess_blob_gas: header.excess_blob_gas,
}))
} else {
Err(format!(
"block {} is post-capella but payload body doesn't have withdrawals",
let (Some(withdrawals), Some(deposit_receipts)) =
(self.withdrawals, self.deposit_receipts)
else {
return Err(format!(
"block {} is post-capella but payload body doesn't have withdrawals/deposit_receipts",
header.block_hash
))
}
));
};
Ok(ExecutionPayload::Electra(ExecutionPayloadElectra {
parent_hash: header.parent_hash,
fee_recipient: header.fee_recipient,
state_root: header.state_root,
receipts_root: header.receipts_root,
logs_bloom: header.logs_bloom,
prev_randao: header.prev_randao,
block_number: header.block_number,
gas_limit: header.gas_limit,
gas_used: header.gas_used,
timestamp: header.timestamp,
extra_data: header.extra_data,
base_fee_per_gas: header.base_fee_per_gas,
block_hash: header.block_hash,
transactions: self.transactions,
withdrawals,
blob_gas_used: header.blob_gas_used,
excess_blob_gas: header.excess_blob_gas,
deposit_receipts,
}))
}
}
}
Expand All @@ -644,6 +654,7 @@ pub struct EngineCapabilities {
pub new_payload_v1: bool,
pub new_payload_v2: bool,
pub new_payload_v3: bool,
pub new_payload_v4: bool,
pub forkchoice_updated_v1: bool,
pub forkchoice_updated_v2: bool,
pub forkchoice_updated_v3: bool,
Expand All @@ -652,6 +663,7 @@ pub struct EngineCapabilities {
pub get_payload_v1: bool,
pub get_payload_v2: bool,
pub get_payload_v3: bool,
pub get_payload_v4: bool,
}

impl EngineCapabilities {
Expand All @@ -666,6 +678,9 @@ impl EngineCapabilities {
if self.new_payload_v3 {
response.push(ENGINE_NEW_PAYLOAD_V3);
}
if self.new_payload_v4 {
response.push(ENGINE_NEW_PAYLOAD_V4);
}
if self.forkchoice_updated_v1 {
response.push(ENGINE_FORKCHOICE_UPDATED_V1);
}
Expand All @@ -690,6 +705,9 @@ impl EngineCapabilities {
if self.get_payload_v3 {
response.push(ENGINE_GET_PAYLOAD_V3);
}
if self.get_payload_v4 {
response.push(ENGINE_GET_PAYLOAD_V4);
}

response
}
Expand Down
85 changes: 74 additions & 11 deletions beacon_node/execution_layer/src/engine_api/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ pub const ETH_SYNCING_TIMEOUT: Duration = Duration::from_secs(1);
pub const ENGINE_NEW_PAYLOAD_V1: &str = "engine_newPayloadV1";
pub const ENGINE_NEW_PAYLOAD_V2: &str = "engine_newPayloadV2";
pub const ENGINE_NEW_PAYLOAD_V3: &str = "engine_newPayloadV3";
pub const ENGINE_NEW_PAYLOAD_V4: &str = "engine_newPayloadV4";
pub const ENGINE_NEW_PAYLOAD_TIMEOUT: Duration = Duration::from_secs(8);

pub const ENGINE_GET_PAYLOAD_V1: &str = "engine_getPayloadV1";
pub const ENGINE_GET_PAYLOAD_V2: &str = "engine_getPayloadV2";
pub const ENGINE_GET_PAYLOAD_V3: &str = "engine_getPayloadV3";
pub const ENGINE_GET_PAYLOAD_V4: &str = "engine_getPayloadV4";
pub const ENGINE_GET_PAYLOAD_TIMEOUT: Duration = Duration::from_secs(2);

pub const ENGINE_FORKCHOICE_UPDATED_V1: &str = "engine_forkchoiceUpdatedV1";
Expand All @@ -61,9 +63,11 @@ pub static LIGHTHOUSE_CAPABILITIES: &[&str] = &[
ENGINE_NEW_PAYLOAD_V1,
ENGINE_NEW_PAYLOAD_V2,
ENGINE_NEW_PAYLOAD_V3,
ENGINE_NEW_PAYLOAD_V4,
ENGINE_GET_PAYLOAD_V1,
ENGINE_GET_PAYLOAD_V2,
ENGINE_GET_PAYLOAD_V3,
ENGINE_GET_PAYLOAD_V4,
ENGINE_FORKCHOICE_UPDATED_V1,
ENGINE_FORKCHOICE_UPDATED_V2,
ENGINE_FORKCHOICE_UPDATED_V3,
Expand Down Expand Up @@ -812,7 +816,7 @@ impl HttpJsonRpc {
Ok(response.into())
}

pub async fn new_payload_v3_electra<E: EthSpec>(
pub async fn new_payload_v4_electra<E: EthSpec>(
&self,
new_payload_request_electra: NewPayloadRequestElectra<'_, E>,
) -> Result<PayloadStatusV1, Error> {
Expand All @@ -824,7 +828,7 @@ impl HttpJsonRpc {

let response: JsonPayloadStatusV1 = self
.rpc_request(
ENGINE_NEW_PAYLOAD_V3,
ENGINE_NEW_PAYLOAD_V4,
params,
ENGINE_NEW_PAYLOAD_TIMEOUT * self.execution_timeout_multiplier,
)
Expand Down Expand Up @@ -908,19 +912,69 @@ impl HttpJsonRpc {
.await?;
Ok(JsonGetPayloadResponse::V3(response).into())
}
ForkName::Electra => {
let response: JsonGetPayloadResponseV4<E> = self
ForkName::Base
| ForkName::Altair
| ForkName::Capella
| ForkName::Merge
| ForkName::Electra => Err(Error::UnsupportedForkVariant(format!(
"called get_payload_v3 with {}",
fork_name
))),
}
}

pub async fn get_payload_v4<T: EthSpec>(
&self,
fork_name: ForkName,
payload_id: PayloadId,
) -> Result<GetPayloadResponse<T>, Error> {
let params = json!([JsonPayloadIdRequest::from(payload_id)]);

match fork_name {
ForkName::Merge => {
let response: JsonGetPayloadResponseV1<T> = self
.rpc_request(
ENGINE_GET_PAYLOAD_V2,
params,
ENGINE_GET_PAYLOAD_TIMEOUT * self.execution_timeout_multiplier,
)
.await?;
Ok(JsonGetPayloadResponse::V1(response).into())
}
ForkName::Capella => {
let response: JsonGetPayloadResponseV2<T> = self
.rpc_request(
ENGINE_GET_PAYLOAD_V2,
params,
ENGINE_GET_PAYLOAD_TIMEOUT * self.execution_timeout_multiplier,
)
.await?;
Ok(JsonGetPayloadResponse::V2(response).into())
}
ForkName::Deneb => {
let response: JsonGetPayloadResponseV3<T> = self
.rpc_request(
ENGINE_GET_PAYLOAD_V3,
params,
ENGINE_GET_PAYLOAD_TIMEOUT * self.execution_timeout_multiplier,
)
.await?;
Ok(JsonGetPayloadResponse::V3(response).into())
}
ForkName::Electra => {
let response: JsonGetPayloadResponseV4<T> = self
.rpc_request(
ENGINE_GET_PAYLOAD_V4,
params,
ENGINE_GET_PAYLOAD_TIMEOUT * self.execution_timeout_multiplier,
)
.await?;
Ok(JsonGetPayloadResponse::V4(response).into())
}
ForkName::Base | ForkName::Altair | ForkName::Merge | ForkName::Capella => Err(
Error::UnsupportedForkVariant(format!("called get_payload_v3 with {}", fork_name)),
),
ForkName::Base | ForkName::Altair => Err(Error::UnsupportedForkVariant(format!(
"called get_payload_v4 with {}",
fork_name
))),
}
}

Expand Down Expand Up @@ -1046,6 +1100,7 @@ impl HttpJsonRpc {
new_payload_v1: capabilities.contains(ENGINE_NEW_PAYLOAD_V1),
new_payload_v2: capabilities.contains(ENGINE_NEW_PAYLOAD_V2),
new_payload_v3: capabilities.contains(ENGINE_NEW_PAYLOAD_V3),
new_payload_v4: capabilities.contains(ENGINE_NEW_PAYLOAD_V4),
forkchoice_updated_v1: capabilities.contains(ENGINE_FORKCHOICE_UPDATED_V1),
forkchoice_updated_v2: capabilities.contains(ENGINE_FORKCHOICE_UPDATED_V2),
forkchoice_updated_v3: capabilities.contains(ENGINE_FORKCHOICE_UPDATED_V3),
Expand All @@ -1056,6 +1111,7 @@ impl HttpJsonRpc {
get_payload_v1: capabilities.contains(ENGINE_GET_PAYLOAD_V1),
get_payload_v2: capabilities.contains(ENGINE_GET_PAYLOAD_V2),
get_payload_v3: capabilities.contains(ENGINE_GET_PAYLOAD_V3),
get_payload_v4: capabilities.contains(ENGINE_GET_PAYLOAD_V4),
})
}

Expand Down Expand Up @@ -1114,11 +1170,11 @@ impl HttpJsonRpc {
}
}
NewPayloadRequest::Electra(new_payload_request_electra) => {
if engine_capabilities.new_payload_v3 {
self.new_payload_v3_electra(new_payload_request_electra)
if engine_capabilities.new_payload_v4 {
self.new_payload_v4_electra(new_payload_request_electra)
.await
} else {
Err(Error::RequiredMethodUnsupported("engine_newPayloadV3"))
Err(Error::RequiredMethodUnsupported("engine_newPayloadV4"))
}
}
}
Expand All @@ -1142,13 +1198,20 @@ impl HttpJsonRpc {
Err(Error::RequiredMethodUnsupported("engine_getPayload"))
}
}
ForkName::Deneb | ForkName::Electra => {
ForkName::Deneb => {
if engine_capabilities.get_payload_v3 {
self.get_payload_v3(fork_name, payload_id).await
} else {
Err(Error::RequiredMethodUnsupported("engine_getPayloadV3"))
}
}
ForkName::Electra => {
if engine_capabilities.get_payload_v4 {
self.get_payload_v4(fork_name, payload_id).await
} else {
Err(Error::RequiredMethodUnsupported("engine_getPayloadV3"))
}
}
ForkName::Base | ForkName::Altair => Err(Error::UnsupportedForkVariant(format!(
"called get_payload with {}",
fork_name
Expand Down
Loading
Loading