# Dev Update #8 Hi :blush:, In my [last update](https://hackmd.io/@kevinbogner/HJOn-F7wi), I presented the work done for implementing `sync_committee_rewards` into [Lighthouse](https://github.com/sigp/lighthouse). This week, I had two meetings with [NC](https://github.com/naviechan) to discuss how we want to coordinate the work. The meeting notes can be found [here](https://hackmd.io/@kevinbogner/meeting-notes-dev-rewards-API). In the following, I want to talk about the current state of our work by explaining our modifications. However, this is just a draft and will most likely be changed in the future after reviews by the Lighthouse team. ## [`sync_committee_rewards.rs`](https://github.com/naviechan/lighthouse/blob/rewards_api/beacon_node/http_api/src/sync_committee_rewards.rs) This part still needs some modifications. We get different values and then call `compute_sync_aggregate_rewards()`. ```rust! pub fn compute_sync_committee_rewards<T: BeaconChainTypes>( chain: Arc<BeaconChain<T>>, block_id: BlockId, validators: Vec<ValidatorId>, log: Logger ) -> Result<T, E> { let spec: ChainSpec = chain.spec; let (block, execution_optimistic) = block_id.blinded_block(&chain)?; let slot: Slot = block.message().slot(); let state_root = chain.state_root_at_slot(slot)?.unwrap(); let state = chain.get_state(&state_root, Some(slot))?.unwrap(); let (_, rewards) = compute_sync_aggregate_rewards(&state, &spec)?; // Create SyncCommitteeRewards with calculated rewards Ok(SyncCommitteeAttestationRewards{ execution_optimistic: false, finalized: false, data: Vec::new(), }) ``` ## [`lib.rs`](https://github.com/naviechan/lighthouse/blob/rewards_api/beacon_node/http_api/src/lib.rs#L1711-L1727) This is our API handler, which supplies a `chain` of type `Arc<BeaconChain>`, which is the handle to everything. ```rust! let post_beacon_rewards_sync_committee = beacon_rewards_path .clone() .and(warp::path("sync_committee")) .and(block_id_or_err) .and(warp::path::end()) .and(warp::body::json()) .and(log_filter.clone()) .and_then( |chain: Arc<BeaconChain<T>>, block_id: BlockId, validators: Vec<ValidatorId>, log: Logger| { // Do something here blocking_json_task(move || Ok(sync_committee_rewards::compute_sync_committee_rewards( chain, block_id, validators, log))) }); ``` ## [`sync_committee_attestation_rewards.rs`](https://github.com/naviechan/lighthouse/blob/rewards_api/common/eth2/src/lighthouse/sync_committee_attestation_rewards.rs) We implement our [schema](https://ethereum.github.io/beacon-APIs/?urls.primaryName=dev#/Experimental/getSyncCommitteeRewards), which we defined in the `beacon-API` endpoint. ```rust! #[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] pub struct SyncCommitteeAttestationRewards { pub execution_optimistic: bool, pub finalized: bool, pub data: Vec<SyncCommitteeAttestationReward>, } #[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] pub struct SyncCommitteeAttestationReward { pub validator_index: u8, pub reward: u64, } ``` ## Conclusion The endpoint is still in an early stage and will change over time. I'm optimistic that I can give a more precise overview of our work in the next dev update once we finish our draft PR. Until then, some work needs to get done. Bye :wave: