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

[EIP-6110 | Deneb] In-Protocol deposits PoC #3

Open
wants to merge 55 commits into
base: deneb-free-blobs
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 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
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
3 changes: 2 additions & 1 deletion beacon_node/beacon_chain/src/beacon_block_streamer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use execution_layer::{ExecutionLayer, ExecutionPayloadBodyV1};
use slog::{crit, debug, Logger};
use std::collections::HashMap;
use std::sync::Arc;
use store::{DatabaseBlock, ExecutionPayloadDeneb};
use store::{DatabaseBlock, ExecutionPayloadDeneb, ExecutionPayloadEip6110};
use task_executor::TaskExecutor;
use tokio::sync::{
mpsc::{self, UnboundedSender},
Expand Down Expand Up @@ -98,6 +98,7 @@ fn reconstruct_default_header_block<E: EthSpec>(
ForkName::Merge => ExecutionPayloadMerge::default().into(),
ForkName::Capella => ExecutionPayloadCapella::default().into(),
ForkName::Deneb => ExecutionPayloadDeneb::default().into(),
ForkName::Eip6110 => ExecutionPayloadEip6110::default().into(),
ForkName::Base | ForkName::Altair => {
return Err(Error::PayloadReconstruction(format!(
"Block with fork variant {} has execution payload",
Expand Down
40 changes: 38 additions & 2 deletions beacon_node/beacon_chain/src/beacon_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4515,7 +4515,10 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
// allows it to run concurrently with things like attestation packing.
let prepare_payload_handle = match &state {
BeaconState::Base(_) | BeaconState::Altair(_) => None,
BeaconState::Merge(_) | BeaconState::Capella(_) | BeaconState::Deneb(_) => {
BeaconState::Merge(_)
| BeaconState::Capella(_)
| BeaconState::Deneb(_)
| BeaconState::Eip6110(_) => {
let prepare_payload_handle =
get_execution_payload(self.clone(), &state, proposer_index, builder_params)?;
Some(prepare_payload_handle)
Expand Down Expand Up @@ -4860,6 +4863,39 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
proofs,
)
}
BeaconState::Eip6110(_) => {
let (payload, kzg_commitments, blobs, proofs) = block_contents
.ok_or(BlockProductionError::MissingExecutionPayload)?
.deconstruct();
(
BeaconBlock::Eip6110(BeaconBlockEip6110 {
slot,
proposer_index,
parent_root,
state_root: Hash256::zero(),
body: BeaconBlockBodyEip6110 {
randao_reveal,
eth1_data,
graffiti,
proposer_slashings: proposer_slashings.into(),
attester_slashings: attester_slashings.into(),
attestations: attestations.into(),
deposits: deposits.into(),
voluntary_exits: voluntary_exits.into(),
sync_aggregate: sync_aggregate
.ok_or(BlockProductionError::MissingSyncAggregate)?,
execution_payload: payload
.try_into()
.map_err(|_| BlockProductionError::InvalidPayloadFork)?,
bls_to_execution_changes: bls_to_execution_changes.into(),
blob_kzg_commitments: kzg_commitments
.ok_or(BlockProductionError::InvalidPayloadFork)?,
},
}),
blobs,
proofs,
)
}
};

let block = SignedBeaconBlock::from_block(
Expand Down Expand Up @@ -5221,7 +5257,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
} else {
let withdrawals = match self.spec.fork_name_at_slot::<T::EthSpec>(prepare_slot) {
ForkName::Base | ForkName::Altair | ForkName::Merge => None,
ForkName::Capella | ForkName::Deneb => {
ForkName::Capella | ForkName::Deneb | ForkName::Eip6110 => {
let chain = self.clone();
self.spawn_blocking_handle(
move || {
Expand Down
2 changes: 1 addition & 1 deletion beacon_node/beacon_chain/src/execution_payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ pub fn get_execution_payload<
let latest_execution_payload_header_block_hash =
state.latest_execution_payload_header()?.block_hash();
let withdrawals = match state {
&BeaconState::Capella(_) | &BeaconState::Deneb(_) => {
&BeaconState::Capella(_) | &BeaconState::Deneb(_) | &BeaconState::Eip6110(_) => {
Some(get_expected_withdrawals(state, spec)?.into())
}
&BeaconState::Merge(_) => None,
Expand Down
10 changes: 9 additions & 1 deletion beacon_node/beacon_chain/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,9 @@ where
let deneb_time = spec.deneb_fork_epoch.map(|epoch| {
HARNESS_GENESIS_TIME + spec.seconds_per_slot * E::slots_per_epoch() * epoch.as_u64()
});
let eip6110_time = spec.eip6110_fork_epoch.map(|epoch| {
HARNESS_GENESIS_TIME + spec.seconds_per_slot * E::slots_per_epoch() * epoch.as_u64()
});

let trusted_setup: TrustedSetup =
serde_json::from_reader(eth2_network_config::TRUSTED_SETUP)
Expand All @@ -462,6 +465,7 @@ where
DEFAULT_TERMINAL_BLOCK,
shanghai_time,
deneb_time,
eip6110_time,
None,
Some(JwtKey::from_slice(&DEFAULT_JWT_SECRET).unwrap()),
spec,
Expand Down Expand Up @@ -489,6 +493,9 @@ where
let deneb_time = spec.deneb_fork_epoch.map(|epoch| {
HARNESS_GENESIS_TIME + spec.seconds_per_slot * E::slots_per_epoch() * epoch.as_u64()
});
let eip6110_time = spec.eip6110_fork_epoch.map(|epoch| {
HARNESS_GENESIS_TIME + spec.seconds_per_slot * E::slots_per_epoch() * epoch.as_u64()
});
let trusted_setup: TrustedSetup =
serde_json::from_reader(eth2_network_config::TRUSTED_SETUP)
.map_err(|e| format!("Unable to read trusted setup file: {}", e))
Expand All @@ -499,6 +506,7 @@ where
DEFAULT_TERMINAL_BLOCK,
shanghai_time,
deneb_time,
eip6110_time,
builder_threshold,
Some(JwtKey::from_slice(&DEFAULT_JWT_SECRET).unwrap()),
spec.clone(),
Expand Down Expand Up @@ -819,7 +827,7 @@ where
| SignedBeaconBlock::Altair(_)
| SignedBeaconBlock::Merge(_)
| SignedBeaconBlock::Capella(_) => (signed_block, None),
SignedBeaconBlock::Deneb(_) => {
SignedBeaconBlock::Deneb(_) | SignedBeaconBlock::Eip6110(_) => {
if let Some(blobs) = self
.chain
.proposal_blob_cache
Expand Down
106 changes: 95 additions & 11 deletions beacon_node/execution_layer/src/engine_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ use crate::http::{
ENGINE_EXCHANGE_TRANSITION_CONFIGURATION_V1, ENGINE_FORKCHOICE_UPDATED_V1,
ENGINE_FORKCHOICE_UPDATED_V2, 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_V3, ENGINE_GET_PAYLOAD_V6110, ENGINE_NEW_PAYLOAD_V1, ENGINE_NEW_PAYLOAD_V2,
ENGINE_NEW_PAYLOAD_V3, ENGINE_NEW_PAYLOAD_V6110,
};
use crate::BlobTxConversionError;
use eth2::types::{SsePayloadAttributes, SsePayloadAttributesV1, SsePayloadAttributesV2};
pub use ethers_core::types::Transaction;
use ethers_core::utils::rlp::{self, Decodable, Rlp};
use http::deposit_methods::RpcError;
pub use json_structures::{JsonWithdrawal, TransitionConfigurationV1};
pub use json_structures::{JsonDepositReceipt, JsonWithdrawal, TransitionConfigurationV1};
use reqwest::StatusCode;
use serde::{Deserialize, Serialize};
use std::convert::TryFrom;
Expand All @@ -19,11 +20,14 @@ use superstruct::superstruct;
use types::beacon_block_body::KzgCommitments;
use types::blob_sidecar::Blobs;
pub use types::{
Address, EthSpec, ExecutionBlockHash, ExecutionPayload, ExecutionPayloadHeader,
ExecutionPayloadRef, FixedVector, ForkName, Hash256, Transactions, Uint256, VariableList,
Withdrawal, Withdrawals,
Address, DepositReceipt, DepositReceipts, EthSpec, ExecutionBlockHash, ExecutionPayload,
ExecutionPayloadHeader, ExecutionPayloadRef, FixedVector, ForkName, Hash256, Transactions,
Uint256, VariableList, Withdrawal, Withdrawals,
};
use types::{
ExecutionPayloadCapella, ExecutionPayloadDeneb, ExecutionPayloadEip6110, ExecutionPayloadMerge,
KzgProofs,
};
use types::{ExecutionPayloadCapella, ExecutionPayloadDeneb, ExecutionPayloadMerge, KzgProofs};

pub mod auth;
pub mod http;
Expand Down Expand Up @@ -53,6 +57,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 @@ -152,7 +157,7 @@ pub struct ExecutionBlock {

/// Representation of an execution block with enough detail to reconstruct a payload.
#[superstruct(
variants(Merge, Capella, Deneb),
variants(Merge, Capella, Deneb, Eip6110),
variant_attributes(
derive(Clone, Debug, PartialEq, Serialize, Deserialize,),
serde(bound = "T: EthSpec", rename_all = "camelCase"),
Expand Down Expand Up @@ -186,11 +191,13 @@ pub struct ExecutionBlockWithTransactions<T: EthSpec> {
#[serde(rename = "hash")]
pub block_hash: ExecutionBlockHash,
pub transactions: Vec<Transaction>,
#[superstruct(only(Capella, Deneb))]
#[superstruct(only(Capella, Deneb, Eip6110))]
pub withdrawals: Vec<JsonWithdrawal>,
#[superstruct(only(Deneb))]
#[superstruct(only(Deneb, Eip6110))]
#[serde(with = "serde_utils::u256_hex_be")]
pub excess_data_gas: Uint256,
#[superstruct(only(Eip6110))]
pub deposit_receipts: Vec<JsonDepositReceipt>,
}

impl<T: EthSpec> TryFrom<ExecutionPayload<T>> for ExecutionBlockWithTransactions<T> {
Expand Down Expand Up @@ -269,6 +276,37 @@ impl<T: EthSpec> TryFrom<ExecutionPayload<T>> for ExecutionBlockWithTransactions
.collect(),
excess_data_gas: block.excess_data_gas,
}),
ExecutionPayload::Eip6110(block) => {
Self::Eip6110(ExecutionBlockWithTransactionsEip6110 {
parent_hash: block.parent_hash,
fee_recipient: block.fee_recipient,
state_root: block.state_root,
receipts_root: block.receipts_root,
logs_bloom: block.logs_bloom,
prev_randao: block.prev_randao,
block_number: block.block_number,
gas_limit: block.gas_limit,
gas_used: block.gas_used,
timestamp: block.timestamp,
extra_data: block.extra_data,
base_fee_per_gas: block.base_fee_per_gas,
block_hash: block.block_hash,
transactions: block
.transactions
.iter()
.map(|tx| Transaction::decode(&Rlp::new(tx)))
.collect::<Result<Vec<_>, _>>()?,
withdrawals: Vec::from(block.withdrawals)
.into_iter()
.map(|withdrawal| withdrawal.into())
.collect(),
excess_data_gas: block.excess_data_gas,
deposit_receipts: Vec::from(block.deposit_receipts)
.into_iter()
.map(|deposit_receipt| deposit_receipt.into())
.collect(),
})
}
};
Ok(json_payload)
}
Expand Down Expand Up @@ -363,7 +401,7 @@ pub struct ProposeBlindedBlockResponse {
}

#[superstruct(
variants(Merge, Capella, Deneb),
variants(Merge, Capella, Deneb, Eip6110),
variant_attributes(derive(Clone, Debug, PartialEq),),
map_into(ExecutionPayload),
map_ref_into(ExecutionPayloadRef),
Expand All @@ -378,8 +416,10 @@ pub struct GetPayloadResponse<T: EthSpec> {
pub execution_payload: ExecutionPayloadCapella<T>,
#[superstruct(only(Deneb), partial_getter(rename = "execution_payload_deneb"))]
pub execution_payload: ExecutionPayloadDeneb<T>,
#[superstruct(only(Eip6110), partial_getter(rename = "execution_payload_eip6110"))]
pub execution_payload: ExecutionPayloadEip6110<T>,
pub block_value: Uint256,
#[superstruct(only(Deneb))]
#[superstruct(only(Deneb, Eip6110))]
pub blobs_bundle: BlobsBundleV1<T>,
}

Expand Down Expand Up @@ -419,6 +459,11 @@ impl<T: EthSpec> From<GetPayloadResponse<T>>
inner.block_value,
Some(inner.blobs_bundle),
),
GetPayloadResponse::Eip6110(inner) => (
ExecutionPayload::Eip6110(inner.execution_payload),
inner.block_value,
Some(inner.blobs_bundle),
),
}
}
}
Expand All @@ -433,6 +478,7 @@ impl<T: EthSpec> GetPayloadResponse<T> {
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 @@ -518,6 +564,36 @@ impl<E: EthSpec> ExecutionPayloadBodyV1<E> {
))
}
}
ExecutionPayloadHeader::Eip6110(header) => {
if let (Some(withdrawals), Some(deposit_receipts)) =
(self.withdrawals, self.deposit_receipts)
{
Ok(ExecutionPayload::Eip6110(ExecutionPayloadEip6110 {
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,
excess_data_gas: header.excess_data_gas,
deposit_receipts,
}))
} else {
Err(format!(
"block {} is eip6110 but payload body doesn't have withdrawals and deposit_receipts",
header.block_hash
))
}
}
}
}
}
Expand All @@ -534,13 +610,15 @@ pub struct EngineCapabilities {
pub new_payload_v1: bool,
pub new_payload_v2: bool,
pub new_payload_v3: bool,
pub new_payload_v6110: bool,
pub forkchoice_updated_v1: bool,
pub forkchoice_updated_v2: bool,
pub get_payload_bodies_by_hash_v1: bool,
pub get_payload_bodies_by_range_v1: bool,
pub get_payload_v1: bool,
pub get_payload_v2: bool,
pub get_payload_v3: bool,
pub get_payload_v6110: bool,
pub exchange_transition_configuration_v1: bool,
}

Expand All @@ -556,6 +634,9 @@ impl EngineCapabilities {
if self.new_payload_v3 {
response.push(ENGINE_NEW_PAYLOAD_V3);
}
if self.new_payload_v6110 {
response.push(ENGINE_NEW_PAYLOAD_V6110);
}
if self.forkchoice_updated_v1 {
response.push(ENGINE_FORKCHOICE_UPDATED_V1);
}
Expand All @@ -577,6 +658,9 @@ impl EngineCapabilities {
if self.get_payload_v3 {
response.push(ENGINE_GET_PAYLOAD_V3);
}
if self.get_payload_v6110 {
response.push(ENGINE_GET_PAYLOAD_V6110);
}
if self.exchange_transition_configuration_v1 {
response.push(ENGINE_EXCHANGE_TRANSITION_CONFIGURATION_V1);
}
Expand Down
Loading