Skip to content

Commit

Permalink
merge unstable
Browse files Browse the repository at this point in the history
  • Loading branch information
eserilev committed Sep 27, 2023
1 parent 6441c52 commit c68e7af
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 40 deletions.
4 changes: 1 addition & 3 deletions beacon_node/http_api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3004,7 +3004,6 @@ pub fn serve<T: BeaconChainTypes>(
.and(warp::header::optional::<api_types::Accept>("accept"))
.and(not_while_syncing_filter.clone())
.and(warp::query::<api_types::ValidatorBlocksQuery>())
.and(warp::header::optional::<api_types::Accept>("accept"))
.and(task_spawner_filter.clone())
.and(chain_filter.clone())
.and(log_filter.clone())
Expand All @@ -3013,7 +3012,6 @@ pub fn serve<T: BeaconChainTypes>(
slot: Slot,
accept_header: Option<api_types::Accept>,
query: api_types::ValidatorBlocksQuery,
accept_header: Option<api_types::Accept>,
task_spawner: TaskSpawner<T::EthSpec>,
chain: Arc<BeaconChain<T>>,
log: Logger| {
Expand Down Expand Up @@ -3055,7 +3053,7 @@ pub fn serve<T: BeaconChainTypes>(
task_spawner: TaskSpawner<T::EthSpec>,
chain: Arc<BeaconChain<T>>| {
task_spawner.spawn_async_with_rejection(Priority::P0, async move {
produce_blinded_block_v2(EndpointVersion(2), chain, slot, query).await
produce_blinded_block_v2(EndpointVersion(2), accept_header, chain, slot, query).await
})
},
);
Expand Down
3 changes: 2 additions & 1 deletion beacon_node/http_api/src/validator.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use types::{payload::BlockProductionVersion, *};

use bytes::Bytes;
use std::sync::Arc;

use beacon_chain::{
Expand Down Expand Up @@ -56,6 +56,7 @@ pub fn get_randao_verification(

pub async fn produce_blinded_block_v2<T: BeaconChainTypes>(
endpoint_version: EndpointVersion,
accept_header: Option<api_types::Accept>,
chain: Arc<BeaconChain<T>>,
slot: Slot,
query: api_types::ValidatorBlocksQuery,
Expand Down
82 changes: 46 additions & 36 deletions common/eth2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1603,6 +1603,26 @@ impl BeaconNodeHttpClient {
.await
}

/// `GET v2/validator/blocks/{slot}`
pub async fn get_validator_blocks_modular<T: EthSpec, Payload: AbstractExecPayload<T>>(
&self,
slot: Slot,
randao_reveal: &SignatureBytes,
graffiti: Option<&Graffiti>,
skip_randao_verification: SkipRandaoVerification,
) -> Result<ForkVersionedResponse<BeaconBlock<T, Payload>>, Error> {
let path = self
.get_validator_blocks_path::<T, Payload>(
slot,
randao_reveal,
graffiti,
skip_randao_verification,
)
.await?;

self.get(path).await
}

/// returns `GET v2/validator/blocks/{slot}` URL path
pub async fn get_validator_blocks_path<T: EthSpec, Payload: AbstractExecPayload<T>>(
&self,
Expand Down Expand Up @@ -1635,45 +1655,14 @@ impl BeaconNodeHttpClient {
Ok(path)
}

/// `GET v2/validator/blocks/{slot}`
pub async fn get_validator_blocks_modular<T: EthSpec, Payload: AbstractExecPayload<T>>(
&self,
slot: Slot,
randao_reveal: &SignatureBytes,
graffiti: Option<&Graffiti>,
skip_randao_verification: SkipRandaoVerification,
) -> Result<ForkVersionedResponse<BeaconBlock<T, Payload>>, Error> {
let path = self
.get_validator_blocks_path::<T, Payload>(
slot,
randao_reveal,
graffiti,
skip_randao_verification,
)
.await?;

self.get(path).await
}

/// `GET v3/validator/blocks/{slot}`
pub async fn get_validator_blocks_v3<T: EthSpec>(
&self,
slot: Slot,
randao_reveal: &SignatureBytes,
graffiti: Option<&Graffiti>,
) -> Result<ForkVersionedBeaconBlockType<T>, Error> {
self.get_validator_blocks_v3_modular()
}

/// `GET v2/validator/blocks/{slot}` in ssz format
pub async fn get_validator_blocks_ssz<T: EthSpec, Payload: AbstractExecPayload<T>>(
&self,
slot: Slot,
randao_reveal: &SignatureBytes,
graffiti: Option<&Graffiti>,
skip_randao_verification: SkipRandaoVerification,
) -> Result<Option<Vec<u8>>, Error> {
self.get_validator_blocks_modular_ssz::<T, Payload>(
self.get_validator_blocks_v3_modular(
slot,
randao_reveal,
graffiti,
Expand All @@ -1682,8 +1671,8 @@ impl BeaconNodeHttpClient {
.await
}

/// `GET v2/validator/blocks/{slot}` in ssz format
pub async fn get_validator_blocks_modular_ssz<T: EthSpec, Payload: AbstractExecPayload<T>>(
/// `GET v3/validator/blocks/{slot}`
pub async fn get_validator_blocks_v3_modular<T: EthSpec>(
&self,
slot: Slot,
randao_reveal: &SignatureBytes,
Expand Down Expand Up @@ -1728,8 +1717,29 @@ impl BeaconNodeHttpClient {
Ok(ForkVersionedBeaconBlockType::Full(full_payload))
}

/// `GET v3/validator/blocks/{slot}`
pub async fn get_validator_blocks_v3_modular<T: EthSpec>(
/// `GET v2/validator/blocks/{slot}` in ssz format
pub async fn get_validator_blocks_ssz<T: EthSpec, Payload: AbstractExecPayload<T>>(
&self,
slot: Slot,
randao_reveal: &SignatureBytes,
graffiti: Option<&Graffiti>,
) -> Result<Option<Vec<u8>>, Error> {
self.get_validator_blocks_modular_ssz::<T, Payload>(
slot,
randao_reveal,
graffiti,
SkipRandaoVerification::No,
)
.await
}

/// `GET v2/validator/blocks/{slot}` in ssz format
pub async fn get_validator_blocks_modular_ssz<T: EthSpec, Payload: AbstractExecPayload<T>>(
&self,
slot: Slot,
randao_reveal: &SignatureBytes,
graffiti: Option<&Graffiti>,
skip_randao_verification: SkipRandaoVerification,
) -> Result<Option<Vec<u8>>, Error> {
let path = self
.get_validator_blocks_path::<T, Payload>(
Expand Down

0 comments on commit c68e7af

Please sign in to comment.