Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
42245b7
add light client optimistic and finality update rpc
GeemoCandama Dec 20, 2022
5d59207
Arc the updates in the response
GeemoCandama Jan 7, 2023
9643686
add conditional advertisement for both LightClientOptimisticUpdate an…
GeemoCandama Jan 30, 2023
9b0901c
alter display for inboundrequest light client optimistic and finality…
GeemoCandama Jan 30, 2023
17e6436
remove LightClientOptimistic/FinalityReuest struct and some minor fixes
GeemoCandama Feb 14, 2023
ddf0874
rebase
GeemoCandama Mar 15, 2023
29bfdb8
failing rpc_test for LightClientBootstrap and beginning of MockLib2pL…
GeemoCandama Mar 12, 2023
e6c4c72
minor change
GeemoCandama Mar 13, 2023
5620c74
added MockRPCHandler by importing everything except OutboundRequest. …
GeemoCandama Mar 13, 2023
520962f
almost there but ran into issue where needed to implement BaseOutboun…
GeemoCandama Mar 14, 2023
68d43d5
failing but running with a light client service of sorts
GeemoCandama Mar 14, 2023
cf4a24c
small test change
GeemoCandama Mar 14, 2023
555bf46
changed Protocol::LightClientBootstrap response limit
GeemoCandama Mar 14, 2023
d5ae43d
deleted some stuff from ConnectionHandler Implementation for the mock…
GeemoCandama Mar 14, 2023
2a6299a
deleted purging expired inbound/outbound streams code
GeemoCandama Mar 14, 2023
d7cdae1
deleted drive inbound streams that need to be processed
GeemoCandama Mar 14, 2023
909c34c
removed unused imports
GeemoCandama Mar 14, 2023
194d8d3
made things private again
GeemoCandama Mar 14, 2023
9abc31e
deleted inject_fully_negotiated_inbound
GeemoCandama Mar 14, 2023
81ba801
made more things private again
GeemoCandama Mar 14, 2023
4c41643
more
GeemoCandama Mar 14, 2023
f55977f
turned the logger off in the test
GeemoCandama Mar 14, 2023
f7371e2
added failing test for new rpc
GeemoCandama Mar 15, 2023
5027b83
add rate limit for new rpcs
GeemoCandama Mar 15, 2023
8226f05
change InboundUpgrade function to use new rpcs. fmt. add test for Lig…
GeemoCandama Mar 15, 2023
474d512
rebasing fix
GeemoCandama Mar 29, 2023
86aa148
add LightClientUpdate to handle_rpc functions
GeemoCandama Mar 30, 2023
3f7c8c2
added context bytes
GeemoCandama Mar 30, 2023
55a4596
fmt
GeemoCandama Mar 30, 2023
8ffd209
use correct unsed_tcp4_port function
GeemoCandama Mar 31, 2023
c9fa08f
fix for recent config changes and adding context_bytes for the light …
GeemoCandama Apr 2, 2023
691f688
fix clippy complaint
GeemoCandama Apr 5, 2023
64dac1b
Merge branch 'unstable' into lc-reqresp
jimmygchen Nov 4, 2023
38a029a
Error handling updates and various cleanups.
jimmygchen Nov 4, 2023
9b5d14f
Moar minor clean ups.
jimmygchen Nov 4, 2023
e5f9738
Do not ban peer for rate limiting light client requests
jimmygchen Nov 4, 2023
8e72d38
Merge branch 'unstable' into lc-reqresp. Also removed the mock light …
jimmygchen Feb 1, 2024
a610e2a
Remove unnecessary changes
jimmygchen Feb 1, 2024
8d3b26f
Add missing light client queue handling.
jimmygchen Feb 2, 2024
e393bf3
Merge branch 'unstable' into lc-reqresp
jimmygchen Mar 11, 2024
8015b2d
Merge branch 'unstable' into lc-reqresp
jimmygchen Mar 25, 2024
2e8ccbb
Add context bytes for light client RPC responses.
jimmygchen Mar 25, 2024
c888923
Add RPC limits for light client object.
jimmygchen Apr 2, 2024
bd167fa
Fix lint
jimmygchen Apr 2, 2024
00144af
Fix incorrect light client max size computation.
jimmygchen Apr 8, 2024
50c463d
Merge branch 'unstable' into lc-reqresp
jimmygchen Apr 8, 2024
08ed69e
Remove unwanted local changes.
jimmygchen Apr 8, 2024
1df31be
Merge branch 'unstable' into lc-reqresp
jimmygchen Apr 9, 2024
51fe0ce
Replace `unimplemented` electra code path with deneb values.
jimmygchen Apr 9, 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
11 changes: 6 additions & 5 deletions beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ use std::marker::PhantomData;
use std::sync::Arc;
use tokio_util::codec::{Decoder, Encoder};
use types::{
BlobSidecar, EthSpec, ForkContext, ForkName, Hash256, RuntimeVariableList, SignedBeaconBlock,
BlobSidecar, ChainSpec, EthSpec, ForkContext, ForkName, Hash256, LightClientBootstrap,
LightClientFinalityUpdate, LightClientOptimisticUpdate, RuntimeVariableList, SignedBeaconBlock,
SignedBeaconBlockAltair, SignedBeaconBlockBase, SignedBeaconBlockCapella,
SignedBeaconBlockDeneb, SignedBeaconBlockMerge,
};
use types::{
ChainSpec, LightClientBootstrap, LightClientFinalityUpdate, LightClientOptimisticUpdate,
SignedBeaconBlockDeneb, SignedBeaconBlockElectra, SignedBeaconBlockMerge,
};
use unsigned_varint::codec::Uvi;

Expand Down Expand Up @@ -396,6 +394,9 @@ fn context_bytes<E: EthSpec>(
return match **ref_box_block {
// NOTE: If you are adding another fork type here, be sure to modify the
// `fork_context.to_context_bytes()` function to support it as well!
SignedBeaconBlock::Electra { .. } => {
fork_context.to_context_bytes(ForkName::Electra)
}
SignedBeaconBlock::Deneb { .. } => {
fork_context.to_context_bytes(ForkName::Deneb)
}
Expand Down
4 changes: 2 additions & 2 deletions beacon_node/lighthouse_network/src/rpc/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,10 @@ pub enum RPCResponse<E: EthSpec> {
LightClientBootstrap(Arc<LightClientBootstrap<E>>),

/// A response to a get LIGHT_CLIENT_OPTIMISTIC_UPDATE request.
LightClientOptimisticUpdate(Arc<LightClientOptimisticUpdate<T>>),
LightClientOptimisticUpdate(Arc<LightClientOptimisticUpdate<E>>),

/// A response to a get LIGHT_CLIENT_FINALITY_UPDATE request.
LightClientFinalityUpdate(Arc<LightClientFinalityUpdate<T>>),
LightClientFinalityUpdate(Arc<LightClientFinalityUpdate<E>>),

/// A response to a get BLOBS_BY_ROOT request.
BlobsByRoot(Arc<BlobSidecar<E>>),
Expand Down
36 changes: 32 additions & 4 deletions beacon_node/lighthouse_network/src/rpc/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ use tokio_util::{
compat::{Compat, FuturesAsyncReadCompatExt},
};
use types::{
BeaconBlock, BeaconBlockAltair, BeaconBlockBase, BeaconBlockCapella, BeaconBlockMerge,
BlobSidecar, ChainSpec, EmptyBlock, EthSpec, ForkContext, ForkName, LightClientBootstrap,
LightClientFinalityUpdate, LightClientFinalityUpdateAltair, LightClientOptimisticUpdate,
BeaconBlock, BeaconBlockAltair, BeaconBlockBase, BeaconBlockCapella, BeaconBlockElectra,
BeaconBlockMerge, BlobSidecar, ChainSpec, EmptyBlock, EthSpec, ForkContext, ForkName,
LightClientBootstrap, LightClientBootstrapAltair, LightClientFinalityUpdate,
LightClientFinalityUpdateAltair, LightClientOptimisticUpdate,
LightClientOptimisticUpdateAltair, MainnetEthSpec, Signature, SignedBeaconBlock,
};

Expand Down Expand Up @@ -169,6 +170,24 @@ pub fn rpc_block_limits_by_fork(current_fork: ForkName) -> RpcLimits {
}
}

#[test]
fn test_limits() {
for fork in ForkName::list_all() {
println!(
"rpc_light_client_finality_update_limits_by_fork: {:?}",
rpc_light_client_finality_update_limits_by_fork(fork)
);
println!(
"rpc_light_client_optimistic_update_limits_by_fork: {:?}",
rpc_light_client_optimistic_update_limits_by_fork(fork)
);
println!(
"rpc_light_client_bootstrap_limits_by_fork: {:?}",
rpc_light_client_bootstrap_limits_by_fork(fork)
);
}
}

fn rpc_light_client_finality_update_limits_by_fork(current_fork: ForkName) -> RpcLimits {
let altair_fixed_len = LightClientFinalityUpdateAltair::<MainnetEthSpec>::ssz_fixed_len();

Expand All @@ -181,6 +200,9 @@ fn rpc_light_client_finality_update_limits_by_fork(current_fork: ForkName) -> Rp
ForkName::Deneb => {
RpcLimits::new(altair_fixed_len, *LIGHT_CLIENT_FINALITY_UPDATE_DENEB_MAX)
}
ForkName::Electra => {
unimplemented!("Electra not implemented")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not default to Deneb for now?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with the Electra changes to light clients, and I'd rather not forget to update this when Electra comes. What's the value of adding a value that might be obsolete? We're not going to hit this code path pre Electra.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I worry we forget, enable the light-client server by default and LH gets panics on devnets / testnets. Could add a default to electra and a TODO(electra)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 51fe0ce

}
}
}

Expand All @@ -197,17 +219,23 @@ fn rpc_light_client_optimistic_update_limits_by_fork(current_fork: ForkName) ->
ForkName::Deneb => {
RpcLimits::new(altair_fixed_len, *LIGHT_CLIENT_OPTIMISTIC_UPDATE_DENEB_MAX)
}
ForkName::Electra => {
unimplemented!("Electra not implemented")
}
}
}

fn rpc_light_client_bootstrap_limits_by_fork(current_fork: ForkName) -> RpcLimits {
let altair_fixed_len = LightClientBootstrap::<MainnetEthSpec>::ssz_fixed_len();
let altair_fixed_len = LightClientBootstrapAltair::<MainnetEthSpec>::ssz_fixed_len();

match &current_fork {
ForkName::Base => RpcLimits::new(0, 0),
ForkName::Altair | ForkName::Merge => RpcLimits::new(altair_fixed_len, altair_fixed_len),
ForkName::Capella => RpcLimits::new(altair_fixed_len, *LIGHT_CLIENT_BOOTSTRAP_CAPELLA_MAX),
ForkName::Deneb => RpcLimits::new(altair_fixed_len, *LIGHT_CLIENT_BOOTSTRAP_DENEB_MAX),
ForkName::Electra => {
unimplemented!("Electra not implemented")
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions beacon_node/lighthouse_network/src/service/api_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ pub enum Response<E: EthSpec> {
/// A response to a get BLOBS_BY_ROOT request.
BlobsByRoot(Option<Arc<BlobSidecar<E>>>),
/// A response to a LightClientUpdate request.
LightClientBootstrap(Arc<LightClientBootstrap<TSpec>>),
LightClientBootstrap(Arc<LightClientBootstrap<E>>),
/// A response to a LightClientOptimisticUpdate request.
LightClientOptimisticUpdate(Arc<LightClientOptimisticUpdate<TSpec>>),
LightClientOptimisticUpdate(Arc<LightClientOptimisticUpdate<E>>),
/// A response to a LightClientFinalityUpdate request.
LightClientFinalityUpdate(Arc<LightClientFinalityUpdate<TSpec>>),
LightClientFinalityUpdate(Arc<LightClientFinalityUpdate<E>>),
}

impl<E: EthSpec> std::convert::From<Response<E>> for RPCCodedResponse<E> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ pub fn process_registry_updates<E: EthSpec>(
Ok(())
}

pub fn process_registry_updates_slow<T: EthSpec>(
state: &mut BeaconState<T>,
pub fn process_registry_updates_slow<E: EthSpec>(
state: &mut BeaconState<E>,
spec: &ChainSpec,
) -> Result<(), Error> {
process_epoch_single_pass(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ pub fn process_slashings<E: EthSpec>(
Ok(())
}

pub fn process_slashings_slow<T: EthSpec>(
state: &mut BeaconState<T>,
pub fn process_slashings_slow<E: EthSpec>(
state: &mut BeaconState<E>,
spec: &ChainSpec,
) -> Result<(), Error> {
process_epoch_single_pass(
Expand Down
5 changes: 4 additions & 1 deletion consensus/types/src/execution_payload_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ impl<E: EthSpec> ExecutionPayloadHeader<E> {
| ForkName::Capella
| ForkName::Deneb => {
// Max size of variable length `extra_data` field
T::max_extra_data_bytes() * <u8 as Encode>::ssz_fixed_len()
E::max_extra_data_bytes() * <u8 as Encode>::ssz_fixed_len()
}
ForkName::Electra => {
unimplemented!("Electra not implemented")
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion consensus/types/src/light_client_bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,12 @@ impl<E: EthSpec> LightClientBootstrap<E> {
match fork_name {
ForkName::Base => 0,
ForkName::Altair | ForkName::Merge | ForkName::Capella | ForkName::Deneb => {
<Self as Encode>::ssz_fixed_len()
<LightClientBootstrapAltair<E> as Encode>::ssz_fixed_len()
+ LightClientHeader::<E>::ssz_max_var_len_for_fork(fork_name)
}
ForkName::Electra => {
unimplemented!("Electra not implemented")
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion consensus/types/src/light_client_finality_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,12 @@ impl<E: EthSpec> LightClientFinalityUpdate<E> {
match fork_name {
ForkName::Base => 0,
ForkName::Altair | ForkName::Merge | ForkName::Capella | ForkName::Deneb => {
<Self as Encode>::ssz_fixed_len()
<LightClientFinalityUpdateAltair<E> as Encode>::ssz_fixed_len()
+ 2 * LightClientHeader::<E>::ssz_max_var_len_for_fork(fork_name)
}
ForkName::Electra => {
unimplemented!("Electra not implemented")
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions consensus/types/src/light_client_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ impl<E: EthSpec> LightClientHeader<E> {
ForkName::Capella | ForkName::Deneb => {
ExecutionPayloadHeader::<E>::ssz_max_var_len_for_fork(fork_name)
}
ForkName::Electra => {
unimplemented!("Electra not implemented")
}
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion consensus/types/src/light_client_optimistic_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,12 @@ impl<E: EthSpec> LightClientOptimisticUpdate<E> {
match fork_name {
ForkName::Base => 0,
ForkName::Altair | ForkName::Merge | ForkName::Capella | ForkName::Deneb => {
<Self as Encode>::ssz_fixed_len()
<LightClientOptimisticUpdateAltair<E> as Encode>::ssz_fixed_len()
+ LightClientHeader::<E>::ssz_max_var_len_for_fork(fork_name)
}
ForkName::Electra => {
unimplemented!("Electra not implemented")
}
}
}
}
Expand Down