add HTTP API to retrieve validator IL duties

This commit is contained in:
jacobkaufmann
2024-12-11 20:49:34 -07:00
parent ba336501f6
commit 2b3c602b8f
8 changed files with 210 additions and 1 deletions

View File

@@ -812,7 +812,7 @@ impl<E: EthSpec> BeaconState<E> {
/// Returns the inclusion list committee for the given `slot` in the current or next epoch.
///
/// Spec v0.12.1
pub fn get_inclusion_list_commitee(
pub fn get_inclusion_list_committee(
&self,
slot: Slot,
spec: &ChainSpec,
@@ -1721,6 +1721,21 @@ impl<E: EthSpec> BeaconState<E> {
Ok(cache.get_attestation_duties(validator_index))
}
pub fn get_inclusion_list_duties(
&self,
validator_index: usize,
epoch: Epoch,
spec: &ChainSpec,
) -> Result<Option<InclusionListDuty>, Error> {
for slot in epoch.slot_iter(E::slots_per_epoch()) {
let committee = self.get_inclusion_list_committee(slot, spec)?;
if committee.contains(&validator_index) {
return Ok(Some(InclusionListDuty { slot }));
}
}
Ok(None)
}
/// Compute the total active balance cache from scratch.
///
/// This method should rarely be invoked because single-pass epoch processing keeps the total

View File

@@ -0,0 +1,8 @@
use crate::*;
use serde::{Deserialize, Serialize};
#[derive(arbitrary::Arbitrary, Debug, PartialEq, Clone, Copy, Default, Serialize, Deserialize)]
pub struct InclusionListDuty {
/// The slot during which the validator must produce an inclusion list.
pub slot: Slot,
}

View File

@@ -49,6 +49,7 @@ pub mod graffiti;
pub mod historical_batch;
pub mod historical_summary;
pub mod inclusion_list;
pub mod inclusion_list_duty;
pub mod indexed_attestation;
pub mod light_client_bootstrap;
pub mod light_client_finality_update;
@@ -180,6 +181,7 @@ pub use crate::fork_versioned_response::{ForkVersionDeserialize, ForkVersionedRe
pub use crate::graffiti::{Graffiti, GRAFFITI_BYTES_LEN};
pub use crate::historical_batch::HistoricalBatch;
pub use crate::inclusion_list::{InclusionList, SignedInclusionList};
pub use crate::inclusion_list_duty::InclusionListDuty;
pub use crate::indexed_attestation::{
IndexedAttestation, IndexedAttestationBase, IndexedAttestationElectra, IndexedAttestationRef,
};