Merge branch 'unstable' into gloas-fc-proto

This commit is contained in:
hopinheimer
2026-03-16 01:42:53 -04:00
committed by GitHub
31 changed files with 646 additions and 707 deletions

View File

@@ -1801,8 +1801,16 @@ pub fn serve<T: BeaconChainTypes>(
let execution_optimistic =
chain.is_optimistic_or_invalid_head().unwrap_or_default();
Ok(api_types::GenericResponse::from(attestation_rewards))
.map(|resp| resp.add_execution_optimistic(execution_optimistic))
let finalized = epoch + 2
<= chain
.canonical_head
.cached_head()
.finalized_checkpoint()
.epoch;
Ok(api_types::GenericResponse::from(attestation_rewards)).map(|resp| {
resp.add_execution_optimistic_finalized(execution_optimistic, finalized)
})
})
},
);

View File

@@ -2,7 +2,7 @@ use crate::metrics;
use std::future::Future;
use beacon_chain::blob_verification::{GossipBlobError, GossipVerifiedBlob};
use beacon_chain::block_verification_types::{AsBlock, RpcBlock};
use beacon_chain::block_verification_types::{AsBlock, LookupBlock};
use beacon_chain::data_column_verification::GossipVerifiedDataColumn;
use beacon_chain::validator_monitor::{get_block_delay_ms, timestamp_now};
use beacon_chain::{
@@ -311,19 +311,11 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlock<T>>(
slot = %block.slot(),
"Block previously seen"
);
let Ok(rpc_block) = RpcBlock::new(
block.clone(),
None,
&chain.data_availability_checker,
chain.spec.clone(),
) else {
return Err(warp_utils::reject::custom_bad_request(
"Unable to construct rpc block".to_string(),
));
};
// try to reprocess as a lookup (single) block and let sync take care of missing components
let lookup_block = LookupBlock::new(block.clone());
let import_result = Box::pin(chain.process_block(
block_root,
rpc_block,
lookup_block,
NotifyExecutionLayer::Yes,
BlockImportSource::HttpApi,
publish_fn,

View File

@@ -7206,15 +7206,16 @@ impl ApiTester {
assert_eq!(result.execution_optimistic, Some(true));
}
async fn test_get_beacon_rewards_blocks_at_head(&self) -> StandardBlockReward {
async fn test_get_beacon_rewards_blocks_at_head(
&self,
) -> ExecutionOptimisticFinalizedResponse<StandardBlockReward> {
self.client
.get_beacon_rewards_blocks(CoreBlockId::Head)
.await
.unwrap()
.data
}
async fn test_beacon_block_rewards_electra(self) -> Self {
async fn test_beacon_block_rewards_fulu(self) -> Self {
for _ in 0..E::slots_per_epoch() {
let state = self.harness.get_current_state();
let slot = state.slot() + Slot::new(1);
@@ -7228,8 +7229,80 @@ impl ApiTester {
.compute_beacon_block_reward(signed_block.message(), &mut state)
.unwrap();
self.harness.extend_slots(1).await;
let api_beacon_block_reward = self.test_get_beacon_rewards_blocks_at_head().await;
assert_eq!(beacon_block_reward, api_beacon_block_reward);
let response = self.test_get_beacon_rewards_blocks_at_head().await;
assert_eq!(response.execution_optimistic, Some(false));
assert_eq!(response.finalized, Some(false));
assert_eq!(beacon_block_reward, response.data);
}
self
}
async fn test_get_beacon_rewards_sync_committee_at_head(
&self,
) -> ExecutionOptimisticFinalizedResponse<Vec<SyncCommitteeReward>> {
self.client
.post_beacon_rewards_sync_committee(CoreBlockId::Head, &[])
.await
.unwrap()
}
async fn test_beacon_sync_committee_rewards_fulu(self) -> Self {
for _ in 0..E::slots_per_epoch() {
let state = self.harness.get_current_state();
let slot = state.slot() + Slot::new(1);
let ((signed_block, _maybe_blob_sidecars), mut state) =
self.harness.make_block_return_pre_state(state, slot).await;
let mut expected_rewards = self
.harness
.chain
.compute_sync_committee_rewards(signed_block.message(), &mut state)
.unwrap();
expected_rewards.sort_by_key(|r| r.validator_index);
self.harness.extend_slots(1).await;
let response = self.test_get_beacon_rewards_sync_committee_at_head().await;
assert_eq!(response.execution_optimistic, Some(false));
assert_eq!(response.finalized, Some(false));
let mut api_rewards = response.data;
api_rewards.sort_by_key(|r| r.validator_index);
assert_eq!(expected_rewards, api_rewards);
}
self
}
async fn test_get_beacon_rewards_attestations(
&self,
epoch: Epoch,
) -> ExecutionOptimisticFinalizedResponse<StandardAttestationRewards> {
self.client
.post_beacon_rewards_attestations(epoch, &[])
.await
.unwrap()
}
async fn test_beacon_attestation_rewards_fulu(self) -> Self {
// Check 3 epochs.
let num_epochs = 3;
for _ in 0..num_epochs {
self.harness
.extend_slots(E::slots_per_epoch() as usize)
.await;
let epoch = self.chain.epoch().unwrap() - 1;
let expected_rewards = self
.harness
.chain
.compute_attestation_rewards(epoch, vec![])
.unwrap();
let response = self.test_get_beacon_rewards_attestations(epoch).await;
assert_eq!(response.execution_optimistic, Some(false));
assert_eq!(response.finalized, Some(false));
assert_eq!(expected_rewards, response.data);
}
self
}
@@ -8545,16 +8618,47 @@ async fn expected_withdrawals_valid_capella() {
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn get_beacon_rewards_blocks_electra() {
async fn get_beacon_rewards_blocks_fulu() {
let mut config = ApiTesterConfig::default();
config.spec.altair_fork_epoch = Some(Epoch::new(0));
config.spec.bellatrix_fork_epoch = Some(Epoch::new(0));
config.spec.capella_fork_epoch = Some(Epoch::new(0));
config.spec.deneb_fork_epoch = Some(Epoch::new(0));
config.spec.electra_fork_epoch = Some(Epoch::new(0));
config.spec.fulu_fork_epoch = Some(Epoch::new(0));
ApiTester::new_from_config(config)
.await
.test_beacon_block_rewards_electra()
.test_beacon_block_rewards_fulu()
.await;
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn get_beacon_rewards_sync_committee_fulu() {
let mut config = ApiTesterConfig::default();
config.spec.altair_fork_epoch = Some(Epoch::new(0));
config.spec.bellatrix_fork_epoch = Some(Epoch::new(0));
config.spec.capella_fork_epoch = Some(Epoch::new(0));
config.spec.deneb_fork_epoch = Some(Epoch::new(0));
config.spec.electra_fork_epoch = Some(Epoch::new(0));
config.spec.fulu_fork_epoch = Some(Epoch::new(0));
ApiTester::new_from_config(config)
.await
.test_beacon_sync_committee_rewards_fulu()
.await;
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn get_beacon_rewards_attestations_fulu() {
let mut config = ApiTesterConfig::default();
config.spec.altair_fork_epoch = Some(Epoch::new(0));
config.spec.bellatrix_fork_epoch = Some(Epoch::new(0));
config.spec.capella_fork_epoch = Some(Epoch::new(0));
config.spec.deneb_fork_epoch = Some(Epoch::new(0));
config.spec.electra_fork_epoch = Some(Epoch::new(0));
config.spec.fulu_fork_epoch = Some(Epoch::new(0));
ApiTester::new_from_config(config)
.await
.test_beacon_attestation_rewards_fulu()
.await;
}