-
Notifications
You must be signed in to change notification settings - Fork 53
Construct and sign the Gloas SignedExecutionPayloadEnvelope, and broadcast it to beacon nodes #503
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
Changes from all commits
3e9b7dd
6dc736a
c8b92ab
37a569a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ use std::sync::{ | |
| }; | ||
|
|
||
| use futures::future::join_all; | ||
| use helix_types::{ForkName, VersionedSignedProposal}; | ||
| use helix_types::{ForkName, SignedExecutionPayloadEnvelopeContents, VersionedSignedProposal}; | ||
|
|
||
| use crate::{ | ||
| beacon::{beacon_client::BeaconClient, error::BeaconClientError, types::BroadcastValidation}, | ||
|
|
@@ -83,4 +83,94 @@ impl MultiBeaconClient { | |
|
|
||
| Err(last_error.unwrap_or(BeaconClientError::BeaconNodeUnavailable)) | ||
| } | ||
|
|
||
| /// Publishes the signed execution payload envelope to all beacon clients; returns on first | ||
|
0w3n-d marked this conversation as resolved.
|
||
| /// success. Unlike `publish_block`, fans out via plain concurrent futures, not | ||
| /// `spawn_tracked!`. | ||
|
Comment on lines
+88
to
+89
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| pub async fn publish_execution_payload_envelope( | ||
| &self, | ||
| envelope: Arc<SignedExecutionPayloadEnvelopeContents>, | ||
| fork: ForkName, | ||
| ) -> Result<(), BeaconClientError> { | ||
| let futures = self | ||
| .beacon_clients | ||
| .iter() | ||
| .map(|client| client.publish_execution_payload_envelope(envelope.clone(), fork)); | ||
|
|
||
| let mut last_error: Option<BeaconClientError> = None; | ||
| for res in join_all(futures).await { | ||
| match res { | ||
| Ok(_) => return Ok(()), | ||
| Err(err) => last_error = Some(err), | ||
| } | ||
| } | ||
|
|
||
| Err(last_error.unwrap_or(BeaconClientError::BeaconNodeUnavailable)) | ||
| } | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use helix_types::{BlsSignature, ExecutionPayloadEnvelope, SignedExecutionPayloadEnvelope}; | ||
| use httpmock::{Method::POST, MockServer}; | ||
| use reqwest::Url; | ||
|
|
||
| use super::*; | ||
| use crate::BeaconClientConfig; | ||
|
|
||
| fn envelope() -> Arc<SignedExecutionPayloadEnvelopeContents> { | ||
| Arc::new(SignedExecutionPayloadEnvelopeContents { | ||
| signed_execution_payload_envelope: SignedExecutionPayloadEnvelope { | ||
| message: ExecutionPayloadEnvelope::empty(), | ||
| signature: BlsSignature::empty(), | ||
| }, | ||
| kzg_proofs: Default::default(), | ||
| blobs: Default::default(), | ||
| }) | ||
| } | ||
|
|
||
| fn client_for(server: &MockServer) -> Arc<BeaconClient> { | ||
| let url = Url::parse(&server.url("/")).unwrap(); | ||
| Arc::new(BeaconClient::new(BeaconClientConfig { url })) | ||
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn publish_execution_payload_envelope_returns_ok_on_first_success() { | ||
| crate::utils::install_default_crypto_provider(); | ||
| let failing = MockServer::start(); | ||
| failing.mock(|when, then| { | ||
| when.method(POST).path("/eth/v1/beacon/execution_payload_envelopes"); | ||
| then.status(500); | ||
| }); | ||
| let succeeding = MockServer::start(); | ||
| succeeding.mock(|when, then| { | ||
| when.method(POST).path("/eth/v1/beacon/execution_payload_envelopes"); | ||
| then.status(200); | ||
| }); | ||
|
|
||
| let multi = MultiBeaconClient::new(vec![client_for(&failing), client_for(&succeeding)]); | ||
| let result = multi.publish_execution_payload_envelope(envelope(), ForkName::Gloas).await; | ||
|
|
||
| assert!(result.is_ok(), "expected Ok, got {result:?}"); | ||
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn publish_execution_payload_envelope_returns_err_when_all_clients_fail() { | ||
| crate::utils::install_default_crypto_provider(); | ||
| let a = MockServer::start(); | ||
| a.mock(|when, then| { | ||
| when.method(POST).path("/eth/v1/beacon/execution_payload_envelopes"); | ||
| then.status(500); | ||
| }); | ||
| let b = MockServer::start(); | ||
| b.mock(|when, then| { | ||
| when.method(POST).path("/eth/v1/beacon/execution_payload_envelopes"); | ||
| then.status(500); | ||
| }); | ||
|
|
||
| let multi = MultiBeaconClient::new(vec![client_for(&a), client_for(&b)]); | ||
| let result = multi.publish_execution_payload_envelope(envelope(), ForkName::Gloas).await; | ||
|
|
||
| assert!(result.is_err(), "expected Err, got {result:?}"); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,6 +87,10 @@ pub struct RelayConfig { | |
| #[serde(default)] | ||
| pub operator_config: Option<OperatorConfig>, | ||
| pub blacklist_provider: Option<Url>, | ||
| /// This relay's on-chain Gloas (ePBS) builder_index. Placeholder until helix has a real | ||
| /// on-chain builder registration; signs under the relay's own key in the meantime. | ||
| #[serde(default)] | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this really have a default?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will be addressed by #635 |
||
| pub gloas_builder_index: u64, | ||
|
0w3n-d marked this conversation as resolved.
|
||
| } | ||
|
|
||
| #[derive(Serialize, Deserialize, Clone, Default)] | ||
|
|
@@ -160,6 +164,7 @@ impl RelayConfig { | |
| enable_flux_profiler: false, | ||
| operator_config: None, | ||
| blacklist_provider: None, | ||
| gloas_builder_index: 0, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ use helix_common::{ | |
| use helix_database::handle::DbHandle; | ||
| use helix_operator::OperatorPubSub; | ||
| use hyper::StatusCode; | ||
| pub use submit_signed_beacon_block::{GloasBuilderIdentity, GloasPayloadStore}; | ||
|
|
||
| use crate::{ | ||
| api::{Api, proposer::ip_tracker::IpTracker, router::Terminating}, | ||
|
|
@@ -46,6 +47,8 @@ pub struct ProposerApi<A: Api> { | |
| pub reg_handle: RegWorkerHandle, | ||
| pub operator_api: Option<Arc<OperatorPubSub>>, | ||
| pub ip_tracker: IpTracker, | ||
| pub gloas_builder_identity: Arc<GloasBuilderIdentity>, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't need an arc here because it's not shared? |
||
| pub gloas_payload_store: Arc<GloasPayloadStore>, | ||
| } | ||
|
|
||
| impl<A: Api> ProposerApi<A> { | ||
|
|
@@ -64,7 +67,12 @@ impl<A: Api> ProposerApi<A> { | |
| reg_handle: RegWorkerHandle, | ||
| alert_manager: Arc<AlertManager>, | ||
| operator_api: Option<Arc<OperatorPubSub>>, | ||
| gloas_payload_store: Arc<GloasPayloadStore>, | ||
| ) -> Self { | ||
| let gloas_builder_identity = Arc::new(GloasBuilderIdentity { | ||
| builder_index: relay_config.gloas_builder_index, | ||
| keypair: signing_context.keypair.clone(), | ||
| }); | ||
| Self { | ||
| local_cache, | ||
| db, | ||
|
|
@@ -81,6 +89,8 @@ impl<A: Api> ProposerApi<A> { | |
| reg_handle, | ||
| operator_api, | ||
| ip_tracker: IpTracker::default(), | ||
| gloas_builder_identity, | ||
| gloas_payload_store, | ||
| } | ||
| } | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.