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

Electra engine api #5743

Merged
merged 190 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from 188 commits
Commits
Show all changes
190 commits
Select commit Hold shift + click to select a range
3b7132b
Attestation superstruct changes for EIP 7549 (#5644)
eserilev Apr 30, 2024
e6c7f14
`superstruct` the `AttesterSlashing` (#5636)
ethDreamer May 2, 2024
3a41e13
Merge remote-tracking branch 'upstream/unstable' into electra_attesta…
ethDreamer May 2, 2024
9b98f4e
Make EF Tests Fork-Agnostic (#5713)
ethDreamer May 3, 2024
7c6526d
Finish EF Test Fork Agnostic (#5714)
ethDreamer May 3, 2024
19a9479
Superstruct `AggregateAndProof` (#5715)
ethDreamer May 6, 2024
9f6de8e
Merge remote-tracking branch 'sigp/unstable' into electra_attestation…
realbigsean May 6, 2024
38382a3
cargo fmt
realbigsean May 6, 2024
2c2e44c
Merge pull request #5726 from realbigsean/electra_attestation_changes
realbigsean May 6, 2024
e2e82ff
process withdrawals updates
realbigsean May 6, 2024
e0abede
cleanup withdrawals processing
realbigsean May 7, 2024
f1f9f92
update `process_operations` deposit length check
realbigsean May 7, 2024
3c68841
add apply_deposit changes
realbigsean May 7, 2024
1d5f755
add execution layer withdrawal request processing
realbigsean May 7, 2024
32357d8
process deposit receipts
realbigsean May 7, 2024
c40bec9
add consolidation processing
realbigsean May 7, 2024
31955c2
update process operations function
realbigsean May 7, 2024
75ab913
exit updates
realbigsean May 7, 2024
5728f78
clean up
realbigsean May 7, 2024
8517236
update slash_validator
realbigsean May 7, 2024
90179d4
EIP7549 `get_attestation_indices` (#5657)
eserilev May 8, 2024
f30246b
Some small changes (#5739)
ethDreamer May 8, 2024
7c0a8f8
Merge branch 'electra_attestation_changes' of https://github.com/sigp…
realbigsean May 8, 2024
43c3f63
cargo fmt (#5740)
ethDreamer May 8, 2024
721e73f
Merge branch 'electra_attestation_changes' of https://github.com/sigp…
realbigsean May 8, 2024
7abb762
fix attestation verification
realbigsean May 8, 2024
42a4993
Add new engine api methods
pawanjay176 May 6, 2024
ca2a946
Fix the versioning of v4 requests
pawanjay176 May 7, 2024
1ddd078
Handle new engine api methods in mock EL
pawanjay176 May 7, 2024
3ef7c90
Note todo
pawanjay176 May 7, 2024
683de56
Fix todos
pawanjay176 May 8, 2024
dd5c9a8
Add support for electra fields in getPayloadBodies
pawanjay176 May 8, 2024
5e1d5ff
Add comments for potential versioning confusion
pawanjay176 May 8, 2024
7cb7653
Sketch op pool changes
michaelsproul May 9, 2024
e32dfcd
fix get attesting indices (#5742)
realbigsean May 9, 2024
3ea3d22
Merge branch 'electra_attestation_changes' of https://github.com/sigp…
realbigsean May 9, 2024
07229b7
Ef test fixes (#5753)
realbigsean May 9, 2024
36a559e
Merge branch 'electra_attestation_changes' of https://github.com/sigp…
realbigsean May 9, 2024
6fe919a
Merge branch 'block-processing-electra' of https://github.com/sigp/li…
realbigsean May 9, 2024
cb8c8f5
Fix Aggregation Pool for Electra (#5754)
ethDreamer May 9, 2024
c30f709
fix ssz (#5755)
realbigsean May 9, 2024
ab9e58a
Get `electra_op_pool` up to date (#5756)
ethDreamer May 9, 2024
ca09671
Revert "Get `electra_op_pool` up to date (#5756)" (#5757)
ethDreamer May 9, 2024
b807d39
Merge branch 'electra_attestation_changes' of https://github.com/sigp…
realbigsean May 9, 2024
19f8333
Merge branch 'electra_attestation_changes' of https://github.com/sigp…
realbigsean May 9, 2024
fae4a2b
Merge branch 'block-processing-electra' of https://github.com/sigp/li…
realbigsean May 9, 2024
411fcee
Compute on chain aggregate impl (#5752)
eserilev May 10, 2024
e448557
update the naive agg pool interface (#5760)
realbigsean May 10, 2024
aa83e8b
Merge branch 'electra_attestation_changes' of https://github.com/sigp…
realbigsean May 10, 2024
9b5ea9d
Merge branch 'block-processing-electra' of https://github.com/sigp/li…
realbigsean May 10, 2024
437e851
Fix bugs in cross-committee aggregation
michaelsproul May 10, 2024
16265ef
Add comment to max cover optimisation
michaelsproul May 10, 2024
72548cb
Fix assert
michaelsproul May 10, 2024
08e0458
Electra epoch processing
michaelsproul May 7, 2024
6d2c396
Merge branch 'electra-epoch-proc' of https://github.com/sigp/lighthou…
realbigsean May 10, 2024
7926afe
Merge pull request #5749 from sigp/electra_op_pool
realbigsean May 10, 2024
89e4de9
don't fail on empty consolidations
realbigsean May 10, 2024
f60eac6
Merge branch 'electra_attestation_changes' of https://github.com/sigp…
realbigsean May 10, 2024
677a94d
Merge branch 'block-processing-electra' of https://github.com/sigp/li…
realbigsean May 10, 2024
9bd430b
Merge branch 'electra-epoch-proc' of https://github.com/sigp/lighthou…
realbigsean May 10, 2024
e1dcfb6
update committee offset
realbigsean May 11, 2024
b819d2d
Merge branch 'electra_attestation_changes' of https://github.com/sigp…
realbigsean May 11, 2024
40c4c00
update committee offset
realbigsean May 11, 2024
5364ba5
update committee offset
realbigsean May 11, 2024
a97e86c
only increment the state deposit index on old deposit flow
realbigsean May 11, 2024
261551e
Merge branch 'block-processing-electra' of https://github.com/sigp/li…
realbigsean May 11, 2024
518a91a
Merge branch 'electra-epoch-proc' of https://github.com/sigp/lighthou…
realbigsean May 11, 2024
a75257f
use correct max eb in epoch cache initialization
realbigsean May 11, 2024
f4907ef
drop initiate validator ordering optimization
realbigsean May 11, 2024
75f22ee
fix initiate exit for single pass
realbigsean May 11, 2024
28cf796
Merge branch 'electra-epoch-proc' of https://github.com/sigp/lighthou…
realbigsean May 11, 2024
fc2c942
accept new payload v4 in mock el
realbigsean May 11, 2024
3b1fb0a
Fix Electra Fork Choice Tests (#5764)
ethDreamer May 12, 2024
af7ba6f
Fix Electra Fork Choice Tests (#5764)
ethDreamer May 12, 2024
aaf8e50
Fix Electra Fork Choice Tests (#5764)
ethDreamer May 12, 2024
c900a88
Merge branch 'electra_attestation_changes' of https://github.com/sigp…
realbigsean May 12, 2024
97e88dd
Merge branch 'block-processing-electra' of https://github.com/sigp/li…
realbigsean May 12, 2024
67ba04e
Merge branch 'electra-epoch-proc' of https://github.com/sigp/lighthou…
realbigsean May 12, 2024
217fa9f
Fix Consolidation Sigs & Withdrawals
ethDreamer May 12, 2024
793764f
Merge pull request #5766 from ethDreamer/two_fixes
realbigsean May 12, 2024
c53d4ac
Merge branches 'block-processing-electra' and 'electra-epoch-proc' of…
realbigsean May 12, 2024
5f73d31
Merge branch 'electra-epoch-proc' of https://github.com/sigp/lighthou…
realbigsean May 12, 2024
7f54906
Fix ser/de
pawanjay176 May 14, 2024
4f0ecf2
Subscribe to the correct subnets for electra attestations (#5782)
eserilev May 15, 2024
227aa4b
cargo fmt
realbigsean May 15, 2024
fc15736
Subscribe to the correct subnets for electra attestations (#5782)
eserilev May 15, 2024
d8941d7
cargo fmt
realbigsean May 15, 2024
0c29896
Subscribe to the correct subnets for electra attestations (#5782)
eserilev May 15, 2024
210ad2f
cargo fmt
realbigsean May 15, 2024
79a5f25
Subscribe to the correct subnets for electra attestations (#5782)
eserilev May 15, 2024
a8088f1
cargo fmt
realbigsean May 15, 2024
8e537d1
update electra readiness with new endpoints
realbigsean May 15, 2024
bafb5f0
fix slashing handling
realbigsean May 17, 2024
f9c50bc
Fix Bug In Block Processing with 0x02 Credentials
ethDreamer May 16, 2024
987abe0
Merge remote-tracking branch 'upstream/unstable'
ethDreamer May 24, 2024
82858bc
Send unagg attestation based on fork
pawanjay176 May 13, 2024
154b7a7
Publish all aggregates
ethDreamer May 15, 2024
bb734af
just one more check bro plz..
ethDreamer May 15, 2024
469296b
Merge pull request #5832 from ethDreamer/electra_attestation_changes_…
realbigsean May 24, 2024
3f169ef
Merge pull request #5835 from realbigsean/fix-validator-logic
realbigsean May 24, 2024
3e10e68
Merge pull request #5816 from realbigsean/electra-attestation-slashin…
realbigsean May 24, 2024
9440c36
Merge branch 'electra_attestation_changes' of https://github.com/sigp…
realbigsean May 24, 2024
57b6a9a
Merge branch 'block-processing-electra' of https://github.com/sigp/li…
realbigsean May 24, 2024
1aa410c
Merge branch 'electra-epoch-proc' of https://github.com/sigp/lighthou…
realbigsean May 24, 2024
aed25c4
fix: serde rename camle case for execution payload body (#5846)
mattsse May 28, 2024
75432e1
Electra attestation changes rm decode impl (#5856)
ethDreamer May 30, 2024
e340998
Fix failing attestation tests and misc electra attestation cleanup (#…
eserilev May 30, 2024
b61d244
fix some todos (#5817)
realbigsean May 30, 2024
49de63f
Merge branch 'unstable' of https://github.com/sigp/lighthouse into el…
realbigsean May 31, 2024
29ed1c5
add consolidations to merkle calc for inclusion proof
realbigsean May 12, 2024
a647a36
Merge branch 'electra_attestation_changes' of https://github.com/sigp…
realbigsean May 31, 2024
4013944
Merge branch 'block-processing-electra' of https://github.com/sigp/li…
realbigsean May 31, 2024
7d3a5df
Merge branch 'electra-epoch-proc' of https://github.com/sigp/lighthou…
realbigsean May 31, 2024
f9d3545
Remove Duplicate KZG Commitment Merkle Proof Code (#5874)
ethDreamer Jun 1, 2024
77c630b
Merge branch 'unstable' of https://github.com/sigp/lighthouse into el…
realbigsean Jun 13, 2024
f25531d
Merge branch 'electra_attestation_changes' of https://github.com/sigp…
realbigsean Jun 13, 2024
772ab53
Merge branch 'block-processing-electra' of https://github.com/sigp/li…
realbigsean Jun 13, 2024
49db91b
Merge branch 'electra-epoch-proc' of https://github.com/sigp/lighthou…
realbigsean Jun 13, 2024
b21b108
fix compile
realbigsean Jun 13, 2024
8dc9f38
Merge branch 'electra_attestation_changes' of https://github.com/sigp…
realbigsean Jun 13, 2024
c43d1c2
Merge branch 'block-processing-electra' of https://github.com/sigp/li…
realbigsean Jun 13, 2024
f57fa87
Merge branch 'electra-epoch-proc' of https://github.com/sigp/lighthou…
realbigsean Jun 13, 2024
35e07eb
Fix slasher tests (#5906)
pawanjay176 Jun 14, 2024
d7f3c95
Update superstruct to 0.8
michaelsproul Jun 14, 2024
d5aa2d8
Merge remote-tracking branch 'origin/unstable' into electra_attestati…
michaelsproul Jun 14, 2024
c4f2284
Small cleanup in slasher tests
michaelsproul Jun 14, 2024
3ac3ddb
Clean up Electra observed aggregates (#5929)
michaelsproul Jun 17, 2024
9a01b6b
Merge branch 'unstable' of https://github.com/sigp/lighthouse into el…
realbigsean Jun 17, 2024
d87541c
De-dup attestation constructor logic
dapplion Jun 17, 2024
dd0d5e2
Remove unwraps in Attestation construction
dapplion Jun 17, 2024
3ec21a2
Dedup match_attestation_data
dapplion Jun 17, 2024
795eff9
Remove outdated TODO
dapplion Jun 17, 2024
960f8c5
Use ForkName Ord in fork-choice tests
dapplion Jun 17, 2024
1d0e3f4
Use ForkName Ord in BeaconBlockBody
dapplion Jun 17, 2024
5acc052
Make to_electra not fallible
dapplion Jun 17, 2024
4f08f6e
Remove TestRandom impl for IndexedAttestation
dapplion Jun 17, 2024
f049285
Remove IndexedAttestation faulty Decode impl
dapplion Jun 17, 2024
5070ab2
Drop TestRandom impl
dapplion Jun 17, 2024
45d007a
Add PendingAttestationInElectra
dapplion Jun 17, 2024
9e84779
Indexed att on disk (#35)
realbigsean Jun 18, 2024
7af3f2e
add electra fork enabled fn to ForkName impl (#36)
eserilev Jun 18, 2024
2634a1f
Update common/eth2/src/types.rs
dapplion Jun 18, 2024
dec7cff
Dedup attestation constructor logic in attester cache
dapplion Jun 17, 2024
6a4d842
Use if let Ok for committee_bits
dapplion Jun 18, 2024
6f0b784
Dedup Attestation constructor code
dapplion Jun 18, 2024
444cd62
Diff reduction in tests
dapplion Jun 18, 2024
d264736
Fix beacon_chain tests
dapplion Jun 18, 2024
7521f97
Diff reduction
dapplion Jun 18, 2024
4d3edfe
Use Ord for ForkName in pubsub
dapplion Jun 18, 2024
7fce143
Resolve into_attestation_and_indices todo
dapplion Jun 18, 2024
4d4c268
Remove stale TODO
dapplion Jun 18, 2024
370d511
Fix beacon_chain tests
dapplion Jun 18, 2024
cbb7c5d
Test spec invariant
dapplion Jun 19, 2024
70a2d4d
Use electra_enabled in pubsub
dapplion Jun 19, 2024
9e6e76f
Remove get_indexed_attestation_from_signed_aggregate
dapplion Jun 19, 2024
a8d8989
Use ok_or instead of if let else
dapplion Jun 19, 2024
d67270f
committees are sorted
dapplion Jun 19, 2024
3977b92
remove dup method `get_indexed_attestation_from_committees`
realbigsean Jun 19, 2024
6e44832
Merge pull request #5940 from dapplion/electra_attestation_changes_li…
realbigsean Jun 19, 2024
afb9122
update default persisted op pool deserialization
realbigsean Jun 19, 2024
381bbab
ensure aggregate and proof uses serde untagged on ref
realbigsean Jun 19, 2024
0e2add2
Fork aware ssz static attestation tests
dapplion Jun 20, 2024
f85a124
Electra attestation changes from Lions review (#5971)
eserilev Jun 20, 2024
efb8a01
Merge branch 'unstable' of https://github.com/sigp/lighthouse into el…
realbigsean Jun 20, 2024
dd0aa8e
Merge branch 'electra_attestation_changes' of https://github.com/sigp…
realbigsean Jun 20, 2024
536c9f8
Merge branch 'block-processing-electra' of https://github.com/sigp/li…
realbigsean Jun 20, 2024
c276af6
Merge branch 'electra-epoch-proc' of https://github.com/sigp/lighthou…
realbigsean Jun 20, 2024
27ed90e
Electra attestation changes sean review (#5972)
realbigsean Jun 21, 2024
b6913ae
Avoid changing slasher schema for Electra
michaelsproul Jun 21, 2024
ebbb17b
Delete slasher schema v4
michaelsproul Jun 21, 2024
13b1b05
Fix clippy
michaelsproul Jun 21, 2024
339d1b8
Fix compilation of beacon_chain tests
michaelsproul Jun 21, 2024
70a80d5
Update database.rs
dapplion Jun 21, 2024
7509cf6
Update per_block_processing.rs
dapplion Jun 21, 2024
8715589
Add electra lightclient types
dapplion Jun 21, 2024
09141ec
Update slasher/src/database.rs
realbigsean Jun 21, 2024
8fc5333
fix imports
realbigsean Jun 21, 2024
5517c78
Merge pull request #5980 from dapplion/electra-lightclient
realbigsean Jun 21, 2024
cf030d0
Merge pull request #5975 from michaelsproul/electra-slasher-no-migration
realbigsean Jun 21, 2024
68fd7a7
Update beacon_node/beacon_chain/src/attestation_verification.rs
realbigsean Jun 21, 2024
d137881
Update beacon_node/beacon_chain/src/attestation_verification.rs
realbigsean Jun 21, 2024
87fde51
Merge branch 'unstable' of https://github.com/sigp/lighthouse into el…
realbigsean Jun 25, 2024
a8d84d6
Merge branch 'electra_attestation_changes' of https://github.com/real…
realbigsean Jun 25, 2024
51a8c80
Merge branch 'block-processing-electra' of https://github.com/sigp/li…
realbigsean Jun 25, 2024
4a858b3
Merge branch 'electra-epoch-proc' of https://github.com/sigp/lighthou…
realbigsean Jun 25, 2024
806a5eb
The great renaming receipt -> request
pawanjay176 Jun 28, 2024
033457c
Address some more review comments
pawanjay176 Jun 28, 2024
257bcc3
Merge branch 'unstable' of https://github.com/sigp/lighthouse into el…
realbigsean Jul 1, 2024
c9fe10b
Update beacon_node/beacon_chain/src/electra_readiness.rs
realbigsean Jul 1, 2024
69ac342
Update consensus/types/src/chain_spec.rs
realbigsean Jul 1, 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
24 changes: 8 additions & 16 deletions beacon_node/beacon_chain/src/electra_readiness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
//! transition.

use crate::{BeaconChain, BeaconChainTypes};
use execution_layer::http::{
ENGINE_FORKCHOICE_UPDATED_V3, ENGINE_GET_PAYLOAD_V3, ENGINE_NEW_PAYLOAD_V3,
};
use execution_layer::http::{ENGINE_GET_PAYLOAD_V4, ENGINE_NEW_PAYLOAD_V4};
use serde::{Deserialize, Serialize};
use std::fmt;
use std::time::Duration;
Expand All @@ -22,7 +20,7 @@ pub enum ElectraReadiness {
/// The execution engine is electra-enabled (as far as we can tell)
Ready,
/// We are connected to an execution engine which doesn't support the V3 engine api methods
realbigsean marked this conversation as resolved.
Show resolved Hide resolved
V3MethodsNotSupported { error: String },
V4MethodsNotSupported { error: String },
/// The transition configuration with the EL failed, there might be a problem with
/// connectivity, authentication or a difference in configuration.
ExchangeCapabilitiesFailed { error: String },
Expand All @@ -47,7 +45,7 @@ impl fmt::Display for ElectraReadiness {
"The --execution-endpoint flag is not specified, this is a \
requirement post-merge"
),
ElectraReadiness::V3MethodsNotSupported { error } => write!(
ElectraReadiness::V4MethodsNotSupported { error } => write!(
f,
"Execution endpoint does not support Electra methods: {}",
error
Expand Down Expand Up @@ -88,29 +86,23 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
}
}
Ok(capabilities) => {
// TODO(electra): Update in the event we get V4s.
let mut missing_methods = String::from("Required Methods Unsupported:");
let mut all_good = true;
if !capabilities.get_payload_v3 {
if !capabilities.get_payload_v4 {
missing_methods.push(' ');
missing_methods.push_str(ENGINE_GET_PAYLOAD_V3);
missing_methods.push_str(ENGINE_GET_PAYLOAD_V4);
all_good = false;
}
if !capabilities.forkchoice_updated_v3 {
if !capabilities.new_payload_v4 {
missing_methods.push(' ');
missing_methods.push_str(ENGINE_FORKCHOICE_UPDATED_V3);
all_good = false;
}
if !capabilities.new_payload_v3 {
missing_methods.push(' ');
missing_methods.push_str(ENGINE_NEW_PAYLOAD_V3);
missing_methods.push_str(ENGINE_NEW_PAYLOAD_V4);
all_good = false;
}

if all_good {
ElectraReadiness::Ready
} else {
ElectraReadiness::V3MethodsNotSupported {
ElectraReadiness::V4MethodsNotSupported {
error: missing_methods,
}
}
Expand Down
52 changes: 44 additions & 8 deletions beacon_node/execution_layer/src/engine_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use crate::http::{
ENGINE_FORKCHOICE_UPDATED_V1, ENGINE_FORKCHOICE_UPDATED_V2, ENGINE_FORKCHOICE_UPDATED_V3,
ENGINE_GET_CLIENT_VERSION_V1, 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_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 @@ -19,6 +20,7 @@ use reqwest::StatusCode;
use serde::{Deserialize, Serialize};
use strum::IntoStaticStr;
use superstruct::superstruct;
use types::execution_payload::{DepositRequests, WithdrawalRequests};
pub use types::{
Address, BeaconBlockRef, EthSpec, ExecutionBlockHash, ExecutionPayload, ExecutionPayloadHeader,
ExecutionPayloadRef, FixedVector, ForkName, Hash256, Transactions, Uint256, VariableList,
Expand All @@ -40,6 +42,8 @@ pub use new_payload_request::{
NewPayloadRequestDeneb, NewPayloadRequestElectra,
};

use self::json_structures::{JsonDepositRequest, JsonWithdrawalRequest};

pub const LATEST_TAG: &str = "latest";

pub type PayloadId = [u8; 8];
Expand All @@ -60,9 +64,10 @@ pub enum Error {
ExecutionHeadBlockNotFound,
ParentHashEqualsBlockHash(ExecutionBlockHash),
PayloadIdUnavailable,
TransitionConfigurationMismatch,
SszError(ssz_types::Error),
pawanjay176 marked this conversation as resolved.
Show resolved Hide resolved
DeserializeWithdrawals(ssz_types::Error),
DeserializeDepositRequests(ssz_types::Error),
DeserializeWithdrawalRequests(ssz_types::Error),
BuilderApi(builder_client::Error),
IncorrectStateVariant,
RequiredMethodUnsupported(&'static str),
Expand Down Expand Up @@ -197,6 +202,10 @@ 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_requests: Vec<JsonDepositRequest>,
#[superstruct(only(Electra))]
pub withdrawal_requests: Vec<JsonWithdrawalRequest>,
}

impl<E: EthSpec> TryFrom<ExecutionPayload<E>> for ExecutionBlockWithTransactions<E> {
Expand Down Expand Up @@ -304,6 +313,16 @@ impl<E: EthSpec> TryFrom<ExecutionPayload<E>> for ExecutionBlockWithTransactions
.collect(),
blob_gas_used: block.blob_gas_used,
excess_blob_gas: block.excess_blob_gas,
deposit_requests: block
.deposit_requests
.into_iter()
.map(|deposit| deposit.into())
.collect(),
withdrawal_requests: block
.withdrawal_requests
.into_iter()
.map(|withdrawal| withdrawal.into())
.collect(),
})
}
};
Expand Down Expand Up @@ -526,6 +545,8 @@ impl<E: EthSpec> GetPayloadResponse<E> {
pub struct ExecutionPayloadBodyV1<E: EthSpec> {
pub transactions: Transactions<E>,
pub withdrawals: Option<Withdrawals<E>>,
pub deposit_requests: Option<DepositRequests<E>>,
pub withdrawal_requests: Option<WithdrawalRequests<E>>,
}

impl<E: EthSpec> ExecutionPayloadBodyV1<E> {
Expand Down Expand Up @@ -613,7 +634,14 @@ impl<E: EthSpec> ExecutionPayloadBodyV1<E> {
}
}
ExecutionPayloadHeader::Electra(header) => {
if let Some(withdrawals) = self.withdrawals {
let withdrawals_exist = self.withdrawals.is_some();
let deposit_requests_exist = self.deposit_requests.is_some();
let withdrawal_requests_exist = self.withdrawal_requests.is_some();
if let (Some(withdrawals), Some(deposit_requests), Some(withdrawal_requests)) = (
self.withdrawals,
self.deposit_requests,
self.withdrawal_requests,
) {
Ok(ExecutionPayload::Electra(ExecutionPayloadElectra {
parent_hash: header.parent_hash,
fee_recipient: header.fee_recipient,
Expand All @@ -632,14 +660,14 @@ impl<E: EthSpec> ExecutionPayloadBodyV1<E> {
withdrawals,
blob_gas_used: header.blob_gas_used,
excess_blob_gas: header.excess_blob_gas,
// TODO(electra)
deposit_receipts: <_>::default(),
withdrawal_requests: <_>::default(),
deposit_requests,
withdrawal_requests,
}))
} else {
Err(format!(
"block {} is post-capella but payload body doesn't have withdrawals",
header.block_hash
"block {} is post-electra but payload body doesn't have withdrawals/deposit_requests/withdrawal_requests \
withdrawals: {}, deposit_requests: {}, withdrawal_requests: {}",
header.block_hash, withdrawals_exist, deposit_requests_exist, withdrawal_requests_exist
))
}
}
Expand All @@ -652,6 +680,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 @@ -660,6 +689,7 @@ pub struct EngineCapabilities {
pub get_payload_v1: bool,
pub get_payload_v2: bool,
pub get_payload_v3: bool,
pub get_payload_v4: bool,
pub get_client_version_v1: bool,
}

Expand All @@ -675,6 +705,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 @@ -699,6 +732,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);
}
if self.get_client_version_v1 {
response.push(ENGINE_GET_CLIENT_VERSION_V1);
}
Expand Down
61 changes: 49 additions & 12 deletions beacon_node/execution_layer/src/engine_api/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,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 Down Expand Up @@ -66,9 +68,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 @@ -830,7 +834,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 @@ -842,7 +846,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 @@ -926,19 +930,43 @@ impl HttpJsonRpc {
.await?;
Ok(JsonGetPayloadResponse::V3(response).into())
}
ForkName::Base
| ForkName::Altair
| ForkName::Bellatrix
| ForkName::Capella
| ForkName::Electra => Err(Error::UnsupportedForkVariant(format!(
"called get_payload_v3 with {}",
fork_name
))),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if let ForkName::Deneb = fork_name else { err } for less future fork boilerplate :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually match all fork names so that we don't miss potential changes to functions on addition of new forks.
For e.g. if ForkName::F* had some changes that affect this function, then we might potentially miss it in a refactor if we do.the if let pattern.
It won't affect this specific function, but I think its good to be consistent.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we've kinda shifted policy here towards being less verbose, or at least considering it on a case by case basis. In this case it makes sense that any fork post-electra shouldn't be calling this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can leave this one since this is in line with all the other similar methods in this file. But we can come back and change them all to reduce boiler plate

}
}

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

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

Expand Down Expand Up @@ -1064,6 +1092,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 @@ -1074,6 +1103,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),
get_client_version_v1: capabilities.contains(ENGINE_GET_CLIENT_VERSION_V1),
})
}
Expand Down Expand Up @@ -1196,11 +1226,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 @@ -1218,17 +1248,24 @@ impl HttpJsonRpc {
ForkName::Bellatrix | ForkName::Capella => {
if engine_capabilities.get_payload_v2 {
self.get_payload_v2(fork_name, payload_id).await
} else if engine_capabilities.new_payload_v1 {
} else if engine_capabilities.get_payload_v1 {
self.get_payload_v1(payload_id).await
} else {
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"))
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_getPayloadv4"))
}
}
ForkName::Base | ForkName::Altair => Err(Error::UnsupportedForkVariant(format!(
Expand Down
Loading
Loading