Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge queue: embarking unstable (5121d65) and [#5406 + #5397 + #4946 + #5418 + #5383 + #5174] together #5461

Closed
wants to merge 106 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
388a7cd
rebase and add comment
GeemoCandama Feb 7, 2023
b47b4f2
conditional test
GeemoCandama Feb 8, 2023
df78885
test
GeemoCandama Feb 8, 2023
e124c99
optimistic chould be working now
GeemoCandama Feb 8, 2023
cfdeca0
finality should be working now
GeemoCandama Feb 8, 2023
e15b98f
try again
GeemoCandama Feb 8, 2023
6db8a41
try again
GeemoCandama Feb 8, 2023
1537947
clippy fix
GeemoCandama Feb 8, 2023
5dbde26
add lc bootstrap beacon api
GeemoCandama Feb 9, 2023
4611a9c
add lc optimistic/finality update to events
GeemoCandama Feb 9, 2023
d3da99f
fmt
GeemoCandama Feb 9, 2023
a2f6a8a
That error isn't occuring on my computer but I think this should fix it
GeemoCandama Feb 11, 2023
00179e4
Merge branch 'unstable' into light_client_beacon_api_1
jimmygchen Nov 16, 2023
d74e3b4
Add missing test file
jimmygchen Nov 16, 2023
ad3cc69
Update light client types to comply with Altair light client spec.
jimmygchen Nov 16, 2023
f062e77
Fix test compilation
jimmygchen Nov 16, 2023
7307756
Merge branch 'unstable' into light_client_beacon_api_1
jimmygchen Nov 16, 2023
bfd3fb7
Support deserializing light client structures for the Bellatrix fork
jimmygchen Nov 17, 2023
d90df3f
Move `get_light_client_bootstrap` logic to `BeaconChain`. `LightClien…
jimmygchen Nov 17, 2023
80ff555
Misc fixes.
jimmygchen Nov 17, 2023
75bd2ac
Add light client bootstrap API test and fix existing ones.
jimmygchen Nov 17, 2023
bd75152
Merge branch 'unstable' into light_client_beacon_api_1
jimmygchen Nov 17, 2023
e0d0ece
Fix test for `light-client-server` http api config.
jimmygchen Nov 17, 2023
161ece6
Appease clippy
jimmygchen Nov 17, 2023
885958e
Add Altair light client SSZ tests
jimmygchen Nov 21, 2023
fc30e04
Merge branch 'unstable' of https://github.com/sigp/lighthouse into li…
eserilev Nov 21, 2023
fe8e2e4
updates to light client header
eserilev Nov 21, 2023
ec1400f
light client header from signed beacon block
eserilev Nov 22, 2023
435da02
using options
eserilev Nov 24, 2023
73a581a
implement helper functions
eserilev Nov 25, 2023
5ff6f43
placeholder conversion from vec hash256 to exec branch
eserilev Nov 25, 2023
7aacc65
add deneb
eserilev Nov 25, 2023
3593f52
using fixed vector
eserilev Nov 25, 2023
65a5770
remove unwraps
eserilev Nov 26, 2023
fd1a691
by epoch
eserilev Nov 28, 2023
443d219
compute merkle proof
eserilev Nov 28, 2023
a9fa092
merkle proof
eserilev Nov 28, 2023
effeec1
update comments
eserilev Nov 28, 2023
f92a296
resolve merge conflicts
eserilev Nov 28, 2023
03c163f
linting
eserilev Nov 28, 2023
67df375
Merge branch 'unstable' into light-client-ssz-tests
jimmygchen Nov 28, 2023
16740c2
superstruct attempt
eserilev Dec 1, 2023
302a1cb
superstruct changes
eserilev Dec 3, 2023
79eeefd
lint
eserilev Dec 3, 2023
17adb6a
altair
eserilev Dec 3, 2023
5ab7681
update
eserilev Dec 3, 2023
74b0b6f
update
eserilev Dec 3, 2023
1879bfd
changes to light_client_optimistic_ and finality
eserilev Dec 3, 2023
9f0a2bc
merge unstable
eserilev Dec 12, 2023
1d10abe
refactor
eserilev Dec 12, 2023
22dc62f
resolved merge conflicts
eserilev Jan 31, 2024
8ba6ebe
Merge branch 'unstable' of https://github.com/sigp/lighthouse into ca…
eserilev Jan 31, 2024
b75d23b
block_to_light_client_header fork aware
eserilev Feb 1, 2024
5f75f25
fmt
eserilev Feb 1, 2024
96f89a2
comment fix
eserilev Feb 1, 2024
7a253bf
comment fix
eserilev Feb 1, 2024
c19c2fc
Verify whether validators really are unknown during sync committee du…
dknopik Feb 2, 2024
5808f7c
include merge fork, update deserialize_by_fork, refactor
eserilev Feb 3, 2024
6663614
fmt
eserilev Feb 3, 2024
f442b5a
pass by ref to prevent clone
eserilev Feb 3, 2024
932f440
rename merkle proof fn
eserilev Feb 3, 2024
5556891
add FIXME
eserilev Feb 5, 2024
06da24a
LightClientHeader TestRandom
eserilev Feb 6, 2024
453b4d2
fix comments
eserilev Feb 6, 2024
cf73a5c
Merge branch 'unstable' into fix-4717
dknopik Feb 22, 2024
d97d496
fork version deserialize
eserilev Feb 29, 2024
e6f6876
merge unstable
eserilev Feb 29, 2024
b23c913
move fn arguments, fork name calc
eserilev Mar 2, 2024
dde9274
use task executor
eserilev Mar 3, 2024
38cdd77
remove unneeded fns
eserilev Mar 5, 2024
c064c45
remove dead code
eserilev Mar 6, 2024
b964f3f
add manual ssz decoding/encoding and add ssz_tests_by_fork macro
eserilev Mar 7, 2024
9c9fbca
merge deneb types with tests
eserilev Mar 7, 2024
3a3616c
merge ssz tests, revert code deletion, cleanup
eserilev Mar 7, 2024
6ddfe7e
move chainspec
eserilev Mar 7, 2024
258f51b
update ssz tests
eserilev Mar 8, 2024
cb41899
fmt
eserilev Mar 8, 2024
57d90fe
light client ssz tests
eserilev Mar 11, 2024
534e808
change to superstruct
eserilev Mar 11, 2024
6fea81b
Adjust width
chong-he Mar 11, 2024
d00859a
Commit changes
chong-he Mar 12, 2024
8a84b45
Fix `beacon-processor-work-queue-len`
michaelsproul Mar 12, 2024
04ed608
Hide beacon-processor flags
michaelsproul Mar 12, 2024
d9811e9
Fix geth processes not being killed when stopping a local testnet
danielrachi1 Mar 12, 2024
dd43c12
changes from feedback
eserilev Mar 12, 2024
aba1475
linting
eserilev Mar 12, 2024
6fb0270
Merge branch 'unstable' of https://github.com/sigp/lighthouse into ca…
eserilev Mar 12, 2024
b3f7b81
test fix
eserilev Mar 12, 2024
8a7b2bc
cleanup
eserilev Mar 12, 2024
d314d12
Remove unused `derive`.
jimmygchen Mar 13, 2024
2c63ff8
Delete PRE_CAPELLA_ENGINE_CAPABILITIES
chong-he Mar 13, 2024
fc66452
Revert "Adjust width"
chong-he Mar 13, 2024
c976609
Revert "Commit changes"
chong-he Mar 13, 2024
84c7718
Simplify
chong-he Mar 14, 2024
1b63a0f
Merge branch 'delete-pre-capella' of https://github.com/chong-he/ligh…
chong-he Mar 14, 2024
5f57126
Merge branch 'unstable' into fix-4717
dknopik Mar 14, 2024
ebb2b1d
Delete unused incomplete_processing_components
dapplion Mar 17, 2024
7516afe
lint
dapplion Mar 22, 2024
b384c3f
Merge branch 'unstable' of https://github.com/sigp/lighthouse into fi…
realbigsean Mar 22, 2024
3207dde
Merge branch 'unstable' of https://github.com/sigp/lighthouse into fi…
realbigsean Mar 22, 2024
276477b
Merge of #5406
mergify[bot] Mar 22, 2024
255ed79
Merge of #5397
mergify[bot] Mar 22, 2024
02b35c8
Merge of #4946
mergify[bot] Mar 22, 2024
b9698cf
Merge of #5418
mergify[bot] Mar 22, 2024
c90a618
Merge of #5383
mergify[bot] Mar 22, 2024
22deb57
Merge of #5174
mergify[bot] Mar 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions beacon_node/beacon_chain/src/beacon_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1347,11 +1347,12 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
(parent_root, slot, sync_aggregate): LightClientProducerEvent<T::EthSpec>,
) -> Result<(), Error> {
self.light_client_server_cache.recompute_and_cache_updates(
&self.log,
self.store.clone(),
&parent_root,
slot,
&sync_aggregate,
&self.log,
&self.spec,
)
}

Expand Down Expand Up @@ -2566,7 +2567,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
&self,
epoch: Epoch,
validator_indices: &[u64],
) -> Result<Vec<Option<SyncDuty>>, Error> {
) -> Result<Vec<Result<Option<SyncDuty>, BeaconStateError>>, Error> {
self.with_head(move |head| {
head.beacon_state
.get_sync_committee_duties(epoch, validator_indices, &self.spec)
Expand Down Expand Up @@ -2891,7 +2892,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
}

self.data_availability_checker
.notify_gossip_blob(blob.slot(), block_root, &blob);
.notify_gossip_blob(block_root, &blob);
let r = self.check_gossip_blob_availability_and_import(blob).await;
self.remove_notified(&block_root, r)
}
Expand Down Expand Up @@ -2925,7 +2926,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
}

self.data_availability_checker
.notify_rpc_blobs(slot, block_root, &blobs);
.notify_rpc_blobs(block_root, &blobs);
let r = self
.check_rpc_blob_availability_and_import(slot, block_root, blobs)
.await;
Expand Down Expand Up @@ -6635,13 +6636,17 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
&self,
block_root: &Hash256,
) -> Result<Option<(LightClientBootstrap<T::EthSpec>, ForkName)>, Error> {
let Some((state_root, slot)) = self
.get_blinded_block(block_root)?
.map(|block| (block.state_root(), block.slot()))
else {
let handle = self
.task_executor
.handle()
.ok_or(BeaconChainError::RuntimeShutdown)?;

let Some(block) = handle.block_on(async { self.get_block(block_root).await })? else {
return Ok(None);
};

let (state_root, slot) = (block.state_root(), block.slot());

let Some(mut state) = self.get_state(&state_root, Some(slot))? else {
return Ok(None);
};
Expand All @@ -6651,12 +6656,12 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
.map_err(Error::InconsistentFork)?;

match fork_name {
ForkName::Altair | ForkName::Merge => {
LightClientBootstrap::from_beacon_state(&mut state)
ForkName::Altair | ForkName::Merge | ForkName::Capella | ForkName::Deneb => {
LightClientBootstrap::from_beacon_state(&mut state, &block, &self.spec)
.map(|bootstrap| Some((bootstrap, fork_name)))
.map_err(Error::LightClientError)
}
ForkName::Base | ForkName::Capella | ForkName::Deneb => Err(Error::UnsupportedFork),
ForkName::Base => Err(Error::UnsupportedFork),
}
}
}
Expand Down
31 changes: 6 additions & 25 deletions beacon_node/beacon_chain/src/data_availability_checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use std::sync::Arc;
use task_executor::TaskExecutor;
use types::beacon_block_body::KzgCommitmentOpts;
use types::blob_sidecar::{BlobIdentifier, BlobSidecar, FixedBlobSidecarList};
use types::{BlobSidecarList, ChainSpec, Epoch, EthSpec, Hash256, SignedBeaconBlock, Slot};
use types::{BlobSidecarList, ChainSpec, Epoch, EthSpec, Hash256, SignedBeaconBlock};

mod availability_view;
mod child_components;
Expand Down Expand Up @@ -356,41 +356,30 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
/// them here is useful to avoid duplicate downloads of blocks, as well as understanding
/// our blob download requirements. We will also serve this over RPC.
pub fn notify_block(&self, block_root: Hash256, block: Arc<SignedBeaconBlock<T::EthSpec>>) {
let slot = block.slot();
self.processing_cache
.write()
.entry(block_root)
.or_insert_with(|| ProcessingComponents::new(slot))
.or_default()
.merge_block(block);
}

/// Add a single blob commitment to the processing cache. This commitment is unverified but caching
/// them here is useful to avoid duplicate downloads of blobs, as well as understanding
/// our block and blob download requirements.
pub fn notify_gossip_blob(
&self,
slot: Slot,
block_root: Hash256,
blob: &GossipVerifiedBlob<T>,
) {
pub fn notify_gossip_blob(&self, block_root: Hash256, blob: &GossipVerifiedBlob<T>) {
let index = blob.index();
let commitment = blob.kzg_commitment();
self.processing_cache
.write()
.entry(block_root)
.or_insert_with(|| ProcessingComponents::new(slot))
.or_default()
.merge_single_blob(index as usize, commitment);
}

/// Adds blob commitments to the processing cache. These commitments are unverified but caching
/// them here is useful to avoid duplicate downloads of blobs, as well as understanding
/// our block and blob download requirements.
pub fn notify_rpc_blobs(
&self,
slot: Slot,
block_root: Hash256,
blobs: &FixedBlobSidecarList<T::EthSpec>,
) {
pub fn notify_rpc_blobs(&self, block_root: Hash256, blobs: &FixedBlobSidecarList<T::EthSpec>) {
let mut commitments = KzgCommitmentOpts::<T::EthSpec>::default();
for blob in blobs.iter().flatten() {
if let Some(commitment) = commitments.get_mut(blob.index as usize) {
Expand All @@ -400,7 +389,7 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
self.processing_cache
.write()
.entry(block_root)
.or_insert_with(|| ProcessingComponents::new(slot))
.or_default()
.merge_blobs(commitments);
}

Expand All @@ -409,14 +398,6 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
self.processing_cache.write().remove(block_root)
}

/// Gather all block roots for which we are not currently processing all components for the
/// given slot.
pub fn incomplete_processing_components(&self, slot: Slot) -> Vec<Hash256> {
self.processing_cache
.read()
.incomplete_processing_components(slot)
}

/// The epoch at which we require a data availability check in block processing.
/// `None` if the `Deneb` fork is disabled.
pub fn data_availability_boundary(&self) -> Option<Epoch> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::collections::hash_map::Entry;
use std::collections::HashMap;
use std::sync::Arc;
use types::beacon_block_body::KzgCommitmentOpts;
use types::{EthSpec, Hash256, SignedBeaconBlock, Slot};
use types::{EthSpec, Hash256, SignedBeaconBlock};

/// This cache is used only for gossip blocks/blobs and single block/blob lookups, to give req/resp
/// a view of what we have and what we require. This cache serves a slightly different purpose than
Expand All @@ -29,23 +29,13 @@ impl<E: EthSpec> ProcessingCache<E> {
.get(block_root)
.map_or(false, |b| b.block_exists())
}
pub fn incomplete_processing_components(&self, slot: Slot) -> Vec<Hash256> {
let mut roots_missing_components = vec![];
for (&block_root, info) in self.processing_cache.iter() {
if info.slot == slot && !info.is_available() {
roots_missing_components.push(block_root);
}
}
roots_missing_components
}
pub fn len(&self) -> usize {
self.processing_cache.len()
}
}

#[derive(Debug, Clone)]
#[derive(Default, Debug, Clone)]
pub struct ProcessingComponents<E: EthSpec> {
slot: Slot,
/// Blobs required for a block can only be known if we have seen the block. So `Some` here
/// means we've seen it, a `None` means we haven't. The `kzg_commitments` value helps us figure
/// out whether incoming blobs actually match the block.
Expand All @@ -56,12 +46,8 @@ pub struct ProcessingComponents<E: EthSpec> {
}

impl<E: EthSpec> ProcessingComponents<E> {
pub fn new(slot: Slot) -> Self {
Self {
slot,
block: None,
blob_commitments: KzgCommitmentOpts::<E>::default(),
}
pub fn new() -> Self {
Self::default()
}
}

Expand All @@ -70,7 +56,6 @@ impl<E: EthSpec> ProcessingComponents<E> {
impl<E: EthSpec> ProcessingComponents<E> {
pub fn empty(_block_root: Hash256) -> Self {
Self {
slot: Slot::new(0),
block: None,
blob_commitments: KzgCommitmentOpts::<E>::default(),
}
Expand Down
1 change: 1 addition & 0 deletions beacon_node/beacon_chain/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ easy_from_to!(StateAdvanceError, BeaconChainError);
easy_from_to!(BlockReplayError, BeaconChainError);
easy_from_to!(InconsistentFork, BeaconChainError);
easy_from_to!(AvailabilityCheckError, BeaconChainError);
easy_from_to!(LightClientError, BeaconChainError);

#[derive(Debug)]
pub enum BlockProductionError {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl<T: BeaconChainTypes> VerifiedLightClientFinalityUpdate<T> {
// verify that enough time has passed for the block to have been propagated
let start_time = chain
.slot_clock
.start_of(rcv_finality_update.signature_slot)
.start_of(*rcv_finality_update.signature_slot())
.ok_or(Error::SigSlotStartIsNone)?;
let one_third_slot_duration = Duration::new(chain.spec.seconds_per_slot / 3, 0);
if seen_timestamp + chain.spec.maximum_gossip_clock_disparity()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl<T: BeaconChainTypes> VerifiedLightClientOptimisticUpdate<T> {
// verify that enough time has passed for the block to have been propagated
let start_time = chain
.slot_clock
.start_of(rcv_optimistic_update.signature_slot)
.start_of(*rcv_optimistic_update.signature_slot())
.ok_or(Error::SigSlotStartIsNone)?;
let one_third_slot_duration = Duration::new(chain.spec.seconds_per_slot / 3, 0);
if seen_timestamp + chain.spec.maximum_gossip_clock_disparity()
Expand All @@ -65,10 +65,7 @@ impl<T: BeaconChainTypes> VerifiedLightClientOptimisticUpdate<T> {
let head_block = &head.snapshot.beacon_block;
// check if we can process the optimistic update immediately
// otherwise queue
let canonical_root = rcv_optimistic_update
.attested_header
.beacon
.canonical_root();
let canonical_root = rcv_optimistic_update.get_canonical_root();

if canonical_root != head_block.message().parent_root() {
return Err(Error::UnknownBlockParentRoot(canonical_root));
Expand All @@ -84,7 +81,7 @@ impl<T: BeaconChainTypes> VerifiedLightClientOptimisticUpdate<T> {
return Err(Error::InvalidLightClientOptimisticUpdate);
}

let parent_root = rcv_optimistic_update.attested_header.beacon.parent_root;
let parent_root = rcv_optimistic_update.get_parent_root();
Ok(Self {
light_client_optimistic_update: rcv_optimistic_update,
parent_root,
Expand Down
67 changes: 31 additions & 36 deletions beacon_node/beacon_chain/src/light_client_server_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use types::light_client_update::{FinalizedRootProofLen, FINALIZED_ROOT_INDEX};
use types::non_zero_usize::new_non_zero_usize;
use types::{
BeaconBlockRef, BeaconState, ChainSpec, EthSpec, ForkName, Hash256, LightClientFinalityUpdate,
LightClientHeader, LightClientOptimisticUpdate, Slot, SyncAggregate,
LightClientOptimisticUpdate, Slot, SyncAggregate,
};

/// A prev block cache miss requires to re-generate the state of the post-parent block. Items in the
Expand Down Expand Up @@ -71,24 +71,26 @@ impl<T: BeaconChainTypes> LightClientServerCache<T> {
/// results are cached either on disk or memory to be served via p2p and rest API
pub fn recompute_and_cache_updates(
&self,
log: &Logger,
store: BeaconStore<T>,
block_parent_root: &Hash256,
block_slot: Slot,
sync_aggregate: &SyncAggregate<T::EthSpec>,
log: &Logger,
chain_spec: &ChainSpec,
) -> Result<(), BeaconChainError> {
let _timer =
metrics::start_timer(&metrics::LIGHT_CLIENT_SERVER_CACHE_RECOMPUTE_UPDATES_TIMES);

let signature_slot = block_slot;
let attested_block_root = block_parent_root;

let attested_block = store.get_blinded_block(attested_block_root)?.ok_or(
BeaconChainError::DBInconsistent(format!(
"Block not available {:?}",
attested_block_root
)),
)?;
let attested_block =
store
.get_full_block(attested_block_root)?
.ok_or(BeaconChainError::DBInconsistent(format!(
"Block not available {:?}",
attested_block_root
)))?;

let cached_parts = self.get_or_compute_prev_block_cache(
store.clone(),
Expand All @@ -109,11 +111,12 @@ impl<T: BeaconChainTypes> LightClientServerCache<T> {
};
if is_latest_optimistic {
// can create an optimistic update, that is more recent
*self.latest_optimistic_update.write() = Some(LightClientOptimisticUpdate {
attested_header: block_to_light_client_header(attested_block.message()),
sync_aggregate: sync_aggregate.clone(),
*self.latest_optimistic_update.write() = Some(LightClientOptimisticUpdate::new(
&attested_block,
sync_aggregate.clone(),
signature_slot,
});
chain_spec,
)?);
};

// Spec: Full nodes SHOULD provide the LightClientFinalityUpdate with the highest
Expand All @@ -127,17 +130,16 @@ impl<T: BeaconChainTypes> LightClientServerCache<T> {
if is_latest_finality & !cached_parts.finalized_block_root.is_zero() {
// Immediately after checkpoint sync the finalized block may not be available yet.
if let Some(finalized_block) =
store.get_blinded_block(&cached_parts.finalized_block_root)?
store.get_full_block(&cached_parts.finalized_block_root)?
{
*self.latest_finality_update.write() = Some(LightClientFinalityUpdate {
// TODO: may want to cache this result from latest_optimistic_update if producing a
// light_client header becomes expensive
attested_header: block_to_light_client_header(attested_block.message()),
finalized_header: block_to_light_client_header(finalized_block.message()),
finality_branch: cached_parts.finality_branch.clone(),
sync_aggregate: sync_aggregate.clone(),
*self.latest_finality_update.write() = Some(LightClientFinalityUpdate::new(
&attested_block,
&finalized_block,
cached_parts.finality_branch.clone(),
sync_aggregate.clone(),
signature_slot,
});
chain_spec,
)?);
} else {
debug!(
log,
Expand Down Expand Up @@ -214,7 +216,7 @@ impl LightClientCachedData {
}
}

// Implements spec priorization rules:
// Implements spec prioritization rules:
// > Full nodes SHOULD provide the LightClientFinalityUpdate with the highest attested_header.beacon.slot (if multiple, highest signature_slot)
//
// ref: https://github.com/ethereum/consensus-specs/blob/113c58f9bf9c08867f6f5f633c4d98e0364d612a/specs/altair/light-client/full-node.md#create_light_client_finality_update
Expand All @@ -223,14 +225,15 @@ fn is_latest_finality_update<T: EthSpec>(
attested_slot: Slot,
signature_slot: Slot,
) -> bool {
if attested_slot > prev.attested_header.beacon.slot {
let prev_slot = prev.get_attested_header_slot();
if attested_slot > prev_slot {
true
} else {
attested_slot == prev.attested_header.beacon.slot && signature_slot > prev.signature_slot
attested_slot == prev_slot && signature_slot > *prev.signature_slot()
}
}

// Implements spec priorization rules:
// Implements spec prioritization rules:
// > Full nodes SHOULD provide the LightClientOptimisticUpdate with the highest attested_header.beacon.slot (if multiple, highest signature_slot)
//
// ref: https://github.com/ethereum/consensus-specs/blob/113c58f9bf9c08867f6f5f633c4d98e0364d612a/specs/altair/light-client/full-node.md#create_light_client_optimistic_update
Expand All @@ -239,18 +242,10 @@ fn is_latest_optimistic_update<T: EthSpec>(
attested_slot: Slot,
signature_slot: Slot,
) -> bool {
if attested_slot > prev.attested_header.beacon.slot {
let prev_slot = prev.get_slot();
if attested_slot > prev_slot {
true
} else {
attested_slot == prev.attested_header.beacon.slot && signature_slot > prev.signature_slot
}
}

fn block_to_light_client_header<T: EthSpec>(
block: BeaconBlockRef<T, types::BlindedPayload<T>>,
) -> LightClientHeader {
// TODO: make fork aware
LightClientHeader {
beacon: block.block_header(),
attested_slot == prev_slot && signature_slot > *prev.signature_slot()
}
}
Loading
Loading