Skip to content

Commit

Permalink
Added prepare_beacon_proposer api endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Jan 18, 2022
1 parent 49e27f6 commit 2feef90
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
13 changes: 12 additions & 1 deletion beacon_node/execution_layer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use tokio::{
sync::{Mutex, MutexGuard},
time::{sleep, sleep_until, Instant},
};
use types::ChainSpec;
use types::{ ChainSpec, ProposerPreparationData };

pub use engine_api::{http::HttpJsonRpc, ExecutePayloadResponseStatus};

Expand Down Expand Up @@ -239,6 +239,17 @@ impl ExecutionLayer {
self.engines().any_synced().await
}

/// Updates the proposer preparation data provided by validators
pub fn update_proposer_preparation(&self, preparation_data: Vec<ProposerPreparationData>) -> Result<(), Error> {
info!(
self.log(),
"Received proposer preperation data";
"count" => preparation_data.len(),
);
Ok(())
}


/// Maps to the `engine_getPayload` JSON-RPC call.
///
/// However, it will attempt to call `self.prepare_payload` if it cannot find an existing
Expand Down
33 changes: 31 additions & 2 deletions beacon_node/http_api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ use tokio::sync::mpsc::UnboundedSender;
use tokio_stream::{wrappers::BroadcastStream, StreamExt};
use types::{
Attestation, AttesterSlashing, BeaconStateError, CommitteeCache, ConfigAndPreset, Epoch,
EthSpec, ForkName, ProposerSlashing, RelativeEpoch, SignedAggregateAndProof, SignedBeaconBlock,
SignedContributionAndProof, SignedVoluntaryExit, Slot, SyncCommitteeMessage,
EthSpec, ForkName, ProposerPreparationData, ProposerSlashing, RelativeEpoch, SignedAggregateAndProof,
SignedBeaconBlock, SignedContributionAndProof, SignedVoluntaryExit, Slot, SyncCommitteeMessage,
SyncContributionData,
};
use version::{
Expand Down Expand Up @@ -2174,6 +2174,34 @@ pub fn serve<T: BeaconChainTypes>(
})
},
);

let post_validator_prepare_beacon_proposer = eth1_v1
.and(warp::path("validator"))
.and(warp::path("prepare_beacon_proposer"))
.and(warp::path::end())
.and(not_while_syncing_filter.clone())
.and(chain_filter.clone())
.and(warp::body::json())
.and_then(
|chain: Arc<BeaconChain<T>>,
preparation_data: Vec<ProposerPreparationData>| {
blocking_json_task(move || {
let execution_layer = chain
.execution_layer
.as_ref()
.ok_or(BeaconChainError::ExecutionLayerMissing)
.map_err(warp_utils::reject::beacon_chain_error)?;

execution_layer
.update_proposer_preparation(preparation_data)
.map_err(|_| {
warp_utils::reject::custom_not_found(
"error processing proposer preparation data".to_string(),
)
})
})
},
);

// POST validator/sync_committee_subscriptions
let post_validator_sync_committee_subscriptions = eth1_v1
Expand Down Expand Up @@ -2666,6 +2694,7 @@ pub fn serve<T: BeaconChainTypes>(
.or(post_validator_contribution_and_proofs.boxed())
.or(post_validator_beacon_committee_subscriptions.boxed())
.or(post_validator_sync_committee_subscriptions.boxed())
.or(post_validator_prepare_beacon_proposer.boxed())
.or(post_lighthouse_liveness.boxed())
.or(post_lighthouse_database_reconstruct.boxed())
.or(post_lighthouse_database_historical_blocks.boxed()),
Expand Down

0 comments on commit 2feef90

Please sign in to comment.