Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c950ec0
Update specs.rs for Electra
JasonVranek Feb 11, 2025
2c8d2f8
add new Electra structs for BlindedBeaconBlockBody
JasonVranek Feb 11, 2025
1f2310c
make Electra modifications to `IndexedAttestation`
JasonVranek Feb 11, 2025
e04c90b
Make Electra modifications for `Attestation` struct
JasonVranek Feb 11, 2025
183038e
Make Electra modifications to `BlindedBeaconBlockBody` struct
JasonVranek Feb 11, 2025
76fdbb6
fixed all compiler issues related to new Electra types
JasonVranek Feb 12, 2025
5ae1b97
Replace BuilderEventDenebClient and BuilderEventElectraClient withBui…
JasonVranek Feb 12, 2025
a340898
run cargo fmt + remove clippy warnings
JasonVranek Feb 12, 2025
10c6082
Merge remote-tracking branch 'upstream/main' into electra
JasonVranek Feb 12, 2025
b71c6f3
create separate directories for deneb/electra test vectors
JasonVranek Feb 12, 2025
f9559e9
update payload.rs tests
JasonVranek Feb 12, 2025
b62a6f4
update pbs_get_header.rs tests
JasonVranek Feb 12, 2025
0a3508c
add T: EthSpec generic
JasonVranek Feb 12, 2025
3073659
fix pbs_get_status.rs tests
JasonVranek Feb 12, 2025
0d0cb57
fix pbx_mux.rs tests
JasonVranek Feb 12, 2025
6c2e19c
update pbs_post_blinded_block.rs tests
JasonVranek Feb 12, 2025
3574923
update pbs_post_validators.rs tests
JasonVranek Feb 12, 2025
da4c22b
cargo fmt + fix clippy
JasonVranek Feb 12, 2025
3f7e415
update paths to test files
JasonVranek Feb 12, 2025
066e875
update electra signed_blinded_block test vector
JasonVranek Feb 12, 2025
4f999bb
test against electra signed_blinded_block
JasonVranek Feb 12, 2025
5f502f1
test against electra get_header
JasonVranek Feb 12, 2025
2d39d4f
run cargo +nightly fmt --all
JasonVranek Feb 12, 2025
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
42 changes: 17 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ alloy = { version = "0.8.0", features = [
"getrandom",
"providers",
] }
ssz_types = "0.8"
ssz_types = "0.10"
ethereum_serde_utils = "0.7.0"

# networking
Expand Down Expand Up @@ -69,8 +69,8 @@ prometheus = "0.13.4"

# crypto
blst = "0.3.11"
tree_hash = "0.8"
tree_hash_derive = "0.8"
tree_hash = "0.9.1"
tree_hash_derive = "0.9"
eth2_keystore = { git = "https://github.com/sigp/lighthouse", rev = "9e12c21f268c80a3f002ae0ca27477f9f512eb6f" }
k256 = "0.13"
aes = "0.8"
Expand Down
6 changes: 3 additions & 3 deletions benches/pbs/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::time::{Duration, Instant};
use alloy::{primitives::B256, rpc::types::beacon::BlsPublicKey};
use cb_common::{
config::RelayConfig,
pbs::{GetHeaderResponse, RelayClient, RelayEntry},
pbs::{DenebSpec, GetHeaderResponse, RelayClient, RelayEntry},
signer::BlsSecretKey,
types::Chain,
utils::blst_pubkey_to_alloy,
Expand Down Expand Up @@ -63,7 +63,7 @@ async fn main() {
.expect("failed to decode response");

assert!(
serde_json::from_slice::<GetHeaderResponse>(&res).is_ok(),
serde_json::from_slice::<GetHeaderResponse<DenebSpec>>(&res).is_ok(),
"invalid header returned"
);

Expand Down Expand Up @@ -146,7 +146,7 @@ async fn start_mock_relay(chain: Chain, relay_config: RelayConfig) {
let relay_port = relay_config.entry.url.port().expect("missing port");

let mock_relay = MockRelayState::new(chain, signer);
start_mock_relay_service(mock_relay.into(), relay_port)
start_mock_relay_service::<DenebSpec>(mock_relay.into(), relay_port)
.await
.expect("failed to start mock relay");
}
Expand Down
3 changes: 2 additions & 1 deletion bin/pbs.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use cb_common::{
config::load_pbs_config,
pbs::DenebSpec,
utils::{initialize_pbs_tracing_log, wait_for_signal},
};
use cb_pbs::{DefaultBuilderApi, PbsService, PbsState};
Expand All @@ -20,7 +21,7 @@ async fn main() -> Result<()> {

PbsService::init_metrics(pbs_config.chain)?;
let state = PbsState::new(pbs_config);
let server = PbsService::run::<_, DefaultBuilderApi>(state);
let server = PbsService::run::<_, DenebSpec, DefaultBuilderApi>(state);

tokio::select! {
maybe_err = server => {
Expand Down
4 changes: 3 additions & 1 deletion bin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ pub mod prelude {
load_builder_module_config, load_commit_module_config, load_pbs_config,
load_pbs_custom_config, LogsSettings, StartCommitModuleConfig,
},
pbs::{BuilderEvent, BuilderEventClient, OnBuilderApiEvent},
pbs::{
BuilderEvent, BuilderEventClient, DenebSpec, ElectraSpec, EthSpec, OnBuilderApiEvent,
},
signer::{BlsPublicKey, BlsSignature, EcdsaPublicKey, EcdsaSignature},
types::Chain,
utils::{
Expand Down
49 changes: 33 additions & 16 deletions crates/common/src/pbs/event.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::net::SocketAddr;
use std::{marker::PhantomData, net::SocketAddr};

use alloy::{primitives::B256, rpc::types::beacon::relay::ValidatorRegistration};
use async_trait::async_trait;
Expand All @@ -16,21 +16,22 @@ use tracing::{error, info, trace};
use url::Url;

use super::{
GetHeaderParams, GetHeaderResponse, SignedBlindedBeaconBlock, SubmitBlindedBlockResponse,
EthSpec, GetHeaderParams, GetHeaderResponse, SignedBlindedBeaconBlock,
SubmitBlindedBlockResponse,
};
use crate::{
config::{load_optional_env_var, BUILDER_URLS_ENV},
pbs::BUILDER_EVENTS_PATH,
};

#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum BuilderEvent {
pub enum BuilderEvent<T: EthSpec> {
GetHeaderRequest(GetHeaderParams),
GetHeaderResponse(Box<Option<GetHeaderResponse>>),
GetHeaderResponse(Box<Option<GetHeaderResponse<T>>>),
GetStatusEvent,
GetStatusResponse,
SubmitBlockRequest(Box<SignedBlindedBeaconBlock>),
SubmitBlockResponse(Box<SubmitBlindedBlockResponse>),
SubmitBlockRequest(Box<SignedBlindedBeaconBlock<T>>),
SubmitBlockResponse(Box<SubmitBlindedBlockResponse<T>>),
MissedPayload {
/// Hash for the block for which no payload was received
block_hash: B256,
Expand Down Expand Up @@ -69,7 +70,7 @@ impl BuilderEventPublisher {
.transpose()
}

pub fn publish(&self, event: BuilderEvent) {
pub fn publish<T: EthSpec>(&self, event: BuilderEvent<T>) {
for endpoint in self.endpoints.clone() {
let client = self.client.clone();
let event = event.clone();
Expand All @@ -94,21 +95,30 @@ impl BuilderEventPublisher {
}
}

pub struct BuilderEventClient<T: OnBuilderApiEvent> {
pub struct BuilderEventClient<T, S>
where
T: OnBuilderApiEvent<S> + Clone + Send + Sync + 'static,
S: EthSpec + Clone + Send + Sync + 'static + for<'de> Deserialize<'de>,
{
pub port: u16,
pub processor: T,
_phantom: PhantomData<S>,
}

impl<T: OnBuilderApiEvent + Clone + Send + Sync + 'static> BuilderEventClient<T> {
impl<T, S> BuilderEventClient<T, S>
where
T: OnBuilderApiEvent<S> + Clone + Send + Sync + 'static,
S: EthSpec + Clone + Send + Sync + 'static + for<'de> Deserialize<'de>,
{
pub fn new(port: u16, processor: T) -> Self {
Self { port, processor }
Self { port, processor, _phantom: PhantomData }
}

pub async fn run(self) -> eyre::Result<()> {
info!("Starting builder events server on port {}", self.port);

let router = axum::Router::new()
.route(BUILDER_EVENTS_PATH, post(handle_builder_event::<T>))
.route(BUILDER_EVENTS_PATH, post(handle_builder_event::<T, S>))
.with_state(self.processor);
let address = SocketAddr::from(([0, 0, 0, 0], self.port));
let listener = TcpListener::bind(&address).await?;
Expand All @@ -119,17 +129,24 @@ impl<T: OnBuilderApiEvent + Clone + Send + Sync + 'static> BuilderEventClient<T>
}
}

async fn handle_builder_event<T: OnBuilderApiEvent>(
async fn handle_builder_event<T, S>(
State(processor): State<T>,
Json(event): Json<BuilderEvent>,
) -> Response {
Json(event): Json<BuilderEvent<S>>,
) -> Response
where
T: OnBuilderApiEvent<S> + Clone + Send + Sync + 'static,
S: EthSpec + Clone + Send + Sync + 'static + for<'de> Deserialize<'de>,
{
trace!("Handling builder event");
processor.on_builder_api_event(event).await;
StatusCode::OK.into_response()
}

#[async_trait]
/// This is what modules are expected to implement to process BuilderApi events
pub trait OnBuilderApiEvent {
async fn on_builder_api_event(&self, event: BuilderEvent);
pub trait OnBuilderApiEvent<T>
where
T: EthSpec + Clone + Send + Sync + 'static + for<'de> Deserialize<'de>,
{
async fn on_builder_api_event(&self, event: BuilderEvent<T>);
}
Loading
Loading