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 (19b0db2) and #4946 together #5478

Closed
wants to merge 87 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
87 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
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
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
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
9b31545
Merge branch 'unstable' of https://github.com/sigp/lighthouse into ca…
eserilev Mar 23, 2024
a7dd9ee
beta compiler fix
eserilev Mar 23, 2024
d9a0b48
merge
eserilev Mar 23, 2024
fdbf9be
Merge of #4946
mergify[bot] Mar 25, 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
Prev Previous commit
Next Next commit
remove dead code
eserilev committed Mar 6, 2024
commit c064c45dabc7f5d84e495e5162016a7be621f6aa
4 changes: 2 additions & 2 deletions consensus/types/src/light_client_header.rs
Original file line number Diff line number Diff line change
@@ -17,7 +17,6 @@ use test_random_derive::TestRandom;
variants(Altair, Capella, Deneb),
variant_attributes(
derive(
Default,
Debug,
Clone,
PartialEq,
@@ -32,7 +31,7 @@ use test_random_derive::TestRandom;
arbitrary(bound = "E: EthSpec"),
)
)]
#[derive(Debug, Clone, Serialize, Deserialize, Encode, Decode, arbitrary::Arbitrary, PartialEq)]
#[derive(Debug, Clone, Serialize, Deserialize, Decode, Encode, arbitrary::Arbitrary, PartialEq)]
#[serde(untagged)]
#[serde(bound = "E: EthSpec", deny_unknown_fields)]
#[ssz(enum_behaviour = "union")]
@@ -49,6 +48,7 @@ pub struct LightClientHeader<E: EthSpec> {
#[superstruct(only(Deneb), partial_getter(rename = "execution_payload_header_deneb"))]
pub execution: ExecutionPayloadHeaderDeneb<E>,

#[serde(skip)]
#[ssz(skip_serializing, skip_deserializing)]
pub phantom_data: PhantomData<E>,
}
47 changes: 1 addition & 46 deletions consensus/types/src/light_client_optimistic_update.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
use super::{EthSpec, ForkName, ForkVersionDeserialize, Slot, SyncAggregate};
use crate::light_client_header::{
LightClientHeaderAltair, LightClientHeaderCapella, LightClientHeaderDeneb,
};
use crate::light_client_update::Error;
use crate::test_utils::TestRandom;
use crate::{light_client_header::LightClientHeader, ChainSpec};
use crate::{BeaconState, SignedBeaconBlock};
use crate::{light_client_header::LightClientHeader};
use serde::{Deserialize, Deserializer, Serialize};
use serde_json::Value;
use ssz_derive::{Decode, Encode};
use test_random_derive::TestRandom;
use tree_hash::TreeHash;

/// A LightClientOptimisticUpdate is the update we send on each slot,
/// it is based off the current unfinalized epoch is verified only against BLS signature.
@@ -36,45 +30,6 @@ pub struct LightClientOptimisticUpdate<T: EthSpec> {
pub signature_slot: Slot,
}

impl<T: EthSpec> LightClientOptimisticUpdate<T> {
pub fn new(
chain_spec: &ChainSpec,
block: &SignedBeaconBlock<T>,
attested_state: &BeaconState<T>,
attested_block: &SignedBeaconBlock<T>,
) -> Result<Self, Error> {
let sync_aggregate = block.message().body().sync_aggregate()?;
if sync_aggregate.num_set_bits() < chain_spec.min_sync_committee_participants as usize {
return Err(Error::NotEnoughSyncCommitteeParticipants);
}

// Compute and validate attested header.
let mut attested_header = attested_state.latest_block_header().clone();
attested_header.state_root = attested_state.tree_hash_root();

let attested_header: LightClientHeader<T> = match chain_spec
.fork_name_at_epoch(attested_state.slot().epoch(T::slots_per_epoch()))
{
ForkName::Base => return Err(Error::AltairForkNotActive),
ForkName::Merge | ForkName::Altair => {
LightClientHeaderAltair::block_to_light_client_header(attested_block)?.into()
}
ForkName::Capella => {
LightClientHeaderCapella::block_to_light_client_header(attested_block)?.into()
}
ForkName::Deneb => {
LightClientHeaderDeneb::block_to_light_client_header(attested_block)?.into()
}
};

Ok(Self {
attested_header,
sync_aggregate: sync_aggregate.clone(),
signature_slot: block.slot(),
})
}
}

impl<T: EthSpec> ForkVersionDeserialize for LightClientOptimisticUpdate<T> {
fn deserialize_by_fork<'de, D: Deserializer<'de>>(
value: Value,
78 changes: 2 additions & 76 deletions consensus/types/src/light_client_update.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
use super::{BeaconBlockHeader, EthSpec, FixedVector, Hash256, Slot, SyncAggregate, SyncCommittee};
use super::{EthSpec, FixedVector, Hash256, Slot, SyncAggregate, SyncCommittee};
use crate::{
beacon_state,
light_client_header::{
LightClientHeaderAltair, LightClientHeaderCapella, LightClientHeaderDeneb,
},
test_utils::TestRandom,
BeaconBlock, BeaconState, ChainSpec, ForkName, ForkVersionDeserialize, LightClientHeader,
SignedBeaconBlock,
ForkName, ForkVersionDeserialize, LightClientHeader,
};
use safe_arith::ArithError;
use serde::{Deserialize, Deserializer, Serialize};
@@ -15,7 +11,6 @@ use ssz_derive::{Decode, Encode};
use ssz_types::typenum::{U4, U5, U6};
use std::sync::Arc;
use test_random_derive::TestRandom;
use tree_hash::TreeHash;

pub const FINALIZED_ROOT_INDEX: usize = 105;
pub const CURRENT_SYNC_COMMITTEE_INDEX: usize = 54;
@@ -96,75 +91,6 @@ pub struct LightClientUpdate<T: EthSpec> {
pub signature_slot: Slot,
}

impl<T: EthSpec> LightClientUpdate<T> {
pub fn new(
chain_spec: ChainSpec,
beacon_state: BeaconState<T>,
block: BeaconBlock<T>,
attested_state: &mut BeaconState<T>,
attested_block: &SignedBeaconBlock<T>,
finalized_block: &SignedBeaconBlock<T>,
) -> Result<Self, Error> {
let sync_aggregate = block.body().sync_aggregate()?;
if sync_aggregate.num_set_bits() < chain_spec.min_sync_committee_participants as usize {
return Err(Error::NotEnoughSyncCommitteeParticipants);
}

let signature_period = block.epoch().sync_committee_period(&chain_spec)?;
// Compute and validate attested header.
let mut attested_header = attested_state.latest_block_header().clone();
attested_header.state_root = attested_state.tree_hash_root();
let attested_period = attested_header
.slot
.epoch(T::slots_per_epoch())
.sync_committee_period(&chain_spec)?;
if attested_period != signature_period {
return Err(Error::MismatchingPeriods);
}
// Build finalized header from finalized block
let finalized_header = BeaconBlockHeader {
slot: finalized_block.slot(),
proposer_index: finalized_block.message().proposer_index(),
parent_root: finalized_block.parent_root(),
state_root: finalized_block.state_root(),
body_root: finalized_block.message().body_root(),
};
if finalized_header.tree_hash_root() != beacon_state.finalized_checkpoint().root {
return Err(Error::InvalidFinalizedBlock);
}
let next_sync_committee_branch =
attested_state.compute_merkle_proof(NEXT_SYNC_COMMITTEE_INDEX)?;
let finality_branch = attested_state.compute_merkle_proof(FINALIZED_ROOT_INDEX)?;

let (attested_header, finalized_header) =
match chain_spec.fork_name_at_epoch(beacon_state.slot().epoch(T::slots_per_epoch())) {
ForkName::Base => return Err(Error::AltairForkNotActive),
ForkName::Merge | ForkName::Altair => (
LightClientHeaderAltair::block_to_light_client_header(attested_block)?.into(),
LightClientHeaderAltair::block_to_light_client_header(finalized_block)?.into(),
),
ForkName::Capella => (
LightClientHeaderCapella::block_to_light_client_header(attested_block)?.into(),
LightClientHeaderCapella::block_to_light_client_header(finalized_block)?.into(),
),
ForkName::Deneb => (
LightClientHeaderDeneb::block_to_light_client_header(attested_block)?.into(),
LightClientHeaderDeneb::block_to_light_client_header(finalized_block)?.into(),
),
};

Ok(Self {
attested_header,
next_sync_committee: attested_state.next_sync_committee()?.clone(),
next_sync_committee_branch: FixedVector::new(next_sync_committee_branch)?,
finalized_header,
finality_branch: FixedVector::new(finality_branch)?,
sync_aggregate: sync_aggregate.clone(),
signature_slot: block.slot(),
})
}
}

impl<T: EthSpec> ForkVersionDeserialize for LightClientUpdate<T> {
fn deserialize_by_fork<'de, D: Deserializer<'de>>(
value: Value,