diff --git a/beacon_node/http_api/src/lib.rs b/beacon_node/http_api/src/lib.rs index c66ddacdaf6..72797f5eb5d 100644 --- a/beacon_node/http_api/src/lib.rs +++ b/beacon_node/http_api/src/lib.rs @@ -33,7 +33,7 @@ mod validator_inclusion; mod validators; mod version; use crate::light_client::{get_light_client_bootstrap, get_light_client_updates}; -use crate::produce_block::{produce_blinded_block_v2, produce_block_v2, produce_block_v3}; +use crate::produce_block::{produce_block_v2, produce_block_v3}; use crate::version::beacon_response; use beacon_chain::{ attestation_verification::VerifiedAttestation, observed_operations::ObservationOutcome, @@ -254,8 +254,6 @@ pub fn prometheus_metrics() -> warp::filters::log::Log( }, ); - // GET validator/blinded_blocks/{slot} - let get_validator_blinded_blocks = eth_v1 - .and(warp::path("validator")) - .and(warp::path("blinded_blocks")) - .and(warp::path::param::().or_else(|_| async { - Err(warp_utils::reject::custom_bad_request( - "Invalid slot".to_string(), - )) - })) - .and(warp::path::end()) - .and(not_while_syncing_filter.clone()) - .and(warp::query::()) - .and(warp::header::optional::("accept")) - .and(task_spawner_filter.clone()) - .and(chain_filter.clone()) - .then( - |slot: Slot, - not_synced_filter: Result<(), Rejection>, - query: api_types::ValidatorBlocksQuery, - accept_header: Option, - task_spawner: TaskSpawner, - chain: Arc>| { - task_spawner.spawn_async_with_rejection(Priority::P0, async move { - not_synced_filter?; - produce_blinded_block_v2(accept_header, chain, slot, query).await - }) - }, - ); - // GET validator/attestation_data?slot,committee_index let get_validator_attestation_data = eth_v1 .and(warp::path("validator")) @@ -4840,7 +4809,6 @@ pub fn serve( .uor(get_node_peer_count) .uor(get_validator_duties_proposer) .uor(get_validator_blocks) - .uor(get_validator_blinded_blocks) .uor(get_validator_attestation_data) .uor(get_validator_aggregate_attestation) .uor(get_validator_sync_committee_contribution) diff --git a/beacon_node/http_api/src/produce_block.rs b/beacon_node/http_api/src/produce_block.rs index db82ff214c8..2a15ca4899b 100644 --- a/beacon_node/http_api/src/produce_block.rs +++ b/beacon_node/http_api/src/produce_block.rs @@ -127,35 +127,6 @@ pub fn build_response_v3( } } -pub async fn produce_blinded_block_v2( - accept_header: Option, - chain: Arc>, - slot: Slot, - query: api_types::ValidatorBlocksQuery, -) -> Result, warp::Rejection> { - let randao_reveal = query.randao_reveal.decompress().map_err(|e| { - warp_utils::reject::custom_bad_request(format!( - "randao reveal is not a valid BLS signature: {:?}", - e - )) - })?; - - let randao_verification = get_randao_verification(&query, randao_reveal.is_infinity())?; - let block_response_type = chain - .produce_block_with_verification( - randao_reveal, - slot, - query.graffiti, - randao_verification, - None, - BlockProductionVersion::BlindedV2, - ) - .await - .map_err(warp_utils::reject::unhandled_error)?; - - build_response_v2(chain, block_response_type, accept_header) -} - pub async fn produce_block_v2( accept_header: Option, chain: Arc>, diff --git a/beacon_node/http_api/tests/tests.rs b/beacon_node/http_api/tests/tests.rs index 5ac8cd91864..195a3f0adc8 100644 --- a/beacon_node/http_api/tests/tests.rs +++ b/beacon_node/http_api/tests/tests.rs @@ -3688,31 +3688,58 @@ impl ApiTester { sk.sign(message).into() }; - let block = self + let (response, metadata) = self .client - .get_validator_blinded_blocks::(slot, &randao_reveal, None) + .get_validator_blocks_v3::(slot, &randao_reveal, None, None) .await - .unwrap() - .into_data(); + .unwrap(); - let signed_block = block.sign(&sk, &fork, genesis_validators_root, &self.chain.spec); + match response.data { + ProduceBlockV3Response::Blinded(blinded_block) => { + assert!(metadata.execution_payload_blinded); + assert_eq!( + metadata.consensus_version, + blinded_block.to_ref().fork_name(&self.chain.spec).unwrap() + ); + let signed_blinded_block = + blinded_block.sign(&sk, &fork, genesis_validators_root, &self.chain.spec); - self.client - .post_beacon_blinded_blocks(&signed_block) - .await - .unwrap(); + self.client + .post_beacon_blinded_blocks(&signed_blinded_block) + .await + .unwrap(); - let head_block = self - .client - .get_beacon_blocks(CoreBlockId::Head) - .await - .unwrap() - .unwrap() - .into_data(); + let head_block = self.chain.head_beacon_block().clone_as_blinded(); + assert_eq!(head_block, signed_blinded_block); - assert_eq!(head_block.clone_as_blinded(), signed_block); + self.chain.slot_clock.set_slot(slot.as_u64() + 1); + } + ProduceBlockV3Response::Full(block_contents) => { + assert!(!metadata.execution_payload_blinded); + assert_eq!( + metadata.consensus_version, + block_contents + .block() + .to_ref() + .fork_name(&self.chain.spec) + .unwrap() + ); + let signed_block_contents = + block_contents.sign(&sk, &fork, genesis_validators_root, &self.chain.spec); - self.chain.slot_clock.set_slot(slot.as_u64() + 1); + self.client + .post_beacon_blocks(&signed_block_contents) + .await + .unwrap(); + + assert_eq!( + self.chain.head_beacon_block(), + *signed_block_contents.signed_block() + ); + + self.chain.slot_clock.set_slot(slot.as_u64() + 1); + } + } } } @@ -3756,7 +3783,7 @@ impl ApiTester { let block_contents_bytes = self .client - .get_validator_blinded_blocks_ssz::(slot, &randao_reveal, None) + .get_validator_blocks_ssz::(slot, &randao_reveal, None) .await .unwrap() .expect("block bytes"); @@ -3794,18 +3821,27 @@ impl ApiTester { for _ in 0..E::slots_per_epoch() { let slot = self.chain.slot().unwrap(); - let blinded_block = self + let (response, _metadata) = self .client - .get_validator_blinded_blocks_modular::( + .get_validator_blocks_v3_modular::( slot, &Signature::infinity().unwrap().into(), None, SkipRandaoVerification::Yes, + None, ) .await - .unwrap() - .into_data(); - assert_eq!(blinded_block.slot(), slot); + .unwrap(); + + match response.data { + ProduceBlockV3Response::Blinded(blinded_block) => { + assert_eq!(blinded_block.slot(), slot); + } + ProduceBlockV3Response::Full(full_block) => { + assert_eq!(full_block.block().slot(), slot); + } + } + self.chain.slot_clock.set_slot(slot.as_u64() + 1); } @@ -3852,17 +3888,18 @@ impl ApiTester { // Check failure with full randao verification enabled. self.client - .get_validator_blinded_blocks::(slot, &bad_randao_reveal, None) + .get_validator_blocks_v3::(slot, &bad_randao_reveal, None, None) .await .unwrap_err(); // Check failure with `skip_randao_verification` (requires infinity sig). self.client - .get_validator_blinded_blocks_modular::( + .get_validator_blocks_v3_modular::( slot, &bad_randao_reveal, None, SkipRandaoVerification::Yes, + None, ) .await .unwrap_err(); @@ -4555,16 +4592,19 @@ impl ApiTester { let (proposer_index, randao_reveal) = self.get_test_randao(slot, epoch).await; - let payload: BlindedPayload = self + let (payload_type, metadata) = self .client - .get_validator_blinded_blocks::(slot, &randao_reveal, None) + .get_validator_blocks_v3::(slot, &randao_reveal, None, None) .await - .unwrap() - .into_data() - .body() - .execution_payload() - .unwrap() - .into(); + .unwrap(); + Self::check_block_v3_metadata(&metadata, &payload_type); + + let payload: BlindedPayload = match payload_type.data { + ProduceBlockV3Response::Blinded(payload) => { + payload.body().execution_payload().unwrap().into() + } + ProduceBlockV3Response::Full(_) => panic!("Expecting a blinded payload"), + }; let expected_fee_recipient = Address::from_low_u64_be(proposer_index); assert_eq!(payload.fee_recipient(), expected_fee_recipient); @@ -4601,16 +4641,19 @@ impl ApiTester { let (proposer_index, randao_reveal) = self.get_test_randao(slot, epoch).await; - let payload: BlindedPayload = self + let (payload_type, metadata) = self .client - .get_validator_blinded_blocks::(slot, &randao_reveal, None) + .get_validator_blocks_v3::(slot, &randao_reveal, None, None) .await - .unwrap() - .into_data() - .body() - .execution_payload() - .unwrap() - .into(); + .unwrap(); + Self::check_block_v3_metadata(&metadata, &payload_type); + + let payload: BlindedPayload = match payload_type.data { + ProduceBlockV3Response::Blinded(payload) => { + payload.body().execution_payload().unwrap().into() + } + ProduceBlockV3Response::Full(_) => panic!("Expecting a blinded payload"), + }; let expected_fee_recipient = Address::from_low_u64_be(proposer_index); assert_eq!(payload.fee_recipient(), expected_fee_recipient); @@ -4645,16 +4688,19 @@ impl ApiTester { let (_, randao_reveal) = self.get_test_randao(slot, epoch).await; - let payload: BlindedPayload = self + let (payload_type, metadata) = self .client - .get_validator_blinded_blocks::(slot, &randao_reveal, None) + .get_validator_blocks_v3::(slot, &randao_reveal, None, None) .await - .unwrap() - .into_data() - .body() - .execution_payload() - .unwrap() - .into(); + .unwrap(); + Self::check_block_v3_metadata(&metadata, &payload_type); + + let payload: FullPayload = match payload_type.data { + ProduceBlockV3Response::Full(payload) => { + payload.block().body().execution_payload().unwrap().into() + } + ProduceBlockV3Response::Blinded(_) => panic!("Expecting a full payload"), + }; // If this cache is populated, it indicates fallback to the local EE was correctly used. assert!(self @@ -4719,16 +4765,19 @@ impl ApiTester { let (_, randao_reveal) = self.get_test_randao(slot, epoch).await; - let payload: BlindedPayload = self + let (payload_type, metadata) = self .client - .get_validator_blinded_blocks::(slot, &randao_reveal, None) + .get_validator_blocks_v3::(slot, &randao_reveal, None, None) .await - .unwrap() - .into_data() - .body() - .execution_payload() - .unwrap() - .into(); + .unwrap(); + Self::check_block_v3_metadata(&metadata, &payload_type); + + let payload: BlindedPayload = match payload_type.data { + ProduceBlockV3Response::Blinded(payload) => { + payload.body().execution_payload().unwrap().into() + } + ProduceBlockV3Response::Full(_) => panic!("Expecting a blinded payload"), + }; assert_eq!(payload.fee_recipient(), test_fee_recipient); @@ -4805,16 +4854,19 @@ impl ApiTester { let (_, randao_reveal) = self.get_test_randao(slot, epoch).await; - let payload: BlindedPayload = self + let (payload_type, metadata) = self .client - .get_validator_blinded_blocks::(slot, &randao_reveal, None) + .get_validator_blocks_v3::(slot, &randao_reveal, None, None) .await - .unwrap() - .into_data() - .body() - .execution_payload() - .unwrap() - .into(); + .unwrap(); + Self::check_block_v3_metadata(&metadata, &payload_type); + + let payload: FullPayload = match payload_type.data { + ProduceBlockV3Response::Full(payload) => { + payload.block().body().execution_payload().unwrap().into() + } + ProduceBlockV3Response::Blinded(_) => panic!("Expecting a full payload"), + }; assert_eq!(payload.parent_hash(), expected_parent_hash); @@ -4867,7 +4919,7 @@ impl ApiTester { ProduceBlockV3Response::Full(payload) => { payload.block().body().execution_payload().unwrap().into() } - ProduceBlockV3Response::Blinded(_) => panic!("Expecting a blinded payload"), + ProduceBlockV3Response::Blinded(_) => panic!("Expecting a full payload"), }; assert_eq!(payload.parent_hash(), expected_parent_hash); @@ -4897,16 +4949,19 @@ impl ApiTester { .unwrap(); let (_, randao_reveal) = self.get_test_randao(slot, epoch).await; - let payload: BlindedPayload = self + let (payload_type, metadata) = self .client - .get_validator_blinded_blocks::(slot, &randao_reveal, None) + .get_validator_blocks_v3::(slot, &randao_reveal, None, None) .await - .unwrap() - .into_data() - .body() - .execution_payload() - .unwrap() - .into(); + .unwrap(); + Self::check_block_v3_metadata(&metadata, &payload_type); + + let payload: FullPayload = match payload_type.data { + ProduceBlockV3Response::Full(payload) => { + payload.block().body().execution_payload().unwrap().into() + } + ProduceBlockV3Response::Blinded(_) => panic!("Expecting a full payload"), + }; assert_eq!(payload.prev_randao(), expected_prev_randao); @@ -4987,16 +5042,19 @@ impl ApiTester { let (_, randao_reveal) = self.get_test_randao(slot, epoch).await; - let payload: BlindedPayload = self + let (payload_type, metadata) = self .client - .get_validator_blinded_blocks::(slot, &randao_reveal, None) + .get_validator_blocks_v3::(slot, &randao_reveal, None, None) .await - .unwrap() - .into_data() - .body() - .execution_payload() - .unwrap() - .into(); + .unwrap(); + Self::check_block_v3_metadata(&metadata, &payload_type); + + let payload: FullPayload = match payload_type.data { + ProduceBlockV3Response::Full(payload) => { + payload.block().body().execution_payload().unwrap().into() + } + ProduceBlockV3Response::Blinded(_) => panic!("Expecting a full payload"), + }; assert_eq!(payload.block_number(), expected_block_number); @@ -5076,16 +5134,19 @@ impl ApiTester { let (_, randao_reveal) = self.get_test_randao(slot, epoch).await; - let payload: BlindedPayload = self + let (payload_type, metadata) = self .client - .get_validator_blinded_blocks::(slot, &randao_reveal, None) + .get_validator_blocks_v3::(slot, &randao_reveal, None, None) .await - .unwrap() - .into_data() - .body() - .execution_payload() - .unwrap() - .into(); + .unwrap(); + Self::check_block_v3_metadata(&metadata, &payload_type); + + let payload: FullPayload = match payload_type.data { + ProduceBlockV3Response::Full(payload) => { + payload.block().body().execution_payload().unwrap().into() + } + ProduceBlockV3Response::Blinded(_) => panic!("Expecting a full payload"), + }; assert!(payload.timestamp() > min_expected_timestamp); @@ -5135,7 +5196,7 @@ impl ApiTester { ProduceBlockV3Response::Full(payload) => { payload.block().body().execution_payload().unwrap().into() } - ProduceBlockV3Response::Blinded(_) => panic!("Expecting a blinded payload"), + ProduceBlockV3Response::Blinded(_) => panic!("Expecting a full payload"), }; assert!(payload.timestamp() > min_expected_timestamp); @@ -5151,16 +5212,19 @@ impl ApiTester { let (_, randao_reveal) = self.get_test_randao(slot, epoch).await; - let payload: BlindedPayload = self + let (payload_type, metadata) = self .client - .get_validator_blinded_blocks::(slot, &randao_reveal, None) + .get_validator_blocks_v3::(slot, &randao_reveal, None, None) .await - .unwrap() - .into_data() - .body() - .execution_payload() - .unwrap() - .into(); + .unwrap(); + Self::check_block_v3_metadata(&metadata, &payload_type); + + let payload: FullPayload = match payload_type.data { + ProduceBlockV3Response::Full(payload) => { + payload.block().body().execution_payload().unwrap().into() + } + ProduceBlockV3Response::Blinded(_) => panic!("Expecting a full payload"), + }; // If this cache is populated, it indicates fallback to the local EE was correctly used. assert!(self @@ -5214,16 +5278,19 @@ impl ApiTester { let (_, randao_reveal) = self.get_test_randao(slot, epoch).await; - let payload: BlindedPayload = self + let (payload_type, metadata) = self .client - .get_validator_blinded_blocks::(slot, &randao_reveal, None) + .get_validator_blocks_v3::(slot, &randao_reveal, None, None) .await - .unwrap() - .into_data() - .body() - .execution_payload() - .unwrap() - .into(); + .unwrap(); + Self::check_block_v3_metadata(&metadata, &payload_type); + + let payload: FullPayload = match payload_type.data { + ProduceBlockV3Response::Full(payload) => { + payload.block().body().execution_payload().unwrap().into() + } + ProduceBlockV3Response::Blinded(_) => panic!("Expecting a full payload"), + }; // If this cache is populated, it indicates fallback to the local EE was correctly used. assert!(self @@ -5290,16 +5357,19 @@ impl ApiTester { .get_test_randao(next_slot, next_slot.epoch(E::slots_per_epoch())) .await; - let payload: BlindedPayload = self + let (payload_type, metadata) = self .client - .get_validator_blinded_blocks::(next_slot, &randao_reveal, None) + .get_validator_blocks_v3::(next_slot, &randao_reveal, None, None) .await - .unwrap() - .into_data() - .body() - .execution_payload() - .unwrap() - .into(); + .unwrap(); + Self::check_block_v3_metadata(&metadata, &payload_type); + + let payload: BlindedPayload = match payload_type.data { + ProduceBlockV3Response::Blinded(payload) => { + payload.body().execution_payload().unwrap().into() + } + ProduceBlockV3Response::Full(_) => panic!("Expecting a blinded payload"), + }; // This cache should not be populated because fallback should not have been used. assert!(self @@ -5321,16 +5391,19 @@ impl ApiTester { .get_test_randao(next_slot, next_slot.epoch(E::slots_per_epoch())) .await; - let payload: BlindedPayload = self + let (payload_type, metadata) = self .client - .get_validator_blinded_blocks::(next_slot, &randao_reveal, None) + .get_validator_blocks_v3::(next_slot, &randao_reveal, None, None) .await - .unwrap() - .into_data() - .body() - .execution_payload() - .unwrap() - .into(); + .unwrap(); + Self::check_block_v3_metadata(&metadata, &payload_type); + + let payload: FullPayload = match payload_type.data { + ProduceBlockV3Response::Full(payload) => { + payload.block().body().execution_payload().unwrap().into() + } + ProduceBlockV3Response::Blinded(_) => panic!("Expecting a full payload"), + }; // If this cache is populated, it indicates fallback to the local EE was correctly used. assert!(self @@ -5429,16 +5502,19 @@ impl ApiTester { .get_test_randao(next_slot, next_slot.epoch(E::slots_per_epoch())) .await; - let payload: BlindedPayload = self + let (payload_type, metadata) = self .client - .get_validator_blinded_blocks::(next_slot, &randao_reveal, None) + .get_validator_blocks_v3::(next_slot, &randao_reveal, None, None) .await - .unwrap() - .into_data() - .body() - .execution_payload() - .unwrap() - .into(); + .unwrap(); + Self::check_block_v3_metadata(&metadata, &payload_type); + + let payload: FullPayload = match payload_type.data { + ProduceBlockV3Response::Full(payload) => { + payload.block().body().execution_payload().unwrap().into() + } + ProduceBlockV3Response::Blinded(_) => panic!("Expecting a full payload"), + }; // If this cache is populated, it indicates fallback to the local EE was correctly used. assert!(self @@ -5470,16 +5546,19 @@ impl ApiTester { .get_test_randao(next_slot, next_slot.epoch(E::slots_per_epoch())) .await; - let payload: BlindedPayload = self + let (payload_type, metadata) = self .client - .get_validator_blinded_blocks::(next_slot, &randao_reveal, None) + .get_validator_blocks_v3::(next_slot, &randao_reveal, None, None) .await - .unwrap() - .into_data() - .body() - .execution_payload() - .unwrap() - .into(); + .unwrap(); + Self::check_block_v3_metadata(&metadata, &payload_type); + + let payload: BlindedPayload = match payload_type.data { + ProduceBlockV3Response::Blinded(payload) => { + payload.body().execution_payload().unwrap().into() + } + ProduceBlockV3Response::Full(_) => panic!("Expecting a blinded payload"), + }; // This cache should not be populated because fallback should not have been used. assert!(self @@ -5586,16 +5665,19 @@ impl ApiTester { let (proposer_index, randao_reveal) = self.get_test_randao(slot, epoch).await; - let payload: BlindedPayload = self + let (payload_type, metadata) = self .client - .get_validator_blinded_blocks::(slot, &randao_reveal, None) + .get_validator_blocks_v3::(slot, &randao_reveal, None, None) .await - .unwrap() - .into_data() - .body() - .execution_payload() - .unwrap() - .into(); + .unwrap(); + Self::check_block_v3_metadata(&metadata, &payload_type); + + let payload: FullPayload = match payload_type.data { + ProduceBlockV3Response::Full(payload) => { + payload.block().body().execution_payload().unwrap().into() + } + ProduceBlockV3Response::Blinded(_) => panic!("Expecting a full payload"), + }; let expected_fee_recipient = Address::from_low_u64_be(proposer_index); assert_eq!(payload.fee_recipient(), expected_fee_recipient); @@ -5667,16 +5749,19 @@ impl ApiTester { let (_, randao_reveal) = self.get_test_randao(slot, epoch).await; - let payload: BlindedPayload = self + let (payload_type, metadata) = self .client - .get_validator_blinded_blocks::(slot, &randao_reveal, None) + .get_validator_blocks_v3::(slot, &randao_reveal, None, None) .await - .unwrap() - .into_data() - .body() - .execution_payload() - .unwrap() - .into(); + .unwrap(); + Self::check_block_v3_metadata(&metadata, &payload_type); + + let payload: BlindedPayload = match payload_type.data { + ProduceBlockV3Response::Blinded(payload) => { + payload.body().execution_payload().unwrap().into() + } + ProduceBlockV3Response::Full(_) => panic!("Expecting a blinded payload"), + }; // The builder's payload should've been chosen, so this cache should not be populated assert!(self @@ -5735,16 +5820,19 @@ impl ApiTester { let (_, randao_reveal) = self.get_test_randao(slot, epoch).await; - let payload: BlindedPayload = self + let (payload_type, metadata) = self .client - .get_validator_blinded_blocks::(slot, &randao_reveal, None) + .get_validator_blocks_v3::(slot, &randao_reveal, None, None) .await - .unwrap() - .into_data() - .body() - .execution_payload() - .unwrap() - .into(); + .unwrap(); + Self::check_block_v3_metadata(&metadata, &payload_type); + + let payload: FullPayload = match payload_type.data { + ProduceBlockV3Response::Full(payload) => { + payload.block().body().execution_payload().unwrap().into() + } + ProduceBlockV3Response::Blinded(_) => panic!("Expecting a full payload"), + }; // The local payload should've been chosen, so this cache should be populated assert!(self @@ -5803,16 +5891,19 @@ impl ApiTester { let (_, randao_reveal) = self.get_test_randao(slot, epoch).await; - let payload: BlindedPayload = self + let (payload_type, metadata) = self .client - .get_validator_blinded_blocks::(slot, &randao_reveal, None) + .get_validator_blocks_v3::(slot, &randao_reveal, None, None) .await - .unwrap() - .into_data() - .body() - .execution_payload() - .unwrap() - .into(); + .unwrap(); + Self::check_block_v3_metadata(&metadata, &payload_type); + + let payload: FullPayload = match payload_type.data { + ProduceBlockV3Response::Full(payload) => { + payload.block().body().execution_payload().unwrap().into() + } + ProduceBlockV3Response::Blinded(_) => panic!("Expecting a full payload"), + }; // The local payload should've been chosen, so this cache should be populated assert!(self @@ -5870,16 +5961,19 @@ impl ApiTester { let epoch = self.chain.epoch().unwrap(); let (_, randao_reveal) = self.get_test_randao(slot, epoch).await; - let payload: BlindedPayload = self + let (payload_type, metadata) = self .client - .get_validator_blinded_blocks::(slot, &randao_reveal, None) + .get_validator_blocks_v3::(slot, &randao_reveal, None, None) .await - .unwrap() - .into_data() - .body() - .execution_payload() - .unwrap() - .into(); + .unwrap(); + Self::check_block_v3_metadata(&metadata, &payload_type); + + let payload: BlindedPayload = match payload_type.data { + ProduceBlockV3Response::Blinded(payload) => { + payload.body().execution_payload().unwrap().into() + } + ProduceBlockV3Response::Full(_) => panic!("Expecting a blinded payload"), + }; // The builder's payload should've been chosen, so this cache should not be populated assert!(self @@ -5941,16 +6035,19 @@ impl ApiTester { let epoch = self.chain.epoch().unwrap(); let (_, randao_reveal) = self.get_test_randao(slot, epoch).await; - let payload: BlindedPayload = self + let (payload_type, metadata) = self .client - .get_validator_blinded_blocks::(slot, &randao_reveal, None) + .get_validator_blocks_v3::(slot, &randao_reveal, None, None) .await - .unwrap() - .into_data() - .body() - .execution_payload() - .unwrap() - .into(); + .unwrap(); + Self::check_block_v3_metadata(&metadata, &payload_type); + + let payload: FullPayload = match payload_type.data { + ProduceBlockV3Response::Full(payload) => { + payload.block().body().execution_payload().unwrap().into() + } + ProduceBlockV3Response::Blinded(_) => panic!("Expecting a full payload"), + }; // The local payload should've been chosen because the builder's was invalid assert!(self diff --git a/common/eth2/src/lib.rs b/common/eth2/src/lib.rs index a129f9c4fa5..63ce0a22ab7 100644 --- a/common/eth2/src/lib.rs +++ b/common/eth2/src/lib.rs @@ -2400,110 +2400,6 @@ impl BeaconNodeHttpClient { .await } - /// `GET v2/validator/blinded_blocks/{slot}` - pub async fn get_validator_blinded_blocks( - &self, - slot: Slot, - randao_reveal: &SignatureBytes, - graffiti: Option<&Graffiti>, - ) -> Result>, Error> { - self.get_validator_blinded_blocks_modular( - slot, - randao_reveal, - graffiti, - SkipRandaoVerification::No, - ) - .await - } - - /// returns `GET v1/validator/blinded_blocks/{slot}` URL path - pub async fn get_validator_blinded_blocks_path( - &self, - slot: Slot, - randao_reveal: &SignatureBytes, - graffiti: Option<&Graffiti>, - skip_randao_verification: SkipRandaoVerification, - ) -> Result { - let mut path = self.eth_path(V1)?; - - path.path_segments_mut() - .map_err(|()| Error::InvalidUrl(self.server.clone()))? - .push("validator") - .push("blinded_blocks") - .push(&slot.to_string()); - - path.query_pairs_mut() - .append_pair("randao_reveal", &randao_reveal.to_string()); - - if let Some(graffiti) = graffiti { - path.query_pairs_mut() - .append_pair("graffiti", &graffiti.to_string()); - } - - if skip_randao_verification == SkipRandaoVerification::Yes { - path.query_pairs_mut() - .append_key_only("skip_randao_verification"); - } - - Ok(path) - } - - /// `GET v1/validator/blinded_blocks/{slot}` - pub async fn get_validator_blinded_blocks_modular( - &self, - slot: Slot, - randao_reveal: &SignatureBytes, - graffiti: Option<&Graffiti>, - skip_randao_verification: SkipRandaoVerification, - ) -> Result>, Error> { - let path = self - .get_validator_blinded_blocks_path::( - slot, - randao_reveal, - graffiti, - skip_randao_verification, - ) - .await?; - - self.get(path).await.map(BeaconResponse::ForkVersioned) - } - - /// `GET v2/validator/blinded_blocks/{slot}` in ssz format - pub async fn get_validator_blinded_blocks_ssz( - &self, - slot: Slot, - randao_reveal: &SignatureBytes, - graffiti: Option<&Graffiti>, - ) -> Result>, Error> { - self.get_validator_blinded_blocks_modular_ssz::( - slot, - randao_reveal, - graffiti, - SkipRandaoVerification::No, - ) - .await - } - - pub async fn get_validator_blinded_blocks_modular_ssz( - &self, - slot: Slot, - randao_reveal: &SignatureBytes, - graffiti: Option<&Graffiti>, - skip_randao_verification: SkipRandaoVerification, - ) -> Result>, Error> { - let path = self - .get_validator_blinded_blocks_path::( - slot, - randao_reveal, - graffiti, - skip_randao_verification, - ) - .await?; - - self.get_bytes_opt_accept_header(path, Accept::Ssz, self.timeouts.get_validator_block) - .await - } - /// `GET validator/attestation_data?slot,committee_index` pub async fn get_validator_attestation_data( &self,