mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-31 05:07:12 +00:00
add IL service to download IL from EL, sign in VC, and publish via BN
add HTTP API to the beacon node to retrieve IL from the EL. add IL service in the validator client to download the IL from the beacon node. add logic to the beacon node to package the IL for the validator client. add HTTP API to the beacon node to gossip signed ILs. the validator client will sign the ILs from the beacon node and resubmit to the beacon node to gossip.
This commit is contained in:
@@ -816,7 +816,7 @@ impl<E: EthSpec> BeaconState<E> {
|
||||
&self,
|
||||
slot: Slot,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<Vec<usize>, Error> {
|
||||
) -> Result<InclusionListCommittee<E>, Error> {
|
||||
let epoch = slot.epoch(E::slots_per_epoch());
|
||||
let current_epoch = self.current_epoch();
|
||||
let next_epoch = current_epoch + 1;
|
||||
@@ -842,11 +842,11 @@ impl<E: EthSpec> BeaconState<E> {
|
||||
spec.shuffle_round_count,
|
||||
)
|
||||
.ok_or(Error::UnableToShuffle)?;
|
||||
il_committee_indices.push(shuffled_index);
|
||||
il_committee_indices.push(shuffled_index as u64);
|
||||
i.safe_add_assign(1)?;
|
||||
}
|
||||
|
||||
Ok(il_committee_indices)
|
||||
Ok(InclusionListCommittee::<E>::from(il_committee_indices))
|
||||
}
|
||||
|
||||
/// Compute the seed to use for the beacon inclusion list committee selection at the given
|
||||
@@ -1727,10 +1727,16 @@ impl<E: EthSpec> BeaconState<E> {
|
||||
epoch: Epoch,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<Option<InclusionListDuty>, Error> {
|
||||
let validator_index = validator_index as u64;
|
||||
for slot in epoch.slot_iter(E::slots_per_epoch()) {
|
||||
let committee = self.get_inclusion_list_committee(slot, spec)?;
|
||||
let committee_root = committee.tree_hash_root();
|
||||
if committee.contains(&validator_index) {
|
||||
return Ok(Some(InclusionListDuty { slot }));
|
||||
return Ok(Some(InclusionListDuty {
|
||||
slot,
|
||||
validator_index,
|
||||
committee_root,
|
||||
}));
|
||||
}
|
||||
}
|
||||
Ok(None)
|
||||
|
||||
@@ -9,6 +9,11 @@ use test_random_derive::TestRandom;
|
||||
use tree_hash::TreeHash;
|
||||
use tree_hash_derive::TreeHash;
|
||||
|
||||
pub type InclusionListTransactions<E> = VariableList<
|
||||
Transaction<<E as EthSpec>::MaxBytesPerTransaction>,
|
||||
<E as EthSpec>::MaxTransactionsPerInclusionList,
|
||||
>;
|
||||
|
||||
#[derive(
|
||||
Debug,
|
||||
Clone,
|
||||
@@ -29,8 +34,7 @@ pub struct InclusionList<E: EthSpec> {
|
||||
#[serde(with = "serde_utils::quoted_u64")]
|
||||
pub validator_index: u64,
|
||||
pub inclusion_list_committee_root: Hash256,
|
||||
pub transactions:
|
||||
VariableList<Transaction<E::MaxBytesPerTransaction>, E::MaxTransactionsPerInclusionList>,
|
||||
pub transactions: InclusionListTransactions<E>,
|
||||
}
|
||||
|
||||
impl<E: EthSpec> SignedRoot for InclusionList<E> {}
|
||||
|
||||
3
consensus/types/src/inclusion_list_committee.rs
Normal file
3
consensus/types/src/inclusion_list_committee.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
use crate::*;
|
||||
|
||||
pub type InclusionListCommittee<E> = FixedVector<u64, <E as EthSpec>::InclusionListCommitteeSize>;
|
||||
@@ -5,4 +5,9 @@ use serde::{Deserialize, Serialize};
|
||||
pub struct InclusionListDuty {
|
||||
/// The slot during which the validator must produce an inclusion list.
|
||||
pub slot: Slot,
|
||||
#[serde(with = "serde_utils::quoted_u64")]
|
||||
/// The index of the validator.
|
||||
pub validator_index: u64,
|
||||
/// The hash tree root of the inclusion list committee.
|
||||
pub committee_root: Hash256,
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ pub mod graffiti;
|
||||
pub mod historical_batch;
|
||||
pub mod historical_summary;
|
||||
pub mod inclusion_list;
|
||||
pub mod inclusion_list_committee;
|
||||
pub mod inclusion_list_duty;
|
||||
pub mod indexed_attestation;
|
||||
pub mod light_client_bootstrap;
|
||||
@@ -180,7 +181,8 @@ pub use crate::fork_name::{ForkName, InconsistentFork};
|
||||
pub use crate::fork_versioned_response::{ForkVersionDeserialize, ForkVersionedResponse};
|
||||
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::{InclusionList, InclusionListTransactions, SignedInclusionList};
|
||||
pub use crate::inclusion_list_committee::InclusionListCommittee;
|
||||
pub use crate::inclusion_list_duty::InclusionListDuty;
|
||||
pub use crate::indexed_attestation::{
|
||||
IndexedAttestation, IndexedAttestationBase, IndexedAttestationElectra, IndexedAttestationRef,
|
||||
|
||||
Reference in New Issue
Block a user