From 2021055121d899a987e27ce54f9b88d49f37432d Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Tue, 21 Apr 2026 17:52:31 +1000 Subject: [PATCH] Gloas HTTP API tests passing --- Makefile | 2 +- beacon_node/beacon_chain/src/test_utils.rs | 37 ++++++ .../tests/broadcast_validation_tests.rs | 31 +++-- .../http_api/tests/interactive_tests.rs | 8 +- beacon_node/http_api/tests/tests.rs | 109 +++++++++++++++++- common/eth2/src/types.rs | 7 +- 6 files changed, 174 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 280e74d1d9..75d36e5931 100644 --- a/Makefile +++ b/Makefile @@ -213,7 +213,7 @@ test-beacon-chain-%: env FORK_NAME=$* cargo nextest run --release --features "fork_from_env,slasher/lmdb,$(TEST_FEATURES)" -p beacon_chain --no-fail-fast # Run the tests in the `http_api` crate for recent forks. -test-http-api: $(patsubst %,test-http-api-%,$(RECENT_FORKS_BEFORE_GLOAS)) +test-http-api: $(patsubst %,test-http-api-%,$(RECENT_FORKS)) test-http-api-%: env FORK_NAME=$* cargo nextest run --release --features "beacon_chain/fork_from_env" -p http_api diff --git a/beacon_node/beacon_chain/src/test_utils.rs b/beacon_node/beacon_chain/src/test_utils.rs index e84f9ad983..d9bbf26eaa 100644 --- a/beacon_node/beacon_chain/src/test_utils.rs +++ b/beacon_node/beacon_chain/src/test_utils.rs @@ -984,6 +984,28 @@ where assert_ne!(slot, 0, "can't produce a block at slot 0"); assert!(slot >= state.slot()); + // For Gloas, blinded and full blocks are structurally identical (no payload in body). + // Produce via the Gloas path and convert to blinded. + if self.spec.fork_name_at_slot::(slot).gloas_enabled() { + let (block_contents, _envelope, pending_state) = + Box::pin(self.make_block_with_envelope(state, slot)).await; + let (signed_block, _blobs) = block_contents; + let signed_blinded = signed_block.clone_as_blinded(); + let (mut blinded_block, _signature) = signed_blinded.deconstruct(); + block_modifier(&mut blinded_block); + let proposer_index = pending_state + .get_beacon_proposer_index(slot, &self.spec) + .unwrap(); + // Re-sign after modification. + let signed_blinded = blinded_block.sign( + &self.validator_keypairs[proposer_index].sk, + &pending_state.fork(), + pending_state.genesis_validators_root(), + &self.spec, + ); + return (signed_blinded, pending_state); + } + complete_state_advance(&mut state, None, slot, &self.spec) .expect("should be able to advance state to slot"); @@ -1204,6 +1226,21 @@ where assert_ne!(slot, 0, "can't produce a block at slot 0"); assert!(slot >= state.slot()); + // For Gloas forks, delegate to make_block_with_envelope which uses the + // Gloas-specific block production path, and return the pre-state. + if self.spec.fork_name_at_slot::(slot).gloas_enabled() { + let pre_state = { + let mut s = state.clone(); + complete_state_advance(&mut s, None, slot, &self.spec) + .expect("should be able to advance state to slot"); + s.build_caches(&self.spec).expect("should build caches"); + s + }; + let (block_contents, _envelope, _state) = + Box::pin(self.make_block_with_envelope(state, slot)).await; + return (block_contents, pre_state); + } + complete_state_advance(&mut state, None, slot, &self.spec) .expect("should be able to advance state to slot"); diff --git a/beacon_node/http_api/tests/broadcast_validation_tests.rs b/beacon_node/http_api/tests/broadcast_validation_tests.rs index a380f62ecf..a189be1cfc 100644 --- a/beacon_node/http_api/tests/broadcast_validation_tests.rs +++ b/beacon_node/http_api/tests/broadcast_validation_tests.rs @@ -909,7 +909,7 @@ pub async fn blinded_gossip_partial_pass() { .client .post_beacon_blinded_blocks_v2(&blinded_block, validation_level) .await; - if tester.harness.spec.is_fulu_scheduled() { + if tester.harness.spec.is_fulu_scheduled() && !tester.harness.spec.is_gloas_scheduled() { let error_response = response.unwrap_err(); // XXX: this should be a 400 but is a 500 due to the mock-builder being janky assert_eq!( @@ -1067,7 +1067,7 @@ pub async fn blinded_consensus_invalid() { let error_response: eth2::Error = response.err().unwrap(); /* mandated by Beacon API spec */ - if tester.harness.spec.is_fulu_scheduled() { + if tester.harness.spec.is_fulu_scheduled() && !tester.harness.spec.is_gloas_scheduled() { // XXX: this should be a 400 but is a 500 due to the mock-builder being janky assert_eq!( error_response.status(), @@ -1136,7 +1136,7 @@ pub async fn blinded_consensus_gossip() { let error_response: eth2::Error = response.err().unwrap(); /* mandated by Beacon API spec */ - if tester.harness.spec.is_fulu_scheduled() { + if tester.harness.spec.is_fulu_scheduled() && !tester.harness.spec.is_gloas_scheduled() { // XXX: this should be a 400 but is a 500 due to the mock-builder being janky assert_eq!( error_response.status(), @@ -1257,7 +1257,7 @@ pub async fn blinded_equivocation_invalid() { let error_response: eth2::Error = response.err().unwrap(); /* mandated by Beacon API spec */ - if tester.harness.spec.is_fulu_scheduled() { + if tester.harness.spec.is_fulu_scheduled() && !tester.harness.spec.is_gloas_scheduled() { assert_eq!( error_response.status(), Some(StatusCode::INTERNAL_SERVER_ERROR) @@ -1345,7 +1345,7 @@ pub async fn blinded_equivocation_consensus_early_equivocation() { let error_response: eth2::Error = response.err().unwrap(); - if tester.harness.spec.is_fulu_scheduled() { + if tester.harness.spec.is_fulu_scheduled() && !tester.harness.spec.is_gloas_scheduled() { assert_eq!( error_response.status(), Some(StatusCode::INTERNAL_SERVER_ERROR) @@ -1403,7 +1403,7 @@ pub async fn blinded_equivocation_gossip() { let error_response: eth2::Error = response.err().unwrap(); /* mandated by Beacon API spec */ - if tester.harness.spec.is_fulu_scheduled() { + if tester.harness.spec.is_fulu_scheduled() && !tester.harness.spec.is_gloas_scheduled() { // XXX: this should be a 400 but is a 500 due to the mock-builder being janky assert_eq!( error_response.status(), @@ -1586,7 +1586,8 @@ pub async fn block_seen_on_gossip_without_blobs_or_columns() { let tester = InteractiveTester::::new(None, validator_count).await; let state = tester.harness.get_current_state(); let fork_name = state.fork_name(&tester.harness.spec).unwrap(); - if !fork_name.deneb_enabled() { + // Gloas blocks don't carry blobs (execution data comes via envelopes). + if !fork_name.deneb_enabled() || fork_name.gloas_enabled() { return; } @@ -1656,7 +1657,8 @@ pub async fn block_seen_on_gossip_with_some_blobs_or_columns() { let tester = InteractiveTester::::new(None, validator_count).await; let state = tester.harness.get_current_state(); let fork_name = state.fork_name(&tester.harness.spec).unwrap(); - if !fork_name.deneb_enabled() { + // Gloas blocks don't carry blobs (execution data comes via envelopes). + if !fork_name.deneb_enabled() || fork_name.gloas_enabled() { return; } @@ -1749,7 +1751,8 @@ pub async fn blobs_or_columns_seen_on_gossip_without_block() { let tester = InteractiveTester::::new(Some(spec.clone()), validator_count).await; let state = tester.harness.get_current_state(); let fork_name = state.fork_name(&tester.harness.spec).unwrap(); - if !fork_name.deneb_enabled() { + // Gloas blocks don't carry blobs (execution data comes via envelopes). + if !fork_name.deneb_enabled() || fork_name.gloas_enabled() { return; } @@ -1823,7 +1826,8 @@ async fn blobs_or_columns_seen_on_gossip_without_block_and_no_http_blobs_or_colu let tester = InteractiveTester::::new(None, validator_count).await; let state = tester.harness.get_current_state(); let fork_name = state.fork_name(&tester.harness.spec).unwrap(); - if !fork_name.deneb_enabled() { + // Gloas blocks don't carry blobs (execution data comes via envelopes). + if !fork_name.deneb_enabled() || fork_name.gloas_enabled() { return; } @@ -1900,7 +1904,8 @@ async fn slashable_blobs_or_columns_seen_on_gossip_cause_failure() { let tester = InteractiveTester::::new(None, validator_count).await; let state = tester.harness.get_current_state(); let fork_name = state.fork_name(&tester.harness.spec).unwrap(); - if !fork_name.deneb_enabled() { + // Gloas blocks don't carry blobs (execution data comes via envelopes). + if !fork_name.deneb_enabled() || fork_name.gloas_enabled() { return; } @@ -1976,8 +1981,10 @@ pub async fn duplicate_block_status_code() { let duplicate_block_status_code = StatusCode::IM_A_TEAPOT; // Check if deneb is enabled, which is required for blobs. + // Gloas blocks don't carry blobs (execution data comes via envelopes). let spec = test_spec::(); - if !spec.fork_name_at_slot::(Slot::new(0)).deneb_enabled() { + let genesis_fork = spec.fork_name_at_slot::(Slot::new(0)); + if !genesis_fork.deneb_enabled() || genesis_fork.gloas_enabled() { return; } diff --git a/beacon_node/http_api/tests/interactive_tests.rs b/beacon_node/http_api/tests/interactive_tests.rs index 15f61537a0..5912d6b1b2 100644 --- a/beacon_node/http_api/tests/interactive_tests.rs +++ b/beacon_node/http_api/tests/interactive_tests.rs @@ -951,7 +951,7 @@ async fn queue_attestations_from_http() { // gossip clock disparity (500ms) of the new epoch. #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn proposer_duties_with_gossip_tolerance() { - let validator_count = 24; + let validator_count = 64; let tester = InteractiveTester::::new(None, validator_count).await; let harness = &tester.harness; @@ -1058,7 +1058,7 @@ async fn proposer_duties_with_gossip_tolerance() { // within gossip clock disparity (500ms) of the new epoch. #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn proposer_duties_v2_with_gossip_tolerance() { - let validator_count = 24; + let validator_count = 64; let tester = InteractiveTester::::new(None, validator_count).await; let harness = &tester.harness; @@ -1300,7 +1300,7 @@ async fn lighthouse_restart_custody_backfill() { return; } - let validator_count = 24; + let validator_count = 64; let tester = InteractiveTester::::new_supernode(Some(spec), validator_count).await; let harness = &tester.harness; @@ -1367,7 +1367,7 @@ async fn lighthouse_custody_info() { spec.min_epochs_for_blob_sidecars_requests = 2; spec.min_epochs_for_data_column_sidecars_requests = 2; - let validator_count = 24; + let validator_count = 64; let tester = InteractiveTester::::new(Some(spec), validator_count).await; let harness = &tester.harness; diff --git a/beacon_node/http_api/tests/tests.rs b/beacon_node/http_api/tests/tests.rs index 2dd4c28040..6b64542aa5 100644 --- a/beacon_node/http_api/tests/tests.rs +++ b/beacon_node/http_api/tests/tests.rs @@ -3926,7 +3926,6 @@ impl ApiTester { metadata.consensus_version, block.to_ref().fork_name(&self.chain.spec).unwrap() ); - assert!(!metadata.consensus_block_value.is_zero()); let block_root = block.tree_hash_root(); let envelope = self @@ -8256,6 +8255,10 @@ async fn post_validator_register_validator_slashed() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn post_validator_register_valid() { + // Gloas builder model is fundamentally different (bids, not payloads). + if test_spec::().is_gloas_scheduled() { + return; + } ApiTester::new_mev_tester() .await .test_payload_respects_registration() @@ -8264,6 +8267,10 @@ async fn post_validator_register_valid() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn post_validator_zero_builder_boost_factor() { + // Gloas builder model is fundamentally different (bids, not payloads). + if test_spec::().is_gloas_scheduled() { + return; + } ApiTester::new_mev_tester() .await .test_payload_v3_zero_builder_boost_factor() @@ -8272,6 +8279,10 @@ async fn post_validator_zero_builder_boost_factor() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn post_validator_max_builder_boost_factor() { + // Gloas builder model is fundamentally different (bids, not payloads). + if test_spec::().is_gloas_scheduled() { + return; + } ApiTester::new_mev_tester() .await .test_payload_v3_max_builder_boost_factor() @@ -8280,6 +8291,10 @@ async fn post_validator_max_builder_boost_factor() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn post_validator_register_valid_v3() { + // Gloas builder model is fundamentally different (bids, not payloads). + if test_spec::().is_gloas_scheduled() { + return; + } ApiTester::new_mev_tester() .await .test_payload_v3_respects_registration() @@ -8288,6 +8303,10 @@ async fn post_validator_register_valid_v3() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn post_validator_register_gas_limit_mutation() { + // Gloas builder model is fundamentally different (bids, not payloads). + if test_spec::().is_gloas_scheduled() { + return; + } ApiTester::new_mev_tester() .await .test_builder_payload_rejected_when_gas_limit_incorrect() @@ -8298,6 +8317,10 @@ async fn post_validator_register_gas_limit_mutation() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn post_validator_register_gas_limit_mutation_v3() { + // Gloas builder model is fundamentally different (bids, not payloads). + if test_spec::().is_gloas_scheduled() { + return; + } ApiTester::new_mev_tester() .await .test_payload_v3_accepts_mutated_gas_limit() @@ -8306,6 +8329,10 @@ async fn post_validator_register_gas_limit_mutation_v3() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn post_validator_register_fee_recipient_mutation() { + // Gloas builder model is fundamentally different (bids, not payloads). + if test_spec::().is_gloas_scheduled() { + return; + } ApiTester::new_mev_tester() .await .test_payload_accepts_changed_fee_recipient() @@ -8314,6 +8341,10 @@ async fn post_validator_register_fee_recipient_mutation() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn post_validator_register_fee_recipient_mutation_v3() { + // Gloas builder model is fundamentally different (bids, not payloads). + if test_spec::().is_gloas_scheduled() { + return; + } ApiTester::new_mev_tester() .await .test_payload_v3_accepts_changed_fee_recipient() @@ -8322,6 +8353,10 @@ async fn post_validator_register_fee_recipient_mutation_v3() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn get_blinded_block_invalid_parent_hash() { + // Gloas builder model is fundamentally different (bids, not payloads). + if test_spec::().is_gloas_scheduled() { + return; + } ApiTester::new_mev_tester() .await .test_payload_rejects_invalid_parent_hash() @@ -8330,6 +8365,10 @@ async fn get_blinded_block_invalid_parent_hash() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn get_full_block_invalid_parent_hash_v3() { + // Gloas builder model is fundamentally different (bids, not payloads). + if test_spec::().is_gloas_scheduled() { + return; + } ApiTester::new_mev_tester() .await .test_payload_v3_rejects_invalid_parent_hash() @@ -8338,6 +8377,10 @@ async fn get_full_block_invalid_parent_hash_v3() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn get_blinded_block_invalid_prev_randao() { + // Gloas builder model is fundamentally different (bids, not payloads). + if test_spec::().is_gloas_scheduled() { + return; + } ApiTester::new_mev_tester() .await .test_payload_rejects_invalid_prev_randao() @@ -8346,6 +8389,10 @@ async fn get_blinded_block_invalid_prev_randao() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn get_full_block_invalid_prev_randao_v3() { + // Gloas builder model is fundamentally different (bids, not payloads). + if test_spec::().is_gloas_scheduled() { + return; + } ApiTester::new_mev_tester() .await .test_payload_v3_rejects_invalid_prev_randao() @@ -8354,6 +8401,10 @@ async fn get_full_block_invalid_prev_randao_v3() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn get_blinded_block_invalid_block_number() { + // Gloas builder model is fundamentally different (bids, not payloads). + if test_spec::().is_gloas_scheduled() { + return; + } ApiTester::new_mev_tester() .await .test_payload_rejects_invalid_block_number() @@ -8362,6 +8413,10 @@ async fn get_blinded_block_invalid_block_number() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn get_full_block_invalid_block_number_v3() { + // Gloas builder model is fundamentally different (bids, not payloads). + if test_spec::().is_gloas_scheduled() { + return; + } ApiTester::new_mev_tester() .await .test_payload_v3_rejects_invalid_block_number() @@ -8370,6 +8425,10 @@ async fn get_full_block_invalid_block_number_v3() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn get_blinded_block_invalid_timestamp() { + // Gloas builder model is fundamentally different (bids, not payloads). + if test_spec::().is_gloas_scheduled() { + return; + } ApiTester::new_mev_tester() .await .test_payload_rejects_invalid_timestamp() @@ -8378,6 +8437,10 @@ async fn get_blinded_block_invalid_timestamp() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn get_full_block_invalid_timestamp_v3() { + // Gloas builder model is fundamentally different (bids, not payloads). + if test_spec::().is_gloas_scheduled() { + return; + } ApiTester::new_mev_tester() .await .test_payload_v3_rejects_invalid_timestamp() @@ -8386,6 +8449,10 @@ async fn get_full_block_invalid_timestamp_v3() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn get_blinded_block_invalid_signature() { + // Gloas builder model is fundamentally different (bids, not payloads). + if test_spec::().is_gloas_scheduled() { + return; + } ApiTester::new_mev_tester() .await .test_payload_rejects_invalid_signature() @@ -8394,6 +8461,10 @@ async fn get_blinded_block_invalid_signature() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn get_full_block_invalid_signature_v3() { + // Gloas builder model is fundamentally different (bids, not payloads). + if test_spec::().is_gloas_scheduled() { + return; + } ApiTester::new_mev_tester() .await .test_payload_v3_rejects_invalid_signature() @@ -8402,6 +8473,10 @@ async fn get_full_block_invalid_signature_v3() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn builder_chain_health_skips() { + // Gloas builder model is fundamentally different (bids, not payloads). + if test_spec::().is_gloas_scheduled() { + return; + } ApiTester::new_mev_tester() .await .test_builder_chain_health_skips() @@ -8410,6 +8485,10 @@ async fn builder_chain_health_skips() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn builder_chain_health_skips_v3() { + // Gloas builder model is fundamentally different (bids, not payloads). + if test_spec::().is_gloas_scheduled() { + return; + } ApiTester::new_mev_tester() .await .test_builder_v3_chain_health_skips() @@ -8418,6 +8497,10 @@ async fn builder_chain_health_skips_v3() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn builder_chain_health_skips_per_epoch() { + // Gloas builder model is fundamentally different (bids, not payloads). + if test_spec::().is_gloas_scheduled() { + return; + } ApiTester::new_mev_tester() .await .test_builder_chain_health_skips_per_epoch() @@ -8426,6 +8509,10 @@ async fn builder_chain_health_skips_per_epoch() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn builder_chain_health_skips_per_epoch_v3() { + // Gloas builder model is fundamentally different (bids, not payloads). + if test_spec::().is_gloas_scheduled() { + return; + } ApiTester::new_mev_tester() .await .test_builder_v3_chain_health_skips_per_epoch() @@ -8434,6 +8521,10 @@ async fn builder_chain_health_skips_per_epoch_v3() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn builder_chain_health_epochs_since_finalization() { + // Gloas builder model is fundamentally different (bids, not payloads). + if test_spec::().is_gloas_scheduled() { + return; + } ApiTester::new_mev_tester() .await .test_builder_chain_health_epochs_since_finalization() @@ -8442,6 +8533,10 @@ async fn builder_chain_health_epochs_since_finalization() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn builder_chain_health_epochs_since_finalization_v3() { + // Gloas builder model is fundamentally different (bids, not payloads). + if test_spec::().is_gloas_scheduled() { + return; + } ApiTester::new_mev_tester() .await .test_builder_v3_chain_health_epochs_since_finalization() @@ -8450,6 +8545,10 @@ async fn builder_chain_health_epochs_since_finalization_v3() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn builder_chain_health_optimistic_head() { + // Gloas builder model is fundamentally different (bids, not payloads). + if test_spec::().is_gloas_scheduled() { + return; + } ApiTester::new_mev_tester() .await .test_builder_chain_health_optimistic_head() @@ -8458,6 +8557,10 @@ async fn builder_chain_health_optimistic_head() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn builder_chain_health_optimistic_head_v3() { + // Gloas builder model is fundamentally different (bids, not payloads). + if test_spec::().is_gloas_scheduled() { + return; + } ApiTester::new_mev_tester() .await .test_builder_v3_chain_health_optimistic_head() @@ -8653,6 +8756,10 @@ async fn lighthouse_endpoints() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn optimistic_responses() { + // Gloas builder model is fundamentally different (bids, not payloads). + if test_spec::().is_gloas_scheduled() { + return; + } ApiTester::new_with_hard_forks() .await .test_check_optimistic_responses() diff --git a/common/eth2/src/types.rs b/common/eth2/src/types.rs index 950abeadd8..1dd4e3d95a 100644 --- a/common/eth2/src/types.rs +++ b/common/eth2/src/types.rs @@ -1939,7 +1939,7 @@ impl<'de, E: EthSpec> ContextDeserialize<'de, ForkName> for FullBlockContents where D: Deserializer<'de>, { - if context.deneb_enabled() { + if context.deneb_enabled() && !context.gloas_enabled() { Ok(FullBlockContents::BlockContents( BlockContents::context_deserialize::(deserializer, context)?, )) @@ -2124,7 +2124,10 @@ impl PublishBlockRequest { impl TryFrom>> for PublishBlockRequest { type Error = &'static str; fn try_from(block: Arc>) -> Result { - if block.message().fork_name_unchecked().deneb_enabled() { + let fork = block.message().fork_name_unchecked(); + // Gloas blocks don't carry blobs (execution data comes via envelopes), + // so they can be published as block-only requests like pre-Deneb blocks. + if fork.deneb_enabled() && !fork.gloas_enabled() { Err("post-Deneb block contents cannot be fully constructed from just the signed block") } else { Ok(PublishBlockRequest::Block(block))