Files
lighthouse/beacon_node/http_api/src/standard_block_rewards.rs
chonghe 522bd9e9c6 Update Rust Edition to 2024 (#7766)
* #7749

Thanks @dknopik and @michaelsproul for your help!
2025-08-13 03:04:31 +00:00

26 lines
982 B
Rust

use crate::BlockId;
use crate::ExecutionOptimistic;
use crate::sync_committee_rewards::get_state_before_applying_block;
use beacon_chain::{BeaconChain, BeaconChainTypes};
use eth2::types::StandardBlockReward;
use std::sync::Arc;
use warp_utils::reject::unhandled_error;
/// The difference between block_rewards and beacon_block_rewards is the later returns block
/// reward format that satisfies beacon-api specs
pub fn compute_beacon_block_rewards<T: BeaconChainTypes>(
chain: Arc<BeaconChain<T>>,
block_id: BlockId,
) -> Result<(StandardBlockReward, ExecutionOptimistic, bool), warp::Rejection> {
let (block, execution_optimistic, finalized) = block_id.blinded_block(&chain)?;
let block_ref = block.message();
let mut state = get_state_before_applying_block(chain.clone(), &block)?;
let rewards = chain
.compute_beacon_block_reward(block_ref, &mut state)
.map_err(unhandled_error)?;
Ok((rewards, execution_optimistic, finalized))
}