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 #250

Closed
wants to merge 20 commits into from
Closed
Changes from 1 commit
Commits
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
Next Next commit
relay updates for electra
ralexstokes committed Oct 23, 2024
commit 40b0e07851e0dd6e23cd537938fa24e9c9b03961
36 changes: 36 additions & 0 deletions mev-relay-rs/src/auction_context.rs
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@ fn to_header(execution_payload: &ExecutionPayload) -> Result<ExecutionPayloadHea
}
ExecutionPayload::Capella(payload) => ExecutionPayloadHeader::Capella(payload.try_into()?),
ExecutionPayload::Deneb(payload) => ExecutionPayloadHeader::Deneb(payload.try_into()?),
ExecutionPayload::Electra(payload) => ExecutionPayloadHeader::Electra(payload.try_into()?),
};
Ok(header)
}
@@ -89,11 +90,16 @@ pub mod deneb {
}
}

pub mod electra {
pub use super::deneb::*;
}

#[derive(Debug, PartialEq, Eq, Hash)]
pub enum AuctionContext {
Bellatrix(bellatrix::AuctionContext),
Capella(capella::AuctionContext),
Deneb(deneb::AuctionContext),
Electra(electra::AuctionContext),
}

impl AuctionContext {
@@ -134,6 +140,14 @@ impl AuctionContext {
public_key: relay_public_key,
})
}
SignedBidSubmission::Electra(ref submission) => {
BuilderBid::Electra(builder_bid::electra::BuilderBid {
header: execution_payload_header,
blob_kzg_commitments: submission.blobs_bundle.commitments.clone(),
value,
public_key: relay_public_key,
})
}
};

let signature = sign_builder_message(&bid, relay_secret_key, context)?;
@@ -167,6 +181,15 @@ impl AuctionContext {
value,
blobs_bundle: submission.blobs_bundle,
}),
SignedBidSubmission::Electra(submission) => Self::Electra(electra::AuctionContext {
builder_public_key,
bid_trace: submission.message,
receive_duration,
signed_builder_bid,
execution_payload,
value,
blobs_bundle: submission.blobs_bundle,
}),
};

Ok(auction_context)
@@ -177,6 +200,7 @@ impl AuctionContext {
Self::Bellatrix(context) => &context.builder_public_key,
Self::Capella(context) => &context.builder_public_key,
Self::Deneb(context) => &context.builder_public_key,
Self::Electra(context) => &context.builder_public_key,
}
}

@@ -185,6 +209,7 @@ impl AuctionContext {
Self::Bellatrix(context) => &context.bid_trace,
Self::Capella(context) => &context.bid_trace,
Self::Deneb(context) => &context.bid_trace,
Self::Electra(context) => &context.bid_trace,
}
}

@@ -193,6 +218,7 @@ impl AuctionContext {
Self::Bellatrix(context) => context.receive_duration,
Self::Capella(context) => context.receive_duration,
Self::Deneb(context) => context.receive_duration,
Self::Electra(context) => context.receive_duration,
}
}

@@ -201,6 +227,7 @@ impl AuctionContext {
Self::Bellatrix(context) => &context.signed_builder_bid,
Self::Capella(context) => &context.signed_builder_bid,
Self::Deneb(context) => &context.signed_builder_bid,
Self::Electra(context) => &context.signed_builder_bid,
}
}

@@ -209,6 +236,7 @@ impl AuctionContext {
Self::Bellatrix(context) => &context.execution_payload,
Self::Capella(context) => &context.execution_payload,
Self::Deneb(context) => &context.execution_payload,
Self::Electra(context) => &context.execution_payload,
}
}

@@ -217,6 +245,7 @@ impl AuctionContext {
Self::Bellatrix(_) => None,
Self::Capella(_) => None,
Self::Deneb(context) => Some(&context.blobs_bundle),
Self::Electra(context) => Some(&context.blobs_bundle),
}
}

@@ -225,6 +254,7 @@ impl AuctionContext {
Self::Bellatrix(context) => context.value,
Self::Capella(context) => context.value,
Self::Deneb(context) => context.value,
Self::Electra(context) => context.value,
}
}

@@ -240,6 +270,12 @@ impl AuctionContext {
blobs_bundle: context.blobs_bundle.clone(),
})
}
Self::Electra(context) => {
AuctionContents::Electra(auction_contents::electra::AuctionContents {
execution_payload: context.execution_payload.clone(),
blobs_bundle: context.blobs_bundle.clone(),
})
}
}
}
}
44 changes: 44 additions & 0 deletions mev-relay-rs/src/relay.rs
Original file line number Diff line number Diff line change
@@ -40,13 +40,15 @@ use ethereum_consensus::{
bellatrix::mainnet as bellatrix,
capella::mainnet as capella,
deneb::mainnet as deneb,
electra::mainnet as electra,
types::mainnet::{ExecutionPayloadHeaderRef, SignedBeaconBlock},
};
#[cfg(feature = "minimal-preset")]
use ethereum_consensus::{
bellatrix::minimal as bellatrix,
capella::minimal as capella,
deneb::minimal as deneb,
electra::minimal as electra,
types::minimal::{ExecutionPayloadHeaderRef, SignedBeaconBlock},
};

@@ -80,6 +82,13 @@ fn validate_header_equality(
return Err(RelayError::InvalidExecutionPayloadInBlock);
}
}
ExecutionPayloadHeader::Electra(local_header) => {
let provided_header =
provided_header.electra().ok_or(RelayError::InvalidExecutionPayloadInBlock)?;
if local_header != provided_header {
return Err(RelayError::InvalidExecutionPayloadInBlock);
}
}
}
Ok(())
}
@@ -188,6 +197,41 @@ fn unblind_block(
};
Ok(SignedBeaconBlock::Deneb(inner))
}
SignedBlindedBeaconBlock::Electra(blinded_block) => {
let signature = blinded_block.signature.clone();
let block = &blinded_block.message;
let body = &block.body;
let execution_payload = execution_payload.electra().ok_or(Error::InvalidFork {
expected: Fork::Electra,
provided: execution_payload.version(),
})?;

let inner = electra::SignedBeaconBlock {
message: electra::BeaconBlock {
slot: block.slot,
proposer_index: block.proposer_index,
parent_root: block.parent_root,
state_root: block.state_root,
body: electra::BeaconBlockBody {
randao_reveal: body.randao_reveal.clone(),
eth1_data: body.eth1_data.clone(),
graffiti: body.graffiti.clone(),
proposer_slashings: body.proposer_slashings.clone(),
attester_slashings: body.attester_slashings.clone(),
attestations: body.attestations.clone(),
deposits: body.deposits.clone(),
voluntary_exits: body.voluntary_exits.clone(),
sync_aggregate: body.sync_aggregate.clone(),
execution_payload: execution_payload.clone(),
bls_to_execution_changes: body.bls_to_execution_changes.clone(),
blob_kzg_commitments: body.blob_kzg_commitments.clone(),
consolidations: body.consolidations.clone(),
},
},
signature,
};
Ok(SignedBeaconBlock::Electra(inner))
}
}
}