From 388a7cd05b535258fea2134ade12665758ff7efa Mon Sep 17 00:00:00 2001 From: geemo Date: Tue, 7 Feb 2023 14:58:12 -0600 Subject: [PATCH 01/71] rebase and add comment --- beacon_node/http_api/src/lib.rs | 93 +++++++++++++++++++++++++++++ beacon_node/http_api/tests/tests.rs | 51 +++++++++++++++- common/eth2/src/lib.rs | 34 +++++++++++ lighthouse/src/main.rs | 2 +- 4 files changed, 178 insertions(+), 2 deletions(-) diff --git a/beacon_node/http_api/src/lib.rs b/beacon_node/http_api/src/lib.rs index 973be2d49b4..78cf5c02dd8 100644 --- a/beacon_node/http_api/src/lib.rs +++ b/beacon_node/http_api/src/lib.rs @@ -1726,6 +1726,97 @@ pub fn serve( * beacon/rewards */ + let beacon_light_client_path = eth_v1 + .and(warp::path("beacon")) + .and(warp::path("light_client")) + .and(chain_filter.clone()); + + // GET beacon/light_client/optimistic_update + let get_beacon_light_client_optimistic_update = beacon_light_client_path + .clone() + .and(warp::path("optimistic_update")) + .and(warp::path::end()) + .and(warp::header::optional::("accept")) + .and_then( + |chain: Arc>, accept_header: Option| { + blocking_task(move || { + let update = chain + .latest_seen_optimistic_update + .lock() + .clone() + .ok_or_else(|| { + warp_utils::reject::custom_not_found(format!( + "No LightClientOptimisticUpdate is available" + )) + })?; + + let fork_name = chain + .spec + .fork_name_at_slot::(update.signature_slot); + match accept_header { + Some(api_types::Accept::Ssz) => Response::builder() + .status(200) + .header("Content-Type", "application/octet-stream") + .body(update.as_ssz_bytes().into()) + .map_err(|e| { + warp_utils::reject::custom_server_error(format!( + "failed to create response: {}", + e + )) + }), + _ => Ok(warp::reply::json(&api_types::GenericResponse::from(update)) + .into_response()), + } + .map(|resp| add_consensus_version_header(resp, fork_name)) + }) + }, + ); + + // GET beacon/light_client/finality_update + let get_beacon_light_client_finality_update = beacon_light_client_path + .clone() + .and(warp::path("finality_update")) + .and(warp::path::end()) + .and(warp::header::optional::("accept")) + .and_then( + |chain: Arc>, accept_header: Option| { + blocking_task(move || { + let update = chain + .latest_seen_finality_update + .lock() + .clone() + .ok_or_else(|| { + warp_utils::reject::custom_not_found(format!( + "No LightClientFinalityUpdate is available" + )) + })?; + + let fork_name = chain + .spec + .fork_name_at_slot::(update.signature_slot); + match accept_header { + Some(api_types::Accept::Ssz) => Response::builder() + .status(200) + .header("Content-Type", "application/octet-stream") + .body(update.as_ssz_bytes().into()) + .map_err(|e| { + warp_utils::reject::custom_server_error(format!( + "failed to create response: {}", + e + )) + }), + _ => Ok(warp::reply::json(&api_types::GenericResponse::from(update)) + .into_response()), + } + .map(|resp| add_consensus_version_header(resp, fork_name)) + }) + }, + ); + + /* + * beacon/rewards + */ + let beacon_rewards_path = eth_v1 .and(warp::path("beacon")) .and(warp::path("rewards")) @@ -3456,6 +3547,8 @@ pub fn serve( .or(get_beacon_pool_voluntary_exits.boxed()) .or(get_beacon_deposit_snapshot.boxed()) .or(get_beacon_rewards_blocks.boxed()) + .or(get_beacon_light_client_optimistic_update.boxed()) + .or(get_beacon_light_client_finality_update.boxed()) .or(get_config_fork_schedule.boxed()) .or(get_config_spec.boxed()) .or(get_config_deposit_contract.boxed()) diff --git a/beacon_node/http_api/tests/tests.rs b/beacon_node/http_api/tests/tests.rs index 2e795e522d5..ab2b347fced 100644 --- a/beacon_node/http_api/tests/tests.rs +++ b/beacon_node/http_api/tests/tests.rs @@ -31,7 +31,7 @@ use tree_hash::TreeHash; use types::application_domain::ApplicationDomain; use types::{ AggregateSignature, BitList, Domain, EthSpec, ExecutionBlockHash, Hash256, Keypair, - MainnetEthSpec, RelativeEpoch, SelectionProof, SignedRoot, Slot, + LightClientOptimisticUpdate, MainnetEthSpec, RelativeEpoch, SelectionProof, SignedRoot, Slot, }; type E = MainnetEthSpec; @@ -1202,6 +1202,39 @@ impl ApiTester { self } + pub async fn test_get_beacon_light_client_optimistic_update(self) -> Self { + // get_beacon_light_client_optimistic_update returns Ok(None) on 404 NOT FOUND + let result = match self + .client + .get_beacon_light_client_optimistic_update::() + .await + { + Ok(result) => result, + Err(_) => panic!("query did not fail correctly"), + }; + + let expected = self.chain.latest_seen_optimistic_update.lock().clone(); + assert_eq!(result, expected); + + self + } + + pub async fn test_get_beacon_light_client_finality_update(self) -> Self { + let result = match self + .client + .get_beacon_light_client_finality_update::() + .await + { + Ok(result) => result, + Err(_) => panic!("query did not fail correctly"), + }; + + let expected = self.chain.latest_seen_finality_update.lock().clone(); + assert_eq!(result, expected); + + self + } + pub async fn test_get_beacon_pool_attestations(self) -> Self { let result = self .client @@ -3947,6 +3980,22 @@ async fn node_get() { .await; } +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn get_light_client_optimistic_update() { + ApiTester::new() + .await + .test_get_beacon_light_client_optimistic_update() + .await; +} + +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn get_light_client_finality_update() { + ApiTester::new() + .await + .test_get_beacon_light_client_finality_update() + .await; +} + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn get_validator_duties_early() { ApiTester::new() diff --git a/common/eth2/src/lib.rs b/common/eth2/src/lib.rs index 653c6c0bcc7..77f7088e722 100644 --- a/common/eth2/src/lib.rs +++ b/common/eth2/src/lib.rs @@ -562,6 +562,40 @@ impl BeaconNodeHttpClient { self.get_opt(path).await } + /// `GET beacon/light_client/optimimistic_update` + /// + /// Returns `Ok(None)` on a 404 error. + pub async fn get_beacon_light_client_optimistic_update( + &self, + ) -> Result>, Error> { + let mut path = self.eth_path(V1)?; + + path.path_segments_mut() + .map_err(|()| Error::InvalidUrl(self.server.clone()))? + .push("beacon") + .push("light_client") + .push("optimistic_update"); + + self.get_opt(path).await + } + + /// `GET beacon/light_client/finality_update` + /// + /// Returns `Ok(None)` on a 404 error. + pub async fn get_beacon_light_client_finality_update( + &self, + ) -> Result>, Error> { + let mut path = self.eth_path(V1)?; + + path.path_segments_mut() + .map_err(|()| Error::InvalidUrl(self.server.clone()))? + .push("beacon") + .push("light_client") + .push("finality_update"); + + self.get_opt(path).await + } + /// `GET beacon/headers?slot,parent_root` /// /// Returns `Ok(None)` on a 404 error. diff --git a/lighthouse/src/main.rs b/lighthouse/src/main.rs index babe2f8dca7..d9ad22decbd 100644 --- a/lighthouse/src/main.rs +++ b/lighthouse/src/main.rs @@ -1,4 +1,4 @@ -#![recursion_limit = "256"] +#![recursion_limit = "512"] mod metrics; From b47b4f25c258c858473d12b0be2bf7b2ce9a8bd6 Mon Sep 17 00:00:00 2001 From: geemo Date: Wed, 8 Feb 2023 12:36:31 -0600 Subject: [PATCH 02/71] conditional test --- beacon_node/client/src/builder.rs | 1 + beacon_node/http_api/src/lib.rs | 20 ++++++++++++++++++-- beacon_node/http_api/tests/common.rs | 1 + beacon_node/http_api/tests/main.rs | 2 +- beacon_node/http_api/tests/tests.rs | 2 +- 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/beacon_node/client/src/builder.rs b/beacon_node/client/src/builder.rs index 3b016ebda9c..a1eecbc9814 100644 --- a/beacon_node/client/src/builder.rs +++ b/beacon_node/client/src/builder.rs @@ -147,6 +147,7 @@ where } else { None }; + self.http_api_config.enable_light_client_server = config.network.enable_light_client_server; let execution_layer = if let Some(config) = config.execution_layer { let context = runtime_context.service_context("exec".into()); diff --git a/beacon_node/http_api/src/lib.rs b/beacon_node/http_api/src/lib.rs index 78cf5c02dd8..b4aaccbb67b 100644 --- a/beacon_node/http_api/src/lib.rs +++ b/beacon_node/http_api/src/lib.rs @@ -118,6 +118,7 @@ pub struct Config { pub allow_sync_stalled: bool, pub spec_fork_name: Option, pub data_dir: PathBuf, + pub enable_light_client_server: bool, } impl Default for Config { @@ -131,6 +132,7 @@ impl Default for Config { allow_sync_stalled: false, spec_fork_name: None, data_dir: PathBuf::from(DEFAULT_ROOT_DIR), + enable_light_client_server: false, } } } @@ -251,6 +253,18 @@ pub fn prometheus_metrics() -> warp::filters::log::Log impl Filter + Clone { + warp::any() + .and_then(move || async move { + if is_enabled { + Ok(()) + } else { + Err(warp::reject::not_found()) + } + }) + .untuple_one() +} + /// Creates a server that will serve requests using information from `ctx`. /// /// The server will shut down gracefully when the `shutdown` future resolves. @@ -3547,8 +3561,6 @@ pub fn serve( .or(get_beacon_pool_voluntary_exits.boxed()) .or(get_beacon_deposit_snapshot.boxed()) .or(get_beacon_rewards_blocks.boxed()) - .or(get_beacon_light_client_optimistic_update.boxed()) - .or(get_beacon_light_client_finality_update.boxed()) .or(get_config_fork_schedule.boxed()) .or(get_config_spec.boxed()) .or(get_config_deposit_contract.boxed()) @@ -3591,6 +3603,10 @@ pub fn serve( .recover(warp_utils::reject::handle_rejection), ) .boxed() + .or(enable(true) + .and(get_beacon_light_client_optimistic_update.boxed()) + ) + .boxed() .or(warp::post().and( post_beacon_blocks .boxed() diff --git a/beacon_node/http_api/tests/common.rs b/beacon_node/http_api/tests/common.rs index 7c228d9803f..ee85db8fc44 100644 --- a/beacon_node/http_api/tests/common.rs +++ b/beacon_node/http_api/tests/common.rs @@ -176,6 +176,7 @@ pub async fn create_api_server_on_port( allow_sync_stalled: false, data_dir: std::path::PathBuf::from(DEFAULT_ROOT_DIR), spec_fork_name: None, + enable_light_client_server: true, }, chain: Some(chain.clone()), network_senders: Some(network_senders), diff --git a/beacon_node/http_api/tests/main.rs b/beacon_node/http_api/tests/main.rs index ca6a27530a6..76a851dc4d2 100644 --- a/beacon_node/http_api/tests/main.rs +++ b/beacon_node/http_api/tests/main.rs @@ -1,5 +1,5 @@ #![cfg(not(debug_assertions))] // Tests are too slow in debug. -#![recursion_limit = "256"] +#![recursion_limit = "512"] pub mod common; pub mod fork_tests; diff --git a/beacon_node/http_api/tests/tests.rs b/beacon_node/http_api/tests/tests.rs index ab2b347fced..4058160771f 100644 --- a/beacon_node/http_api/tests/tests.rs +++ b/beacon_node/http_api/tests/tests.rs @@ -1210,7 +1210,7 @@ impl ApiTester { .await { Ok(result) => result, - Err(_) => panic!("query did not fail correctly"), + Err(e) => panic!("query did not fail correctly"), }; let expected = self.chain.latest_seen_optimistic_update.lock().clone(); From df78885f93e05a3986341c8e778f133652c26c44 Mon Sep 17 00:00:00 2001 From: geemo Date: Wed, 8 Feb 2023 13:18:29 -0600 Subject: [PATCH 03/71] test --- beacon_node/http_api/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beacon_node/http_api/src/lib.rs b/beacon_node/http_api/src/lib.rs index b4aaccbb67b..409b068e0ac 100644 --- a/beacon_node/http_api/src/lib.rs +++ b/beacon_node/http_api/src/lib.rs @@ -3604,7 +3604,7 @@ pub fn serve( ) .boxed() .or(enable(true) - .and(get_beacon_light_client_optimistic_update.boxed()) + .and(get_beacon_light_client_optimistic_update) ) .boxed() .or(warp::post().and( From e124c995220d6181802d3cdf1a36799d4751ab0e Mon Sep 17 00:00:00 2001 From: geemo Date: Wed, 8 Feb 2023 13:47:46 -0600 Subject: [PATCH 04/71] optimistic chould be working now --- beacon_node/http_api/src/lib.rs | 7 +++---- beacon_node/http_api/tests/tests.rs | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/beacon_node/http_api/src/lib.rs b/beacon_node/http_api/src/lib.rs index 409b068e0ac..51c459b3545 100644 --- a/beacon_node/http_api/src/lib.rs +++ b/beacon_node/http_api/src/lib.rs @@ -3597,16 +3597,15 @@ pub fn serve( .or(get_lighthouse_database_info.boxed()) .or(get_lighthouse_block_rewards.boxed()) .or(get_lighthouse_attestation_performance.boxed()) + .or(enable(ctx.config.enable_light_client_server) + .and(get_beacon_light_client_optimistic_update.boxed()) + ) .or(get_lighthouse_block_packing_efficiency.boxed()) .or(get_lighthouse_merge_readiness.boxed()) .or(get_events.boxed()) .recover(warp_utils::reject::handle_rejection), ) .boxed() - .or(enable(true) - .and(get_beacon_light_client_optimistic_update) - ) - .boxed() .or(warp::post().and( post_beacon_blocks .boxed() diff --git a/beacon_node/http_api/tests/tests.rs b/beacon_node/http_api/tests/tests.rs index 4058160771f..945847b7365 100644 --- a/beacon_node/http_api/tests/tests.rs +++ b/beacon_node/http_api/tests/tests.rs @@ -31,7 +31,7 @@ use tree_hash::TreeHash; use types::application_domain::ApplicationDomain; use types::{ AggregateSignature, BitList, Domain, EthSpec, ExecutionBlockHash, Hash256, Keypair, - LightClientOptimisticUpdate, MainnetEthSpec, RelativeEpoch, SelectionProof, SignedRoot, Slot, + MainnetEthSpec, RelativeEpoch, SelectionProof, SignedRoot, Slot, }; type E = MainnetEthSpec; From cfdeca0650fcf195132ef5e9f597a6325add198a Mon Sep 17 00:00:00 2001 From: geemo Date: Wed, 8 Feb 2023 14:00:01 -0600 Subject: [PATCH 05/71] finality should be working now --- beacon_node/http_api/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/beacon_node/http_api/src/lib.rs b/beacon_node/http_api/src/lib.rs index 51c459b3545..e56d63b395b 100644 --- a/beacon_node/http_api/src/lib.rs +++ b/beacon_node/http_api/src/lib.rs @@ -3599,6 +3599,7 @@ pub fn serve( .or(get_lighthouse_attestation_performance.boxed()) .or(enable(ctx.config.enable_light_client_server) .and(get_beacon_light_client_optimistic_update.boxed()) + .or(get_beacon_light_client_finality_update.boxed()) ) .or(get_lighthouse_block_packing_efficiency.boxed()) .or(get_lighthouse_merge_readiness.boxed()) From e15b98f4709484478ab062885f73faafdb0193f4 Mon Sep 17 00:00:00 2001 From: geemo Date: Wed, 8 Feb 2023 14:08:15 -0600 Subject: [PATCH 06/71] try again --- beacon_node/http_api/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beacon_node/http_api/src/lib.rs b/beacon_node/http_api/src/lib.rs index e56d63b395b..b3fb75ec475 100644 --- a/beacon_node/http_api/src/lib.rs +++ b/beacon_node/http_api/src/lib.rs @@ -3599,7 +3599,7 @@ pub fn serve( .or(get_lighthouse_attestation_performance.boxed()) .or(enable(ctx.config.enable_light_client_server) .and(get_beacon_light_client_optimistic_update.boxed()) - .or(get_beacon_light_client_finality_update.boxed()) + .and(get_beacon_light_client_finality_update.boxed()) ) .or(get_lighthouse_block_packing_efficiency.boxed()) .or(get_lighthouse_merge_readiness.boxed()) From 6db8a414b3c4ca834bff9dc1f6670cd6e10472a5 Mon Sep 17 00:00:00 2001 From: geemo Date: Wed, 8 Feb 2023 14:10:09 -0600 Subject: [PATCH 07/71] try again --- beacon_node/http_api/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/beacon_node/http_api/src/lib.rs b/beacon_node/http_api/src/lib.rs index b3fb75ec475..d0123c5be03 100644 --- a/beacon_node/http_api/src/lib.rs +++ b/beacon_node/http_api/src/lib.rs @@ -3599,6 +3599,8 @@ pub fn serve( .or(get_lighthouse_attestation_performance.boxed()) .or(enable(ctx.config.enable_light_client_server) .and(get_beacon_light_client_optimistic_update.boxed()) + ) + .or(enable(ctx.config.enable_light_client_server) .and(get_beacon_light_client_finality_update.boxed()) ) .or(get_lighthouse_block_packing_efficiency.boxed()) From 1537947ee582b3560cba61e8866ef78708d1580d Mon Sep 17 00:00:00 2001 From: geemo Date: Wed, 8 Feb 2023 14:30:40 -0600 Subject: [PATCH 08/71] clippy fix --- beacon_node/http_api/src/lib.rs | 18 ++++++++---------- beacon_node/http_api/tests/tests.rs | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/beacon_node/http_api/src/lib.rs b/beacon_node/http_api/src/lib.rs index d0123c5be03..27f5c998904 100644 --- a/beacon_node/http_api/src/lib.rs +++ b/beacon_node/http_api/src/lib.rs @@ -1759,9 +1759,9 @@ pub fn serve( .lock() .clone() .ok_or_else(|| { - warp_utils::reject::custom_not_found(format!( - "No LightClientOptimisticUpdate is available" - )) + warp_utils::reject::custom_not_found( + "No LightClientOptimisticUpdate is available".to_string(), + ) })?; let fork_name = chain @@ -1800,9 +1800,9 @@ pub fn serve( .lock() .clone() .ok_or_else(|| { - warp_utils::reject::custom_not_found(format!( - "No LightClientFinalityUpdate is available" - )) + warp_utils::reject::custom_not_found( + "No LightClientFinalityUpdate is available".to_string(), + ) })?; let fork_name = chain @@ -3598,11 +3598,9 @@ pub fn serve( .or(get_lighthouse_block_rewards.boxed()) .or(get_lighthouse_attestation_performance.boxed()) .or(enable(ctx.config.enable_light_client_server) - .and(get_beacon_light_client_optimistic_update.boxed()) - ) + .and(get_beacon_light_client_optimistic_update.boxed())) .or(enable(ctx.config.enable_light_client_server) - .and(get_beacon_light_client_finality_update.boxed()) - ) + .and(get_beacon_light_client_finality_update.boxed())) .or(get_lighthouse_block_packing_efficiency.boxed()) .or(get_lighthouse_merge_readiness.boxed()) .or(get_events.boxed()) diff --git a/beacon_node/http_api/tests/tests.rs b/beacon_node/http_api/tests/tests.rs index 945847b7365..5960d1bfb9a 100644 --- a/beacon_node/http_api/tests/tests.rs +++ b/beacon_node/http_api/tests/tests.rs @@ -1210,7 +1210,7 @@ impl ApiTester { .await { Ok(result) => result, - Err(e) => panic!("query did not fail correctly"), + Err(_) => panic!("query did not fail correctly"), }; let expected = self.chain.latest_seen_optimistic_update.lock().clone(); From 5dbde26a64b99fd437f5fbeee6ca80d4f5cb90c6 Mon Sep 17 00:00:00 2001 From: geemo Date: Wed, 8 Feb 2023 19:57:16 -0600 Subject: [PATCH 09/71] add lc bootstrap beacon api --- beacon_node/http_api/src/lib.rs | 71 ++++++++++++++++++- .../src/rpc/codec/ssz_snappy.rs | 2 +- .../lighthouse_network/src/rpc/methods.rs | 2 +- .../src/service/api_types.rs | 2 +- .../beacon_processor/worker/rpc_methods.rs | 2 +- consensus/types/src/lib.rs | 1 + 6 files changed, 75 insertions(+), 5 deletions(-) diff --git a/beacon_node/http_api/src/lib.rs b/beacon_node/http_api/src/lib.rs index 27f5c998904..091d81b79d3 100644 --- a/beacon_node/http_api/src/lib.rs +++ b/beacon_node/http_api/src/lib.rs @@ -58,7 +58,7 @@ use types::{ ProposerPreparationData, ProposerSlashing, RelativeEpoch, SignedAggregateAndProof, SignedBeaconBlock, SignedBlindedBeaconBlock, SignedContributionAndProof, SignedValidatorRegistrationData, SignedVoluntaryExit, Slot, SyncCommitteeMessage, - SyncContributionData, + SyncContributionData, Hash256, LightClientBootstrap, }; use version::{ add_consensus_version_header, execution_optimistic_fork_versioned_response, @@ -1745,6 +1745,73 @@ pub fn serve( .and(warp::path("light_client")) .and(chain_filter.clone()); + // GET beacon/light_client/bootrap/{block_root} + let get_beacon_light_client_bootstrap = beacon_light_client_path + .clone() + .and(warp::path("bootstrap")) + .and(warp::path::param::().or_else(|_| async { + Err(warp_utils::reject::custom_bad_request( + "Invalid block root value".to_string(), + )) + })) + .and(warp::path::end()) + .and(warp::header::optional::("accept")) + .and_then( + |chain: Arc>, + block_root: Hash256, + accept_header: Option| { + blocking_task(move || { + let state_root = chain + .get_blinded_block(&block_root) + .map_err(|_| { + warp_utils::reject::custom_server_error( + "Error retrieving block".to_string(), + ) + })? + .map(|signed_block| signed_block.state_root()) + .ok_or_else(|| { + warp_utils::reject::custom_not_found( + "Light client bootstrap unavailable".to_string(), + ) + })?; + + let mut state = chain.get_state(&state_root, None).map_err(|_| { + warp_utils::reject::custom_server_error( + "Error retrieving state".to_string(), + ) + })? + .ok_or_else(|| { + warp_utils::reject::custom_not_found("Light client bootstrap unavailable".to_string()) + })?; + let fork_name = state + .fork_name(&chain.spec) + .map_err(inconsistent_fork_rejection)?; + let bootstrap = LightClientBootstrap::from_beacon_state(&mut state) + .map_err(|_| { + warp_utils::reject::custom_server_error( + "Failed to create light client bootstrap".to_string(), + ) + })?; + match accept_header { + Some(api_types::Accept::Ssz) => Response::builder() + .status(200) + .header("Content-Type", "application/octet-stream") + .body(bootstrap.as_ssz_bytes().into()) + .map_err(|e| { + warp_utils::reject::custom_server_error(format!( + "failed to create response: {}", + e + )) + }), + _ => Ok(warp::reply::json(&api_types::GenericResponse::from(bootstrap)) + .into_response()), + } + .map(|resp| add_consensus_version_header(resp, fork_name)) + }) + } + ); + + // GET beacon/light_client/optimistic_update let get_beacon_light_client_optimistic_update = beacon_light_client_path .clone() @@ -3601,6 +3668,8 @@ pub fn serve( .and(get_beacon_light_client_optimistic_update.boxed())) .or(enable(ctx.config.enable_light_client_server) .and(get_beacon_light_client_finality_update.boxed())) + .or(enable(ctx.config.enable_light_client_server) + .and(get_beacon_light_client_bootstrap.boxed())) .or(get_lighthouse_block_packing_efficiency.boxed()) .or(get_lighthouse_merge_readiness.boxed()) .or(get_events.boxed()) diff --git a/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs b/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs index eccbf0dd623..96b0cd26eb6 100644 --- a/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs +++ b/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs @@ -16,7 +16,7 @@ use std::marker::PhantomData; use std::sync::Arc; use tokio_util::codec::{Decoder, Encoder}; use types::{ - light_client_bootstrap::LightClientBootstrap, EthSpec, ForkContext, ForkName, Hash256, + LightClientBootstrap, EthSpec, ForkContext, ForkName, Hash256, SignedBeaconBlock, SignedBeaconBlockAltair, SignedBeaconBlockBase, SignedBeaconBlockMerge, }; use unsigned_varint::codec::Uvi; diff --git a/beacon_node/lighthouse_network/src/rpc/methods.rs b/beacon_node/lighthouse_network/src/rpc/methods.rs index 5da595c3db7..ed302fc475e 100644 --- a/beacon_node/lighthouse_network/src/rpc/methods.rs +++ b/beacon_node/lighthouse_network/src/rpc/methods.rs @@ -13,7 +13,7 @@ use std::sync::Arc; use strum::IntoStaticStr; use superstruct::superstruct; use types::{ - light_client_bootstrap::LightClientBootstrap, Epoch, EthSpec, Hash256, SignedBeaconBlock, Slot, + LightClientBootstrap, Epoch, EthSpec, Hash256, SignedBeaconBlock, Slot, }; /// Maximum number of blocks in a single request. diff --git a/beacon_node/lighthouse_network/src/service/api_types.rs b/beacon_node/lighthouse_network/src/service/api_types.rs index 849a86f51ba..bd76b1beb13 100644 --- a/beacon_node/lighthouse_network/src/service/api_types.rs +++ b/beacon_node/lighthouse_network/src/service/api_types.rs @@ -1,7 +1,7 @@ use std::sync::Arc; use libp2p::core::connection::ConnectionId; -use types::{light_client_bootstrap::LightClientBootstrap, EthSpec, SignedBeaconBlock}; +use types::{LightClientBootstrap, EthSpec, SignedBeaconBlock}; use crate::rpc::{ methods::{ diff --git a/beacon_node/network/src/beacon_processor/worker/rpc_methods.rs b/beacon_node/network/src/beacon_processor/worker/rpc_methods.rs index bfa0ea516fa..7523d584351 100644 --- a/beacon_node/network/src/beacon_processor/worker/rpc_methods.rs +++ b/beacon_node/network/src/beacon_processor/worker/rpc_methods.rs @@ -11,7 +11,7 @@ use slog::{debug, error}; use slot_clock::SlotClock; use std::sync::Arc; use task_executor::TaskExecutor; -use types::{light_client_bootstrap::LightClientBootstrap, Epoch, EthSpec, Hash256, Slot}; +use types::{LightClientBootstrap, Epoch, EthSpec, Hash256, Slot}; use super::Worker; diff --git a/consensus/types/src/lib.rs b/consensus/types/src/lib.rs index 87f5ebe8b3c..c803c0e5192 100644 --- a/consensus/types/src/lib.rs +++ b/consensus/types/src/lib.rs @@ -139,6 +139,7 @@ pub use crate::free_attestation::FreeAttestation; pub use crate::graffiti::{Graffiti, GRAFFITI_BYTES_LEN}; pub use crate::historical_batch::HistoricalBatch; pub use crate::indexed_attestation::IndexedAttestation; +pub use crate::light_client_bootstrap::LightClientBootstrap; pub use crate::light_client_finality_update::LightClientFinalityUpdate; pub use crate::light_client_optimistic_update::LightClientOptimisticUpdate; pub use crate::participation_flags::ParticipationFlags; From 4611a9c21cf7cd73a62fda45edefc8c337eba0f1 Mon Sep 17 00:00:00 2001 From: geemo Date: Wed, 8 Feb 2023 20:18:11 -0600 Subject: [PATCH 10/71] add lc optimistic/finality update to events --- beacon_node/beacon_chain/src/events.rs | 18 ++++++++++++++++++ beacon_node/http_api/src/lib.rs | 6 ++++++ common/eth2/src/types.rs | 26 ++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/beacon_node/beacon_chain/src/events.rs b/beacon_node/beacon_chain/src/events.rs index 6f4415ef4f3..a0075efd24e 100644 --- a/beacon_node/beacon_chain/src/events.rs +++ b/beacon_node/beacon_chain/src/events.rs @@ -15,6 +15,8 @@ pub struct ServerSentEventHandler { chain_reorg_tx: Sender>, contribution_tx: Sender>, late_head: Sender>, + light_client_finality_update_tx: Sender>, + light_client_optimistic_update_tx: Sender>, block_reward_tx: Sender>, log: Logger, } @@ -33,6 +35,8 @@ impl ServerSentEventHandler { let (chain_reorg_tx, _) = broadcast::channel(capacity); let (contribution_tx, _) = broadcast::channel(capacity); let (late_head, _) = broadcast::channel(capacity); + let (light_client_finality_update_tx, _) = broadcast::channel(capacity); + let (light_client_optimistic_update_tx, _) = broadcast::channel(capacity); let (block_reward_tx, _) = broadcast::channel(capacity); Self { @@ -44,6 +48,8 @@ impl ServerSentEventHandler { chain_reorg_tx, contribution_tx, late_head, + light_client_finality_update_tx, + light_client_optimistic_update_tx, block_reward_tx, log, } @@ -70,6 +76,10 @@ impl ServerSentEventHandler { .map(|count| trace!(self.log, "Registering server-sent contribution and proof event"; "receiver_count" => count)), EventKind::LateHead(late_head) => self.late_head.send(EventKind::LateHead(late_head)) .map(|count| trace!(self.log, "Registering server-sent late head event"; "receiver_count" => count)), + EventKind::LightClientFinalityUpdate(update) => self.light_client_finality_update_tx.send(EventKind::LightClientFinalityUpdate(update)) + .map(|count| trace!(self.log, "Registering server-sent light client finality update event"; "receiver_count" => count)), + EventKind::LightClientOptimisticUpdate(update) => self.light_client_optimistic_update_tx.send(EventKind::LightClientOptimisticUpdate(update)) + .map(|count| trace!(self.log, "Registering server-sent light client optimistic update event"; "receiver_count" => count)), EventKind::BlockReward(block_reward) => self.block_reward_tx.send(EventKind::BlockReward(block_reward)) .map(|count| trace!(self.log, "Registering server-sent contribution and proof event"; "receiver_count" => count)), }; @@ -110,6 +120,14 @@ impl ServerSentEventHandler { self.late_head.subscribe() } + pub fn subscribe_light_client_finality_update(&self) -> Receiver> { + self.light_client_finality_update_tx.subscribe() + } + + pub fn subscribe_light_client_optimistic_update(&self) -> Receiver> { + self.light_client_optimistic_update_tx.subscribe() + } + pub fn subscribe_block_reward(&self) -> Receiver> { self.block_reward_tx.subscribe() } diff --git a/beacon_node/http_api/src/lib.rs b/beacon_node/http_api/src/lib.rs index 091d81b79d3..7df8a9c7e4f 100644 --- a/beacon_node/http_api/src/lib.rs +++ b/beacon_node/http_api/src/lib.rs @@ -3567,6 +3567,12 @@ pub fn serve( api_types::EventTopic::LateHead => { event_handler.subscribe_late_head() } + api_types::EventTopic::LightClientFinalityUpdate => { + event_handler.subscribe_light_client_finality_update() + } + api_types::EventTopic::LightClientOptimisticUpdate => { + event_handler.subscribe_light_client_optimistic_update() + } api_types::EventTopic::BlockReward => { event_handler.subscribe_block_reward() } diff --git a/common/eth2/src/types.rs b/common/eth2/src/types.rs index 53cca49120a..788cbc5309d 100644 --- a/common/eth2/src/types.rs +++ b/common/eth2/src/types.rs @@ -923,6 +923,8 @@ pub enum EventKind { ChainReorg(SseChainReorg), ContributionAndProof(Box>), LateHead(SseLateHead), + LightClientFinalityUpdate(Box>), + LightClientOptimisticUpdate(Box>), #[cfg(feature = "lighthouse")] BlockReward(BlockReward), } @@ -938,6 +940,8 @@ impl EventKind { EventKind::ChainReorg(_) => "chain_reorg", EventKind::ContributionAndProof(_) => "contribution_and_proof", EventKind::LateHead(_) => "late_head", + EventKind::LightClientFinalityUpdate(_) => "light_client_finality_update", + EventKind::LightClientOptimisticUpdate(_) => "light_client_optimistic_update", #[cfg(feature = "lighthouse")] EventKind::BlockReward(_) => "block_reward", } @@ -992,6 +996,22 @@ impl EventKind { ServerError::InvalidServerSentEvent(format!("Contribution and Proof: {:?}", e)) })?, ))), + "light_client_finality_update" => Ok(EventKind::LightClientFinalityUpdate( + serde_json::from_str(data).map_err(|e| { + ServerError::InvalidServerSentEvent(format!( + "Light Client Finality Update: {:?}", + e + )) + })?, + )), + "light_client_optimistic_update" => Ok(EventKind::LightClientOptimisticUpdate( + serde_json::from_str(data).map_err(|e| { + ServerError::InvalidServerSentEvent(format!( + "Light Client Optimistic Update: {:?}", + e + )) + })?, + )), #[cfg(feature = "lighthouse")] "block_reward" => Ok(EventKind::BlockReward(serde_json::from_str(data).map_err( |e| ServerError::InvalidServerSentEvent(format!("Block Reward: {:?}", e)), @@ -1021,6 +1041,8 @@ pub enum EventTopic { ChainReorg, ContributionAndProof, LateHead, + LightClientFinalityUpdate, + LightClientOptimisticUpdate, #[cfg(feature = "lighthouse")] BlockReward, } @@ -1038,6 +1060,8 @@ impl FromStr for EventTopic { "chain_reorg" => Ok(EventTopic::ChainReorg), "contribution_and_proof" => Ok(EventTopic::ContributionAndProof), "late_head" => Ok(EventTopic::LateHead), + "light_client_finality_update" => Ok(EventTopic::LightClientFinalityUpdate), + "light_client_optimistic_update" => Ok(EventTopic::LightClientOptimisticUpdate), #[cfg(feature = "lighthouse")] "block_reward" => Ok(EventTopic::BlockReward), _ => Err("event topic cannot be parsed.".to_string()), @@ -1056,6 +1080,8 @@ impl fmt::Display for EventTopic { EventTopic::ChainReorg => write!(f, "chain_reorg"), EventTopic::ContributionAndProof => write!(f, "contribution_and_proof"), EventTopic::LateHead => write!(f, "late_head"), + EventTopic::LightClientFinalityUpdate => write!(f, "light_client_finality_update"), + EventTopic::LightClientOptimisticUpdate => write!(f, "light_client_optimistic_update"), #[cfg(feature = "lighthouse")] EventTopic::BlockReward => write!(f, "block_reward"), } From d3da99fa748a6eb50e8f76701d5f090a72721494 Mon Sep 17 00:00:00 2001 From: geemo Date: Wed, 8 Feb 2023 20:30:06 -0600 Subject: [PATCH 11/71] fmt --- beacon_node/http_api/src/lib.rs | 49 ++++++++++--------- .../src/rpc/codec/ssz_snappy.rs | 4 +- .../lighthouse_network/src/rpc/methods.rs | 4 +- .../src/service/api_types.rs | 2 +- .../beacon_processor/worker/rpc_methods.rs | 2 +- 5 files changed, 32 insertions(+), 29 deletions(-) diff --git a/beacon_node/http_api/src/lib.rs b/beacon_node/http_api/src/lib.rs index 7df8a9c7e4f..698e5715f71 100644 --- a/beacon_node/http_api/src/lib.rs +++ b/beacon_node/http_api/src/lib.rs @@ -54,11 +54,11 @@ use tokio::sync::mpsc::{Sender, UnboundedSender}; use tokio_stream::{wrappers::BroadcastStream, StreamExt}; use types::{ Attestation, AttestationData, AttesterSlashing, BeaconStateError, BlindedPayload, - CommitteeCache, ConfigAndPreset, Epoch, EthSpec, ForkName, FullPayload, - ProposerPreparationData, ProposerSlashing, RelativeEpoch, SignedAggregateAndProof, - SignedBeaconBlock, SignedBlindedBeaconBlock, SignedContributionAndProof, - SignedValidatorRegistrationData, SignedVoluntaryExit, Slot, SyncCommitteeMessage, - SyncContributionData, Hash256, LightClientBootstrap, + CommitteeCache, ConfigAndPreset, Epoch, EthSpec, ForkName, FullPayload, Hash256, + LightClientBootstrap, ProposerPreparationData, ProposerSlashing, RelativeEpoch, + SignedAggregateAndProof, SignedBeaconBlock, SignedBlindedBeaconBlock, + SignedContributionAndProof, SignedValidatorRegistrationData, SignedVoluntaryExit, Slot, + SyncCommitteeMessage, SyncContributionData, }; use version::{ add_consensus_version_header, execution_optimistic_fork_versioned_response, @@ -1758,8 +1758,8 @@ pub fn serve( .and(warp::header::optional::("accept")) .and_then( |chain: Arc>, - block_root: Hash256, - accept_header: Option| { + block_root: Hash256, + accept_header: Option| { blocking_task(move || { let state_root = chain .get_blinded_block(&block_root) @@ -1775,19 +1775,23 @@ pub fn serve( ) })?; - let mut state = chain.get_state(&state_root, None).map_err(|_| { - warp_utils::reject::custom_server_error( - "Error retrieving state".to_string(), - ) - })? - .ok_or_else(|| { - warp_utils::reject::custom_not_found("Light client bootstrap unavailable".to_string()) - })?; + let mut state = chain + .get_state(&state_root, None) + .map_err(|_| { + warp_utils::reject::custom_server_error( + "Error retrieving state".to_string(), + ) + })? + .ok_or_else(|| { + warp_utils::reject::custom_not_found( + "Light client bootstrap unavailable".to_string(), + ) + })?; let fork_name = state .fork_name(&chain.spec) .map_err(inconsistent_fork_rejection)?; - let bootstrap = LightClientBootstrap::from_beacon_state(&mut state) - .map_err(|_| { + let bootstrap = + LightClientBootstrap::from_beacon_state(&mut state).map_err(|_| { warp_utils::reject::custom_server_error( "Failed to create light client bootstrap".to_string(), ) @@ -1803,15 +1807,16 @@ pub fn serve( e )) }), - _ => Ok(warp::reply::json(&api_types::GenericResponse::from(bootstrap)) - .into_response()), + _ => Ok( + warp::reply::json(&api_types::GenericResponse::from(bootstrap)) + .into_response(), + ), } .map(|resp| add_consensus_version_header(resp, fork_name)) - }) - } + }) + }, ); - // GET beacon/light_client/optimistic_update let get_beacon_light_client_optimistic_update = beacon_light_client_path .clone() diff --git a/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs b/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs index 96b0cd26eb6..1481e38c6a7 100644 --- a/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs +++ b/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs @@ -16,8 +16,8 @@ use std::marker::PhantomData; use std::sync::Arc; use tokio_util::codec::{Decoder, Encoder}; use types::{ - LightClientBootstrap, EthSpec, ForkContext, ForkName, Hash256, - SignedBeaconBlock, SignedBeaconBlockAltair, SignedBeaconBlockBase, SignedBeaconBlockMerge, + EthSpec, ForkContext, ForkName, Hash256, LightClientBootstrap, SignedBeaconBlock, + SignedBeaconBlockAltair, SignedBeaconBlockBase, SignedBeaconBlockMerge, }; use unsigned_varint::codec::Uvi; diff --git a/beacon_node/lighthouse_network/src/rpc/methods.rs b/beacon_node/lighthouse_network/src/rpc/methods.rs index ed302fc475e..47963c7000d 100644 --- a/beacon_node/lighthouse_network/src/rpc/methods.rs +++ b/beacon_node/lighthouse_network/src/rpc/methods.rs @@ -12,9 +12,7 @@ use std::ops::Deref; use std::sync::Arc; use strum::IntoStaticStr; use superstruct::superstruct; -use types::{ - LightClientBootstrap, Epoch, EthSpec, Hash256, SignedBeaconBlock, Slot, -}; +use types::{Epoch, EthSpec, Hash256, LightClientBootstrap, SignedBeaconBlock, Slot}; /// Maximum number of blocks in a single request. pub type MaxRequestBlocks = U1024; diff --git a/beacon_node/lighthouse_network/src/service/api_types.rs b/beacon_node/lighthouse_network/src/service/api_types.rs index bd76b1beb13..cc524ea4b60 100644 --- a/beacon_node/lighthouse_network/src/service/api_types.rs +++ b/beacon_node/lighthouse_network/src/service/api_types.rs @@ -1,7 +1,7 @@ use std::sync::Arc; use libp2p::core::connection::ConnectionId; -use types::{LightClientBootstrap, EthSpec, SignedBeaconBlock}; +use types::{EthSpec, LightClientBootstrap, SignedBeaconBlock}; use crate::rpc::{ methods::{ diff --git a/beacon_node/network/src/beacon_processor/worker/rpc_methods.rs b/beacon_node/network/src/beacon_processor/worker/rpc_methods.rs index 7523d584351..b490ff0170e 100644 --- a/beacon_node/network/src/beacon_processor/worker/rpc_methods.rs +++ b/beacon_node/network/src/beacon_processor/worker/rpc_methods.rs @@ -11,7 +11,7 @@ use slog::{debug, error}; use slot_clock::SlotClock; use std::sync::Arc; use task_executor::TaskExecutor; -use types::{LightClientBootstrap, Epoch, EthSpec, Hash256, Slot}; +use types::{Epoch, EthSpec, Hash256, LightClientBootstrap, Slot}; use super::Worker; From a2f6a8ac52a7aaf50894bec3ada0466a5df23870 Mon Sep 17 00:00:00 2001 From: geemo Date: Fri, 10 Feb 2023 23:53:41 -0600 Subject: [PATCH 12/71] That error isn't occuring on my computer but I think this should fix it --- beacon_node/tests/test.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beacon_node/tests/test.rs b/beacon_node/tests/test.rs index 1c11a8349dd..8ccb260d29b 100644 --- a/beacon_node/tests/test.rs +++ b/beacon_node/tests/test.rs @@ -1,5 +1,5 @@ #![cfg(test)] -#![recursion_limit = "256"] +#![recursion_limit = "512"] use beacon_chain::StateSkipConfig; use node_test_rig::{ From d74e3b46b179e55034e28b1a0364ddd7fcd4cc5a Mon Sep 17 00:00:00 2001 From: Jimmy Chen Date: Thu, 16 Nov 2023 12:05:05 +1100 Subject: [PATCH 13/71] Add missing test file --- .../fixtures/mainnet/test_blobs_bundle.ssz | Bin 0 -> 131180 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 beacon_node/execution_layer/src/test_utils/fixtures/mainnet/test_blobs_bundle.ssz diff --git a/beacon_node/execution_layer/src/test_utils/fixtures/mainnet/test_blobs_bundle.ssz b/beacon_node/execution_layer/src/test_utils/fixtures/mainnet/test_blobs_bundle.ssz new file mode 100644 index 0000000000000000000000000000000000000000..6b549a4da84f33f1feea50ab073da9078c18bd6d GIT binary patch literal 131180 zcmWKX^II5v6ve-}g=O3JvTZKgT+6m?EZeoLW!trEuT`sMt@r)m`~~-U?z!i4o{Izk z5cpqT{#OYx@86(#eM3TtSizXc_UI?!!AJ@E)15b>uWbu|$e)>$=d8adZ;~5_^2c>( zT^TiTo&RaOfMyouK4(STJ@Y{xRC`_Pihl|=^IEBKRhgPz7M~(PWOsdHHD4O~YR?NO zX~@kyro#PHzYAj^Tt&}+Qr&hk{!`S*>i*`*^veq5qdo4_Prz3Mq2v|k@Y%k2!t0!_ zj&^ak#j|9`S+9W*!a`~PY%*fL4sQ~&pMbm8Zh;rI@bW{AQYJG*N)WhT*b@H+VZJUr z+Je)HO8NR-cRKL!C@hgIaQ-*;8#iEqEB2M=g}Pb%NJr*-5qhYp>+apPjYOgmQaL{A zR|@Wi#pZs5t+H3txmUy31q>=@Jrndr1W^ei*b0X{eFT#;IA*IGI%+&hiX>tw&OZ}p zDVk^WCx?_N)7ZB0KLL)j(CNBm%f)Iq`hO=W<$F@mTg~RtU(T6P*+I9<0cf+ltjB{r zNBM~Q#ilZPdr?oSw7#FHjH3{K_9Q%%2M|{4%K5aX%!YXy|3%m~vtsngWH84@2O1;G)M(b^K@PzqH#^XtP8w+x|=o!D`NZYTZMeYY1Frl*(X9Ft9tw7+jd3j z0*?w@c?RB~?)+SJC;mZPuH&X3&@<3nVf5ViV0-jUWl&Fc3`YWylmZ?^V?w-kuedR4 zDs?6^_`!XT0-;_1ae1oJfFvMbyn%FlT|1x$C4+;_hT`{h(Ds^b;C-yIa4Y`wnggon z$DY&sx5Xg8i%!TGCVjEh{sdiS=-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y638U?O0c(Xla{Kdwu_R^tDE0tQy2oLyJkq*Pj@>Z|TfZ3KSL#uDN=aGJRsJeu5=; z9R#<5Y7|6MBKvE`9A7uq04Yn9k7oWf9&&4 zeO}jkUipRe(V#5^&%Rd9N|Vq*Cm_ej5Qu!cA!3Gek_+ef>iHc3b;~Awqy&zH1Xo-g z)sm7;JD8Ktu>Iv39<{iz1!xOct6ApAY Date: Thu, 16 Nov 2023 16:34:02 +1100 Subject: [PATCH 14/71] Update light client types to comply with Altair light client spec. --- ...ght_client_finality_update_verification.rs | 4 +- ...t_client_optimistic_update_verification.rs | 5 ++- .../lighthouse_network/src/rpc/methods.rs | 6 ++- common/eth2/src/lib.rs | 29 +++++++++++--- .../state_processing/src/upgrade/altair.rs | 2 +- consensus/types/src/lib.rs | 2 + consensus/types/src/light_client_bootstrap.rs | 34 +++++++++++++--- .../types/src/light_client_finality_update.rs | 39 +++++++++++++++---- consensus/types/src/light_client_header.rs | 26 +++++++++++++ .../src/light_client_optimistic_update.rs | 30 ++++++++++++-- consensus/types/src/light_client_update.rs | 34 +++++++++++++--- consensus/types/src/sync_committee.rs | 12 ++---- 12 files changed, 180 insertions(+), 43 deletions(-) create mode 100644 consensus/types/src/light_client_header.rs diff --git a/beacon_node/beacon_chain/src/light_client_finality_update_verification.rs b/beacon_node/beacon_chain/src/light_client_finality_update_verification.rs index 86cc6695edb..791d63ccfe5 100644 --- a/beacon_node/beacon_chain/src/light_client_finality_update_verification.rs +++ b/beacon_node/beacon_chain/src/light_client_finality_update_verification.rs @@ -67,7 +67,7 @@ impl VerifiedLightClientFinalityUpdate { chain: &BeaconChain, seen_timestamp: Duration, ) -> Result { - let gossiped_finality_slot = light_client_finality_update.finalized_header.slot; + let gossiped_finality_slot = light_client_finality_update.finalized_header.beacon.slot; let one_third_slot_duration = Duration::new(chain.spec.seconds_per_slot / 3, 0); let signature_slot = light_client_finality_update.signature_slot; let start_time = chain.slot_clock.start_of(signature_slot); @@ -88,7 +88,7 @@ impl VerifiedLightClientFinalityUpdate { .get_blinded_block(&finalized_block_root)? .ok_or(Error::FailedConstructingUpdate)?; let latest_seen_finality_update_slot = match latest_seen_finality_update.as_ref() { - Some(update) => update.finalized_header.slot, + Some(update) => update.finalized_header.beacon.slot, None => Slot::new(0), }; diff --git a/beacon_node/beacon_chain/src/light_client_optimistic_update_verification.rs b/beacon_node/beacon_chain/src/light_client_optimistic_update_verification.rs index 8b7e6445273..374cc9a7753 100644 --- a/beacon_node/beacon_chain/src/light_client_optimistic_update_verification.rs +++ b/beacon_node/beacon_chain/src/light_client_optimistic_update_verification.rs @@ -71,7 +71,7 @@ impl VerifiedLightClientOptimisticUpdate { chain: &BeaconChain, seen_timestamp: Duration, ) -> Result { - let gossiped_optimistic_slot = light_client_optimistic_update.attested_header.slot; + let gossiped_optimistic_slot = light_client_optimistic_update.attested_header.beacon.slot; let one_third_slot_duration = Duration::new(chain.spec.seconds_per_slot / 3, 0); let signature_slot = light_client_optimistic_update.signature_slot; let start_time = chain.slot_clock.start_of(signature_slot); @@ -88,7 +88,7 @@ impl VerifiedLightClientOptimisticUpdate { .get_state(&attested_block.state_root(), Some(attested_block.slot()))? .ok_or(Error::FailedConstructingUpdate)?; let latest_seen_optimistic_update_slot = match latest_seen_optimistic_update.as_ref() { - Some(update) => update.attested_header.slot, + Some(update) => update.attested_header.beacon.slot, None => Slot::new(0), }; @@ -114,6 +114,7 @@ impl VerifiedLightClientOptimisticUpdate { // otherwise queue let canonical_root = light_client_optimistic_update .attested_header + .beacon .canonical_root(); if canonical_root != head_block.message().parent_root() { diff --git a/beacon_node/lighthouse_network/src/rpc/methods.rs b/beacon_node/lighthouse_network/src/rpc/methods.rs index a293de4e9bd..627c871c471 100644 --- a/beacon_node/lighthouse_network/src/rpc/methods.rs +++ b/beacon_node/lighthouse_network/src/rpc/methods.rs @@ -571,7 +571,11 @@ impl std::fmt::Display for RPCResponse { RPCResponse::Pong(ping) => write!(f, "Pong: {}", ping.data), RPCResponse::MetaData(metadata) => write!(f, "Metadata: {}", metadata.seq_number()), RPCResponse::LightClientBootstrap(bootstrap) => { - write!(f, "LightClientBootstrap Slot: {}", bootstrap.header.slot) + write!( + f, + "LightClientBootstrap Slot: {}", + bootstrap.header.beacon.slot + ) } } } diff --git a/common/eth2/src/lib.rs b/common/eth2/src/lib.rs index 9436d303ac6..7ed1c5c540c 100644 --- a/common/eth2/src/lib.rs +++ b/common/eth2/src/lib.rs @@ -667,12 +667,31 @@ impl BeaconNodeHttpClient { self.get_opt(path).await } - /// `GET beacon/light_client/optimimistic_update` + /// `GET beacon/light_client/bootstrap` /// /// Returns `Ok(None)` on a 404 error. - pub async fn get_beacon_light_client_optimistic_update( + pub async fn get_light_client_bootstrap( &self, - ) -> Result>, Error> { + block_root: Hash256, + ) -> Result>>, Error> { + let mut path = self.eth_path(V1)?; + + path.path_segments_mut() + .map_err(|()| Error::InvalidUrl(self.server.clone()))? + .push("beacon") + .push("light_client") + .push("bootstrap") + .push(&format!("{:?}", block_root)); + + self.get_opt(path).await + } + + /// `GET beacon/light_client/optimistic_update` + /// + /// Returns `Ok(None)` on a 404 error. + pub async fn get_beacon_light_client_optimistic_update( + &self, + ) -> Result>>, Error> { let mut path = self.eth_path(V1)?; path.path_segments_mut() @@ -687,9 +706,9 @@ impl BeaconNodeHttpClient { /// `GET beacon/light_client/finality_update` /// /// Returns `Ok(None)` on a 404 error. - pub async fn get_beacon_light_client_finality_update( + pub async fn get_beacon_light_client_finality_update( &self, - ) -> Result>, Error> { + ) -> Result>>, Error> { let mut path = self.eth_path(V1)?; path.path_segments_mut() diff --git a/consensus/state_processing/src/upgrade/altair.rs b/consensus/state_processing/src/upgrade/altair.rs index 26b1192bc16..5bb4f0bd592 100644 --- a/consensus/state_processing/src/upgrade/altair.rs +++ b/consensus/state_processing/src/upgrade/altair.rs @@ -54,7 +54,7 @@ pub fn upgrade_to_altair( VariableList::new(vec![ParticipationFlags::default(); pre.validators.len()])?; let inactivity_scores = VariableList::new(vec![0; pre.validators.len()])?; - let temp_sync_committee = Arc::new(SyncCommittee::temporary()?); + let temp_sync_committee = Arc::new(SyncCommittee::temporary()); // Where possible, use something like `mem::take` to move fields from behind the &mut // reference. For other fields that don't have a good default value, use `clone`. diff --git a/consensus/types/src/lib.rs b/consensus/types/src/lib.rs index 52300df3fd4..262cd24f9a8 100644 --- a/consensus/types/src/lib.rs +++ b/consensus/types/src/lib.rs @@ -99,6 +99,7 @@ pub mod slot_data; pub mod sqlite; pub mod blob_sidecar; +pub mod light_client_header; pub mod sidecar; pub mod signed_blob; @@ -156,6 +157,7 @@ pub use crate::historical_batch::HistoricalBatch; pub use crate::indexed_attestation::IndexedAttestation; pub use crate::light_client_bootstrap::LightClientBootstrap; pub use crate::light_client_finality_update::LightClientFinalityUpdate; +pub use crate::light_client_header::LightClientHeader; pub use crate::light_client_optimistic_update::LightClientOptimisticUpdate; pub use crate::participation_flags::ParticipationFlags; pub use crate::participation_list::ParticipationList; diff --git a/consensus/types/src/light_client_bootstrap.rs b/consensus/types/src/light_client_bootstrap.rs index 1d70456d732..15cc564c6e7 100644 --- a/consensus/types/src/light_client_bootstrap.rs +++ b/consensus/types/src/light_client_bootstrap.rs @@ -1,6 +1,10 @@ -use super::{BeaconBlockHeader, BeaconState, EthSpec, FixedVector, Hash256, SyncCommittee}; -use crate::{light_client_update::*, test_utils::TestRandom}; -use serde::{Deserialize, Serialize}; +use super::{BeaconState, EthSpec, FixedVector, Hash256, SyncCommittee}; +use crate::{ + light_client_update::*, test_utils::TestRandom, ForkName, ForkVersionDeserialize, + LightClientHeader, +}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_json::Value; use ssz_derive::{Decode, Encode}; use std::sync::Arc; use test_random_derive::TestRandom; @@ -22,8 +26,8 @@ use tree_hash::TreeHash; #[serde(bound = "T: EthSpec")] #[arbitrary(bound = "T: EthSpec")] pub struct LightClientBootstrap { - /// Requested beacon block header. - pub header: BeaconBlockHeader, + /// The requested beacon block header. + pub header: LightClientHeader, /// The `SyncCommittee` used in the requested period. pub current_sync_committee: Arc>, /// Merkle proof for sync committee @@ -37,13 +41,31 @@ impl LightClientBootstrap { let current_sync_committee_branch = beacon_state.compute_merkle_proof(CURRENT_SYNC_COMMITTEE_INDEX)?; Ok(LightClientBootstrap { - header, + header: header.into(), current_sync_committee: beacon_state.current_sync_committee()?.clone(), current_sync_committee_branch: FixedVector::new(current_sync_committee_branch)?, }) } } +impl ForkVersionDeserialize for LightClientBootstrap { + fn deserialize_by_fork<'de, D: Deserializer<'de>>( + value: Value, + fork_name: ForkName, + ) -> Result { + match fork_name { + ForkName::Altair => Ok(serde_json::from_value::>(value) + .map_err(serde::de::Error::custom))?, + ForkName::Base | ForkName::Merge | ForkName::Capella | ForkName::Deneb => { + Err(serde::de::Error::custom(format!( + "LightClientBootstrap failed to deserialize: unsupported fork '{}'", + fork_name + ))) + } + } + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/consensus/types/src/light_client_finality_update.rs b/consensus/types/src/light_client_finality_update.rs index 30f337fb2bb..49c2db28b90 100644 --- a/consensus/types/src/light_client_finality_update.rs +++ b/consensus/types/src/light_client_finality_update.rs @@ -1,9 +1,12 @@ use super::{ - BeaconBlockHeader, EthSpec, FixedVector, Hash256, SignedBeaconBlock, SignedBlindedBeaconBlock, - Slot, SyncAggregate, + EthSpec, FixedVector, Hash256, SignedBeaconBlock, SignedBlindedBeaconBlock, Slot, SyncAggregate, }; -use crate::{light_client_update::*, test_utils::TestRandom, BeaconState, ChainSpec}; -use serde::{Deserialize, Serialize}; +use crate::{ + light_client_update::*, test_utils::TestRandom, BeaconState, ChainSpec, ForkName, + ForkVersionDeserialize, LightClientHeader, +}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_json::Value; use ssz_derive::{Decode, Encode}; use test_random_derive::TestRandom; use tree_hash::TreeHash; @@ -25,9 +28,9 @@ use tree_hash::TreeHash; #[arbitrary(bound = "T: EthSpec")] pub struct LightClientFinalityUpdate { /// The last `BeaconBlockHeader` from the last attested block by the sync committee. - pub attested_header: BeaconBlockHeader, + pub attested_header: LightClientHeader, /// The last `BeaconBlockHeader` from the last attested finalized block (end of epoch). - pub finalized_header: BeaconBlockHeader, + pub finalized_header: LightClientHeader, /// Merkle proof attesting finalized header. pub finality_branch: FixedVector, /// current sync aggreggate @@ -68,8 +71,8 @@ impl LightClientFinalityUpdate { let finality_branch = attested_state.compute_merkle_proof(FINALIZED_ROOT_INDEX)?; Ok(Self { - attested_header, - finalized_header, + attested_header: attested_header.into(), + finalized_header: finalized_header.into(), finality_branch: FixedVector::new(finality_branch)?, sync_aggregate: sync_aggregate.clone(), signature_slot: block.slot(), @@ -77,6 +80,26 @@ impl LightClientFinalityUpdate { } } +impl ForkVersionDeserialize for LightClientFinalityUpdate { + fn deserialize_by_fork<'de, D: Deserializer<'de>>( + value: Value, + fork_name: ForkName, + ) -> Result { + match fork_name { + ForkName::Altair => Ok( + serde_json::from_value::>(value) + .map_err(serde::de::Error::custom), + )?, + ForkName::Base | ForkName::Merge | ForkName::Capella | ForkName::Deneb => { + Err(serde::de::Error::custom(format!( + "LightClientFinalityUpdate failed to deserialize: unsupported fork '{}'", + fork_name + ))) + } + } + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/consensus/types/src/light_client_header.rs b/consensus/types/src/light_client_header.rs new file mode 100644 index 00000000000..8fe31f7af8c --- /dev/null +++ b/consensus/types/src/light_client_header.rs @@ -0,0 +1,26 @@ +use crate::test_utils::TestRandom; +use crate::BeaconBlockHeader; +use serde::{Deserialize, Serialize}; +use ssz_derive::{Decode, Encode}; +use test_random_derive::TestRandom; + +#[derive( + Debug, + Clone, + PartialEq, + Serialize, + Deserialize, + Encode, + Decode, + TestRandom, + arbitrary::Arbitrary, +)] +pub struct LightClientHeader { + pub beacon: BeaconBlockHeader, +} + +impl From for LightClientHeader { + fn from(beacon: BeaconBlockHeader) -> Self { + LightClientHeader { beacon } + } +} diff --git a/consensus/types/src/light_client_optimistic_update.rs b/consensus/types/src/light_client_optimistic_update.rs index fbb0558eced..3a0f1d536c8 100644 --- a/consensus/types/src/light_client_optimistic_update.rs +++ b/consensus/types/src/light_client_optimistic_update.rs @@ -1,8 +1,10 @@ -use super::{BeaconBlockHeader, EthSpec, Slot, SyncAggregate}; +use super::{EthSpec, ForkName, ForkVersionDeserialize, Slot, SyncAggregate}; +use crate::light_client_header::LightClientHeader; use crate::{ light_client_update::Error, test_utils::TestRandom, BeaconState, ChainSpec, SignedBeaconBlock, }; -use serde::{Deserialize, Serialize}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_json::Value; use ssz_derive::{Decode, Encode}; use test_random_derive::TestRandom; use tree_hash::TreeHash; @@ -24,7 +26,7 @@ use tree_hash::TreeHash; #[arbitrary(bound = "T: EthSpec")] pub struct LightClientOptimisticUpdate { /// The last `BeaconBlockHeader` from the last attested block by the sync committee. - pub attested_header: BeaconBlockHeader, + pub attested_header: LightClientHeader, /// current sync aggreggate pub sync_aggregate: SyncAggregate, /// Slot of the sync aggregated singature @@ -53,13 +55,33 @@ impl LightClientOptimisticUpdate { let mut attested_header = attested_state.latest_block_header().clone(); attested_header.state_root = attested_state.tree_hash_root(); Ok(Self { - attested_header, + attested_header: attested_header.into(), sync_aggregate: sync_aggregate.clone(), signature_slot: block.slot(), }) } } +impl ForkVersionDeserialize for LightClientOptimisticUpdate { + fn deserialize_by_fork<'de, D: Deserializer<'de>>( + value: Value, + fork_name: ForkName, + ) -> Result { + match fork_name { + ForkName::Altair => Ok(serde_json::from_value::>( + value, + ) + .map_err(serde::de::Error::custom))?, + ForkName::Base | ForkName::Merge | ForkName::Capella | ForkName::Deneb => { + Err(serde::de::Error::custom(format!( + "LightClientOptimisticUpdate failed to deserialize: unsupported fork '{}'", + fork_name + ))) + } + } + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/consensus/types/src/light_client_update.rs b/consensus/types/src/light_client_update.rs index 6e53e14c994..6fb98427267 100644 --- a/consensus/types/src/light_client_update.rs +++ b/consensus/types/src/light_client_update.rs @@ -1,7 +1,11 @@ use super::{BeaconBlockHeader, EthSpec, FixedVector, Hash256, Slot, SyncAggregate, SyncCommittee}; -use crate::{beacon_state, test_utils::TestRandom, BeaconBlock, BeaconState, ChainSpec}; +use crate::{ + beacon_state, test_utils::TestRandom, BeaconBlock, BeaconState, ChainSpec, ForkName, + ForkVersionDeserialize, LightClientHeader, +}; use safe_arith::ArithError; -use serde::{Deserialize, Serialize}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_json::Value; use ssz_derive::{Decode, Encode}; use ssz_types::typenum::{U5, U6}; use std::sync::Arc; @@ -67,13 +71,13 @@ impl From for Error { #[arbitrary(bound = "T: EthSpec")] pub struct LightClientUpdate { /// The last `BeaconBlockHeader` from the last attested block by the sync committee. - pub attested_header: BeaconBlockHeader, + pub attested_header: LightClientHeader, /// The `SyncCommittee` used in the next period. pub next_sync_committee: Arc>, /// Merkle proof for next sync committee pub next_sync_committee_branch: FixedVector, /// The last `BeaconBlockHeader` from the last attested finalized block (end of epoch). - pub finalized_header: BeaconBlockHeader, + pub finalized_header: LightClientHeader, /// Merkle proof attesting finalized header. pub finality_branch: FixedVector, /// current sync aggreggate @@ -128,10 +132,10 @@ impl LightClientUpdate { attested_state.compute_merkle_proof(NEXT_SYNC_COMMITTEE_INDEX)?; let finality_branch = attested_state.compute_merkle_proof(FINALIZED_ROOT_INDEX)?; Ok(Self { - attested_header, + attested_header: attested_header.into(), next_sync_committee: attested_state.next_sync_committee()?.clone(), next_sync_committee_branch: FixedVector::new(next_sync_committee_branch)?, - finalized_header, + finalized_header: finalized_header.into(), finality_branch: FixedVector::new(finality_branch)?, sync_aggregate: sync_aggregate.clone(), signature_slot: block.slot(), @@ -139,6 +143,24 @@ impl LightClientUpdate { } } +impl ForkVersionDeserialize for LightClientUpdate { + fn deserialize_by_fork<'de, D: Deserializer<'de>>( + value: Value, + fork_name: ForkName, + ) -> Result { + match fork_name { + ForkName::Altair => Ok(serde_json::from_value::>(value) + .map_err(serde::de::Error::custom))?, + ForkName::Base | ForkName::Merge | ForkName::Capella | ForkName::Deneb => { + Err(serde::de::Error::custom(format!( + "LightClientUpdate failed to deserialize: unsupported fork '{}'", + fork_name + ))) + } + } + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/consensus/types/src/sync_committee.rs b/consensus/types/src/sync_committee.rs index 0bcf505f257..b42a000bb00 100644 --- a/consensus/types/src/sync_committee.rs +++ b/consensus/types/src/sync_committee.rs @@ -1,5 +1,4 @@ use crate::test_utils::TestRandom; -use crate::typenum::Unsigned; use crate::{EthSpec, FixedVector, SyncSubnetId}; use bls::PublicKeyBytes; use safe_arith::{ArithError, SafeArith}; @@ -46,14 +45,11 @@ pub struct SyncCommittee { impl SyncCommittee { /// Create a temporary sync committee that should *never* be included in a legitimate consensus object. - pub fn temporary() -> Result { - Ok(Self { - pubkeys: FixedVector::new(vec![ - PublicKeyBytes::empty(); - T::SyncCommitteeSize::to_usize() - ])?, + pub fn temporary() -> Self { + Self { + pubkeys: FixedVector::from_elem(PublicKeyBytes::empty()), aggregate_pubkey: PublicKeyBytes::empty(), - }) + } } /// Return the pubkeys in this `SyncCommittee` for the given `subcommittee_index`. From f062e774acc412f18e881b61c0d52b688dc545b7 Mon Sep 17 00:00:00 2001 From: Jimmy Chen Date: Thu, 16 Nov 2023 21:52:43 +1100 Subject: [PATCH 15/71] Fix test compilation --- beacon_node/http_api/tests/tests.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/beacon_node/http_api/tests/tests.rs b/beacon_node/http_api/tests/tests.rs index 5e5212b0cbc..8e049c5e387 100644 --- a/beacon_node/http_api/tests/tests.rs +++ b/beacon_node/http_api/tests/tests.rs @@ -1651,7 +1651,7 @@ impl ApiTester { .get_beacon_light_client_optimistic_update::() .await { - Ok(result) => result, + Ok(result) => result.map(|res| res.data), Err(_) => panic!("query did not fail correctly"), }; @@ -1667,7 +1667,7 @@ impl ApiTester { .get_beacon_light_client_finality_update::() .await { - Ok(result) => result, + Ok(result) => result.map(|res| res.data), Err(_) => panic!("query did not fail correctly"), }; From bfd3fb7b312aa7f1f63cdc8ab22ec2181fd0a26f Mon Sep 17 00:00:00 2001 From: Jimmy Chen Date: Fri, 17 Nov 2023 13:32:38 +1100 Subject: [PATCH 16/71] Support deserializing light client structures for the Bellatrix fork --- consensus/types/src/light_client_bootstrap.rs | 8 +++++--- consensus/types/src/light_client_finality_update.rs | 10 +++++----- consensus/types/src/light_client_optimistic_update.rs | 8 ++++---- consensus/types/src/light_client_update.rs | 8 +++++--- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/consensus/types/src/light_client_bootstrap.rs b/consensus/types/src/light_client_bootstrap.rs index 15cc564c6e7..14bed794633 100644 --- a/consensus/types/src/light_client_bootstrap.rs +++ b/consensus/types/src/light_client_bootstrap.rs @@ -54,9 +54,11 @@ impl ForkVersionDeserialize for LightClientBootstrap { fork_name: ForkName, ) -> Result { match fork_name { - ForkName::Altair => Ok(serde_json::from_value::>(value) - .map_err(serde::de::Error::custom))?, - ForkName::Base | ForkName::Merge | ForkName::Capella | ForkName::Deneb => { + ForkName::Altair | ForkName::Merge => { + Ok(serde_json::from_value::>(value) + .map_err(serde::de::Error::custom))? + } + ForkName::Base | ForkName::Capella | ForkName::Deneb => { Err(serde::de::Error::custom(format!( "LightClientBootstrap failed to deserialize: unsupported fork '{}'", fork_name diff --git a/consensus/types/src/light_client_finality_update.rs b/consensus/types/src/light_client_finality_update.rs index 49c2db28b90..87601b81565 100644 --- a/consensus/types/src/light_client_finality_update.rs +++ b/consensus/types/src/light_client_finality_update.rs @@ -86,11 +86,11 @@ impl ForkVersionDeserialize for LightClientFinalityUpdate { fork_name: ForkName, ) -> Result { match fork_name { - ForkName::Altair => Ok( - serde_json::from_value::>(value) - .map_err(serde::de::Error::custom), - )?, - ForkName::Base | ForkName::Merge | ForkName::Capella | ForkName::Deneb => { + ForkName::Altair | ForkName::Merge => Ok(serde_json::from_value::< + LightClientFinalityUpdate, + >(value) + .map_err(serde::de::Error::custom))?, + ForkName::Base | ForkName::Capella | ForkName::Deneb => { Err(serde::de::Error::custom(format!( "LightClientFinalityUpdate failed to deserialize: unsupported fork '{}'", fork_name diff --git a/consensus/types/src/light_client_optimistic_update.rs b/consensus/types/src/light_client_optimistic_update.rs index 3a0f1d536c8..d883d735f35 100644 --- a/consensus/types/src/light_client_optimistic_update.rs +++ b/consensus/types/src/light_client_optimistic_update.rs @@ -68,11 +68,11 @@ impl ForkVersionDeserialize for LightClientOptimisticUpdate { fork_name: ForkName, ) -> Result { match fork_name { - ForkName::Altair => Ok(serde_json::from_value::>( - value, - ) + ForkName::Altair | ForkName::Merge => Ok(serde_json::from_value::< + LightClientOptimisticUpdate, + >(value) .map_err(serde::de::Error::custom))?, - ForkName::Base | ForkName::Merge | ForkName::Capella | ForkName::Deneb => { + ForkName::Base | ForkName::Capella | ForkName::Deneb => { Err(serde::de::Error::custom(format!( "LightClientOptimisticUpdate failed to deserialize: unsupported fork '{}'", fork_name diff --git a/consensus/types/src/light_client_update.rs b/consensus/types/src/light_client_update.rs index 6fb98427267..718cd7553f9 100644 --- a/consensus/types/src/light_client_update.rs +++ b/consensus/types/src/light_client_update.rs @@ -149,9 +149,11 @@ impl ForkVersionDeserialize for LightClientUpdate { fork_name: ForkName, ) -> Result { match fork_name { - ForkName::Altair => Ok(serde_json::from_value::>(value) - .map_err(serde::de::Error::custom))?, - ForkName::Base | ForkName::Merge | ForkName::Capella | ForkName::Deneb => { + ForkName::Altair | ForkName::Merge => { + Ok(serde_json::from_value::>(value) + .map_err(serde::de::Error::custom))? + } + ForkName::Base | ForkName::Capella | ForkName::Deneb => { Err(serde::de::Error::custom(format!( "LightClientUpdate failed to deserialize: unsupported fork '{}'", fork_name From d90df3f103fe68e9b49d7a81fd04a70e4b3519c1 Mon Sep 17 00:00:00 2001 From: Jimmy Chen Date: Fri, 17 Nov 2023 15:02:13 +1100 Subject: [PATCH 17/71] Move `get_light_client_bootstrap` logic to `BeaconChain`. `LightClientBootstrap` API to return `ForkVersionedResponse`. --- beacon_node/beacon_chain/src/beacon_chain.rs | 27 +++++++ beacon_node/beacon_chain/src/errors.rs | 1 + beacon_node/http_api/src/lib.rs | 59 +++++---------- .../network_beacon_processor/rpc_methods.rs | 74 +++++-------------- consensus/types/src/lib.rs | 1 + 5 files changed, 68 insertions(+), 94 deletions(-) diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index 2fd70056cc1..c08a1e227fb 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -6446,6 +6446,33 @@ impl BeaconChain { pub fn data_availability_boundary(&self) -> Option { self.data_availability_checker.data_availability_boundary() } + + /// Gets the `LightClientBootstrap` object for a requested block root. + /// + /// Returns `None` when the state or block is not found in the database. + pub fn get_light_client_bootstrap( + &self, + block_root: &Hash256, + ) -> Result, ForkName)>, Error> { + let Some(state_root) = self + .get_blinded_block(block_root)? + .map(|block| block.state_root()) + else { + return Ok(None); + }; + + let Some(mut state) = self.get_state(&state_root, None)? else { + return Ok(None); + }; + + let fork_name = state + .fork_name(&self.spec) + .map_err(Error::InconsistentFork)?; + + LightClientBootstrap::from_beacon_state(&mut state) + .map(|bootstrap| Some((bootstrap, fork_name))) + .map_err(Error::LightClientError) + } } impl Drop for BeaconChain { diff --git a/beacon_node/beacon_chain/src/errors.rs b/beacon_node/beacon_chain/src/errors.rs index 7c1bb04917d..8e6018c72b0 100644 --- a/beacon_node/beacon_chain/src/errors.rs +++ b/beacon_node/beacon_chain/src/errors.rs @@ -221,6 +221,7 @@ pub enum BeaconChainError { ProposerHeadForkChoiceError(fork_choice::Error), UnableToPublish, AvailabilityCheckError(AvailabilityCheckError), + LightClientError(LightClientError), } easy_from_to!(SlotProcessingError, BeaconChainError); diff --git a/beacon_node/http_api/src/lib.rs b/beacon_node/http_api/src/lib.rs index 63af4309981..11984bb88d0 100644 --- a/beacon_node/http_api/src/lib.rs +++ b/beacon_node/http_api/src/lib.rs @@ -76,8 +76,8 @@ use tokio_stream::{ }; use types::{ Attestation, AttestationData, AttestationShufflingId, AttesterSlashing, BeaconStateError, - BlindedPayload, CommitteeCache, ConfigAndPreset, Epoch, EthSpec, ForkName, Hash256, - LightClientBootstrap, ProposerPreparationData, ProposerSlashing, RelativeEpoch, + BlindedPayload, CommitteeCache, ConfigAndPreset, Epoch, EthSpec, ForkName, + ForkVersionedResponse, Hash256, ProposerPreparationData, ProposerSlashing, RelativeEpoch, SignedAggregateAndProof, SignedBlsToExecutionChange, SignedContributionAndProof, SignedValidatorRegistrationData, SignedVoluntaryExit, Slot, SyncCommitteeMessage, SyncContributionData, @@ -2423,41 +2423,21 @@ pub fn serve( block_root: Hash256, accept_header: Option| { task_spawner.blocking_response_task(Priority::P1, move || { - let state_root = chain - .get_blinded_block(&block_root) - .map_err(|_| { - warp_utils::reject::custom_server_error( - "Error retrieving block".to_string(), - ) - })? - .map(|signed_block| signed_block.state_root()) - .ok_or_else(|| { - warp_utils::reject::custom_not_found( + let (bootstrap, fork_name) = match chain.get_light_client_bootstrap(&block_root) + { + Ok(Some(res)) => res, + Ok(None) => { + return Err(warp_utils::reject::custom_not_found( "Light client bootstrap unavailable".to_string(), - ) - })?; + )); + } + Err(e) => { + return Err(warp_utils::reject::custom_server_error(format!( + "Unable to obtain LightClientBootstrap instance: {e:?}" + ))); + } + }; - let mut state = chain - .get_state(&state_root, None) - .map_err(|_| { - warp_utils::reject::custom_server_error( - "Error retrieving state".to_string(), - ) - })? - .ok_or_else(|| { - warp_utils::reject::custom_not_found( - "Light client bootstrap unavailable".to_string(), - ) - })?; - let fork_name = state - .fork_name(&chain.spec) - .map_err(inconsistent_fork_rejection)?; - let bootstrap = - LightClientBootstrap::from_beacon_state(&mut state).map_err(|_| { - warp_utils::reject::custom_server_error( - "Failed to create light client bootstrap".to_string(), - ) - })?; match accept_header { Some(api_types::Accept::Ssz) => Response::builder() .status(200) @@ -2469,10 +2449,11 @@ pub fn serve( e )) }), - _ => Ok( - warp::reply::json(&api_types::GenericResponse::from(bootstrap)) - .into_response(), - ), + _ => Ok(warp::reply::json(&ForkVersionedResponse { + version: Some(fork_name), + data: bootstrap, + }) + .into_response()), } .map(|resp| add_consensus_version_header(resp, fork_name)) }) diff --git a/beacon_node/network/src/network_beacon_processor/rpc_methods.rs b/beacon_node/network/src/network_beacon_processor/rpc_methods.rs index 0e6c76e222b..7210e08c621 100644 --- a/beacon_node/network/src/network_beacon_processor/rpc_methods.rs +++ b/beacon_node/network/src/network_beacon_processor/rpc_methods.rs @@ -18,9 +18,7 @@ use std::sync::Arc; use task_executor::TaskExecutor; use tokio_stream::StreamExt; use types::blob_sidecar::BlobIdentifier; -use types::{ - light_client_bootstrap::LightClientBootstrap, Epoch, EthSpec, ForkName, Hash256, Slot, -}; +use types::{Epoch, EthSpec, ForkName, Hash256, Slot}; impl NetworkBeaconProcessor { /* Auxiliary functions */ @@ -304,66 +302,32 @@ impl NetworkBeaconProcessor { request: LightClientBootstrapRequest, ) { let block_root = request.root; - let state_root = match self.chain.get_blinded_block(&block_root) { - Ok(signed_block) => match signed_block { - Some(signed_block) => signed_block.state_root(), - None => { - self.send_error_response( - peer_id, - RPCResponseErrorCode::ResourceUnavailable, - "Bootstrap not available".into(), - request_id, - ); - return; - } - }, - Err(_) => { - self.send_error_response( - peer_id, - RPCResponseErrorCode::ResourceUnavailable, - "Bootstrap not available".into(), - request_id, - ); - return; - } - }; - let mut beacon_state = match self.chain.get_state(&state_root, None) { - Ok(beacon_state) => match beacon_state { - Some(state) => state, - None => { - self.send_error_response( - peer_id, - RPCResponseErrorCode::ResourceUnavailable, - "Bootstrap not available".into(), - request_id, - ); - return; - } - }, - Err(_) => { + match self.chain.get_light_client_bootstrap(&block_root) { + Ok(Some((bootstrap, _))) => self.send_response( + peer_id, + Response::LightClientBootstrap(bootstrap), + request_id, + ), + Ok(None) => self.send_error_response( + peer_id, + RPCResponseErrorCode::ResourceUnavailable, + "Bootstrap not available".into(), + request_id, + ), + Err(e) => { self.send_error_response( peer_id, RPCResponseErrorCode::ResourceUnavailable, "Bootstrap not available".into(), request_id, ); - return; + error!(self.log, "Error getting LightClientBootstrap instance"; + "block_root" => ?block_root, + "peer" => %peer_id, + "error" => ?e + ) } }; - let Ok(bootstrap) = LightClientBootstrap::from_beacon_state(&mut beacon_state) else { - self.send_error_response( - peer_id, - RPCResponseErrorCode::ResourceUnavailable, - "Bootstrap not available".into(), - request_id, - ); - return; - }; - self.send_response( - peer_id, - Response::LightClientBootstrap(bootstrap), - request_id, - ) } /// Handle a `BlocksByRange` request from the peer. diff --git a/consensus/types/src/lib.rs b/consensus/types/src/lib.rs index 262cd24f9a8..0f284bde9d2 100644 --- a/consensus/types/src/lib.rs +++ b/consensus/types/src/lib.rs @@ -159,6 +159,7 @@ pub use crate::light_client_bootstrap::LightClientBootstrap; pub use crate::light_client_finality_update::LightClientFinalityUpdate; pub use crate::light_client_header::LightClientHeader; pub use crate::light_client_optimistic_update::LightClientOptimisticUpdate; +pub use crate::light_client_update::{Error as LightClientError, LightClientUpdate}; pub use crate::participation_flags::ParticipationFlags; pub use crate::participation_list::ParticipationList; pub use crate::payload::{ From 80ff555de54a0726cfd5624d8fcb7e2436e462b7 Mon Sep 17 00:00:00 2001 From: Jimmy Chen Date: Sat, 18 Nov 2023 01:48:46 +1100 Subject: [PATCH 18/71] Misc fixes. - log cleanup - move http_api config mutation to `config::get_config` for consistency - fix light client API responses --- beacon_node/beacon_chain/src/events.rs | 14 ++------------ beacon_node/client/src/builder.rs | 1 - beacon_node/http_api/src/lib.rs | 18 ++++++++++++------ beacon_node/src/config.rs | 3 +++ lighthouse/tests/beacon_node.rs | 10 ++++++++-- 5 files changed, 25 insertions(+), 21 deletions(-) diff --git a/beacon_node/beacon_chain/src/events.rs b/beacon_node/beacon_chain/src/events.rs index d52e763a410..0e5dfc80596 100644 --- a/beacon_node/beacon_chain/src/events.rs +++ b/beacon_node/beacon_chain/src/events.rs @@ -117,21 +117,11 @@ impl ServerSentEventHandler { EventKind::LightClientFinalityUpdate(_) => self .light_client_finality_update_tx .send(kind) - .map(|count| { - log_count( - "Registering server-sent light client finality update event", - count, - ) - }), + .map(|count| log_count("light client finality update", count)), EventKind::LightClientOptimisticUpdate(_) => self .light_client_optimistic_update_tx .send(kind) - .map(|count| { - log_count( - "Registering server-sent light client optimistic update event", - count, - ) - }), + .map(|count| log_count("light client optimistic update", count)), EventKind::BlockReward(_) => self .block_reward_tx .send(kind) diff --git a/beacon_node/client/src/builder.rs b/beacon_node/client/src/builder.rs index ce1ab0005d6..cedf347b9a8 100644 --- a/beacon_node/client/src/builder.rs +++ b/beacon_node/client/src/builder.rs @@ -165,7 +165,6 @@ where } else { None }; - self.http_api_config.enable_light_client_server = config.network.enable_light_client_server; let execution_layer = if let Some(config) = config.execution_layer.clone() { let context = runtime_context.service_context("exec".into()); diff --git a/beacon_node/http_api/src/lib.rs b/beacon_node/http_api/src/lib.rs index 11984bb88d0..5f2c641af97 100644 --- a/beacon_node/http_api/src/lib.rs +++ b/beacon_node/http_api/src/lib.rs @@ -2397,7 +2397,7 @@ pub fn serve( ); /* - * beacon/rewards + * beacon/light_client */ let beacon_light_client_path = eth_v1 @@ -2405,7 +2405,7 @@ pub fn serve( .and(warp::path("light_client")) .and(chain_filter.clone()); - // GET beacon/light_client/bootrap/{block_root} + // GET beacon/light_client/bootstrap/{block_root} let get_beacon_light_client_bootstrap = beacon_light_client_path .clone() .and(task_spawner_filter.clone()) @@ -2496,8 +2496,11 @@ pub fn serve( e )) }), - _ => Ok(warp::reply::json(&api_types::GenericResponse::from(update)) - .into_response()), + _ => Ok(warp::reply::json(&ForkVersionedResponse { + version: Some(fork_name), + data: update, + }) + .into_response()), } .map(|resp| add_consensus_version_header(resp, fork_name)) }) @@ -2540,8 +2543,11 @@ pub fn serve( e )) }), - _ => Ok(warp::reply::json(&api_types::GenericResponse::from(update)) - .into_response()), + _ => Ok(warp::reply::json(&ForkVersionedResponse { + version: Some(fork_name), + data: update, + }) + .into_response()), } .map(|resp| add_consensus_version_header(resp, fork_name)) }) diff --git a/beacon_node/src/config.rs b/beacon_node/src/config.rs index 609626ae88a..9ceab47f336 100644 --- a/beacon_node/src/config.rs +++ b/beacon_node/src/config.rs @@ -151,6 +151,9 @@ pub fn get_config( client_config.http_api.duplicate_block_status_code = parse_required(cli_args, "http-duplicate-block-status")?; + + client_config.http_api.enable_light_client_server = + cli_args.is_present("light-client-server"); } if let Some(cache_size) = clap_utils::parse_optional(cli_args, "shuffling-cache-size")? { diff --git a/lighthouse/tests/beacon_node.rs b/lighthouse/tests/beacon_node.rs index c8e064e224d..eb1341f9181 100644 --- a/lighthouse/tests/beacon_node.rs +++ b/lighthouse/tests/beacon_node.rs @@ -2346,7 +2346,10 @@ fn sync_eth1_chain_disable_deposit_contract_sync_flag() { fn light_client_server_default() { CommandLineTest::new() .run_with_zero_port() - .with_config(|config| assert_eq!(config.network.enable_light_client_server, false)); + .with_config(|config| { + assert_eq!(config.network.enable_light_client_server, false); + assert_eq!(config.http_api.enable_light_client_server, false); + }); } #[test] @@ -2354,7 +2357,10 @@ fn light_client_server_enabled() { CommandLineTest::new() .flag("light-client-server", None) .run_with_zero_port() - .with_config(|config| assert_eq!(config.network.enable_light_client_server, true)); + .with_config(|config| { + assert_eq!(config.network.enable_light_client_server, true); + assert_eq!(config.http_api.enable_light_client_server, true); + }); } #[test] From 75bd2ace39e4b944c8b2ce09bdc061e3ff05ceb9 Mon Sep 17 00:00:00 2001 From: Jimmy Chen Date: Sat, 18 Nov 2023 03:21:44 +1100 Subject: [PATCH 19/71] Add light client bootstrap API test and fix existing ones. --- beacon_node/beacon_chain/src/beacon_chain.rs | 11 +++-- beacon_node/beacon_chain/src/errors.rs | 1 + beacon_node/http_api/src/test_utils.rs | 1 + beacon_node/http_api/tests/tests.rs | 48 +++++++++++++++++-- consensus/types/src/light_client_bootstrap.rs | 3 +- 5 files changed, 55 insertions(+), 9 deletions(-) diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index c08a1e227fb..dce2194a08d 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -6469,9 +6469,14 @@ impl BeaconChain { .fork_name(&self.spec) .map_err(Error::InconsistentFork)?; - LightClientBootstrap::from_beacon_state(&mut state) - .map(|bootstrap| Some((bootstrap, fork_name))) - .map_err(Error::LightClientError) + match fork_name { + ForkName::Altair | ForkName::Merge => { + LightClientBootstrap::from_beacon_state(&mut state) + .map(|bootstrap| Some((bootstrap, fork_name))) + .map_err(Error::LightClientError) + } + ForkName::Base | ForkName::Capella | ForkName::Deneb => Err(Error::UnsupportedFork), + } } } diff --git a/beacon_node/beacon_chain/src/errors.rs b/beacon_node/beacon_chain/src/errors.rs index 8e6018c72b0..9c1ba06f853 100644 --- a/beacon_node/beacon_chain/src/errors.rs +++ b/beacon_node/beacon_chain/src/errors.rs @@ -222,6 +222,7 @@ pub enum BeaconChainError { UnableToPublish, AvailabilityCheckError(AvailabilityCheckError), LightClientError(LightClientError), + UnsupportedFork, } easy_from_to!(SlotProcessingError, BeaconChainError); diff --git a/beacon_node/http_api/src/test_utils.rs b/beacon_node/http_api/src/test_utils.rs index fe47e56dc57..bafb5738194 100644 --- a/beacon_node/http_api/src/test_utils.rs +++ b/beacon_node/http_api/src/test_utils.rs @@ -209,6 +209,7 @@ pub async fn create_api_server( enabled: true, listen_port: port, data_dir: std::path::PathBuf::from(DEFAULT_ROOT_DIR), + enable_light_client_server: true, ..Config::default() }, chain: Some(chain), diff --git a/beacon_node/http_api/tests/tests.rs b/beacon_node/http_api/tests/tests.rs index 8e049c5e387..eaee6e6e352 100644 --- a/beacon_node/http_api/tests/tests.rs +++ b/beacon_node/http_api/tests/tests.rs @@ -1644,6 +1644,26 @@ impl ApiTester { self } + pub async fn test_get_beacon_light_client_bootstrap(self) -> Self { + let block_id = BlockId(CoreBlockId::Finalized); + let (block_root, _, _) = block_id.root(&self.chain).unwrap(); + let (block, _, _) = block_id.full_block(&self.chain).await.unwrap(); + + let result = match self + .client + .get_light_client_bootstrap::(block_root) + .await + { + Ok(result) => result.unwrap().data, + Err(e) => panic!("query failed incorrectly: {e:?}"), + }; + + let expected = block.slot(); + assert_eq!(result.header.beacon.slot, expected); + + self + } + pub async fn test_get_beacon_light_client_optimistic_update(self) -> Self { // get_beacon_light_client_optimistic_update returns Ok(None) on 404 NOT FOUND let result = match self @@ -1652,7 +1672,7 @@ impl ApiTester { .await { Ok(result) => result.map(|res| res.data), - Err(_) => panic!("query did not fail correctly"), + Err(e) => panic!("query failed incorrectly: {e:?}"), }; let expected = self.chain.latest_seen_optimistic_update.lock().clone(); @@ -1668,7 +1688,7 @@ impl ApiTester { .await { Ok(result) => result.map(|res| res.data), - Err(_) => panic!("query did not fail correctly"), + Err(e) => panic!("query failed incorrectly: {e:?}"), }; let expected = self.chain.latest_seen_finality_update.lock().clone(); @@ -5092,9 +5112,25 @@ async fn node_get() { .await; } +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn get_light_client_bootstrap() { + let config = ApiTesterConfig { + spec: ForkName::Altair.make_genesis_spec(E::default_spec()), + ..<_>::default() + }; + ApiTester::new_from_config(config) + .await + .test_get_beacon_light_client_bootstrap() + .await; +} + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn get_light_client_optimistic_update() { - ApiTester::new() + let config = ApiTesterConfig { + spec: ForkName::Altair.make_genesis_spec(E::default_spec()), + ..<_>::default() + }; + ApiTester::new_from_config(config) .await .test_get_beacon_light_client_optimistic_update() .await; @@ -5102,7 +5138,11 @@ async fn get_light_client_optimistic_update() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn get_light_client_finality_update() { - ApiTester::new() + let config = ApiTesterConfig { + spec: ForkName::Altair.make_genesis_spec(E::default_spec()), + ..<_>::default() + }; + ApiTester::new_from_config(config) .await .test_get_beacon_light_client_finality_update() .await; diff --git a/consensus/types/src/light_client_bootstrap.rs b/consensus/types/src/light_client_bootstrap.rs index 14bed794633..616aced483a 100644 --- a/consensus/types/src/light_client_bootstrap.rs +++ b/consensus/types/src/light_client_bootstrap.rs @@ -8,7 +8,6 @@ use serde_json::Value; use ssz_derive::{Decode, Encode}; use std::sync::Arc; use test_random_derive::TestRandom; -use tree_hash::TreeHash; /// A LightClientBootstrap is the initializer we send over to lightclient nodes /// that are trying to generate their basic storage when booting up. @@ -37,7 +36,7 @@ pub struct LightClientBootstrap { impl LightClientBootstrap { pub fn from_beacon_state(beacon_state: &mut BeaconState) -> Result { let mut header = beacon_state.latest_block_header().clone(); - header.state_root = beacon_state.tree_hash_root(); + header.state_root = beacon_state.update_tree_hash_cache()?; let current_sync_committee_branch = beacon_state.compute_merkle_proof(CURRENT_SYNC_COMMITTEE_INDEX)?; Ok(LightClientBootstrap { From e0d0ece7ba2ece330dac7f6a70bebcf1390b4468 Mon Sep 17 00:00:00 2001 From: Jimmy Chen Date: Sat, 18 Nov 2023 03:57:51 +1100 Subject: [PATCH 20/71] Fix test for `light-client-server` http api config. --- lighthouse/tests/beacon_node.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lighthouse/tests/beacon_node.rs b/lighthouse/tests/beacon_node.rs index eb1341f9181..5f75cb1acff 100644 --- a/lighthouse/tests/beacon_node.rs +++ b/lighthouse/tests/beacon_node.rs @@ -2359,6 +2359,16 @@ fn light_client_server_enabled() { .run_with_zero_port() .with_config(|config| { assert_eq!(config.network.enable_light_client_server, true); + }); +} + +#[test] +fn light_client_http_server_enabled() { + CommandLineTest::new() + .flag("http", None) + .flag("light-client-server", None) + .run_with_zero_port() + .with_config(|config| { assert_eq!(config.http_api.enable_light_client_server, true); }); } From 161ece641c777146e3e7aa2fd459ec7c2194bd48 Mon Sep 17 00:00:00 2001 From: Jimmy Chen Date: Sat, 18 Nov 2023 09:28:56 +1100 Subject: [PATCH 21/71] Appease clippy --- beacon_node/beacon_chain/src/beacon_chain.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index 46f4fd8cbcd..4a2a308948f 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -6450,6 +6450,7 @@ impl BeaconChain { /// Gets the `LightClientBootstrap` object for a requested block root. /// /// Returns `None` when the state or block is not found in the database. + #[allow(clippy::type_complexity)] pub fn get_light_client_bootstrap( &self, block_root: &Hash256, From 885958e654ff19a1742c531d4217f635141f0fc3 Mon Sep 17 00:00:00 2001 From: Jimmy Chen Date: Tue, 21 Nov 2023 16:24:57 +1100 Subject: [PATCH 22/71] Add Altair light client SSZ tests --- consensus/types/src/light_client_bootstrap.rs | 2 + .../types/src/light_client_finality_update.rs | 2 + consensus/types/src/light_client_header.rs | 2 + .../src/light_client_optimistic_update.rs | 2 + consensus/types/src/light_client_update.rs | 2 + testing/ef_tests/check_all_files_accessed.py | 14 ------- testing/ef_tests/src/type_name.rs | 5 +++ testing/ef_tests/tests/tests.rs | 41 ++++++++++++++++++- 8 files changed, 55 insertions(+), 15 deletions(-) diff --git a/consensus/types/src/light_client_bootstrap.rs b/consensus/types/src/light_client_bootstrap.rs index 616aced483a..843b3cd514b 100644 --- a/consensus/types/src/light_client_bootstrap.rs +++ b/consensus/types/src/light_client_bootstrap.rs @@ -8,6 +8,7 @@ use serde_json::Value; use ssz_derive::{Decode, Encode}; use std::sync::Arc; use test_random_derive::TestRandom; +use tree_hash_derive::TreeHash; /// A LightClientBootstrap is the initializer we send over to lightclient nodes /// that are trying to generate their basic storage when booting up. @@ -19,6 +20,7 @@ use test_random_derive::TestRandom; Deserialize, Encode, Decode, + TreeHash, TestRandom, arbitrary::Arbitrary, )] diff --git a/consensus/types/src/light_client_finality_update.rs b/consensus/types/src/light_client_finality_update.rs index 87601b81565..b0ae9028896 100644 --- a/consensus/types/src/light_client_finality_update.rs +++ b/consensus/types/src/light_client_finality_update.rs @@ -10,6 +10,7 @@ use serde_json::Value; use ssz_derive::{Decode, Encode}; use test_random_derive::TestRandom; use tree_hash::TreeHash; +use tree_hash_derive::TreeHash; /// A LightClientFinalityUpdate is the update lightclient request or received by a gossip that /// signal a new finalized beacon block header for the light client sync protocol. @@ -21,6 +22,7 @@ use tree_hash::TreeHash; Deserialize, Encode, Decode, + TreeHash, TestRandom, arbitrary::Arbitrary, )] diff --git a/consensus/types/src/light_client_header.rs b/consensus/types/src/light_client_header.rs index 8fe31f7af8c..f7d3c633ab9 100644 --- a/consensus/types/src/light_client_header.rs +++ b/consensus/types/src/light_client_header.rs @@ -3,6 +3,7 @@ use crate::BeaconBlockHeader; use serde::{Deserialize, Serialize}; use ssz_derive::{Decode, Encode}; use test_random_derive::TestRandom; +use tree_hash_derive::TreeHash; #[derive( Debug, @@ -12,6 +13,7 @@ use test_random_derive::TestRandom; Deserialize, Encode, Decode, + TreeHash, TestRandom, arbitrary::Arbitrary, )] diff --git a/consensus/types/src/light_client_optimistic_update.rs b/consensus/types/src/light_client_optimistic_update.rs index d883d735f35..dd17a64342c 100644 --- a/consensus/types/src/light_client_optimistic_update.rs +++ b/consensus/types/src/light_client_optimistic_update.rs @@ -8,6 +8,7 @@ use serde_json::Value; use ssz_derive::{Decode, Encode}; use test_random_derive::TestRandom; use tree_hash::TreeHash; +use tree_hash_derive::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. @@ -19,6 +20,7 @@ use tree_hash::TreeHash; Deserialize, Encode, Decode, + TreeHash, TestRandom, arbitrary::Arbitrary, )] diff --git a/consensus/types/src/light_client_update.rs b/consensus/types/src/light_client_update.rs index 718cd7553f9..76a3bd3b9bc 100644 --- a/consensus/types/src/light_client_update.rs +++ b/consensus/types/src/light_client_update.rs @@ -11,6 +11,7 @@ use ssz_types::typenum::{U5, U6}; use std::sync::Arc; use test_random_derive::TestRandom; use tree_hash::TreeHash; +use tree_hash_derive::TreeHash; pub const FINALIZED_ROOT_INDEX: usize = 105; pub const CURRENT_SYNC_COMMITTEE_INDEX: usize = 54; @@ -64,6 +65,7 @@ impl From for Error { Deserialize, Encode, Decode, + TreeHash, TestRandom, arbitrary::Arbitrary, )] diff --git a/testing/ef_tests/check_all_files_accessed.py b/testing/ef_tests/check_all_files_accessed.py index a5ab897c33f..0fbbc5ed786 100755 --- a/testing/ef_tests/check_all_files_accessed.py +++ b/testing/ef_tests/check_all_files_accessed.py @@ -27,20 +27,6 @@ "tests/.*/.*/ssz_static/PowBlock/", # light_client "tests/.*/.*/light_client", - # LightClientStore - "tests/.*/.*/ssz_static/LightClientStore", - # LightClientUpdate - "tests/.*/.*/ssz_static/LightClientUpdate", - # LightClientSnapshot - "tests/.*/.*/ssz_static/LightClientSnapshot", - # LightClientBootstrap - "tests/.*/.*/ssz_static/LightClientBootstrap", - # LightClientOptimistic - "tests/.*/.*/ssz_static/LightClientOptimistic", - # LightClientFinalityUpdate - "tests/.*/.*/ssz_static/LightClientFinalityUpdate", - # LightClientHeader - "tests/.*/.*/ssz_static/LightClientHeader", # One of the EF researchers likes to pack the tarballs on a Mac ".*\.DS_Store.*", # More Mac weirdness. diff --git a/testing/ef_tests/src/type_name.rs b/testing/ef_tests/src/type_name.rs index ef128440301..e57e2b13598 100644 --- a/testing/ef_tests/src/type_name.rs +++ b/testing/ef_tests/src/type_name.rs @@ -73,6 +73,11 @@ type_name!(Fork); type_name!(ForkData); type_name_generic!(HistoricalBatch); type_name_generic!(IndexedAttestation); +type_name_generic!(LightClientBootstrap); +type_name_generic!(LightClientFinalityUpdate); +type_name!(LightClientHeader); +type_name_generic!(LightClientOptimisticUpdate); +type_name_generic!(LightClientUpdate); type_name_generic!(PendingAttestation); type_name!(ProposerSlashing); type_name_generic!(SignedAggregateAndProof); diff --git a/testing/ef_tests/tests/tests.rs b/testing/ef_tests/tests/tests.rs index d2d30b596cc..000a557a5f5 100644 --- a/testing/ef_tests/tests/tests.rs +++ b/testing/ef_tests/tests/tests.rs @@ -236,7 +236,6 @@ mod ssz_static { ssz_static_test!(fork_data, ForkData); ssz_static_test!(historical_batch, HistoricalBatch<_>); ssz_static_test!(indexed_attestation, IndexedAttestation<_>); - // NOTE: LightClient* intentionally omitted ssz_static_test!(pending_attestation, PendingAttestation<_>); ssz_static_test!(proposer_slashing, ProposerSlashing); ssz_static_test!(signed_aggregate_and_proof, SignedAggregateAndProof<_>); @@ -285,6 +284,46 @@ mod ssz_static { .run(); } + #[test] + fn light_client_bootstrap() { + SszStaticHandler::, MinimalEthSpec>::altair_only() + .run(); + SszStaticHandler::, MainnetEthSpec>::altair_only() + .run(); + } + + #[test] + fn light_client_finality_update() { + SszStaticHandler::, MinimalEthSpec>::altair_only( + ) + .run(); + SszStaticHandler::, MainnetEthSpec>::altair_only( + ) + .run(); + } + + #[test] + fn light_client_header() { + SszStaticHandler::::altair_only().run(); + SszStaticHandler::::altair_only().run(); + } + + #[test] + fn light_client_optimistic_update() { + SszStaticHandler::, MinimalEthSpec>::altair_only( + ) + .run(); + SszStaticHandler::, MainnetEthSpec>::altair_only( + ) + .run(); + } + + #[test] + fn light_client_update() { + SszStaticHandler::, MinimalEthSpec>::altair_only().run(); + SszStaticHandler::, MainnetEthSpec>::altair_only().run(); + } + #[test] fn signed_contribution_and_proof() { SszStaticHandler::, MinimalEthSpec>::altair_and_later().run(); From fe8e2e44b1520ea948045efce481c9c192bfaa3c Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Tue, 21 Nov 2023 14:36:20 -0800 Subject: [PATCH 23/71] updates to light client header --- consensus/types/src/light_client_bootstrap.rs | 2 +- .../types/src/light_client_finality_update.rs | 4 +- consensus/types/src/light_client_header.rs | 87 ++++++++++++++++++- .../src/light_client_optimistic_update.rs | 2 +- consensus/types/src/light_client_update.rs | 4 +- 5 files changed, 89 insertions(+), 10 deletions(-) diff --git a/consensus/types/src/light_client_bootstrap.rs b/consensus/types/src/light_client_bootstrap.rs index 616aced483a..e1fc01737e0 100644 --- a/consensus/types/src/light_client_bootstrap.rs +++ b/consensus/types/src/light_client_bootstrap.rs @@ -26,7 +26,7 @@ use test_random_derive::TestRandom; #[arbitrary(bound = "T: EthSpec")] pub struct LightClientBootstrap { /// The requested beacon block header. - pub header: LightClientHeader, + pub header: LightClientHeader, /// The `SyncCommittee` used in the requested period. pub current_sync_committee: Arc>, /// Merkle proof for sync committee diff --git a/consensus/types/src/light_client_finality_update.rs b/consensus/types/src/light_client_finality_update.rs index 87601b81565..44cb8edbd13 100644 --- a/consensus/types/src/light_client_finality_update.rs +++ b/consensus/types/src/light_client_finality_update.rs @@ -28,9 +28,9 @@ use tree_hash::TreeHash; #[arbitrary(bound = "T: EthSpec")] pub struct LightClientFinalityUpdate { /// The last `BeaconBlockHeader` from the last attested block by the sync committee. - pub attested_header: LightClientHeader, + pub attested_header: LightClientHeader, /// The last `BeaconBlockHeader` from the last attested finalized block (end of epoch). - pub finalized_header: LightClientHeader, + pub finalized_header: LightClientHeader, /// Merkle proof attesting finalized header. pub finality_branch: FixedVector, /// current sync aggreggate diff --git a/consensus/types/src/light_client_header.rs b/consensus/types/src/light_client_header.rs index 8fe31f7af8c..ba9b71577d8 100644 --- a/consensus/types/src/light_client_header.rs +++ b/consensus/types/src/light_client_header.rs @@ -1,8 +1,13 @@ -use crate::test_utils::TestRandom; use crate::BeaconBlockHeader; +use crate::{test_utils::TestRandom, EthSpec, ExecutionPayloadHeader, Hash256}; +use merkle_proof::verify_merkle_proof; use serde::{Deserialize, Serialize}; use ssz_derive::{Decode, Encode}; use test_random_derive::TestRandom; +use tree_hash::TreeHash; + +const EXECUTION_PAYLOAD_INDEX: u32 = 25; +const FLOOR_LOG2_EXECUTION_PAYLOAD_INDEX: u32 = 4; #[derive( Debug, @@ -15,12 +20,86 @@ use test_random_derive::TestRandom; TestRandom, arbitrary::Arbitrary, )] -pub struct LightClientHeader { +pub struct ExecutionBranch(pub [u8; FLOOR_LOG2_EXECUTION_PAYLOAD_INDEX as usize]); + +#[derive( + Debug, + Clone, + PartialEq, + Serialize, + Deserialize, + Encode, + Decode, + TestRandom, + arbitrary::Arbitrary, +)] +#[serde(bound = "E: EthSpec")] +#[arbitrary(bound = "T: EthSpec")] +pub struct LightClientHeader { pub beacon: BeaconBlockHeader, + pub execution: Option>, + pub execution_branch: Option, } -impl From for LightClientHeader { +impl From for LightClientHeader { fn from(beacon: BeaconBlockHeader) -> Self { - LightClientHeader { beacon } + LightClientHeader { + beacon, + execution: None, + execution_branch: None, + } + } +} + +impl LightClientHeader { + fn get_lc_execution_root(&self) -> Option { + let epoch = self.beacon.slot.epoch(E::slots_per_epoch()); + + // TODO greater than or equal to CAPELLA + if epoch >= 0 { + if let Some(execution) = self.execution { + return Some(execution.tree_hash_root()); + } + } + + return None; + } + + fn is_valid_light_client_header(&self) -> bool { + let epoch = self.beacon.slot.epoch(E::slots_per_epoch()); + + // TODO LESS THAN CAPELLA + if epoch < 0 { + return self.execution == None && self.execution_branch == None; + } + + let Some(execution_root) = self.get_lc_execution_root() else { + return false + }; + + let Some(execution_branch) = self.execution_branch else { + return false + }; + + return verify_merkle_proof( + execution_root, + &execution_branch.into(), + FLOOR_LOG2_EXECUTION_PAYLOAD_INDEX, + get_subtree_index(EXECUTION_PAYLOAD_INDEX), + self.beacon.body_root, + ); + } +} + +// TODO move to the relevant place +fn get_subtree_index(generalized_index: u32) -> u32 { + return generalized_index % 2 * (log2_int(generalized_index)); +} + +// TODO move to the relevant place +fn log2_int(x: u32) -> u32 { + if x == 0 { + return 0; } + 31 - x.leading_zeros() } diff --git a/consensus/types/src/light_client_optimistic_update.rs b/consensus/types/src/light_client_optimistic_update.rs index d883d735f35..39b3619d05a 100644 --- a/consensus/types/src/light_client_optimistic_update.rs +++ b/consensus/types/src/light_client_optimistic_update.rs @@ -26,7 +26,7 @@ use tree_hash::TreeHash; #[arbitrary(bound = "T: EthSpec")] pub struct LightClientOptimisticUpdate { /// The last `BeaconBlockHeader` from the last attested block by the sync committee. - pub attested_header: LightClientHeader, + pub attested_header: LightClientHeader, /// current sync aggreggate pub sync_aggregate: SyncAggregate, /// Slot of the sync aggregated singature diff --git a/consensus/types/src/light_client_update.rs b/consensus/types/src/light_client_update.rs index 718cd7553f9..7eb563ef666 100644 --- a/consensus/types/src/light_client_update.rs +++ b/consensus/types/src/light_client_update.rs @@ -71,13 +71,13 @@ impl From for Error { #[arbitrary(bound = "T: EthSpec")] pub struct LightClientUpdate { /// The last `BeaconBlockHeader` from the last attested block by the sync committee. - pub attested_header: LightClientHeader, + pub attested_header: LightClientHeader, /// The `SyncCommittee` used in the next period. pub next_sync_committee: Arc>, /// Merkle proof for next sync committee pub next_sync_committee_branch: FixedVector, /// The last `BeaconBlockHeader` from the last attested finalized block (end of epoch). - pub finalized_header: LightClientHeader, + pub finalized_header: LightClientHeader, /// Merkle proof attesting finalized header. pub finality_branch: FixedVector, /// current sync aggreggate From ec1400f2de3a86938d05327a549a7c807eeef6ea Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Tue, 21 Nov 2023 18:42:50 -0800 Subject: [PATCH 24/71] light client header from signed beacon block --- consensus/types/src/light_client_header.rs | 37 ++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/consensus/types/src/light_client_header.rs b/consensus/types/src/light_client_header.rs index ba9b71577d8..bfb937b9615 100644 --- a/consensus/types/src/light_client_header.rs +++ b/consensus/types/src/light_client_header.rs @@ -1,10 +1,11 @@ use crate::BeaconBlockHeader; -use crate::{test_utils::TestRandom, EthSpec, ExecutionPayloadHeader, Hash256}; -use merkle_proof::verify_merkle_proof; +use crate::{test_utils::TestRandom, EthSpec, ExecutionPayloadHeader, SignedBeaconBlock, Hash256}; +use merkle_proof::{verify_merkle_proof, MerkleTree}; use serde::{Deserialize, Serialize}; use ssz_derive::{Decode, Encode}; use test_random_derive::TestRandom; use tree_hash::TreeHash; +use ssz::Encode; const EXECUTION_PAYLOAD_INDEX: u32 = 25; const FLOOR_LOG2_EXECUTION_PAYLOAD_INDEX: u32 = 4; @@ -51,6 +52,38 @@ impl From for LightClientHeader { } } +impl From> for LightClientHeader { + fn from(block: SignedBeaconBlock) -> Self { + let epoch = block.message().slot().epoch(E::slots_per_epoch()); + + // TODO epoch greater than or equal to capella + if epoch >= 0 { + let payload = block.message().body().execution_payload(); + + // TODO fix unwrap + let header = ExecutionPayloadHeader::::from(payload.unwrap().into()); + + let leaves = block + .message() + .body_capella() + .unwrap() + .as_ssz_bytes() + .iter() + .map(|data| data.tree_hash_root()) + .collect::>(); + let tree = MerkleTree::create(&leaves, EXECUTION_PAYLOAD_INDEX as usize); + + let execution_branch = generate_proof(block.message().body_capella().unwrap().as_ssz_bytes(), EXECUTION_PAYLOAD_INDEX); + }; + + LightClientHeader { + beacon, + execution: None, + execution_branch: None, + } + } +} + impl LightClientHeader { fn get_lc_execution_root(&self) -> Option { let epoch = self.beacon.slot.epoch(E::slots_per_epoch()); From 435da0272ab2948e782e2166e917366ae7b82d48 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Fri, 24 Nov 2023 13:05:49 -0800 Subject: [PATCH 25/71] using options --- consensus/types/src/light_client_header.rs | 42 ++++++++++++---------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/consensus/types/src/light_client_header.rs b/consensus/types/src/light_client_header.rs index bfb937b9615..e220ab29195 100644 --- a/consensus/types/src/light_client_header.rs +++ b/consensus/types/src/light_client_header.rs @@ -1,28 +1,28 @@ use crate::BeaconBlockHeader; -use crate::{test_utils::TestRandom, EthSpec, ExecutionPayloadHeader, SignedBeaconBlock, Hash256}; +use crate::{test_utils::TestRandom, EthSpec, ExecutionPayloadHeader, Hash256, SignedBeaconBlock}; use merkle_proof::{verify_merkle_proof, MerkleTree}; use serde::{Deserialize, Serialize}; +use ssz::Encode; use ssz_derive::{Decode, Encode}; use test_random_derive::TestRandom; use tree_hash::TreeHash; -use ssz::Encode; const EXECUTION_PAYLOAD_INDEX: u32 = 25; const FLOOR_LOG2_EXECUTION_PAYLOAD_INDEX: u32 = 4; -#[derive( - Debug, - Clone, - PartialEq, - Serialize, - Deserialize, - Encode, - Decode, - TestRandom, - arbitrary::Arbitrary, -)] +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Encode, Decode, arbitrary::Arbitrary)] +#[ssz(struct_behaviour = "transparent")] pub struct ExecutionBranch(pub [u8; FLOOR_LOG2_EXECUTION_PAYLOAD_INDEX as usize]); +impl TestRandom for Option { + fn random_for_test(rng: &mut impl rand::RngCore) -> Self { + Some(ExecutionBranch(<[u8; FLOOR_LOG2_EXECUTION_PAYLOAD_INDEX + as usize] as TestRandom>::random_for_test( + rng + ))) + } +} + #[derive( Debug, Clone, @@ -35,9 +35,10 @@ pub struct ExecutionBranch(pub [u8; FLOOR_LOG2_EXECUTION_PAYLOAD_INDEX as usize] arbitrary::Arbitrary, )] #[serde(bound = "E: EthSpec")] -#[arbitrary(bound = "T: EthSpec")] +#[arbitrary(bound = "E: EthSpec")] pub struct LightClientHeader { pub beacon: BeaconBlockHeader, + #[test_random(default)] pub execution: Option>, pub execution_branch: Option, } @@ -73,7 +74,10 @@ impl From> for LightClientHeader { .collect::>(); let tree = MerkleTree::create(&leaves, EXECUTION_PAYLOAD_INDEX as usize); - let execution_branch = generate_proof(block.message().body_capella().unwrap().as_ssz_bytes(), EXECUTION_PAYLOAD_INDEX); + let execution_branch = generate_proof( + block.message().body_capella().unwrap().as_ssz_bytes(), + EXECUTION_PAYLOAD_INDEX, + ); }; LightClientHeader { @@ -107,18 +111,18 @@ impl LightClientHeader { } let Some(execution_root) = self.get_lc_execution_root() else { - return false + return false; }; let Some(execution_branch) = self.execution_branch else { - return false + return false; }; return verify_merkle_proof( execution_root, &execution_branch.into(), - FLOOR_LOG2_EXECUTION_PAYLOAD_INDEX, - get_subtree_index(EXECUTION_PAYLOAD_INDEX), + FLOOR_LOG2_EXECUTION_PAYLOAD_INDEX as usize, + get_subtree_index(EXECUTION_PAYLOAD_INDEX) as usize, self.beacon.body_root, ); } From 73a581aa22e866211e53c8acc3f8104a3257778a Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Fri, 24 Nov 2023 18:49:12 -0800 Subject: [PATCH 26/71] implement helper functions --- consensus/types/src/light_client_header.rs | 44 +++++++++++++++------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/consensus/types/src/light_client_header.rs b/consensus/types/src/light_client_header.rs index e220ab29195..a3da3d90052 100644 --- a/consensus/types/src/light_client_header.rs +++ b/consensus/types/src/light_client_header.rs @@ -1,5 +1,5 @@ -use crate::BeaconBlockHeader; use crate::{test_utils::TestRandom, EthSpec, ExecutionPayloadHeader, Hash256, SignedBeaconBlock}; +use crate::{BeaconBlockHeader, ExecutionPayload}; use merkle_proof::{verify_merkle_proof, MerkleTree}; use serde::{Deserialize, Serialize}; use ssz::Encode; @@ -36,10 +36,13 @@ impl TestRandom for Option { )] #[serde(bound = "E: EthSpec")] #[arbitrary(bound = "E: EthSpec")] +#[ssz(struct_behaviour = "container")] pub struct LightClientHeader { pub beacon: BeaconBlockHeader, #[test_random(default)] + #[ssz(skip_serializing, skip_deserializing)] pub execution: Option>, + #[test_random(default)] pub execution_branch: Option, } @@ -59,11 +62,17 @@ impl From> for LightClientHeader { // TODO epoch greater than or equal to capella if epoch >= 0 { - let payload = block.message().body().execution_payload(); + let payload: ExecutionPayload = block + .message() + .execution_payload() + .unwrap() + .execution_payload_capella() + .unwrap() + .to_owned() + .into(); // TODO fix unwrap - let header = ExecutionPayloadHeader::::from(payload.unwrap().into()); - + let header = ExecutionPayloadHeader::from(payload.to_ref()); let leaves = block .message() .body_capella() @@ -72,16 +81,25 @@ impl From> for LightClientHeader { .iter() .map(|data| data.tree_hash_root()) .collect::>(); - let tree = MerkleTree::create(&leaves, EXECUTION_PAYLOAD_INDEX as usize); - let execution_branch = generate_proof( - block.message().body_capella().unwrap().as_ssz_bytes(), - EXECUTION_PAYLOAD_INDEX, - ); + let tree = MerkleTree::create(&leaves, FLOOR_LOG2_EXECUTION_PAYLOAD_INDEX as usize); + + let _ = tree + .generate_proof( + EXECUTION_PAYLOAD_INDEX as usize, + FLOOR_LOG2_EXECUTION_PAYLOAD_INDEX as usize, + ) + .unwrap(); + + return LightClientHeader { + beacon: block.message().block_header(), + execution: Some(header), + execution_branch: None, // Some(execution_branch), + }; }; LightClientHeader { - beacon, + beacon: block.message().block_header(), execution: None, execution_branch: None, } @@ -94,7 +112,7 @@ impl LightClientHeader { // TODO greater than or equal to CAPELLA if epoch >= 0 { - if let Some(execution) = self.execution { + if let Some(execution) = &self.execution { return Some(execution.tree_hash_root()); } } @@ -114,13 +132,13 @@ impl LightClientHeader { return false; }; - let Some(execution_branch) = self.execution_branch else { + let Some(execution_branch) = &self.execution_branch else { return false; }; return verify_merkle_proof( execution_root, - &execution_branch.into(), + &[Hash256::from_slice(&execution_branch.0)], FLOOR_LOG2_EXECUTION_PAYLOAD_INDEX as usize, get_subtree_index(EXECUTION_PAYLOAD_INDEX) as usize, self.beacon.body_root, From 5ff6f432d6f212dc661dfa3d38037fe0c4c2396f Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Fri, 24 Nov 2023 19:49:04 -0800 Subject: [PATCH 27/71] placeholder conversion from vec hash256 to exec branch --- consensus/types/src/light_client_header.rs | 23 ++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/consensus/types/src/light_client_header.rs b/consensus/types/src/light_client_header.rs index a3da3d90052..bb85f55837d 100644 --- a/consensus/types/src/light_client_header.rs +++ b/consensus/types/src/light_client_header.rs @@ -1,5 +1,6 @@ use crate::{test_utils::TestRandom, EthSpec, ExecutionPayloadHeader, Hash256, SignedBeaconBlock}; use crate::{BeaconBlockHeader, ExecutionPayload}; +use ethereum_hashing::hash_fixed; use merkle_proof::{verify_merkle_proof, MerkleTree}; use serde::{Deserialize, Serialize}; use ssz::Encode; @@ -23,6 +24,19 @@ impl TestRandom for Option { } } +impl From> for ExecutionBranch { + fn from(proof: Vec) -> Self { + let mut result = [0u8; 4]; + + for (i, h256) in proof.iter().enumerate().take(4) { + result[i] = h256.as_bytes()[0]; + } + + ExecutionBranch(result) + } + +} + #[derive( Debug, Clone, @@ -36,7 +50,6 @@ impl TestRandom for Option { )] #[serde(bound = "E: EthSpec")] #[arbitrary(bound = "E: EthSpec")] -#[ssz(struct_behaviour = "container")] pub struct LightClientHeader { pub beacon: BeaconBlockHeader, #[test_random(default)] @@ -84,7 +97,7 @@ impl From> for LightClientHeader { let tree = MerkleTree::create(&leaves, FLOOR_LOG2_EXECUTION_PAYLOAD_INDEX as usize); - let _ = tree + let (_, proof) = tree .generate_proof( EXECUTION_PAYLOAD_INDEX as usize, FLOOR_LOG2_EXECUTION_PAYLOAD_INDEX as usize, @@ -94,7 +107,7 @@ impl From> for LightClientHeader { return LightClientHeader { beacon: block.message().block_header(), execution: Some(header), - execution_branch: None, // Some(execution_branch), + execution_branch: Some(proof.into()), }; }; @@ -138,7 +151,9 @@ impl LightClientHeader { return verify_merkle_proof( execution_root, - &[Hash256::from_slice(&execution_branch.0)], + &[Hash256::from_slice( + hash_fixed(&execution_branch.0).as_slice(), + )], FLOOR_LOG2_EXECUTION_PAYLOAD_INDEX as usize, get_subtree_index(EXECUTION_PAYLOAD_INDEX) as usize, self.beacon.body_root, From 7aacc654f0004028f6fda3885c67d30da36e46f6 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Fri, 24 Nov 2023 21:21:18 -0800 Subject: [PATCH 28/71] add deneb --- consensus/types/src/light_client_header.rs | 80 ++++++++++++++-------- 1 file changed, 51 insertions(+), 29 deletions(-) diff --git a/consensus/types/src/light_client_header.rs b/consensus/types/src/light_client_header.rs index bb85f55837d..180e81ecb49 100644 --- a/consensus/types/src/light_client_header.rs +++ b/consensus/types/src/light_client_header.rs @@ -29,12 +29,11 @@ impl From> for ExecutionBranch { let mut result = [0u8; 4]; for (i, h256) in proof.iter().enumerate().take(4) { - result[i] = h256.as_bytes()[0]; + result[i] = h256.as_bytes()[0]; } ExecutionBranch(result) } - } #[derive( @@ -74,47 +73,56 @@ impl From> for LightClientHeader { let epoch = block.message().slot().epoch(E::slots_per_epoch()); // TODO epoch greater than or equal to capella - if epoch >= 0 { - let payload: ExecutionPayload = block + let payload: ExecutionPayload = if epoch >= 0 { + block .message() .execution_payload() .unwrap() .execution_payload_capella() .unwrap() .to_owned() - .into(); - - // TODO fix unwrap - let header = ExecutionPayloadHeader::from(payload.to_ref()); - let leaves = block + .into() + } else if epoch >= 1 { + block .message() - .body_capella() + .execution_payload() .unwrap() - .as_ssz_bytes() - .iter() - .map(|data| data.tree_hash_root()) - .collect::>(); - - let tree = MerkleTree::create(&leaves, FLOOR_LOG2_EXECUTION_PAYLOAD_INDEX as usize); - - let (_, proof) = tree - .generate_proof( - EXECUTION_PAYLOAD_INDEX as usize, - FLOOR_LOG2_EXECUTION_PAYLOAD_INDEX as usize, - ) - .unwrap(); - + .execution_payload_deneb() + .unwrap() + .to_owned() + .into() + } else { return LightClientHeader { beacon: block.message().block_header(), - execution: Some(header), - execution_branch: Some(proof.into()), + execution: None, + execution_branch: None, }; }; + // TODO fix unwrap + let header = ExecutionPayloadHeader::from(payload.to_ref()); + let leaves = block + .message() + .body_capella() + .unwrap() + .as_ssz_bytes() + .iter() + .map(|data| data.tree_hash_root()) + .collect::>(); + + let tree = MerkleTree::create(&leaves, FLOOR_LOG2_EXECUTION_PAYLOAD_INDEX as usize); + + let (_, proof) = tree + .generate_proof( + EXECUTION_PAYLOAD_INDEX as usize, + FLOOR_LOG2_EXECUTION_PAYLOAD_INDEX as usize, + ) + .unwrap(); + LightClientHeader { beacon: block.message().block_header(), - execution: None, - execution_branch: None, + execution: Some(header), + execution_branch: Some(proof.into()), } } } @@ -136,7 +144,21 @@ impl LightClientHeader { fn is_valid_light_client_header(&self) -> bool { let epoch = self.beacon.slot.epoch(E::slots_per_epoch()); - // TODO LESS THAN CAPELLA + // TODO LESS THAN DENEB + if epoch < 1 { + let Some(execution) = &self.execution else { + return false; + }; + + // TODO unwrap + if execution.blob_gas_used().unwrap().to_owned() != 0 as u64 + || execution.excess_blob_gas().unwrap().to_owned() != 0 as u64 + { + return false; + } + } + + // TODO LESS THAN DENEB if epoch < 0 { return self.execution == None && self.execution_branch == None; } From 3593f523ae5b337befeceb3c485d02c4a93388e5 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Sat, 25 Nov 2023 09:26:52 -0800 Subject: [PATCH 29/71] using fixed vector --- consensus/types/src/light_client_header.rs | 48 ++++------------------ consensus/types/src/light_client_update.rs | 6 ++- 2 files changed, 14 insertions(+), 40 deletions(-) diff --git a/consensus/types/src/light_client_header.rs b/consensus/types/src/light_client_header.rs index 180e81ecb49..515a5111b05 100644 --- a/consensus/types/src/light_client_header.rs +++ b/consensus/types/src/light_client_header.rs @@ -1,40 +1,12 @@ -use crate::{test_utils::TestRandom, EthSpec, ExecutionPayloadHeader, Hash256, SignedBeaconBlock}; +use crate::{test_utils::TestRandom, EthSpec, FixedVector, ExecutionPayloadHeader, Hash256, SignedBeaconBlock}; use crate::{BeaconBlockHeader, ExecutionPayload}; -use ethereum_hashing::hash_fixed; use merkle_proof::{verify_merkle_proof, MerkleTree}; use serde::{Deserialize, Serialize}; use ssz::Encode; use ssz_derive::{Decode, Encode}; use test_random_derive::TestRandom; use tree_hash::TreeHash; - -const EXECUTION_PAYLOAD_INDEX: u32 = 25; -const FLOOR_LOG2_EXECUTION_PAYLOAD_INDEX: u32 = 4; - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Encode, Decode, arbitrary::Arbitrary)] -#[ssz(struct_behaviour = "transparent")] -pub struct ExecutionBranch(pub [u8; FLOOR_LOG2_EXECUTION_PAYLOAD_INDEX as usize]); - -impl TestRandom for Option { - fn random_for_test(rng: &mut impl rand::RngCore) -> Self { - Some(ExecutionBranch(<[u8; FLOOR_LOG2_EXECUTION_PAYLOAD_INDEX - as usize] as TestRandom>::random_for_test( - rng - ))) - } -} - -impl From> for ExecutionBranch { - fn from(proof: Vec) -> Self { - let mut result = [0u8; 4]; - - for (i, h256) in proof.iter().enumerate().take(4) { - result[i] = h256.as_bytes()[0]; - } - - ExecutionBranch(result) - } -} +use crate::light_client_update::*; #[derive( Debug, @@ -55,7 +27,7 @@ pub struct LightClientHeader { #[ssz(skip_serializing, skip_deserializing)] pub execution: Option>, #[test_random(default)] - pub execution_branch: Option, + pub execution_branch: Option>, } impl From for LightClientHeader { @@ -110,12 +82,12 @@ impl From> for LightClientHeader { .map(|data| data.tree_hash_root()) .collect::>(); - let tree = MerkleTree::create(&leaves, FLOOR_LOG2_EXECUTION_PAYLOAD_INDEX as usize); + let tree = MerkleTree::create(&leaves, EXECUTION_PAYLOAD_PROOF_LEN); let (_, proof) = tree .generate_proof( - EXECUTION_PAYLOAD_INDEX as usize, - FLOOR_LOG2_EXECUTION_PAYLOAD_INDEX as usize, + EXECUTION_PAYLOAD_INDEX, + EXECUTION_PAYLOAD_PROOF_LEN, ) .unwrap(); @@ -173,11 +145,9 @@ impl LightClientHeader { return verify_merkle_proof( execution_root, - &[Hash256::from_slice( - hash_fixed(&execution_branch.0).as_slice(), - )], - FLOOR_LOG2_EXECUTION_PAYLOAD_INDEX as usize, - get_subtree_index(EXECUTION_PAYLOAD_INDEX) as usize, + &execution_branch, + EXECUTION_PAYLOAD_PROOF_LEN, + get_subtree_index(EXECUTION_PAYLOAD_INDEX as u32) as usize, self.beacon.body_root, ); } diff --git a/consensus/types/src/light_client_update.rs b/consensus/types/src/light_client_update.rs index 7eb563ef666..9204105f232 100644 --- a/consensus/types/src/light_client_update.rs +++ b/consensus/types/src/light_client_update.rs @@ -7,7 +7,7 @@ use safe_arith::ArithError; use serde::{Deserialize, Deserializer, Serialize}; use serde_json::Value; use ssz_derive::{Decode, Encode}; -use ssz_types::typenum::{U5, U6}; +use ssz_types::typenum::{U4, U5, U6}; use std::sync::Arc; use test_random_derive::TestRandom; use tree_hash::TreeHash; @@ -15,14 +15,18 @@ use tree_hash::TreeHash; pub const FINALIZED_ROOT_INDEX: usize = 105; pub const CURRENT_SYNC_COMMITTEE_INDEX: usize = 54; pub const NEXT_SYNC_COMMITTEE_INDEX: usize = 55; +pub const EXECUTION_PAYLOAD_INDEX: usize = 25; pub type FinalizedRootProofLen = U6; pub type CurrentSyncCommitteeProofLen = U5; +pub type ExecutionPayloadProofLen = U4; + pub type NextSyncCommitteeProofLen = U5; pub const FINALIZED_ROOT_PROOF_LEN: usize = 6; pub const CURRENT_SYNC_COMMITTEE_PROOF_LEN: usize = 5; pub const NEXT_SYNC_COMMITTEE_PROOF_LEN: usize = 5; +pub const EXECUTION_PAYLOAD_PROOF_LEN: usize = 4; #[derive(Debug, PartialEq, Clone)] pub enum Error { From 65a5770c3345026955625e1431c690bb4ba5b2fe Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Sun, 26 Nov 2023 09:35:08 -0800 Subject: [PATCH 30/71] remove unwraps --- consensus/types/src/light_client_header.rs | 66 ++++++++++------------ 1 file changed, 29 insertions(+), 37 deletions(-) diff --git a/consensus/types/src/light_client_header.rs b/consensus/types/src/light_client_header.rs index 515a5111b05..4c012d30a73 100644 --- a/consensus/types/src/light_client_header.rs +++ b/consensus/types/src/light_client_header.rs @@ -1,4 +1,8 @@ -use crate::{test_utils::TestRandom, EthSpec, FixedVector, ExecutionPayloadHeader, Hash256, SignedBeaconBlock}; +use crate::light_client_update::*; +use crate::{ + test_utils::TestRandom, EthSpec, ExecutionPayloadHeader, FixedVector, Hash256, + SignedBeaconBlock, +}; use crate::{BeaconBlockHeader, ExecutionPayload}; use merkle_proof::{verify_merkle_proof, MerkleTree}; use serde::{Deserialize, Serialize}; @@ -6,7 +10,6 @@ use ssz::Encode; use ssz_derive::{Decode, Encode}; use test_random_derive::TestRandom; use tree_hash::TreeHash; -use crate::light_client_update::*; #[derive( Debug, @@ -40,43 +43,38 @@ impl From for LightClientHeader { } } -impl From> for LightClientHeader { - fn from(block: SignedBeaconBlock) -> Self { +impl LightClientHeader { + fn new(block: SignedBeaconBlock) -> Result { let epoch = block.message().slot().epoch(E::slots_per_epoch()); // TODO epoch greater than or equal to capella let payload: ExecutionPayload = if epoch >= 0 { block .message() - .execution_payload() - .unwrap() - .execution_payload_capella() - .unwrap() + .execution_payload()? + .execution_payload_capella()? .to_owned() .into() } else if epoch >= 1 { block .message() - .execution_payload() - .unwrap() - .execution_payload_deneb() - .unwrap() + .execution_payload()? + .execution_payload_deneb()? .to_owned() .into() } else { - return LightClientHeader { + return Ok(LightClientHeader { beacon: block.message().block_header(), execution: None, execution_branch: None, - }; + }); }; // TODO fix unwrap let header = ExecutionPayloadHeader::from(payload.to_ref()); let leaves = block .message() - .body_capella() - .unwrap() + .body_capella()? .as_ssz_bytes() .iter() .map(|data| data.tree_hash_root()) @@ -84,22 +82,16 @@ impl From> for LightClientHeader { let tree = MerkleTree::create(&leaves, EXECUTION_PAYLOAD_PROOF_LEN); - let (_, proof) = tree - .generate_proof( - EXECUTION_PAYLOAD_INDEX, - EXECUTION_PAYLOAD_PROOF_LEN, - ) - .unwrap(); + let (_, proof) = + tree.generate_proof(EXECUTION_PAYLOAD_INDEX, EXECUTION_PAYLOAD_PROOF_LEN)?; - LightClientHeader { + Ok(LightClientHeader { beacon: block.message().block_header(), execution: Some(header), execution_branch: Some(proof.into()), - } + }) } -} -impl LightClientHeader { fn get_lc_execution_root(&self) -> Option { let epoch = self.beacon.slot.epoch(E::slots_per_epoch()); @@ -110,46 +102,46 @@ impl LightClientHeader { } } - return None; + None } - fn is_valid_light_client_header(&self) -> bool { + fn is_valid_light_client_header(&self) -> Result { let epoch = self.beacon.slot.epoch(E::slots_per_epoch()); // TODO LESS THAN DENEB if epoch < 1 { let Some(execution) = &self.execution else { - return false; + return Ok(false); }; // TODO unwrap - if execution.blob_gas_used().unwrap().to_owned() != 0 as u64 - || execution.excess_blob_gas().unwrap().to_owned() != 0 as u64 + if execution.blob_gas_used()?.to_owned() != 0 as u64 + || execution.excess_blob_gas()?.to_owned() != 0 as u64 { - return false; + return Ok(false); } } // TODO LESS THAN DENEB if epoch < 0 { - return self.execution == None && self.execution_branch == None; + return Ok(self.execution == None && self.execution_branch == None); } let Some(execution_root) = self.get_lc_execution_root() else { - return false; + return Ok(false); }; let Some(execution_branch) = &self.execution_branch else { - return false; + return Ok(false); }; - return verify_merkle_proof( + Ok(verify_merkle_proof( execution_root, &execution_branch, EXECUTION_PAYLOAD_PROOF_LEN, get_subtree_index(EXECUTION_PAYLOAD_INDEX as u32) as usize, self.beacon.body_root, - ); + )) } } From fd1a6917f3482c863427b27159d237524205f435 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Mon, 27 Nov 2023 16:20:04 -0800 Subject: [PATCH 31/71] by epoch --- consensus/types/src/light_client_header.rs | 133 +++++++++++---------- 1 file changed, 67 insertions(+), 66 deletions(-) diff --git a/consensus/types/src/light_client_header.rs b/consensus/types/src/light_client_header.rs index 4c012d30a73..39048930053 100644 --- a/consensus/types/src/light_client_header.rs +++ b/consensus/types/src/light_client_header.rs @@ -1,12 +1,11 @@ -use crate::light_client_update::*; +use crate::{light_client_update::*, ChainSpec}; use crate::{ test_utils::TestRandom, EthSpec, ExecutionPayloadHeader, FixedVector, Hash256, SignedBeaconBlock, }; use crate::{BeaconBlockHeader, ExecutionPayload}; -use merkle_proof::{verify_merkle_proof, MerkleTree}; +use merkle_proof::verify_merkle_proof; use serde::{Deserialize, Serialize}; -use ssz::Encode; use ssz_derive::{Decode, Encode}; use test_random_derive::TestRandom; use tree_hash::TreeHash; @@ -44,90 +43,92 @@ impl From for LightClientHeader { } impl LightClientHeader { - fn new(block: SignedBeaconBlock) -> Result { - let epoch = block.message().slot().epoch(E::slots_per_epoch()); - - // TODO epoch greater than or equal to capella - let payload: ExecutionPayload = if epoch >= 0 { - block - .message() - .execution_payload()? - .execution_payload_capella()? - .to_owned() - .into() - } else if epoch >= 1 { - block - .message() - .execution_payload()? - .execution_payload_deneb()? - .to_owned() - .into() - } else { - return Ok(LightClientHeader { - beacon: block.message().block_header(), - execution: None, - execution_branch: None, - }); + fn new(chain_spec: ChainSpec, block: SignedBeaconBlock) -> Result { + let current_epoch = block.slot().epoch(E::slots_per_epoch()); + + if let Some(deneb_fork_epoch) = chain_spec.deneb_fork_epoch { + if current_epoch >= deneb_fork_epoch { + let payload: ExecutionPayload = block + .message() + .execution_payload()? + .execution_payload_deneb()? + .to_owned() + .into(); + let header = ExecutionPayloadHeader::from(payload.to_ref()); + + // TODO calculate execution branch, i.e. the merkle proof of the execution payload header + return Ok(LightClientHeader { + beacon: block.message().block_header(), + execution: Some(header), + execution_branch: None, + }); + } }; - // TODO fix unwrap - let header = ExecutionPayloadHeader::from(payload.to_ref()); - let leaves = block - .message() - .body_capella()? - .as_ssz_bytes() - .iter() - .map(|data| data.tree_hash_root()) - .collect::>(); - - let tree = MerkleTree::create(&leaves, EXECUTION_PAYLOAD_PROOF_LEN); - - let (_, proof) = - tree.generate_proof(EXECUTION_PAYLOAD_INDEX, EXECUTION_PAYLOAD_PROOF_LEN)?; + if let Some(capella_fork_epoch) = chain_spec.capella_fork_epoch { + if current_epoch >= capella_fork_epoch { + let payload: ExecutionPayload = block + .message() + .execution_payload()? + .execution_payload_capella()? + .to_owned() + .into(); + let header = ExecutionPayloadHeader::from(payload.to_ref()); + + // TODO calculate execution branch, i.e. the merkle proof of the execution payload header + return Ok(LightClientHeader { + beacon: block.message().block_header(), + execution: Some(header), + execution_branch: None, + }); + } + }; Ok(LightClientHeader { beacon: block.message().block_header(), - execution: Some(header), - execution_branch: Some(proof.into()), + execution: None, + execution_branch: None, }) } - fn get_lc_execution_root(&self) -> Option { - let epoch = self.beacon.slot.epoch(E::slots_per_epoch()); + fn get_lc_execution_root(&self, chain_spec: ChainSpec) -> Option { + let current_epoch = self.beacon.slot.epoch(E::slots_per_epoch()); - // TODO greater than or equal to CAPELLA - if epoch >= 0 { - if let Some(execution) = &self.execution { - return Some(execution.tree_hash_root()); + if let Some(capella_fork_epoch) = chain_spec.capella_fork_epoch { + if current_epoch >= capella_fork_epoch { + if let Some(execution) = &self.execution { + return Some(execution.tree_hash_root()); + } } } None } - fn is_valid_light_client_header(&self) -> Result { - let epoch = self.beacon.slot.epoch(E::slots_per_epoch()); + fn is_valid_light_client_header(&self, chain_spec: ChainSpec) -> Result { + let current_epoch = self.beacon.slot.epoch(E::slots_per_epoch()); - // TODO LESS THAN DENEB - if epoch < 1 { - let Some(execution) = &self.execution else { - return Ok(false); - }; - - // TODO unwrap - if execution.blob_gas_used()?.to_owned() != 0 as u64 - || execution.excess_blob_gas()?.to_owned() != 0 as u64 - { - return Ok(false); + if let Some(capella_fork_epoch) = chain_spec.capella_fork_epoch { + if current_epoch < capella_fork_epoch { + return Ok(self.execution == None && self.execution_branch == None); } } - // TODO LESS THAN DENEB - if epoch < 0 { - return Ok(self.execution == None && self.execution_branch == None); + if let Some(deneb_fork_epoch) = chain_spec.deneb_fork_epoch { + if current_epoch < deneb_fork_epoch { + let Some(execution) = &self.execution else { + return Ok(false); + }; + + if execution.blob_gas_used()?.to_owned() != 0 as u64 + || execution.excess_blob_gas()?.to_owned() != 0 as u64 + { + return Ok(false); + } + } } - let Some(execution_root) = self.get_lc_execution_root() else { + let Some(execution_root) = self.get_lc_execution_root(chain_spec) else { return Ok(false); }; From 443d2197da91a3e63ea13475568aff3f05b726ff Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Mon, 27 Nov 2023 19:12:07 -0800 Subject: [PATCH 32/71] compute merkle proof --- consensus/types/src/beacon_block_body.rs | 44 +++++++++++++++++++++- consensus/types/src/light_client_header.rs | 26 +++++++++++-- consensus/types/src/light_client_update.rs | 1 + 3 files changed, 67 insertions(+), 4 deletions(-) diff --git a/consensus/types/src/beacon_block_body.rs b/consensus/types/src/beacon_block_body.rs index 2f7c6891e4c..cd86cb9ecb5 100644 --- a/consensus/types/src/beacon_block_body.rs +++ b/consensus/types/src/beacon_block_body.rs @@ -7,6 +7,7 @@ use ssz_types::VariableList; use std::marker::PhantomData; use superstruct::superstruct; use test_random_derive::TestRandom; +use tree_hash::TreeHash; use tree_hash_derive::TreeHash; pub type KzgCommitments = @@ -42,11 +43,12 @@ pub type KzgCommitmentOpts = cast_error(ty = "Error", expr = "Error::IncorrectStateVariant"), partial_getter_error(ty = "Error", expr = "Error::IncorrectStateVariant") )] -#[derive(Debug, Clone, Serialize, Deserialize, Derivative, arbitrary::Arbitrary)] +#[derive(Debug, Clone, Serialize, Deserialize, Derivative, TreeHash, arbitrary::Arbitrary)] #[derivative(PartialEq, Hash(bound = "T: EthSpec"))] #[serde(untagged)] #[serde(bound = "T: EthSpec, Payload: AbstractExecPayload")] #[arbitrary(bound = "T: EthSpec, Payload: AbstractExecPayload")] +#[tree_hash(enum_behaviour = "transparent")] pub struct BeaconBlockBody = FullPayload> { pub randao_reveal: Signature, pub eth1_data: Eth1Data, @@ -508,6 +510,46 @@ impl From>> } } +impl BeaconBlockBody { + pub fn compute_merkle_proof( + &mut self, + generalized_index: usize, + ) -> Result, Error> { + let mut leaves = vec![ + self.randao_reveal().tree_hash_root(), + self.eth1_data().tree_hash_root(), + self.graffiti().tree_hash_root(), + self.proposer_slashings().tree_hash_root(), + self.attester_slashings().tree_hash_root(), + self.attestations().tree_hash_root(), + self.deposits().tree_hash_root(), + self.voluntary_exits().tree_hash_root(), + ]; + + if let Ok(sync_aggregate) = self.sync_aggregate() { + leaves.push(sync_aggregate.tree_hash_root()) + }; + + if let Ok(execution_payload) = self.execution_payload() { + leaves.push(execution_payload.tree_hash_root()) + }; + + if let Ok(bls_to_execution_changes) = self.bls_to_execution_changes() { + leaves.push(bls_to_execution_changes.tree_hash_root()) + } + + if let Ok(blob_kzg_commitments) = self.blob_kzg_commitments() { + leaves.push(blob_kzg_commitments.tree_hash_root()) + } + + let depth = light_client_update::EXECUTION_PAYLOAD_PROOF_LEN; + let tree = merkle_proof::MerkleTree::create(&leaves, depth); + let (_, proof) = tree.generate_proof(generalized_index, depth)?; + + Ok(proof) + } +} + /// Util method helpful for logging. pub fn format_kzg_commitments(commitments: &[KzgCommitment]) -> String { let commitment_strings: Vec = commitments.iter().map(|x| x.to_string()).collect(); diff --git a/consensus/types/src/light_client_header.rs b/consensus/types/src/light_client_header.rs index 39048930053..e4abf316372 100644 --- a/consensus/types/src/light_client_header.rs +++ b/consensus/types/src/light_client_header.rs @@ -1,4 +1,4 @@ -use crate::{light_client_update::*, ChainSpec}; +use crate::{light_client_update::*, BeaconBlockBody, ChainSpec}; use crate::{ test_utils::TestRandom, EthSpec, ExecutionPayloadHeader, FixedVector, Hash256, SignedBeaconBlock, @@ -54,13 +54,23 @@ impl LightClientHeader { .execution_payload_deneb()? .to_owned() .into(); + let header = ExecutionPayloadHeader::from(payload.to_ref()); + let mut beacon_block_body = BeaconBlockBody::from( + block + .message() + .body_deneb() + .map_err(|_| Error::BeaconBlockBodyError)? + .to_owned(), + ); + let execution_branch = + beacon_block_body.compute_merkle_proof(EXECUTION_PAYLOAD_INDEX)?; // TODO calculate execution branch, i.e. the merkle proof of the execution payload header return Ok(LightClientHeader { beacon: block.message().block_header(), execution: Some(header), - execution_branch: None, + execution_branch: Some(FixedVector::new(execution_branch)?), }); } }; @@ -73,13 +83,23 @@ impl LightClientHeader { .execution_payload_capella()? .to_owned() .into(); + let header = ExecutionPayloadHeader::from(payload.to_ref()); + let mut beacon_block_body = BeaconBlockBody::from( + block + .message() + .body_capella() + .map_err(|_| Error::BeaconBlockBodyError)? + .to_owned(), + ); + let execution_branch = + beacon_block_body.compute_merkle_proof(EXECUTION_PAYLOAD_INDEX)?; // TODO calculate execution branch, i.e. the merkle proof of the execution payload header return Ok(LightClientHeader { beacon: block.message().block_header(), execution: Some(header), - execution_branch: None, + execution_branch: Some(FixedVector::new(execution_branch)?), }); } }; diff --git a/consensus/types/src/light_client_update.rs b/consensus/types/src/light_client_update.rs index 9204105f232..310f79def50 100644 --- a/consensus/types/src/light_client_update.rs +++ b/consensus/types/src/light_client_update.rs @@ -37,6 +37,7 @@ pub enum Error { NotEnoughSyncCommitteeParticipants, MismatchingPeriods, InvalidFinalizedBlock, + BeaconBlockBodyError, } impl From for Error { From a9fa092cb283e44a060957428af83f325b72176f Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Mon, 27 Nov 2023 23:24:47 -0800 Subject: [PATCH 33/71] merkle proof --- consensus/types/src/beacon_block_body.rs | 26 +++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/consensus/types/src/beacon_block_body.rs b/consensus/types/src/beacon_block_body.rs index cd86cb9ecb5..7ea056bf695 100644 --- a/consensus/types/src/beacon_block_body.rs +++ b/consensus/types/src/beacon_block_body.rs @@ -15,6 +15,14 @@ pub type KzgCommitments = pub type KzgCommitmentOpts = FixedVector, ::MaxBlobsPerBlock>; +/// The number of leaves (including padding) on the `BeaconBlockBody` Merkle tree. +/// +/// ## Note +/// +/// This constant is set with the assumption that there are `> 8` and `<= 16` fields on the +/// `BeaconBlockBody`. **Tree hashing will fail if this value is set incorrectly.** +pub const NUM_BEACON_BLOCK_BODY_HASH_TREE_ROOT_LEAVES: usize = 16; + /// The body of a `BeaconChain` block, containing operations. /// /// This *superstruct* abstracts over the hard-fork. @@ -515,6 +523,18 @@ impl BeaconBlockBody { &mut self, generalized_index: usize, ) -> Result, Error> { + + let field_index = match generalized_index { + light_client_update::EXECUTION_PAYLOAD_INDEX => { + // Execution payload is a top-level field, subtract off the generalized indices + // for the internal nodes. Result should be 9. + generalized_index + .checked_sub(NUM_BEACON_BLOCK_BODY_HASH_TREE_ROOT_LEAVES) + .ok_or(Error::IndexNotSupported(generalized_index))? + } + _ => return Err(Error::IndexNotSupported(generalized_index)) + }; + let mut leaves = vec![ self.randao_reveal().tree_hash_root(), self.eth1_data().tree_hash_root(), @@ -528,11 +548,11 @@ impl BeaconBlockBody { if let Ok(sync_aggregate) = self.sync_aggregate() { leaves.push(sync_aggregate.tree_hash_root()) - }; + } if let Ok(execution_payload) = self.execution_payload() { leaves.push(execution_payload.tree_hash_root()) - }; + } if let Ok(bls_to_execution_changes) = self.bls_to_execution_changes() { leaves.push(bls_to_execution_changes.tree_hash_root()) @@ -544,7 +564,7 @@ impl BeaconBlockBody { let depth = light_client_update::EXECUTION_PAYLOAD_PROOF_LEN; let tree = merkle_proof::MerkleTree::create(&leaves, depth); - let (_, proof) = tree.generate_proof(generalized_index, depth)?; + let (_, proof) = tree.generate_proof(field_index, depth)?; Ok(proof) } From effeec1e2987e7c36cce0dd46d187e7c57713870 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Mon, 27 Nov 2023 23:32:01 -0800 Subject: [PATCH 34/71] update comments --- consensus/types/src/beacon_block_body.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/consensus/types/src/beacon_block_body.rs b/consensus/types/src/beacon_block_body.rs index 7ea056bf695..f921a0abf1e 100644 --- a/consensus/types/src/beacon_block_body.rs +++ b/consensus/types/src/beacon_block_body.rs @@ -527,7 +527,9 @@ impl BeaconBlockBody { let field_index = match generalized_index { light_client_update::EXECUTION_PAYLOAD_INDEX => { // Execution payload is a top-level field, subtract off the generalized indices - // for the internal nodes. Result should be 9. + // for the internal nodes. Result should be 9, the field offset of the execution + // payload in the `BeaconBlockBody`: + // https://github.com/ethereum/consensus-specs/blob/dev/specs/deneb/beacon-chain.md#beaconblockbody generalized_index .checked_sub(NUM_BEACON_BLOCK_BODY_HASH_TREE_ROOT_LEAVES) .ok_or(Error::IndexNotSupported(generalized_index))? From 03c163f4a7f03294878d849fd8277a4cea4f3854 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Tue, 28 Nov 2023 00:09:04 -0800 Subject: [PATCH 35/71] linting --- consensus/types/src/beacon_block_body.rs | 3 +- consensus/types/src/light_client_header.rs | 32 ++++++++-------------- 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/consensus/types/src/beacon_block_body.rs b/consensus/types/src/beacon_block_body.rs index f921a0abf1e..e1d2de704e5 100644 --- a/consensus/types/src/beacon_block_body.rs +++ b/consensus/types/src/beacon_block_body.rs @@ -523,7 +523,6 @@ impl BeaconBlockBody { &mut self, generalized_index: usize, ) -> Result, Error> { - let field_index = match generalized_index { light_client_update::EXECUTION_PAYLOAD_INDEX => { // Execution payload is a top-level field, subtract off the generalized indices @@ -534,7 +533,7 @@ impl BeaconBlockBody { .checked_sub(NUM_BEACON_BLOCK_BODY_HASH_TREE_ROOT_LEAVES) .ok_or(Error::IndexNotSupported(generalized_index))? } - _ => return Err(Error::IndexNotSupported(generalized_index)) + _ => return Err(Error::IndexNotSupported(generalized_index)), }; let mut leaves = vec![ diff --git a/consensus/types/src/light_client_header.rs b/consensus/types/src/light_client_header.rs index e4abf316372..a0ec14880e0 100644 --- a/consensus/types/src/light_client_header.rs +++ b/consensus/types/src/light_client_header.rs @@ -1,3 +1,4 @@ +use crate::beacon_block_body::NUM_BEACON_BLOCK_BODY_HASH_TREE_ROOT_LEAVES; use crate::{light_client_update::*, BeaconBlockBody, ChainSpec}; use crate::{ test_utils::TestRandom, EthSpec, ExecutionPayloadHeader, FixedVector, Hash256, @@ -66,7 +67,6 @@ impl LightClientHeader { let execution_branch = beacon_block_body.compute_merkle_proof(EXECUTION_PAYLOAD_INDEX)?; - // TODO calculate execution branch, i.e. the merkle proof of the execution payload header return Ok(LightClientHeader { beacon: block.message().block_header(), execution: Some(header), @@ -95,7 +95,6 @@ impl LightClientHeader { let execution_branch = beacon_block_body.compute_merkle_proof(EXECUTION_PAYLOAD_INDEX)?; - // TODO calculate execution branch, i.e. the merkle proof of the execution payload header return Ok(LightClientHeader { beacon: block.message().block_header(), execution: Some(header), @@ -130,7 +129,7 @@ impl LightClientHeader { if let Some(capella_fork_epoch) = chain_spec.capella_fork_epoch { if current_epoch < capella_fork_epoch { - return Ok(self.execution == None && self.execution_branch == None); + return Ok(self.execution.is_none() && self.execution_branch.is_none()); } } @@ -140,9 +139,7 @@ impl LightClientHeader { return Ok(false); }; - if execution.blob_gas_used()?.to_owned() != 0 as u64 - || execution.excess_blob_gas()?.to_owned() != 0 as u64 - { + if *execution.blob_gas_used()? != 0_u64 || *execution.excess_blob_gas()? != 0_u64 { return Ok(false); } } @@ -156,25 +153,18 @@ impl LightClientHeader { return Ok(false); }; + let Some(field_index) = + EXECUTION_PAYLOAD_INDEX.checked_sub(NUM_BEACON_BLOCK_BODY_HASH_TREE_ROOT_LEAVES) + else { + return Ok(false); + }; + Ok(verify_merkle_proof( execution_root, - &execution_branch, + execution_branch, EXECUTION_PAYLOAD_PROOF_LEN, - get_subtree_index(EXECUTION_PAYLOAD_INDEX as u32) as usize, + field_index, self.beacon.body_root, )) } } - -// TODO move to the relevant place -fn get_subtree_index(generalized_index: u32) -> u32 { - return generalized_index % 2 * (log2_int(generalized_index)); -} - -// TODO move to the relevant place -fn log2_int(x: u32) -> u32 { - if x == 0 { - return 0; - } - 31 - x.leading_zeros() -} From 16740c27e5c2aa3bcc7dc99c613f8b76be4780d8 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Fri, 1 Dec 2023 09:24:14 -0800 Subject: [PATCH 36/71] superstruct attempt --- consensus/types/src/light_client_header.rs | 63 +++++++++++++++------- 1 file changed, 43 insertions(+), 20 deletions(-) diff --git a/consensus/types/src/light_client_header.rs b/consensus/types/src/light_client_header.rs index a0ec14880e0..2c5b1a79b05 100644 --- a/consensus/types/src/light_client_header.rs +++ b/consensus/types/src/light_client_header.rs @@ -1,7 +1,7 @@ use crate::beacon_block_body::NUM_BEACON_BLOCK_BODY_HASH_TREE_ROOT_LEAVES; use crate::{light_client_update::*, BeaconBlockBody, ChainSpec}; use crate::{ - test_utils::TestRandom, EthSpec, ExecutionPayloadHeader, FixedVector, Hash256, + test_utils::TestRandom, EthSpec, ExecutionPayloadHeader, ExecutionPayloadHeaderCapella, ExecutionPayloadHeaderDeneb, FixedVector, Hash256, SignedBeaconBlock, }; use crate::{BeaconBlockHeader, ExecutionPayload}; @@ -10,35 +10,58 @@ use serde::{Deserialize, Serialize}; use ssz_derive::{Decode, Encode}; use test_random_derive::TestRandom; use tree_hash::TreeHash; - +use superstruct::superstruct; +use std::marker::PhantomData; + +#[superstruct( + variants(Merge, Capella, Deneb), + variant_attributes( + derive( + Default, + Debug, + Clone, + PartialEq, + Serialize, + Deserialize, + Encode, + Decode, + TestRandom, + arbitrary::Arbitrary + ), + serde(bound = "E: EthSpec", deny_unknown_fields), + arbitrary(bound = "E: EthSpec"), + ), +)] #[derive( - Debug, - Clone, - PartialEq, - Serialize, - Deserialize, - Encode, - Decode, - TestRandom, - arbitrary::Arbitrary, + Debug, Clone, Serialize, PartialEq, Deserialize, Encode, Decode, arbitrary::Arbitrary, )] -#[serde(bound = "E: EthSpec")] #[arbitrary(bound = "E: EthSpec")] +#[serde(untagged)] +#[serde(bound = "E: EthSpec")] +#[ssz(enum_behaviour = "union")] pub struct LightClientHeader { pub beacon: BeaconBlockHeader, - #[test_random(default)] + #[superstruct(only(Capella, Deneb))] + pub execution_branch: FixedVector, + #[superstruct( + only(Capella), + partial_getter(rename = "execution_payload_header_capella") + )] + pub execution: ExecutionPayloadHeaderCapella, + #[superstruct( + only(Deneb), + partial_getter(rename = "execution_payload_header_deneb") + )] + pub execution: ExecutionPayloadHeaderDeneb, + #[ssz(skip_serializing, skip_deserializing)] - pub execution: Option>, - #[test_random(default)] - pub execution_branch: Option>, + pub phantom_data: PhantomData, } -impl From for LightClientHeader { +impl From for LightClientHeaderMerge { fn from(beacon: BeaconBlockHeader) -> Self { - LightClientHeader { + LightClientHeaderMerge { beacon, - execution: None, - execution_branch: None, } } } From 302a1cbeefd0a38b2824e5a9689c8dd8db55e0f6 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Sat, 2 Dec 2023 22:51:09 -0800 Subject: [PATCH 37/71] superstruct changes --- consensus/types/src/beacon_block_header.rs | 1 + consensus/types/src/light_client_bootstrap.rs | 31 ++- .../types/src/light_client_finality_update.rs | 48 +--- consensus/types/src/light_client_header.rs | 213 ++++++++---------- .../src/light_client_optimistic_update.rs | 26 +-- consensus/types/src/light_client_update.rs | 42 +++- 6 files changed, 180 insertions(+), 181 deletions(-) diff --git a/consensus/types/src/beacon_block_header.rs b/consensus/types/src/beacon_block_header.rs index 689f1a28b08..f8aa61f3dfb 100644 --- a/consensus/types/src/beacon_block_header.rs +++ b/consensus/types/src/beacon_block_header.rs @@ -13,6 +13,7 @@ use tree_hash_derive::TreeHash; #[derive( arbitrary::Arbitrary, Debug, + Default, PartialEq, Eq, Hash, diff --git a/consensus/types/src/light_client_bootstrap.rs b/consensus/types/src/light_client_bootstrap.rs index e1fc01737e0..d28fc6931bc 100644 --- a/consensus/types/src/light_client_bootstrap.rs +++ b/consensus/types/src/light_client_bootstrap.rs @@ -1,7 +1,7 @@ use super::{BeaconState, EthSpec, FixedVector, Hash256, SyncCommittee}; use crate::{ light_client_update::*, test_utils::TestRandom, ForkName, ForkVersionDeserialize, - LightClientHeader, + LightClientHeader, SignedBeaconBlock, ChainSpec, light_client_header::{LightClientHeaderDeneb, LightClientHeaderCapella, LightClientHeaderMerge}, }; use serde::{Deserialize, Deserializer, Serialize}; use serde_json::Value; @@ -34,13 +34,38 @@ pub struct LightClientBootstrap { } impl LightClientBootstrap { - pub fn from_beacon_state(beacon_state: &mut BeaconState) -> Result { + pub fn from_beacon_state( + chain_spec: &ChainSpec, + beacon_state: &mut BeaconState, + block: SignedBeaconBlock, + ) -> Result { let mut header = beacon_state.latest_block_header().clone(); header.state_root = beacon_state.update_tree_hash_cache()?; let current_sync_committee_branch = beacon_state.compute_merkle_proof(CURRENT_SYNC_COMMITTEE_INDEX)?; + + if let Some(deneb_fork_epoch) = chain_spec.deneb_fork_epoch { + if beacon_state.slot().epoch(T::slots_per_epoch()) >= deneb_fork_epoch { + return Ok(LightClientBootstrap { + header: LightClientHeaderDeneb::new(block)?.into(), + current_sync_committee: beacon_state.current_sync_committee()?.clone(), + current_sync_committee_branch: FixedVector::new(current_sync_committee_branch)?, + }) + } + }; + + if let Some(capella_fork_epoch) = chain_spec.capella_fork_epoch { + if beacon_state.slot().epoch(T::slots_per_epoch()) >= capella_fork_epoch { + return Ok(LightClientBootstrap { + header: LightClientHeaderCapella::new(block)?.into(), + current_sync_committee: beacon_state.current_sync_committee()?.clone(), + current_sync_committee_branch: FixedVector::new(current_sync_committee_branch)?, + }) + } + }; + Ok(LightClientBootstrap { - header: header.into(), + header: LightClientHeaderMerge::new(block)?.into(), current_sync_committee: beacon_state.current_sync_committee()?.clone(), current_sync_committee_branch: FixedVector::new(current_sync_committee_branch)?, }) diff --git a/consensus/types/src/light_client_finality_update.rs b/consensus/types/src/light_client_finality_update.rs index 44cb8edbd13..5418b4e2483 100644 --- a/consensus/types/src/light_client_finality_update.rs +++ b/consensus/types/src/light_client_finality_update.rs @@ -2,8 +2,12 @@ use super::{ EthSpec, FixedVector, Hash256, SignedBeaconBlock, SignedBlindedBeaconBlock, Slot, SyncAggregate, }; use crate::{ - light_client_update::*, test_utils::TestRandom, BeaconState, ChainSpec, ForkName, - ForkVersionDeserialize, LightClientHeader, + light_client_header::{ + LightClientHeaderCapella, LightClientHeaderDeneb, LightClientHeaderMerge, + }, + light_client_update::*, + test_utils::TestRandom, + BeaconState, ChainSpec, ForkName, ForkVersionDeserialize, LightClientHeader, }; use serde::{Deserialize, Deserializer, Serialize}; use serde_json::Value; @@ -21,7 +25,6 @@ use tree_hash::TreeHash; Deserialize, Encode, Decode, - TestRandom, arbitrary::Arbitrary, )] #[serde(bound = "T: EthSpec")] @@ -41,41 +44,14 @@ pub struct LightClientFinalityUpdate { impl LightClientFinalityUpdate { pub fn new( - chain_spec: &ChainSpec, - beacon_state: &BeaconState, - block: &SignedBeaconBlock, - attested_state: &mut BeaconState, - finalized_block: &SignedBlindedBeaconBlock, + update: LightClientUpdate, ) -> Result { - let altair_fork_epoch = chain_spec - .altair_fork_epoch - .ok_or(Error::AltairForkNotActive)?; - if beacon_state.slot().epoch(T::slots_per_epoch()) < altair_fork_epoch { - return Err(Error::AltairForkNotActive); - } - - 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.update_tree_hash_cache()?; - // Build finalized header from finalized block - let finalized_header = finalized_block.message().block_header(); - - if finalized_header.tree_hash_root() != beacon_state.finalized_checkpoint().root { - return Err(Error::InvalidFinalizedBlock); - } - - let finality_branch = attested_state.compute_merkle_proof(FINALIZED_ROOT_INDEX)?; Ok(Self { - attested_header: attested_header.into(), - finalized_header: finalized_header.into(), - finality_branch: FixedVector::new(finality_branch)?, - sync_aggregate: sync_aggregate.clone(), - signature_slot: block.slot(), + attested_header: update.attested_header, + finalized_header: update.finalized_header, + finality_branch: update.finality_branch, + sync_aggregate: update.sync_aggregate, + signature_slot: update.signature_slot, }) } } diff --git a/consensus/types/src/light_client_header.rs b/consensus/types/src/light_client_header.rs index 2c5b1a79b05..a059cbda1b1 100644 --- a/consensus/types/src/light_client_header.rs +++ b/consensus/types/src/light_client_header.rs @@ -1,17 +1,18 @@ use crate::beacon_block_body::NUM_BEACON_BLOCK_BODY_HASH_TREE_ROOT_LEAVES; use crate::{light_client_update::*, BeaconBlockBody, ChainSpec}; use crate::{ - test_utils::TestRandom, EthSpec, ExecutionPayloadHeader, ExecutionPayloadHeaderCapella, ExecutionPayloadHeaderDeneb, FixedVector, Hash256, - SignedBeaconBlock, + test_utils::TestRandom, EthSpec, ExecutionPayloadHeader, ExecutionPayloadHeaderCapella, + ExecutionPayloadHeaderDeneb, FixedVector, Hash256, SignedBeaconBlock, }; use crate::{BeaconBlockHeader, ExecutionPayload}; use merkle_proof::verify_merkle_proof; use serde::{Deserialize, Serialize}; +use ssz::Encode; use ssz_derive::{Decode, Encode}; +use std::marker::PhantomData; +use superstruct::superstruct; use test_random_derive::TestRandom; use tree_hash::TreeHash; -use superstruct::superstruct; -use std::marker::PhantomData; #[superstruct( variants(Merge, Capella, Deneb), @@ -30,11 +31,9 @@ use std::marker::PhantomData; ), serde(bound = "E: EthSpec", deny_unknown_fields), arbitrary(bound = "E: EthSpec"), - ), -)] -#[derive( - Debug, Clone, Serialize, PartialEq, Deserialize, Encode, Decode, arbitrary::Arbitrary, + ) )] +#[derive(Debug, Clone, Serialize, PartialEq, Deserialize, Encode, Decode, arbitrary::Arbitrary)] #[arbitrary(bound = "E: EthSpec")] #[serde(untagged)] #[serde(bound = "E: EthSpec")] @@ -48,131 +47,115 @@ pub struct LightClientHeader { partial_getter(rename = "execution_payload_header_capella") )] pub execution: ExecutionPayloadHeaderCapella, - #[superstruct( - only(Deneb), - partial_getter(rename = "execution_payload_header_deneb") - )] + #[superstruct(only(Deneb), partial_getter(rename = "execution_payload_header_deneb"))] pub execution: ExecutionPayloadHeaderDeneb, - + #[ssz(skip_serializing, skip_deserializing)] pub phantom_data: PhantomData, } -impl From for LightClientHeaderMerge { - fn from(beacon: BeaconBlockHeader) -> Self { - LightClientHeaderMerge { - beacon, - } +impl LightClientHeaderMerge { + pub fn new(block: SignedBeaconBlock) -> Result { + Ok(LightClientHeaderMerge { + beacon: block.message().block_header(), + phantom_data: PhantomData, + }) } -} -impl LightClientHeader { - fn new(chain_spec: ChainSpec, block: SignedBeaconBlock) -> Result { - let current_epoch = block.slot().epoch(E::slots_per_epoch()); - - if let Some(deneb_fork_epoch) = chain_spec.deneb_fork_epoch { - if current_epoch >= deneb_fork_epoch { - let payload: ExecutionPayload = block - .message() - .execution_payload()? - .execution_payload_deneb()? - .to_owned() - .into(); - - let header = ExecutionPayloadHeader::from(payload.to_ref()); - let mut beacon_block_body = BeaconBlockBody::from( - block - .message() - .body_deneb() - .map_err(|_| Error::BeaconBlockBodyError)? - .to_owned(), - ); - let execution_branch = - beacon_block_body.compute_merkle_proof(EXECUTION_PAYLOAD_INDEX)?; - - return Ok(LightClientHeader { - beacon: block.message().block_header(), - execution: Some(header), - execution_branch: Some(FixedVector::new(execution_branch)?), - }); - } - }; + fn get_lc_execution_root(&self) -> Option { + return None; + } - if let Some(capella_fork_epoch) = chain_spec.capella_fork_epoch { - if current_epoch >= capella_fork_epoch { - let payload: ExecutionPayload = block - .message() - .execution_payload()? - .execution_payload_capella()? - .to_owned() - .into(); - - let header = ExecutionPayloadHeader::from(payload.to_ref()); - let mut beacon_block_body = BeaconBlockBody::from( - block - .message() - .body_capella() - .map_err(|_| Error::BeaconBlockBodyError)? - .to_owned(), - ); - let execution_branch = - beacon_block_body.compute_merkle_proof(EXECUTION_PAYLOAD_INDEX)?; - - return Ok(LightClientHeader { - beacon: block.message().block_header(), - execution: Some(header), - execution_branch: Some(FixedVector::new(execution_branch)?), - }); - } - }; + fn is_valid_light_client_header(&self) -> Result { + return Ok(true); + } +} - Ok(LightClientHeader { +impl LightClientHeaderCapella { + pub fn new(block: SignedBeaconBlock) -> Result { + let payload = block + .message() + .execution_payload()? + .execution_payload_capella()? + .to_owned(); + + let header = ExecutionPayloadHeaderCapella::from(&payload); + let mut beacon_block_body = BeaconBlockBody::from( + block + .message() + .body_capella() + .map_err(|_| Error::BeaconBlockBodyError)? + .to_owned(), + ); + + let execution_branch = beacon_block_body.compute_merkle_proof(EXECUTION_PAYLOAD_INDEX)?; + + return Ok(LightClientHeaderCapella { beacon: block.message().block_header(), - execution: None, - execution_branch: None, - }) + execution: header, + execution_branch: FixedVector::new(execution_branch)?, + phantom_data: PhantomData, + }); } - fn get_lc_execution_root(&self, chain_spec: ChainSpec) -> Option { - let current_epoch = self.beacon.slot.epoch(E::slots_per_epoch()); - - if let Some(capella_fork_epoch) = chain_spec.capella_fork_epoch { - if current_epoch >= capella_fork_epoch { - if let Some(execution) = &self.execution { - return Some(execution.tree_hash_root()); - } - } - } - - None + fn get_lc_execution_root(&self) -> Option { + return Some(self.execution.tree_hash_root()); } - fn is_valid_light_client_header(&self, chain_spec: ChainSpec) -> Result { - let current_epoch = self.beacon.slot.epoch(E::slots_per_epoch()); + fn is_valid_light_client_header(&self) -> Result { + let Some(execution_root) = self.get_lc_execution_root() else { + return Ok(false); + }; - if let Some(capella_fork_epoch) = chain_spec.capella_fork_epoch { - if current_epoch < capella_fork_epoch { - return Ok(self.execution.is_none() && self.execution_branch.is_none()); - } - } + let Some(field_index) = + EXECUTION_PAYLOAD_INDEX.checked_sub(NUM_BEACON_BLOCK_BODY_HASH_TREE_ROOT_LEAVES) + else { + return Ok(false); + }; - if let Some(deneb_fork_epoch) = chain_spec.deneb_fork_epoch { - if current_epoch < deneb_fork_epoch { - let Some(execution) = &self.execution else { - return Ok(false); - }; + Ok(verify_merkle_proof( + execution_root, + &self.execution_branch, + EXECUTION_PAYLOAD_PROOF_LEN, + field_index, + self.beacon.body_root, + )) + } +} - if *execution.blob_gas_used()? != 0_u64 || *execution.excess_blob_gas()? != 0_u64 { - return Ok(false); - } - } - } +impl LightClientHeaderDeneb { + pub fn new(block: SignedBeaconBlock) -> Result { + let payload = block + .message() + .execution_payload()? + .execution_payload_deneb()? + .to_owned(); + + let header = ExecutionPayloadHeaderDeneb::from(&payload); + let mut beacon_block_body = BeaconBlockBody::from( + block + .message() + .body_deneb() + .map_err(|_| Error::BeaconBlockBodyError)? + .to_owned(), + ); + + let execution_branch = beacon_block_body.compute_merkle_proof(EXECUTION_PAYLOAD_INDEX)?; + + Ok(LightClientHeaderDeneb { + beacon: block.message().block_header(), + execution: header, + execution_branch: FixedVector::new(execution_branch)?, + phantom_data: PhantomData, + }) + } - let Some(execution_root) = self.get_lc_execution_root(chain_spec) else { - return Ok(false); - }; + fn get_lc_execution_root(&self) -> Option { + return Some(self.execution.tree_hash_root()); + } - let Some(execution_branch) = &self.execution_branch else { + fn is_valid_light_client_header(&self) -> Result { + let Some(execution_root) = self.get_lc_execution_root() else { return Ok(false); }; @@ -184,7 +167,7 @@ impl LightClientHeader { Ok(verify_merkle_proof( execution_root, - execution_branch, + &self.execution_branch, EXECUTION_PAYLOAD_PROOF_LEN, field_index, self.beacon.body_root, diff --git a/consensus/types/src/light_client_optimistic_update.rs b/consensus/types/src/light_client_optimistic_update.rs index 39b3619d05a..dc6930f4acb 100644 --- a/consensus/types/src/light_client_optimistic_update.rs +++ b/consensus/types/src/light_client_optimistic_update.rs @@ -1,4 +1,5 @@ use super::{EthSpec, ForkName, ForkVersionDeserialize, Slot, SyncAggregate}; +use crate::LightClientUpdate; use crate::light_client_header::LightClientHeader; use crate::{ light_client_update::Error, test_utils::TestRandom, BeaconState, ChainSpec, SignedBeaconBlock, @@ -35,29 +36,12 @@ pub struct LightClientOptimisticUpdate { impl LightClientOptimisticUpdate { pub fn new( - chain_spec: &ChainSpec, - block: &SignedBeaconBlock, - attested_state: &BeaconState, + update: LightClientUpdate, ) -> Result { - let altair_fork_epoch = chain_spec - .altair_fork_epoch - .ok_or(Error::AltairForkNotActive)?; - if attested_state.slot().epoch(T::slots_per_epoch()) < altair_fork_epoch { - return Err(Error::AltairForkNotActive); - } - - 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(); Ok(Self { - attested_header: attested_header.into(), - sync_aggregate: sync_aggregate.clone(), - signature_slot: block.slot(), + attested_header: update.attested_header, + sync_aggregate: update.sync_aggregate, + signature_slot: update.signature_slot, }) } } diff --git a/consensus/types/src/light_client_update.rs b/consensus/types/src/light_client_update.rs index 310f79def50..bd4704a119d 100644 --- a/consensus/types/src/light_client_update.rs +++ b/consensus/types/src/light_client_update.rs @@ -1,7 +1,7 @@ use super::{BeaconBlockHeader, EthSpec, FixedVector, Hash256, Slot, SyncAggregate, SyncCommittee}; use crate::{ beacon_state, test_utils::TestRandom, BeaconBlock, BeaconState, ChainSpec, ForkName, - ForkVersionDeserialize, LightClientHeader, + ForkVersionDeserialize, LightClientHeader, SignedBeaconBlock, light_client_header::{LightClientHeaderDeneb, LightClientHeaderCapella, LightClientHeaderMerge}, }; use safe_arith::ArithError; use serde::{Deserialize, Deserializer, Serialize}; @@ -97,7 +97,8 @@ impl LightClientUpdate { beacon_state: BeaconState, block: BeaconBlock, attested_state: &mut BeaconState, - finalized_block: BeaconBlock, + attested_block: SignedBeaconBlock, + finalized_block: SignedBeaconBlock, ) -> Result { let altair_fork_epoch = chain_spec .altair_fork_epoch @@ -125,10 +126,10 @@ impl LightClientUpdate { // Build finalized header from finalized block let finalized_header = BeaconBlockHeader { slot: finalized_block.slot(), - proposer_index: finalized_block.proposer_index(), + proposer_index: finalized_block.message().proposer_index(), parent_root: finalized_block.parent_root(), state_root: finalized_block.state_root(), - body_root: finalized_block.body_root(), + body_root: finalized_block.message().body_root(), }; if finalized_header.tree_hash_root() != beacon_state.finalized_checkpoint().root { return Err(Error::InvalidFinalizedBlock); @@ -136,11 +137,40 @@ impl LightClientUpdate { 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)?; + + if let Some(deneb_fork_epoch) = chain_spec.deneb_fork_epoch { + if beacon_state.slot().epoch(T::slots_per_epoch()) >= deneb_fork_epoch { + return Ok(Self { + attested_header: LightClientHeaderDeneb::new(attested_block)?.into(), + next_sync_committee: attested_state.next_sync_committee()?.clone(), + next_sync_committee_branch: FixedVector::new(next_sync_committee_branch)?, + finalized_header: LightClientHeaderDeneb::new(finalized_block)?.into(), + finality_branch: FixedVector::new(finality_branch)?, + sync_aggregate: sync_aggregate.clone(), + signature_slot: block.slot(), + }) + } + }; + + if let Some(capella_fork_epoch) = chain_spec.capella_fork_epoch { + if beacon_state.slot().epoch(T::slots_per_epoch()) >= capella_fork_epoch { + return Ok(Self { + attested_header: LightClientHeaderCapella::new(attested_block)?.into(), + next_sync_committee: attested_state.next_sync_committee()?.clone(), + next_sync_committee_branch: FixedVector::new(next_sync_committee_branch)?, + finalized_header: LightClientHeaderCapella::new(finalized_block)?.into(), + finality_branch: FixedVector::new(finality_branch)?, + sync_aggregate: sync_aggregate.clone(), + signature_slot: block.slot(), + }) + } + }; + Ok(Self { - attested_header: attested_header.into(), + attested_header: LightClientHeaderMerge::new(attested_block)?.into(), next_sync_committee: attested_state.next_sync_committee()?.clone(), next_sync_committee_branch: FixedVector::new(next_sync_committee_branch)?, - finalized_header: finalized_header.into(), + finalized_header: LightClientHeaderMerge::new(finalized_block)?.into(), finality_branch: FixedVector::new(finality_branch)?, sync_aggregate: sync_aggregate.clone(), signature_slot: block.slot(), From 79eeefdd3d9d15bf42ca88b3946629e43a3ef5fe Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Sun, 3 Dec 2023 10:59:37 -0800 Subject: [PATCH 38/71] lint --- .../lighthouse_network/src/rpc/methods.rs | 2 +- consensus/types/src/light_client_bootstrap.rs | 28 +++++++---------- .../types/src/light_client_finality_update.rs | 30 +++---------------- consensus/types/src/light_client_header.rs | 23 ++++++++------ .../src/light_client_optimistic_update.rs | 24 +++------------ consensus/types/src/light_client_update.rs | 29 +++++++----------- 6 files changed, 44 insertions(+), 92 deletions(-) diff --git a/beacon_node/lighthouse_network/src/rpc/methods.rs b/beacon_node/lighthouse_network/src/rpc/methods.rs index 627c871c471..e468ec8531d 100644 --- a/beacon_node/lighthouse_network/src/rpc/methods.rs +++ b/beacon_node/lighthouse_network/src/rpc/methods.rs @@ -574,7 +574,7 @@ impl std::fmt::Display for RPCResponse { write!( f, "LightClientBootstrap Slot: {}", - bootstrap.header.beacon.slot + bootstrap.header.beacon().slot ) } } diff --git a/consensus/types/src/light_client_bootstrap.rs b/consensus/types/src/light_client_bootstrap.rs index d28fc6931bc..5a69f18ce99 100644 --- a/consensus/types/src/light_client_bootstrap.rs +++ b/consensus/types/src/light_client_bootstrap.rs @@ -1,27 +1,19 @@ use super::{BeaconState, EthSpec, FixedVector, Hash256, SyncCommittee}; use crate::{ - light_client_update::*, test_utils::TestRandom, ForkName, ForkVersionDeserialize, - LightClientHeader, SignedBeaconBlock, ChainSpec, light_client_header::{LightClientHeaderDeneb, LightClientHeaderCapella, LightClientHeaderMerge}, + light_client_header::{ + LightClientHeaderCapella, LightClientHeaderDeneb, LightClientHeaderMerge, + }, + light_client_update::*, + ChainSpec, ForkName, ForkVersionDeserialize, LightClientHeader, SignedBeaconBlock, }; use serde::{Deserialize, Deserializer, Serialize}; use serde_json::Value; use ssz_derive::{Decode, Encode}; use std::sync::Arc; -use test_random_derive::TestRandom; /// A LightClientBootstrap is the initializer we send over to lightclient nodes /// that are trying to generate their basic storage when booting up. -#[derive( - Debug, - Clone, - PartialEq, - Serialize, - Deserialize, - Encode, - Decode, - TestRandom, - arbitrary::Arbitrary, -)] +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Encode, Decode, arbitrary::Arbitrary)] #[serde(bound = "T: EthSpec")] #[arbitrary(bound = "T: EthSpec")] pub struct LightClientBootstrap { @@ -45,22 +37,22 @@ impl LightClientBootstrap { beacon_state.compute_merkle_proof(CURRENT_SYNC_COMMITTEE_INDEX)?; if let Some(deneb_fork_epoch) = chain_spec.deneb_fork_epoch { - if beacon_state.slot().epoch(T::slots_per_epoch()) >= deneb_fork_epoch { + if beacon_state.slot().epoch(T::slots_per_epoch()) >= deneb_fork_epoch { return Ok(LightClientBootstrap { header: LightClientHeaderDeneb::new(block)?.into(), current_sync_committee: beacon_state.current_sync_committee()?.clone(), current_sync_committee_branch: FixedVector::new(current_sync_committee_branch)?, - }) + }); } }; if let Some(capella_fork_epoch) = chain_spec.capella_fork_epoch { - if beacon_state.slot().epoch(T::slots_per_epoch()) >= capella_fork_epoch { + if beacon_state.slot().epoch(T::slots_per_epoch()) >= capella_fork_epoch { return Ok(LightClientBootstrap { header: LightClientHeaderCapella::new(block)?.into(), current_sync_committee: beacon_state.current_sync_committee()?.clone(), current_sync_committee_branch: FixedVector::new(current_sync_committee_branch)?, - }) + }); } }; diff --git a/consensus/types/src/light_client_finality_update.rs b/consensus/types/src/light_client_finality_update.rs index 5418b4e2483..aebf9e84a04 100644 --- a/consensus/types/src/light_client_finality_update.rs +++ b/consensus/types/src/light_client_finality_update.rs @@ -1,32 +1,12 @@ -use super::{ - EthSpec, FixedVector, Hash256, SignedBeaconBlock, SignedBlindedBeaconBlock, Slot, SyncAggregate, -}; -use crate::{ - light_client_header::{ - LightClientHeaderCapella, LightClientHeaderDeneb, LightClientHeaderMerge, - }, - light_client_update::*, - test_utils::TestRandom, - BeaconState, ChainSpec, ForkName, ForkVersionDeserialize, LightClientHeader, -}; +use super::{EthSpec, FixedVector, Hash256, Slot, SyncAggregate}; +use crate::{light_client_update::*, ForkName, ForkVersionDeserialize, 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 LightClientFinalityUpdate is the update lightclient request or received by a gossip that /// signal a new finalized beacon block header for the light client sync protocol. -#[derive( - Debug, - Clone, - PartialEq, - Serialize, - Deserialize, - Encode, - Decode, - arbitrary::Arbitrary, -)] +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Encode, Decode, arbitrary::Arbitrary)] #[serde(bound = "T: EthSpec")] #[arbitrary(bound = "T: EthSpec")] pub struct LightClientFinalityUpdate { @@ -43,9 +23,7 @@ pub struct LightClientFinalityUpdate { } impl LightClientFinalityUpdate { - pub fn new( - update: LightClientUpdate, - ) -> Result { + pub fn new(update: LightClientUpdate) -> Result { Ok(Self { attested_header: update.attested_header, finalized_header: update.finalized_header, diff --git a/consensus/types/src/light_client_header.rs b/consensus/types/src/light_client_header.rs index a059cbda1b1..2cb3067e572 100644 --- a/consensus/types/src/light_client_header.rs +++ b/consensus/types/src/light_client_header.rs @@ -1,13 +1,12 @@ use crate::beacon_block_body::NUM_BEACON_BLOCK_BODY_HASH_TREE_ROOT_LEAVES; -use crate::{light_client_update::*, BeaconBlockBody, ChainSpec}; +use crate::BeaconBlockHeader; +use crate::{light_client_update::*, BeaconBlockBody}; use crate::{ - test_utils::TestRandom, EthSpec, ExecutionPayloadHeader, ExecutionPayloadHeaderCapella, - ExecutionPayloadHeaderDeneb, FixedVector, Hash256, SignedBeaconBlock, + test_utils::TestRandom, EthSpec, ExecutionPayloadHeaderCapella, ExecutionPayloadHeaderDeneb, + FixedVector, Hash256, SignedBeaconBlock, }; -use crate::{BeaconBlockHeader, ExecutionPayload}; use merkle_proof::verify_merkle_proof; use serde::{Deserialize, Serialize}; -use ssz::Encode; use ssz_derive::{Decode, Encode}; use std::marker::PhantomData; use superstruct::superstruct; @@ -62,12 +61,14 @@ impl LightClientHeaderMerge { }) } + #[allow(dead_code)] fn get_lc_execution_root(&self) -> Option { - return None; + None } + #[allow(dead_code)] fn is_valid_light_client_header(&self) -> Result { - return Ok(true); + Ok(true) } } @@ -98,10 +99,12 @@ impl LightClientHeaderCapella { }); } + #[allow(dead_code)] fn get_lc_execution_root(&self) -> Option { - return Some(self.execution.tree_hash_root()); + Some(self.execution.tree_hash_root()) } + #[allow(dead_code)] fn is_valid_light_client_header(&self) -> Result { let Some(execution_root) = self.get_lc_execution_root() else { return Ok(false); @@ -150,10 +153,12 @@ impl LightClientHeaderDeneb { }) } + #[allow(dead_code)] fn get_lc_execution_root(&self) -> Option { - return Some(self.execution.tree_hash_root()); + Some(self.execution.tree_hash_root()) } + #[allow(dead_code)] fn is_valid_light_client_header(&self) -> Result { let Some(execution_root) = self.get_lc_execution_root() else { return Ok(false); diff --git a/consensus/types/src/light_client_optimistic_update.rs b/consensus/types/src/light_client_optimistic_update.rs index dc6930f4acb..9150422cf52 100644 --- a/consensus/types/src/light_client_optimistic_update.rs +++ b/consensus/types/src/light_client_optimistic_update.rs @@ -1,28 +1,14 @@ use super::{EthSpec, ForkName, ForkVersionDeserialize, Slot, SyncAggregate}; -use crate::LightClientUpdate; use crate::light_client_header::LightClientHeader; -use crate::{ - light_client_update::Error, test_utils::TestRandom, BeaconState, ChainSpec, SignedBeaconBlock, -}; +use crate::light_client_update::Error; +use crate::LightClientUpdate; 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. -#[derive( - Debug, - Clone, - PartialEq, - Serialize, - Deserialize, - Encode, - Decode, - TestRandom, - arbitrary::Arbitrary, -)] +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Encode, Decode, arbitrary::Arbitrary)] #[serde(bound = "T: EthSpec")] #[arbitrary(bound = "T: EthSpec")] pub struct LightClientOptimisticUpdate { @@ -35,9 +21,7 @@ pub struct LightClientOptimisticUpdate { } impl LightClientOptimisticUpdate { - pub fn new( - update: LightClientUpdate, - ) -> Result { + pub fn new(update: LightClientUpdate) -> Result { Ok(Self { attested_header: update.attested_header, sync_aggregate: update.sync_aggregate, diff --git a/consensus/types/src/light_client_update.rs b/consensus/types/src/light_client_update.rs index bd4704a119d..df41ab4b384 100644 --- a/consensus/types/src/light_client_update.rs +++ b/consensus/types/src/light_client_update.rs @@ -1,7 +1,11 @@ use super::{BeaconBlockHeader, EthSpec, FixedVector, Hash256, Slot, SyncAggregate, SyncCommittee}; use crate::{ - beacon_state, test_utils::TestRandom, BeaconBlock, BeaconState, ChainSpec, ForkName, - ForkVersionDeserialize, LightClientHeader, SignedBeaconBlock, light_client_header::{LightClientHeaderDeneb, LightClientHeaderCapella, LightClientHeaderMerge}, + beacon_state, + light_client_header::{ + LightClientHeaderCapella, LightClientHeaderDeneb, LightClientHeaderMerge, + }, + BeaconBlock, BeaconState, ChainSpec, ForkName, ForkVersionDeserialize, LightClientHeader, + SignedBeaconBlock, }; use safe_arith::ArithError; use serde::{Deserialize, Deserializer, Serialize}; @@ -9,7 +13,6 @@ use serde_json::Value; 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; @@ -61,17 +64,7 @@ impl From for Error { /// A LightClientUpdate is the update we request solely to either complete the bootstraping process, /// or to sync up to the last committee period, we need to have one ready for each ALTAIR period /// we go over, note: there is no need to keep all of the updates from [ALTAIR_PERIOD, CURRENT_PERIOD]. -#[derive( - Debug, - Clone, - PartialEq, - Serialize, - Deserialize, - Encode, - Decode, - TestRandom, - arbitrary::Arbitrary, -)] +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Encode, Decode, arbitrary::Arbitrary)] #[serde(bound = "T: EthSpec")] #[arbitrary(bound = "T: EthSpec")] pub struct LightClientUpdate { @@ -139,7 +132,7 @@ impl LightClientUpdate { let finality_branch = attested_state.compute_merkle_proof(FINALIZED_ROOT_INDEX)?; if let Some(deneb_fork_epoch) = chain_spec.deneb_fork_epoch { - if beacon_state.slot().epoch(T::slots_per_epoch()) >= deneb_fork_epoch { + if beacon_state.slot().epoch(T::slots_per_epoch()) >= deneb_fork_epoch { return Ok(Self { attested_header: LightClientHeaderDeneb::new(attested_block)?.into(), next_sync_committee: attested_state.next_sync_committee()?.clone(), @@ -148,12 +141,12 @@ impl LightClientUpdate { finality_branch: FixedVector::new(finality_branch)?, sync_aggregate: sync_aggregate.clone(), signature_slot: block.slot(), - }) + }); } }; if let Some(capella_fork_epoch) = chain_spec.capella_fork_epoch { - if beacon_state.slot().epoch(T::slots_per_epoch()) >= capella_fork_epoch { + if beacon_state.slot().epoch(T::slots_per_epoch()) >= capella_fork_epoch { return Ok(Self { attested_header: LightClientHeaderCapella::new(attested_block)?.into(), next_sync_committee: attested_state.next_sync_committee()?.clone(), @@ -162,7 +155,7 @@ impl LightClientUpdate { finality_branch: FixedVector::new(finality_branch)?, sync_aggregate: sync_aggregate.clone(), signature_slot: block.slot(), - }) + }); } }; From 17adb6a9b48f2e9631eaf1b7b9d08227b05a787d Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Sun, 3 Dec 2023 11:04:06 -0800 Subject: [PATCH 39/71] altair --- consensus/types/src/light_client_bootstrap.rs | 4 ++-- consensus/types/src/light_client_header.rs | 6 +++--- consensus/types/src/light_client_update.rs | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/consensus/types/src/light_client_bootstrap.rs b/consensus/types/src/light_client_bootstrap.rs index 5a69f18ce99..4e86e347dfd 100644 --- a/consensus/types/src/light_client_bootstrap.rs +++ b/consensus/types/src/light_client_bootstrap.rs @@ -1,7 +1,7 @@ use super::{BeaconState, EthSpec, FixedVector, Hash256, SyncCommittee}; use crate::{ light_client_header::{ - LightClientHeaderCapella, LightClientHeaderDeneb, LightClientHeaderMerge, + LightClientHeaderCapella, LightClientHeaderDeneb, LightClientHeaderAltair, }, light_client_update::*, ChainSpec, ForkName, ForkVersionDeserialize, LightClientHeader, SignedBeaconBlock, @@ -57,7 +57,7 @@ impl LightClientBootstrap { }; Ok(LightClientBootstrap { - header: LightClientHeaderMerge::new(block)?.into(), + header: LightClientHeaderAltair::new(block)?.into(), current_sync_committee: beacon_state.current_sync_committee()?.clone(), current_sync_committee_branch: FixedVector::new(current_sync_committee_branch)?, }) diff --git a/consensus/types/src/light_client_header.rs b/consensus/types/src/light_client_header.rs index 2cb3067e572..5f8b6698c2e 100644 --- a/consensus/types/src/light_client_header.rs +++ b/consensus/types/src/light_client_header.rs @@ -14,7 +14,7 @@ use test_random_derive::TestRandom; use tree_hash::TreeHash; #[superstruct( - variants(Merge, Capella, Deneb), + variants(Altair, Capella, Deneb), variant_attributes( derive( Default, @@ -53,9 +53,9 @@ pub struct LightClientHeader { pub phantom_data: PhantomData, } -impl LightClientHeaderMerge { +impl LightClientHeaderAltair { pub fn new(block: SignedBeaconBlock) -> Result { - Ok(LightClientHeaderMerge { + Ok(LightClientHeaderAltair { beacon: block.message().block_header(), phantom_data: PhantomData, }) diff --git a/consensus/types/src/light_client_update.rs b/consensus/types/src/light_client_update.rs index df41ab4b384..5f42c124832 100644 --- a/consensus/types/src/light_client_update.rs +++ b/consensus/types/src/light_client_update.rs @@ -2,7 +2,7 @@ use super::{BeaconBlockHeader, EthSpec, FixedVector, Hash256, Slot, SyncAggregat use crate::{ beacon_state, light_client_header::{ - LightClientHeaderCapella, LightClientHeaderDeneb, LightClientHeaderMerge, + LightClientHeaderCapella, LightClientHeaderDeneb, LightClientHeaderAltair, }, BeaconBlock, BeaconState, ChainSpec, ForkName, ForkVersionDeserialize, LightClientHeader, SignedBeaconBlock, @@ -160,10 +160,10 @@ impl LightClientUpdate { }; Ok(Self { - attested_header: LightClientHeaderMerge::new(attested_block)?.into(), + attested_header: LightClientHeaderAltair::new(attested_block)?.into(), next_sync_committee: attested_state.next_sync_committee()?.clone(), next_sync_committee_branch: FixedVector::new(next_sync_committee_branch)?, - finalized_header: LightClientHeaderMerge::new(finalized_block)?.into(), + finalized_header: LightClientHeaderAltair::new(finalized_block)?.into(), finality_branch: FixedVector::new(finality_branch)?, sync_aggregate: sync_aggregate.clone(), signature_slot: block.slot(), From 5ab7681e7f22a7d9f66b47a6ebeae2d7f30fd0f3 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Sun, 3 Dec 2023 11:06:42 -0800 Subject: [PATCH 40/71] update --- consensus/types/src/light_client_bootstrap.rs | 4 +-- consensus/types/src/light_client_header.rs | 6 ++-- consensus/types/src/light_client_update.rs | 30 ++++++++++++++----- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/consensus/types/src/light_client_bootstrap.rs b/consensus/types/src/light_client_bootstrap.rs index 4e86e347dfd..cd81b007eb6 100644 --- a/consensus/types/src/light_client_bootstrap.rs +++ b/consensus/types/src/light_client_bootstrap.rs @@ -1,7 +1,7 @@ use super::{BeaconState, EthSpec, FixedVector, Hash256, SyncCommittee}; use crate::{ light_client_header::{ - LightClientHeaderCapella, LightClientHeaderDeneb, LightClientHeaderAltair, + LightClientHeaderAltair, LightClientHeaderCapella, LightClientHeaderDeneb, }, light_client_update::*, ChainSpec, ForkName, ForkVersionDeserialize, LightClientHeader, SignedBeaconBlock, @@ -57,7 +57,7 @@ impl LightClientBootstrap { }; Ok(LightClientBootstrap { - header: LightClientHeaderAltair::new(block)?.into(), + header: LightClientHeaderAltair::block_to_light_client_header(block)?.into(), current_sync_committee: beacon_state.current_sync_committee()?.clone(), current_sync_committee_branch: FixedVector::new(current_sync_committee_branch)?, }) diff --git a/consensus/types/src/light_client_header.rs b/consensus/types/src/light_client_header.rs index 5f8b6698c2e..607fdcda077 100644 --- a/consensus/types/src/light_client_header.rs +++ b/consensus/types/src/light_client_header.rs @@ -54,7 +54,7 @@ pub struct LightClientHeader { } impl LightClientHeaderAltair { - pub fn new(block: SignedBeaconBlock) -> Result { + pub fn block_to_light_client_header(block: SignedBeaconBlock) -> Result { Ok(LightClientHeaderAltair { beacon: block.message().block_header(), phantom_data: PhantomData, @@ -73,7 +73,7 @@ impl LightClientHeaderAltair { } impl LightClientHeaderCapella { - pub fn new(block: SignedBeaconBlock) -> Result { + pub fn block_to_light_client_header(block: SignedBeaconBlock) -> Result { let payload = block .message() .execution_payload()? @@ -127,7 +127,7 @@ impl LightClientHeaderCapella { } impl LightClientHeaderDeneb { - pub fn new(block: SignedBeaconBlock) -> Result { + pub fn block_to_light_client_header(block: SignedBeaconBlock) -> Result { let payload = block .message() .execution_payload()? diff --git a/consensus/types/src/light_client_update.rs b/consensus/types/src/light_client_update.rs index 5f42c124832..4ab89b5652b 100644 --- a/consensus/types/src/light_client_update.rs +++ b/consensus/types/src/light_client_update.rs @@ -2,7 +2,7 @@ use super::{BeaconBlockHeader, EthSpec, FixedVector, Hash256, Slot, SyncAggregat use crate::{ beacon_state, light_client_header::{ - LightClientHeaderCapella, LightClientHeaderDeneb, LightClientHeaderAltair, + LightClientHeaderAltair, LightClientHeaderCapella, LightClientHeaderDeneb, }, BeaconBlock, BeaconState, ChainSpec, ForkName, ForkVersionDeserialize, LightClientHeader, SignedBeaconBlock, @@ -134,10 +134,16 @@ impl LightClientUpdate { if let Some(deneb_fork_epoch) = chain_spec.deneb_fork_epoch { if beacon_state.slot().epoch(T::slots_per_epoch()) >= deneb_fork_epoch { return Ok(Self { - attested_header: LightClientHeaderDeneb::new(attested_block)?.into(), + attested_header: LightClientHeaderDeneb::block_to_light_client_header( + attested_block, + )? + .into(), next_sync_committee: attested_state.next_sync_committee()?.clone(), next_sync_committee_branch: FixedVector::new(next_sync_committee_branch)?, - finalized_header: LightClientHeaderDeneb::new(finalized_block)?.into(), + finalized_header: LightClientHeaderDeneb::block_to_light_client_header( + finalized_block, + )? + .into(), finality_branch: FixedVector::new(finality_branch)?, sync_aggregate: sync_aggregate.clone(), signature_slot: block.slot(), @@ -148,10 +154,16 @@ impl LightClientUpdate { if let Some(capella_fork_epoch) = chain_spec.capella_fork_epoch { if beacon_state.slot().epoch(T::slots_per_epoch()) >= capella_fork_epoch { return Ok(Self { - attested_header: LightClientHeaderCapella::new(attested_block)?.into(), + attested_header: LightClientHeaderCapella::block_to_light_client_header( + attested_block, + )? + .into(), next_sync_committee: attested_state.next_sync_committee()?.clone(), next_sync_committee_branch: FixedVector::new(next_sync_committee_branch)?, - finalized_header: LightClientHeaderCapella::new(finalized_block)?.into(), + finalized_header: LightClientHeaderCapella::block_to_light_client_header( + finalized_block, + )? + .into(), finality_branch: FixedVector::new(finality_branch)?, sync_aggregate: sync_aggregate.clone(), signature_slot: block.slot(), @@ -160,10 +172,14 @@ impl LightClientUpdate { }; Ok(Self { - attested_header: LightClientHeaderAltair::new(attested_block)?.into(), + attested_header: LightClientHeaderAltair::block_to_light_client_header(attested_block)? + .into(), next_sync_committee: attested_state.next_sync_committee()?.clone(), next_sync_committee_branch: FixedVector::new(next_sync_committee_branch)?, - finalized_header: LightClientHeaderAltair::new(finalized_block)?.into(), + finalized_header: LightClientHeaderAltair::block_to_light_client_header( + finalized_block, + )? + .into(), finality_branch: FixedVector::new(finality_branch)?, sync_aggregate: sync_aggregate.clone(), signature_slot: block.slot(), From 74b0b6fcb9fb42f66af1e9864ba34ac0278c24bc Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Sun, 3 Dec 2023 11:07:05 -0800 Subject: [PATCH 41/71] update --- consensus/types/src/light_client_bootstrap.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/consensus/types/src/light_client_bootstrap.rs b/consensus/types/src/light_client_bootstrap.rs index cd81b007eb6..653c5819b05 100644 --- a/consensus/types/src/light_client_bootstrap.rs +++ b/consensus/types/src/light_client_bootstrap.rs @@ -39,7 +39,7 @@ impl LightClientBootstrap { if let Some(deneb_fork_epoch) = chain_spec.deneb_fork_epoch { if beacon_state.slot().epoch(T::slots_per_epoch()) >= deneb_fork_epoch { return Ok(LightClientBootstrap { - header: LightClientHeaderDeneb::new(block)?.into(), + header: LightClientHeaderDeneb::block_to_light_client_header(block)?.into(), current_sync_committee: beacon_state.current_sync_committee()?.clone(), current_sync_committee_branch: FixedVector::new(current_sync_committee_branch)?, }); @@ -49,7 +49,7 @@ impl LightClientBootstrap { if let Some(capella_fork_epoch) = chain_spec.capella_fork_epoch { if beacon_state.slot().epoch(T::slots_per_epoch()) >= capella_fork_epoch { return Ok(LightClientBootstrap { - header: LightClientHeaderCapella::new(block)?.into(), + header: LightClientHeaderCapella::block_to_light_client_header(block)?.into(), current_sync_committee: beacon_state.current_sync_committee()?.clone(), current_sync_committee_branch: FixedVector::new(current_sync_committee_branch)?, }); From 1879bfd5ce2560b0d61bac93e398fd760353e7db Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Sun, 3 Dec 2023 15:53:55 -0800 Subject: [PATCH 42/71] changes to light_client_optimistic_ and finality --- beacon_node/beacon_chain/src/beacon_chain.rs | 19 ++-- ...ght_client_finality_update_verification.rs | 28 ++++-- ...t_client_optimistic_update_verification.rs | 18 ++-- .../src/rpc/codec/ssz_snappy.rs | 2 +- .../lighthouse_network/src/rpc/methods.rs | 2 +- .../src/service/api_types.rs | 2 +- .../network_beacon_processor/rpc_methods.rs | 2 +- .../types/src/light_client_finality_update.rs | 89 +++++++++++++++++-- .../src/light_client_optimistic_update.rs | 63 +++++++++++-- 9 files changed, 186 insertions(+), 39 deletions(-) diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index 6b893d6967a..f26b2b91b12 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -6455,13 +6455,18 @@ impl BeaconChain { &self, block_root: &Hash256, ) -> Result, ForkName)>, Error> { - let Some((state_root, slot)) = self - .get_blinded_block(block_root)? - .map(|block| (block.state_root(), block.slot())) - else { + let runtime = tokio::runtime::Runtime::new().map_err(|_| Error::RuntimeShutdown)?; + + let Some(block) = runtime.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); }; @@ -6471,12 +6476,12 @@ impl BeaconChain { .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(&self.spec, &mut state, block) .map(|bootstrap| Some((bootstrap, fork_name))) .map_err(Error::LightClientError) } - ForkName::Base | ForkName::Capella | ForkName::Deneb => Err(Error::UnsupportedFork), + ForkName::Base => Err(Error::UnsupportedFork), } } } diff --git a/beacon_node/beacon_chain/src/light_client_finality_update_verification.rs b/beacon_node/beacon_chain/src/light_client_finality_update_verification.rs index 791d63ccfe5..2d0bac5d7f5 100644 --- a/beacon_node/beacon_chain/src/light_client_finality_update_verification.rs +++ b/beacon_node/beacon_chain/src/light_client_finality_update_verification.rs @@ -67,7 +67,8 @@ impl VerifiedLightClientFinalityUpdate { chain: &BeaconChain, seen_timestamp: Duration, ) -> Result { - let gossiped_finality_slot = light_client_finality_update.finalized_header.beacon.slot; + let runtime = tokio::runtime::Runtime::new().map_err(|_| Error::FailedConstructingUpdate)?; + let gossiped_finality_slot = light_client_finality_update.finalized_header.beacon().slot; let one_third_slot_duration = Duration::new(chain.spec.seconds_per_slot / 3, 0); let signature_slot = light_client_finality_update.signature_slot; let start_time = chain.slot_clock.start_of(signature_slot); @@ -76,19 +77,29 @@ impl VerifiedLightClientFinalityUpdate { let head = chain.canonical_head.cached_head(); let head_block = &head.snapshot.beacon_block; let attested_block_root = head_block.message().parent_root(); - let attested_block = chain - .get_blinded_block(&attested_block_root)? - .ok_or(Error::FailedConstructingUpdate)?; + + let attested_block = runtime.block_on( async { + chain + .get_block(&attested_block_root).await + } + )? + .ok_or(Error::FailedConstructingUpdate)?; + let mut attested_state = chain .get_state(&attested_block.state_root(), Some(attested_block.slot()))? .ok_or(Error::FailedConstructingUpdate)?; let finalized_block_root = attested_state.finalized_checkpoint().root; - let finalized_block = chain - .get_blinded_block(&finalized_block_root)? - .ok_or(Error::FailedConstructingUpdate)?; + + let finalized_block = runtime.block_on( async { + chain + .get_block(&finalized_block_root).await + } + )? + .ok_or(Error::FailedConstructingUpdate)?; + let latest_seen_finality_update_slot = match latest_seen_finality_update.as_ref() { - Some(update) => update.finalized_header.beacon.slot, + Some(update) => update.finalized_header.beacon().slot, None => Slot::new(0), }; @@ -116,6 +127,7 @@ impl VerifiedLightClientFinalityUpdate { head_state, head_block, &mut attested_state, + &attested_block, &finalized_block, )?; diff --git a/beacon_node/beacon_chain/src/light_client_optimistic_update_verification.rs b/beacon_node/beacon_chain/src/light_client_optimistic_update_verification.rs index 374cc9a7753..9400fd08078 100644 --- a/beacon_node/beacon_chain/src/light_client_optimistic_update_verification.rs +++ b/beacon_node/beacon_chain/src/light_client_optimistic_update_verification.rs @@ -71,7 +71,8 @@ impl VerifiedLightClientOptimisticUpdate { chain: &BeaconChain, seen_timestamp: Duration, ) -> Result { - let gossiped_optimistic_slot = light_client_optimistic_update.attested_header.beacon.slot; + let runtime = tokio::runtime::Runtime::new().map_err(|_| Error::FailedConstructingUpdate)?; + let gossiped_optimistic_slot = light_client_optimistic_update.attested_header.beacon().slot; let one_third_slot_duration = Duration::new(chain.spec.seconds_per_slot / 3, 0); let signature_slot = light_client_optimistic_update.signature_slot; let start_time = chain.slot_clock.start_of(signature_slot); @@ -80,15 +81,18 @@ impl VerifiedLightClientOptimisticUpdate { let head = chain.canonical_head.cached_head(); let head_block = &head.snapshot.beacon_block; let attested_block_root = head_block.message().parent_root(); - let attested_block = chain - .get_blinded_block(&attested_block_root)? - .ok_or(Error::FailedConstructingUpdate)?; + let attested_block = runtime.block_on( async { + chain + .get_block(&attested_block_root).await + } + )? + .ok_or(Error::FailedConstructingUpdate)?; let attested_state = chain .get_state(&attested_block.state_root(), Some(attested_block.slot()))? .ok_or(Error::FailedConstructingUpdate)?; let latest_seen_optimistic_update_slot = match latest_seen_optimistic_update.as_ref() { - Some(update) => update.attested_header.beacon.slot, + Some(update) => update.attested_header.beacon().slot, None => Slot::new(0), }; @@ -114,7 +118,7 @@ impl VerifiedLightClientOptimisticUpdate { // otherwise queue let canonical_root = light_client_optimistic_update .attested_header - .beacon + .beacon() .canonical_root(); if canonical_root != head_block.message().parent_root() { @@ -122,7 +126,7 @@ impl VerifiedLightClientOptimisticUpdate { } let optimistic_update = - LightClientOptimisticUpdate::new(&chain.spec, head_block, &attested_state)?; + LightClientOptimisticUpdate::new(&chain.spec, head_block, &attested_state, attested_block)?; // verify that the gossiped optimistic update is the same as the locally constructed one. if optimistic_update != light_client_optimistic_update { diff --git a/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs b/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs index 787c3dcb7a5..6e58c281a00 100644 --- a/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs +++ b/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs @@ -576,7 +576,7 @@ fn handle_rpc_response( MetaDataV1::from_ssz_bytes(decoded_buffer)?, )))), SupportedProtocol::LightClientBootstrapV1 => Ok(Some(RPCResponse::LightClientBootstrap( - LightClientBootstrap::from_ssz_bytes(decoded_buffer)?, + Arc::new(LightClientBootstrap::from_ssz_bytes(decoded_buffer)?), ))), // MetaData V2 responses have no context bytes, so behave similarly to V1 responses SupportedProtocol::MetaDataV2 => Ok(Some(RPCResponse::MetaData(MetaData::V2( diff --git a/beacon_node/lighthouse_network/src/rpc/methods.rs b/beacon_node/lighthouse_network/src/rpc/methods.rs index e468ec8531d..52ea1e32a12 100644 --- a/beacon_node/lighthouse_network/src/rpc/methods.rs +++ b/beacon_node/lighthouse_network/src/rpc/methods.rs @@ -390,7 +390,7 @@ pub enum RPCResponse { BlobsByRange(Arc>), /// A response to a get LIGHTCLIENT_BOOTSTRAP request. - LightClientBootstrap(LightClientBootstrap), + LightClientBootstrap(Arc>), /// A response to a get BLOBS_BY_ROOT request. BlobsByRoot(Arc>), diff --git a/beacon_node/lighthouse_network/src/service/api_types.rs b/beacon_node/lighthouse_network/src/service/api_types.rs index 96c9d283327..1a16e4c70be 100644 --- a/beacon_node/lighthouse_network/src/service/api_types.rs +++ b/beacon_node/lighthouse_network/src/service/api_types.rs @@ -93,7 +93,7 @@ pub enum Response { /// A response to a get BLOBS_BY_ROOT request. BlobsByRoot(Option>>), /// A response to a LightClientUpdate request. - LightClientBootstrap(LightClientBootstrap), + LightClientBootstrap(Arc>), } impl std::convert::From> for RPCCodedResponse { diff --git a/beacon_node/network/src/network_beacon_processor/rpc_methods.rs b/beacon_node/network/src/network_beacon_processor/rpc_methods.rs index 430e0571b7e..a4c23d25ee5 100644 --- a/beacon_node/network/src/network_beacon_processor/rpc_methods.rs +++ b/beacon_node/network/src/network_beacon_processor/rpc_methods.rs @@ -305,7 +305,7 @@ impl NetworkBeaconProcessor { match self.chain.get_light_client_bootstrap(&block_root) { Ok(Some((bootstrap, _))) => self.send_response( peer_id, - Response::LightClientBootstrap(bootstrap), + Response::LightClientBootstrap(Arc::new(bootstrap)), request_id, ), Ok(None) => self.send_error_response( diff --git a/consensus/types/src/light_client_finality_update.rs b/consensus/types/src/light_client_finality_update.rs index aebf9e84a04..032058eba49 100644 --- a/consensus/types/src/light_client_finality_update.rs +++ b/consensus/types/src/light_client_finality_update.rs @@ -1,8 +1,9 @@ use super::{EthSpec, FixedVector, Hash256, Slot, SyncAggregate}; -use crate::{light_client_update::*, ForkName, ForkVersionDeserialize, LightClientHeader}; +use crate::{light_client_update::*, ForkName, ForkVersionDeserialize, LightClientHeader, ChainSpec, BeaconState, SignedBeaconBlock, light_client_header::{LightClientHeaderDeneb, LightClientHeaderCapella, LightClientHeaderAltair}}; use serde::{Deserialize, Deserializer, Serialize}; use serde_json::Value; use ssz_derive::{Decode, Encode}; +use tree_hash::TreeHash; /// A LightClientFinalityUpdate is the update lightclient request or received by a gossip that /// signal a new finalized beacon block header for the light client sync protocol. @@ -23,13 +24,87 @@ pub struct LightClientFinalityUpdate { } impl LightClientFinalityUpdate { - pub fn new(update: LightClientUpdate) -> Result { + pub fn new( + chain_spec: &ChainSpec, + beacon_state: &BeaconState, + block: &SignedBeaconBlock, + attested_state: &mut BeaconState, + attested_block: &SignedBeaconBlock, + finalized_block: &SignedBeaconBlock + ) -> Result { + let altair_fork_epoch = chain_spec + .altair_fork_epoch + .ok_or(Error::AltairForkNotActive)?; + + if beacon_state.slot().epoch(T::slots_per_epoch()) < altair_fork_epoch { + return Err(Error::AltairForkNotActive); + } + + 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.update_tree_hash_cache()?; + // Build finalized header from finalized block + let finalized_header = finalized_block.message().block_header(); + + if finalized_header.tree_hash_root() != beacon_state.finalized_checkpoint().root { + return Err(Error::InvalidFinalizedBlock); + } + + let finality_branch = attested_state.compute_merkle_proof(FINALIZED_ROOT_INDEX)?; + + if let Some(deneb_fork_epoch) = chain_spec.deneb_fork_epoch { + if attested_state.slot().epoch(T::slots_per_epoch()) >= deneb_fork_epoch { + return Ok(Self { + attested_header: LightClientHeaderDeneb::block_to_light_client_header( + attested_block.to_owned(), + )? + .into(), + finalized_header: LightClientHeaderDeneb::block_to_light_client_header( + finalized_block.to_owned(), + )? + .into(), + finality_branch: FixedVector::new(finality_branch)?, + sync_aggregate: sync_aggregate.clone(), + signature_slot: block.slot(), + }) + } + } + + if let Some(capella_fork_epoch) = chain_spec.capella_fork_epoch { + if attested_state.slot().epoch(T::slots_per_epoch()) >= capella_fork_epoch { + return Ok(Self { + attested_header: LightClientHeaderCapella::block_to_light_client_header( + attested_block.to_owned(), + )? + .into(), + finalized_header: LightClientHeaderCapella::block_to_light_client_header( + finalized_block.to_owned(), + )? + .into(), + finality_branch: FixedVector::new(finality_branch)?, + sync_aggregate: sync_aggregate.clone(), + signature_slot: block.slot(), + }) + } + } + Ok(Self { - attested_header: update.attested_header, - finalized_header: update.finalized_header, - finality_branch: update.finality_branch, - sync_aggregate: update.sync_aggregate, - signature_slot: update.signature_slot, + attested_header: LightClientHeaderAltair::block_to_light_client_header( + attested_block.to_owned(), + )? + .into(), + finalized_header: LightClientHeaderAltair::block_to_light_client_header( + finalized_block.to_owned(), + )? + .into(), + finality_branch: FixedVector::new(finality_branch)?, + sync_aggregate: sync_aggregate.clone(), + signature_slot: block.slot(), }) } } diff --git a/consensus/types/src/light_client_optimistic_update.rs b/consensus/types/src/light_client_optimistic_update.rs index 9150422cf52..3458eb103c0 100644 --- a/consensus/types/src/light_client_optimistic_update.rs +++ b/consensus/types/src/light_client_optimistic_update.rs @@ -1,10 +1,12 @@ use super::{EthSpec, ForkName, ForkVersionDeserialize, Slot, SyncAggregate}; -use crate::light_client_header::LightClientHeader; +use crate::light_client_header::{LightClientHeaderDeneb, LightClientHeaderCapella, LightClientHeaderAltair}; +use crate::{light_client_header::LightClientHeader, ChainSpec}; use crate::light_client_update::Error; -use crate::LightClientUpdate; +use crate::{SignedBeaconBlock, BeaconState}; use serde::{Deserialize, Deserializer, Serialize}; use serde_json::Value; use ssz_derive::{Decode, Encode}; +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. @@ -21,11 +23,60 @@ pub struct LightClientOptimisticUpdate { } impl LightClientOptimisticUpdate { - pub fn new(update: LightClientUpdate) -> Result { + pub fn new( + chain_spec: &ChainSpec, + block: &SignedBeaconBlock, + attested_state: &BeaconState, + attested_block: SignedBeaconBlock, + ) -> Result { + let altair_fork_epoch = chain_spec + .altair_fork_epoch + .ok_or(Error::AltairForkNotActive)?; + if attested_state.slot().epoch(T::slots_per_epoch()) < altair_fork_epoch { + return Err(Error::AltairForkNotActive); + } + + 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(); + + if let Some(deneb_fork_epoch) = chain_spec.deneb_fork_epoch { + if attested_state.slot().epoch(T::slots_per_epoch()) >= deneb_fork_epoch { + return Ok(Self { + attested_header: LightClientHeaderDeneb::block_to_light_client_header( + attested_block, + )? + .into(), + sync_aggregate: sync_aggregate.clone(), + signature_slot: block.slot(), + }) + } + } + + if let Some(capella_fork_epoch) = chain_spec.capella_fork_epoch { + if attested_state.slot().epoch(T::slots_per_epoch()) >= capella_fork_epoch { + return Ok(Self { + attested_header: LightClientHeaderCapella::block_to_light_client_header( + attested_block, + )? + .into(), + sync_aggregate: sync_aggregate.clone(), + signature_slot: block.slot(), + }) + } + } Ok(Self { - attested_header: update.attested_header, - sync_aggregate: update.sync_aggregate, - signature_slot: update.signature_slot, + attested_header: LightClientHeaderAltair::block_to_light_client_header( + attested_block, + )? + .into(), + sync_aggregate: sync_aggregate.clone(), + signature_slot: block.slot(), }) } } From 1d10abe930a06961c9c5ed5a7c977269690a8043 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Mon, 11 Dec 2023 18:45:53 -0800 Subject: [PATCH 43/71] refactor --- beacon_node/beacon_chain/src/beacon_chain.rs | 8 +- ...ght_client_finality_update_verification.rs | 21 ++-- ...t_client_optimistic_update_verification.rs | 20 +-- consensus/types/src/light_client_bootstrap.rs | 28 ++--- .../types/src/light_client_finality_update.rs | 115 ++++++++++-------- .../src/light_client_optimistic_update.rs | 57 +++------ consensus/types/src/light_client_update.rs | 79 +++++------- 7 files changed, 144 insertions(+), 184 deletions(-) diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index 00a95e7a29c..f82b60ac10c 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -6530,13 +6530,9 @@ impl BeaconChain { &self, block_root: &Hash256, ) -> Result, ForkName)>, Error> { - let runtime = tokio::runtime::Runtime::new().map_err(|_| Error::RuntimeShutdown)?; + let runtime = tokio::runtime::Runtime::new().map_err(|_| Error::RuntimeShutdown)?; - let Some(block) = runtime.block_on( async { - self - .get_block(block_root).await - } - )? else { + let Some(block) = runtime.block_on(async { self.get_block(block_root).await })? else { return Ok(None); }; diff --git a/beacon_node/beacon_chain/src/light_client_finality_update_verification.rs b/beacon_node/beacon_chain/src/light_client_finality_update_verification.rs index 2d0bac5d7f5..4be047bbf34 100644 --- a/beacon_node/beacon_chain/src/light_client_finality_update_verification.rs +++ b/beacon_node/beacon_chain/src/light_client_finality_update_verification.rs @@ -67,7 +67,8 @@ impl VerifiedLightClientFinalityUpdate { chain: &BeaconChain, seen_timestamp: Duration, ) -> Result { - let runtime = tokio::runtime::Runtime::new().map_err(|_| Error::FailedConstructingUpdate)?; + let runtime = + tokio::runtime::Runtime::new().map_err(|_| Error::FailedConstructingUpdate)?; let gossiped_finality_slot = light_client_finality_update.finalized_header.beacon().slot; let one_third_slot_duration = Duration::new(chain.spec.seconds_per_slot / 3, 0); let signature_slot = light_client_finality_update.signature_slot; @@ -78,12 +79,9 @@ impl VerifiedLightClientFinalityUpdate { let head_block = &head.snapshot.beacon_block; let attested_block_root = head_block.message().parent_root(); - let attested_block = runtime.block_on( async { - chain - .get_block(&attested_block_root).await - } - )? - .ok_or(Error::FailedConstructingUpdate)?; + let attested_block = runtime + .block_on(async { chain.get_block(&attested_block_root).await })? + .ok_or(Error::FailedConstructingUpdate)?; let mut attested_state = chain .get_state(&attested_block.state_root(), Some(attested_block.slot()))? @@ -91,12 +89,9 @@ impl VerifiedLightClientFinalityUpdate { let finalized_block_root = attested_state.finalized_checkpoint().root; - let finalized_block = runtime.block_on( async { - chain - .get_block(&finalized_block_root).await - } - )? - .ok_or(Error::FailedConstructingUpdate)?; + let finalized_block = runtime + .block_on(async { chain.get_block(&finalized_block_root).await })? + .ok_or(Error::FailedConstructingUpdate)?; let latest_seen_finality_update_slot = match latest_seen_finality_update.as_ref() { Some(update) => update.finalized_header.beacon().slot, diff --git a/beacon_node/beacon_chain/src/light_client_optimistic_update_verification.rs b/beacon_node/beacon_chain/src/light_client_optimistic_update_verification.rs index 9400fd08078..cd72869a738 100644 --- a/beacon_node/beacon_chain/src/light_client_optimistic_update_verification.rs +++ b/beacon_node/beacon_chain/src/light_client_optimistic_update_verification.rs @@ -71,7 +71,8 @@ impl VerifiedLightClientOptimisticUpdate { chain: &BeaconChain, seen_timestamp: Duration, ) -> Result { - let runtime = tokio::runtime::Runtime::new().map_err(|_| Error::FailedConstructingUpdate)?; + let runtime = + tokio::runtime::Runtime::new().map_err(|_| Error::FailedConstructingUpdate)?; let gossiped_optimistic_slot = light_client_optimistic_update.attested_header.beacon().slot; let one_third_slot_duration = Duration::new(chain.spec.seconds_per_slot / 3, 0); let signature_slot = light_client_optimistic_update.signature_slot; @@ -81,12 +82,9 @@ impl VerifiedLightClientOptimisticUpdate { let head = chain.canonical_head.cached_head(); let head_block = &head.snapshot.beacon_block; let attested_block_root = head_block.message().parent_root(); - let attested_block = runtime.block_on( async { - chain - .get_block(&attested_block_root).await - } - )? - .ok_or(Error::FailedConstructingUpdate)?; + let attested_block = runtime + .block_on(async { chain.get_block(&attested_block_root).await })? + .ok_or(Error::FailedConstructingUpdate)?; let attested_state = chain .get_state(&attested_block.state_root(), Some(attested_block.slot()))? @@ -125,8 +123,12 @@ impl VerifiedLightClientOptimisticUpdate { return Err(Error::UnknownBlockParentRoot(canonical_root)); } - let optimistic_update = - LightClientOptimisticUpdate::new(&chain.spec, head_block, &attested_state, attested_block)?; + let optimistic_update = LightClientOptimisticUpdate::new( + &chain.spec, + head_block, + &attested_state, + attested_block, + )?; // verify that the gossiped optimistic update is the same as the locally constructed one. if optimistic_update != light_client_optimistic_update { diff --git a/consensus/types/src/light_client_bootstrap.rs b/consensus/types/src/light_client_bootstrap.rs index 653c5819b05..42d4e364d59 100644 --- a/consensus/types/src/light_client_bootstrap.rs +++ b/consensus/types/src/light_client_bootstrap.rs @@ -36,28 +36,22 @@ impl LightClientBootstrap { let current_sync_committee_branch = beacon_state.compute_merkle_proof(CURRENT_SYNC_COMMITTEE_INDEX)?; - if let Some(deneb_fork_epoch) = chain_spec.deneb_fork_epoch { - if beacon_state.slot().epoch(T::slots_per_epoch()) >= deneb_fork_epoch { - return Ok(LightClientBootstrap { - header: LightClientHeaderDeneb::block_to_light_client_header(block)?.into(), - current_sync_committee: beacon_state.current_sync_committee()?.clone(), - current_sync_committee_branch: FixedVector::new(current_sync_committee_branch)?, - }); + let header: LightClientHeader = match chain_spec + .fork_name_at_epoch(beacon_state.slot().epoch(T::slots_per_epoch())) + { + ForkName::Base => return Err(Error::AltairForkNotActive), + ForkName::Merge => return Err(Error::AltairForkNotActive), + ForkName::Altair => { + LightClientHeaderAltair::block_to_light_client_header(block)?.into() } - }; - - if let Some(capella_fork_epoch) = chain_spec.capella_fork_epoch { - if beacon_state.slot().epoch(T::slots_per_epoch()) >= capella_fork_epoch { - return Ok(LightClientBootstrap { - header: LightClientHeaderCapella::block_to_light_client_header(block)?.into(), - current_sync_committee: beacon_state.current_sync_committee()?.clone(), - current_sync_committee_branch: FixedVector::new(current_sync_committee_branch)?, - }); + ForkName::Capella => { + LightClientHeaderCapella::block_to_light_client_header(block)?.into() } + ForkName::Deneb => LightClientHeaderDeneb::block_to_light_client_header(block)?.into(), }; Ok(LightClientBootstrap { - header: LightClientHeaderAltair::block_to_light_client_header(block)?.into(), + header, current_sync_committee: beacon_state.current_sync_committee()?.clone(), current_sync_committee_branch: FixedVector::new(current_sync_committee_branch)?, }) diff --git a/consensus/types/src/light_client_finality_update.rs b/consensus/types/src/light_client_finality_update.rs index 032058eba49..64608980f8e 100644 --- a/consensus/types/src/light_client_finality_update.rs +++ b/consensus/types/src/light_client_finality_update.rs @@ -1,5 +1,11 @@ use super::{EthSpec, FixedVector, Hash256, Slot, SyncAggregate}; -use crate::{light_client_update::*, ForkName, ForkVersionDeserialize, LightClientHeader, ChainSpec, BeaconState, SignedBeaconBlock, light_client_header::{LightClientHeaderDeneb, LightClientHeaderCapella, LightClientHeaderAltair}}; +use crate::{ + light_client_header::{ + LightClientHeaderAltair, LightClientHeaderCapella, LightClientHeaderDeneb, + }, + light_client_update::*, + BeaconState, ChainSpec, ForkName, ForkVersionDeserialize, LightClientHeader, SignedBeaconBlock, +}; use serde::{Deserialize, Deserializer, Serialize}; use serde_json::Value; use ssz_derive::{Decode, Encode}; @@ -24,22 +30,14 @@ pub struct LightClientFinalityUpdate { } impl LightClientFinalityUpdate { - pub fn new( + pub fn new( chain_spec: &ChainSpec, beacon_state: &BeaconState, block: &SignedBeaconBlock, attested_state: &mut BeaconState, attested_block: &SignedBeaconBlock, - finalized_block: &SignedBeaconBlock + finalized_block: &SignedBeaconBlock, ) -> Result { - let altair_fork_epoch = chain_spec - .altair_fork_epoch - .ok_or(Error::AltairForkNotActive)?; - - if beacon_state.slot().epoch(T::slots_per_epoch()) < altair_fork_epoch { - return Err(Error::AltairForkNotActive); - } - 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); @@ -57,51 +55,60 @@ impl LightClientFinalityUpdate { let finality_branch = attested_state.compute_merkle_proof(FINALIZED_ROOT_INDEX)?; - if let Some(deneb_fork_epoch) = chain_spec.deneb_fork_epoch { - if attested_state.slot().epoch(T::slots_per_epoch()) >= deneb_fork_epoch { - return Ok(Self { - attested_header: LightClientHeaderDeneb::block_to_light_client_header( - attested_block.to_owned(), - )? - .into(), - finalized_header: LightClientHeaderDeneb::block_to_light_client_header( - finalized_block.to_owned(), - )? - .into(), - finality_branch: FixedVector::new(finality_branch)?, - sync_aggregate: sync_aggregate.clone(), - signature_slot: block.slot(), - }) - } - } + 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 => return Err(Error::AltairForkNotActive), + ForkName::Altair => { + let attested_header: LightClientHeader = + LightClientHeaderAltair::block_to_light_client_header( + attested_block.to_owned(), + )? + .into(); + + let finalized_header: LightClientHeader = + LightClientHeaderAltair::block_to_light_client_header( + finalized_block.to_owned(), + )? + .into(); + + (attested_header, finalized_header) + } + ForkName::Capella => { + let attested_header: LightClientHeader = + LightClientHeaderCapella::block_to_light_client_header( + attested_block.to_owned(), + )? + .into(); + + let finalized_header: LightClientHeader = + LightClientHeaderCapella::block_to_light_client_header( + finalized_block.to_owned(), + )? + .into(); + + (attested_header, finalized_header) + } + ForkName::Deneb => { + let attested_header: LightClientHeader = + LightClientHeaderDeneb::block_to_light_client_header( + attested_block.to_owned(), + )? + .into(); + + let finalized_header: LightClientHeader = + LightClientHeaderDeneb::block_to_light_client_header( + finalized_block.to_owned(), + )? + .into(); + + (attested_header, finalized_header) + } + }; - if let Some(capella_fork_epoch) = chain_spec.capella_fork_epoch { - if attested_state.slot().epoch(T::slots_per_epoch()) >= capella_fork_epoch { - return Ok(Self { - attested_header: LightClientHeaderCapella::block_to_light_client_header( - attested_block.to_owned(), - )? - .into(), - finalized_header: LightClientHeaderCapella::block_to_light_client_header( - finalized_block.to_owned(), - )? - .into(), - finality_branch: FixedVector::new(finality_branch)?, - sync_aggregate: sync_aggregate.clone(), - signature_slot: block.slot(), - }) - } - } - Ok(Self { - attested_header: LightClientHeaderAltair::block_to_light_client_header( - attested_block.to_owned(), - )? - .into(), - finalized_header: LightClientHeaderAltair::block_to_light_client_header( - finalized_block.to_owned(), - )? - .into(), + attested_header, + finalized_header, finality_branch: FixedVector::new(finality_branch)?, sync_aggregate: sync_aggregate.clone(), signature_slot: block.slot(), diff --git a/consensus/types/src/light_client_optimistic_update.rs b/consensus/types/src/light_client_optimistic_update.rs index 3458eb103c0..4e905b85412 100644 --- a/consensus/types/src/light_client_optimistic_update.rs +++ b/consensus/types/src/light_client_optimistic_update.rs @@ -1,8 +1,10 @@ use super::{EthSpec, ForkName, ForkVersionDeserialize, Slot, SyncAggregate}; -use crate::light_client_header::{LightClientHeaderDeneb, LightClientHeaderCapella, LightClientHeaderAltair}; -use crate::{light_client_header::LightClientHeader, ChainSpec}; +use crate::light_client_header::{ + LightClientHeaderAltair, LightClientHeaderCapella, LightClientHeaderDeneb, +}; use crate::light_client_update::Error; -use crate::{SignedBeaconBlock, BeaconState}; +use crate::{light_client_header::LightClientHeader, ChainSpec}; +use crate::{BeaconState, SignedBeaconBlock}; use serde::{Deserialize, Deserializer, Serialize}; use serde_json::Value; use ssz_derive::{Decode, Encode}; @@ -29,13 +31,6 @@ impl LightClientOptimisticUpdate { attested_state: &BeaconState, attested_block: SignedBeaconBlock, ) -> Result { - let altair_fork_epoch = chain_spec - .altair_fork_epoch - .ok_or(Error::AltairForkNotActive)?; - if attested_state.slot().epoch(T::slots_per_epoch()) < altair_fork_epoch { - return Err(Error::AltairForkNotActive); - } - 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); @@ -45,36 +40,24 @@ impl LightClientOptimisticUpdate { let mut attested_header = attested_state.latest_block_header().clone(); attested_header.state_root = attested_state.tree_hash_root(); - if let Some(deneb_fork_epoch) = chain_spec.deneb_fork_epoch { - if attested_state.slot().epoch(T::slots_per_epoch()) >= deneb_fork_epoch { - return Ok(Self { - attested_header: LightClientHeaderDeneb::block_to_light_client_header( - attested_block, - )? - .into(), - sync_aggregate: sync_aggregate.clone(), - signature_slot: block.slot(), - }) + let attested_header: LightClientHeader = match chain_spec + .fork_name_at_epoch(attested_state.slot().epoch(T::slots_per_epoch())) + { + ForkName::Base => return Err(Error::AltairForkNotActive), + ForkName::Merge => return Err(Error::AltairForkNotActive), + ForkName::Altair => { + LightClientHeaderAltair::block_to_light_client_header(attested_block)?.into() } - } - - if let Some(capella_fork_epoch) = chain_spec.capella_fork_epoch { - if attested_state.slot().epoch(T::slots_per_epoch()) >= capella_fork_epoch { - return Ok(Self { - attested_header: LightClientHeaderCapella::block_to_light_client_header( - attested_block, - )? - .into(), - sync_aggregate: sync_aggregate.clone(), - signature_slot: block.slot(), - }) + 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: LightClientHeaderAltair::block_to_light_client_header( - attested_block, - )? - .into(), + attested_header, sync_aggregate: sync_aggregate.clone(), signature_slot: block.slot(), }) diff --git a/consensus/types/src/light_client_update.rs b/consensus/types/src/light_client_update.rs index 4ab89b5652b..be0d091f4a3 100644 --- a/consensus/types/src/light_client_update.rs +++ b/consensus/types/src/light_client_update.rs @@ -93,13 +93,6 @@ impl LightClientUpdate { attested_block: SignedBeaconBlock, finalized_block: SignedBeaconBlock, ) -> Result { - let altair_fork_epoch = chain_spec - .altair_fork_epoch - .ok_or(Error::AltairForkNotActive)?; - if attested_state.slot().epoch(T::slots_per_epoch()) < altair_fork_epoch { - return Err(Error::AltairForkNotActive); - } - 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); @@ -131,55 +124,45 @@ impl LightClientUpdate { attested_state.compute_merkle_proof(NEXT_SYNC_COMMITTEE_INDEX)?; let finality_branch = attested_state.compute_merkle_proof(FINALIZED_ROOT_INDEX)?; - if let Some(deneb_fork_epoch) = chain_spec.deneb_fork_epoch { - if beacon_state.slot().epoch(T::slots_per_epoch()) >= deneb_fork_epoch { - return Ok(Self { - attested_header: LightClientHeaderDeneb::block_to_light_client_header( - attested_block, - )? - .into(), - next_sync_committee: attested_state.next_sync_committee()?.clone(), - next_sync_committee_branch: FixedVector::new(next_sync_committee_branch)?, - finalized_header: LightClientHeaderDeneb::block_to_light_client_header( - finalized_block, - )? - .into(), - finality_branch: FixedVector::new(finality_branch)?, - sync_aggregate: sync_aggregate.clone(), - signature_slot: block.slot(), - }); + 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 => return Err(Error::AltairForkNotActive), + ForkName::Altair => { + let attested_header: LightClientHeader = + LightClientHeaderAltair::block_to_light_client_header(attested_block)?.into(); + + let finalized_header: LightClientHeader = + LightClientHeaderAltair::block_to_light_client_header(finalized_block)?.into(); + + (attested_header, finalized_header) } - }; + ForkName::Capella => { + let attested_header: LightClientHeader = + LightClientHeaderCapella::block_to_light_client_header(attested_block)?.into(); + + let finalized_header: LightClientHeader = + LightClientHeaderCapella::block_to_light_client_header(finalized_block)?.into(); + + (attested_header, finalized_header) + } + ForkName::Deneb => { + let attested_header: LightClientHeader = + LightClientHeaderDeneb::block_to_light_client_header(attested_block)?.into(); + + let finalized_header: LightClientHeader = + LightClientHeaderDeneb::block_to_light_client_header(finalized_block)?.into(); - if let Some(capella_fork_epoch) = chain_spec.capella_fork_epoch { - if beacon_state.slot().epoch(T::slots_per_epoch()) >= capella_fork_epoch { - return Ok(Self { - attested_header: LightClientHeaderCapella::block_to_light_client_header( - attested_block, - )? - .into(), - next_sync_committee: attested_state.next_sync_committee()?.clone(), - next_sync_committee_branch: FixedVector::new(next_sync_committee_branch)?, - finalized_header: LightClientHeaderCapella::block_to_light_client_header( - finalized_block, - )? - .into(), - finality_branch: FixedVector::new(finality_branch)?, - sync_aggregate: sync_aggregate.clone(), - signature_slot: block.slot(), - }); + (attested_header, finalized_header) } }; Ok(Self { - attested_header: LightClientHeaderAltair::block_to_light_client_header(attested_block)? - .into(), + attested_header, next_sync_committee: attested_state.next_sync_committee()?.clone(), next_sync_committee_branch: FixedVector::new(next_sync_committee_branch)?, - finalized_header: LightClientHeaderAltair::block_to_light_client_header( - finalized_block, - )? - .into(), + finalized_header, finality_branch: FixedVector::new(finality_branch)?, sync_aggregate: sync_aggregate.clone(), signature_slot: block.slot(), From b75d23b4d0f29ffdbd351ed79a6b1020cb9ac668 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Thu, 1 Feb 2024 11:51:30 +0200 Subject: [PATCH 44/71] block_to_light_client_header fork aware --- beacon_node/beacon_chain/src/light_client_server_cache.rs | 5 +++-- consensus/types/src/light_client_header.rs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/beacon_node/beacon_chain/src/light_client_server_cache.rs b/beacon_node/beacon_chain/src/light_client_server_cache.rs index 0a7514a186d..b8ca5ca7fc4 100644 --- a/beacon_node/beacon_chain/src/light_client_server_cache.rs +++ b/beacon_node/beacon_chain/src/light_client_server_cache.rs @@ -12,6 +12,7 @@ use types::non_zero_usize::new_non_zero_usize; use types::{ BeaconBlockRef, BeaconState, ChainSpec, EthSpec, ForkName, Hash256, LightClientFinalityUpdate, LightClientHeader, LightClientOptimisticUpdate, SignedBeaconBlock, Slot, SyncAggregate, + light_client_update::Error as LightClientError }; /// A prev block cache miss requires to re-generate the state of the post-parent block. Items in the @@ -259,8 +260,8 @@ fn block_to_light_client_header( block: SignedBeaconBlock, ) -> Result, BeaconChainError> { let light_client_header = match fork_name { - ForkName::Base => todo!(), - ForkName::Merge => todo!(), + ForkName::Base => return Err(LightClientError::AltairForkNotActive.into()), + ForkName::Merge => return Err(LightClientError::AltairForkNotActive.into()), ForkName::Altair => LightClientHeaderAltair::block_to_light_client_header(block)?.into(), ForkName::Capella => LightClientHeaderCapella::block_to_light_client_header(block)?.into(), ForkName::Deneb => LightClientHeaderDeneb::block_to_light_client_header(block)?.into(), diff --git a/consensus/types/src/light_client_header.rs b/consensus/types/src/light_client_header.rs index 7a9f5ede142..1bc01cc43a8 100644 --- a/consensus/types/src/light_client_header.rs +++ b/consensus/types/src/light_client_header.rs @@ -26,7 +26,7 @@ use tree_hash::TreeHash; Encode, Decode, TestRandom, - arbitrary::Arbitrary + arbitrary::Arbitrary, ), serde(bound = "E: EthSpec", deny_unknown_fields), arbitrary(bound = "E: EthSpec"), From 5f75f25820f98a91e9b80a3ba3f017acfc29a7f9 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Thu, 1 Feb 2024 11:51:40 +0200 Subject: [PATCH 45/71] fmt --- beacon_node/beacon_chain/src/light_client_server_cache.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/beacon_node/beacon_chain/src/light_client_server_cache.rs b/beacon_node/beacon_chain/src/light_client_server_cache.rs index b8ca5ca7fc4..d2bfdbae670 100644 --- a/beacon_node/beacon_chain/src/light_client_server_cache.rs +++ b/beacon_node/beacon_chain/src/light_client_server_cache.rs @@ -10,9 +10,9 @@ use types::light_client_header::{ 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, SignedBeaconBlock, Slot, SyncAggregate, - light_client_update::Error as LightClientError + light_client_update::Error as LightClientError, BeaconBlockRef, BeaconState, ChainSpec, + EthSpec, ForkName, Hash256, LightClientFinalityUpdate, LightClientHeader, + LightClientOptimisticUpdate, SignedBeaconBlock, Slot, SyncAggregate, }; /// A prev block cache miss requires to re-generate the state of the post-parent block. Items in the From 96f89a25485d549de1cbfb8edfa0fcfa00498b8b Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Thu, 1 Feb 2024 12:32:41 +0200 Subject: [PATCH 46/71] comment fix --- beacon_node/beacon_chain/src/light_client_server_cache.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beacon_node/beacon_chain/src/light_client_server_cache.rs b/beacon_node/beacon_chain/src/light_client_server_cache.rs index d2bfdbae670..ce07ffc32de 100644 --- a/beacon_node/beacon_chain/src/light_client_server_cache.rs +++ b/beacon_node/beacon_chain/src/light_client_server_cache.rs @@ -239,7 +239,7 @@ fn is_latest_finality_update( } } -// 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 From 7a253bf1dc54910d2b87309f38da3aa2db99be2b Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Thu, 1 Feb 2024 12:33:16 +0200 Subject: [PATCH 47/71] comment fix --- beacon_node/beacon_chain/src/light_client_server_cache.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beacon_node/beacon_chain/src/light_client_server_cache.rs b/beacon_node/beacon_chain/src/light_client_server_cache.rs index ce07ffc32de..f3852d23796 100644 --- a/beacon_node/beacon_chain/src/light_client_server_cache.rs +++ b/beacon_node/beacon_chain/src/light_client_server_cache.rs @@ -223,7 +223,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 From 5808f7ccdb27159575fac138ff0e26a6cb279041 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Sat, 3 Feb 2024 17:42:16 +0200 Subject: [PATCH 48/71] include merge fork, update deserialize_by_fork, refactor --- .../src/light_client_server_cache.rs | 5 +- consensus/types/src/light_client_bootstrap.rs | 15 ++- .../types/src/light_client_finality_update.rs | 91 +++++++------------ .../src/light_client_optimistic_update.rs | 7 +- consensus/types/src/light_client_update.rs | 53 ++++------- 5 files changed, 61 insertions(+), 110 deletions(-) diff --git a/beacon_node/beacon_chain/src/light_client_server_cache.rs b/beacon_node/beacon_chain/src/light_client_server_cache.rs index f3852d23796..c503eaa6c13 100644 --- a/beacon_node/beacon_chain/src/light_client_server_cache.rs +++ b/beacon_node/beacon_chain/src/light_client_server_cache.rs @@ -261,8 +261,9 @@ fn block_to_light_client_header( ) -> Result, BeaconChainError> { let light_client_header = match fork_name { ForkName::Base => return Err(LightClientError::AltairForkNotActive.into()), - ForkName::Merge => return Err(LightClientError::AltairForkNotActive.into()), - ForkName::Altair => LightClientHeaderAltair::block_to_light_client_header(block)?.into(), + ForkName::Merge | ForkName::Altair => { + LightClientHeaderAltair::block_to_light_client_header(block)?.into() + } ForkName::Capella => LightClientHeaderCapella::block_to_light_client_header(block)?.into(), ForkName::Deneb => LightClientHeaderDeneb::block_to_light_client_header(block)?.into(), }; diff --git a/consensus/types/src/light_client_bootstrap.rs b/consensus/types/src/light_client_bootstrap.rs index e10ce4f7d2a..ec68ab7390b 100644 --- a/consensus/types/src/light_client_bootstrap.rs +++ b/consensus/types/src/light_client_bootstrap.rs @@ -40,8 +40,7 @@ impl LightClientBootstrap { .fork_name_at_epoch(beacon_state.slot().epoch(T::slots_per_epoch())) { ForkName::Base => return Err(Error::AltairForkNotActive), - ForkName::Merge => return Err(Error::AltairForkNotActive), - ForkName::Altair => { + ForkName::Altair | ForkName::Merge => { LightClientHeaderAltair::block_to_light_client_header(block)?.into() } ForkName::Capella => { @@ -64,16 +63,14 @@ impl ForkVersionDeserialize for LightClientBootstrap { fork_name: ForkName, ) -> Result { match fork_name { - ForkName::Altair | ForkName::Merge => { + ForkName::Altair | ForkName::Merge | ForkName::Capella | ForkName::Deneb => { Ok(serde_json::from_value::>(value) .map_err(serde::de::Error::custom))? } - ForkName::Base | ForkName::Capella | ForkName::Deneb => { - Err(serde::de::Error::custom(format!( - "LightClientBootstrap failed to deserialize: unsupported fork '{}'", - fork_name - ))) - } + ForkName::Base => Err(serde::de::Error::custom(format!( + "LightClientBootstrap failed to deserialize: unsupported fork '{}'", + fork_name + ))), } } } diff --git a/consensus/types/src/light_client_finality_update.rs b/consensus/types/src/light_client_finality_update.rs index f38f5e356d9..da9b1989ece 100644 --- a/consensus/types/src/light_client_finality_update.rs +++ b/consensus/types/src/light_client_finality_update.rs @@ -55,56 +55,29 @@ impl LightClientFinalityUpdate { 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 => return Err(Error::AltairForkNotActive), - ForkName::Altair => { - let attested_header: LightClientHeader = - LightClientHeaderAltair::block_to_light_client_header( - attested_block.to_owned(), - )? - .into(); - - let finalized_header: LightClientHeader = - LightClientHeaderAltair::block_to_light_client_header( - finalized_block.to_owned(), - )? - .into(); - - (attested_header, finalized_header) - } - ForkName::Capella => { - let attested_header: LightClientHeader = - LightClientHeaderCapella::block_to_light_client_header( - attested_block.to_owned(), - )? - .into(); - - let finalized_header: LightClientHeader = - LightClientHeaderCapella::block_to_light_client_header( - finalized_block.to_owned(), - )? - .into(); - - (attested_header, finalized_header) - } - ForkName::Deneb => { - let attested_header: LightClientHeader = - LightClientHeaderDeneb::block_to_light_client_header( - attested_block.to_owned(), - )? - .into(); - - let finalized_header: LightClientHeader = - LightClientHeaderDeneb::block_to_light_client_header( - finalized_block.to_owned(), - )? - .into(); - - (attested_header, finalized_header) - } - }; + 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::Altair | ForkName::Merge => ( + LightClientHeaderAltair::block_to_light_client_header(attested_block.to_owned())? + .into(), + LightClientHeaderAltair::block_to_light_client_header(finalized_block.to_owned())? + .into(), + ), + ForkName::Capella => ( + LightClientHeaderCapella::block_to_light_client_header(attested_block.to_owned())? + .into(), + LightClientHeaderCapella::block_to_light_client_header(finalized_block.to_owned())? + .into(), + ), + ForkName::Deneb => ( + LightClientHeaderDeneb::block_to_light_client_header(attested_block.to_owned())? + .into(), + LightClientHeaderDeneb::block_to_light_client_header(finalized_block.to_owned())? + .into(), + ), + }; Ok(Self { attested_header, @@ -122,16 +95,14 @@ impl ForkVersionDeserialize for LightClientFinalityUpdate { fork_name: ForkName, ) -> Result { match fork_name { - ForkName::Altair | ForkName::Merge => Ok(serde_json::from_value::< - LightClientFinalityUpdate, - >(value) - .map_err(serde::de::Error::custom))?, - ForkName::Base | ForkName::Capella | ForkName::Deneb => { - Err(serde::de::Error::custom(format!( - "LightClientFinalityUpdate failed to deserialize: unsupported fork '{}'", - fork_name - ))) - } + ForkName::Altair | ForkName::Merge | ForkName::Capella | ForkName::Deneb => Ok( + serde_json::from_value::>(value) + .map_err(serde::de::Error::custom), + )?, + ForkName::Base => Err(serde::de::Error::custom(format!( + "LightClientFinalityUpdate failed to deserialize: unsupported fork '{}'", + fork_name + ))), } } } diff --git a/consensus/types/src/light_client_optimistic_update.rs b/consensus/types/src/light_client_optimistic_update.rs index 7c346b5ded0..bc7663cfca9 100644 --- a/consensus/types/src/light_client_optimistic_update.rs +++ b/consensus/types/src/light_client_optimistic_update.rs @@ -44,8 +44,7 @@ impl LightClientOptimisticUpdate { .fork_name_at_epoch(attested_state.slot().epoch(T::slots_per_epoch())) { ForkName::Base => return Err(Error::AltairForkNotActive), - ForkName::Merge => return Err(Error::AltairForkNotActive), - ForkName::Altair => { + ForkName::Merge | ForkName::Altair => { LightClientHeaderAltair::block_to_light_client_header(attested_block)?.into() } ForkName::Capella => { @@ -70,11 +69,11 @@ impl ForkVersionDeserialize for LightClientOptimisticUpdate { fork_name: ForkName, ) -> Result { match fork_name { - ForkName::Altair | ForkName::Merge => Ok(serde_json::from_value::< + ForkName::Altair | ForkName::Merge | ForkName::Capella | ForkName::Deneb => Ok(serde_json::from_value::< LightClientOptimisticUpdate, >(value) .map_err(serde::de::Error::custom))?, - ForkName::Base | ForkName::Capella | ForkName::Deneb => { + ForkName::Base => { Err(serde::de::Error::custom(format!( "LightClientOptimisticUpdate failed to deserialize: unsupported fork '{}'", fork_name diff --git a/consensus/types/src/light_client_update.rs b/consensus/types/src/light_client_update.rs index be53479df5e..c689a453415 100644 --- a/consensus/types/src/light_client_update.rs +++ b/consensus/types/src/light_client_update.rs @@ -124,39 +124,22 @@ impl LightClientUpdate { 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 => return Err(Error::AltairForkNotActive), - ForkName::Altair => { - let attested_header: LightClientHeader = - LightClientHeaderAltair::block_to_light_client_header(attested_block)?.into(); - - let finalized_header: LightClientHeader = - LightClientHeaderAltair::block_to_light_client_header(finalized_block)?.into(); - - (attested_header, finalized_header) - } - ForkName::Capella => { - let attested_header: LightClientHeader = - LightClientHeaderCapella::block_to_light_client_header(attested_block)?.into(); - - let finalized_header: LightClientHeader = - LightClientHeaderCapella::block_to_light_client_header(finalized_block)?.into(); - - (attested_header, finalized_header) - } - ForkName::Deneb => { - let attested_header: LightClientHeader = - LightClientHeaderDeneb::block_to_light_client_header(attested_block)?.into(); - - let finalized_header: LightClientHeader = - LightClientHeaderDeneb::block_to_light_client_header(finalized_block)?.into(); - - (attested_header, finalized_header) - } - }; + 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, @@ -176,11 +159,11 @@ impl ForkVersionDeserialize for LightClientUpdate { fork_name: ForkName, ) -> Result { match fork_name { - ForkName::Altair | ForkName::Merge => { + ForkName::Altair | ForkName::Merge | ForkName::Capella | ForkName::Deneb => { Ok(serde_json::from_value::>(value) .map_err(serde::de::Error::custom))? } - ForkName::Base | ForkName::Capella | ForkName::Deneb => { + ForkName::Base => { Err(serde::de::Error::custom(format!( "LightClientUpdate failed to deserialize: unsupported fork '{}'", fork_name From 6663614af9578c6b72b9603633b4490d76ddb092 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Sat, 3 Feb 2024 17:42:33 +0200 Subject: [PATCH 49/71] fmt --- .../src/light_client_optimistic_update.rs | 18 ++++++++---------- consensus/types/src/light_client_update.rs | 10 ++++------ 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/consensus/types/src/light_client_optimistic_update.rs b/consensus/types/src/light_client_optimistic_update.rs index bc7663cfca9..219430b0d16 100644 --- a/consensus/types/src/light_client_optimistic_update.rs +++ b/consensus/types/src/light_client_optimistic_update.rs @@ -69,16 +69,14 @@ impl ForkVersionDeserialize for LightClientOptimisticUpdate { fork_name: ForkName, ) -> Result { match fork_name { - ForkName::Altair | ForkName::Merge | ForkName::Capella | ForkName::Deneb => Ok(serde_json::from_value::< - LightClientOptimisticUpdate, - >(value) - .map_err(serde::de::Error::custom))?, - ForkName::Base => { - Err(serde::de::Error::custom(format!( - "LightClientOptimisticUpdate failed to deserialize: unsupported fork '{}'", - fork_name - ))) - } + ForkName::Altair | ForkName::Merge | ForkName::Capella | ForkName::Deneb => Ok( + serde_json::from_value::>(value) + .map_err(serde::de::Error::custom), + )?, + ForkName::Base => Err(serde::de::Error::custom(format!( + "LightClientOptimisticUpdate failed to deserialize: unsupported fork '{}'", + fork_name + ))), } } } diff --git a/consensus/types/src/light_client_update.rs b/consensus/types/src/light_client_update.rs index c689a453415..1c8517affea 100644 --- a/consensus/types/src/light_client_update.rs +++ b/consensus/types/src/light_client_update.rs @@ -163,12 +163,10 @@ impl ForkVersionDeserialize for LightClientUpdate { Ok(serde_json::from_value::>(value) .map_err(serde::de::Error::custom))? } - ForkName::Base => { - Err(serde::de::Error::custom(format!( - "LightClientUpdate failed to deserialize: unsupported fork '{}'", - fork_name - ))) - } + ForkName::Base => Err(serde::de::Error::custom(format!( + "LightClientUpdate failed to deserialize: unsupported fork '{}'", + fork_name + ))), } } } From f442b5a844d6193ef252d0d5b6bb98e7fbe1295e Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Sat, 3 Feb 2024 17:55:10 +0200 Subject: [PATCH 50/71] pass by ref to prevent clone --- beacon_node/beacon_chain/src/beacon_chain.rs | 2 +- .../beacon_chain/src/light_client_server_cache.rs | 8 ++++---- consensus/types/src/light_client_bootstrap.rs | 2 +- consensus/types/src/light_client_finality_update.rs | 12 ++++++------ consensus/types/src/light_client_header.rs | 6 +++--- .../types/src/light_client_optimistic_update.rs | 2 +- consensus/types/src/light_client_update.rs | 4 ++-- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index 754611f13d9..d4edefcd5a7 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -6650,7 +6650,7 @@ impl BeaconChain { match fork_name { ForkName::Altair | ForkName::Merge | ForkName::Capella | ForkName::Deneb => { - LightClientBootstrap::from_beacon_state(&self.spec, &mut state, block) + LightClientBootstrap::from_beacon_state(&self.spec, &mut state, &block) .map(|bootstrap| Some((bootstrap, fork_name))) .map_err(Error::LightClientError) } diff --git a/beacon_node/beacon_chain/src/light_client_server_cache.rs b/beacon_node/beacon_chain/src/light_client_server_cache.rs index c503eaa6c13..7cb80dd3730 100644 --- a/beacon_node/beacon_chain/src/light_client_server_cache.rs +++ b/beacon_node/beacon_chain/src/light_client_server_cache.rs @@ -119,7 +119,7 @@ impl LightClientServerCache { 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(fork_name, attested_block.clone())?, + attested_header: block_to_light_client_header(fork_name, &attested_block)?, sync_aggregate: sync_aggregate.clone(), signature_slot, }); @@ -141,8 +141,8 @@ impl LightClientServerCache { *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(fork_name, attested_block)?, - finalized_header: block_to_light_client_header(fork_name, finalized_block)?, + attested_header: block_to_light_client_header(fork_name, &attested_block)?, + finalized_header: block_to_light_client_header(fork_name, &finalized_block)?, finality_branch: cached_parts.finality_branch.clone(), sync_aggregate: sync_aggregate.clone(), signature_slot, @@ -257,7 +257,7 @@ fn is_latest_optimistic_update( fn block_to_light_client_header( fork_name: ForkName, - block: SignedBeaconBlock, + block: &SignedBeaconBlock, ) -> Result, BeaconChainError> { let light_client_header = match fork_name { ForkName::Base => return Err(LightClientError::AltairForkNotActive.into()), diff --git a/consensus/types/src/light_client_bootstrap.rs b/consensus/types/src/light_client_bootstrap.rs index ec68ab7390b..26a239101a1 100644 --- a/consensus/types/src/light_client_bootstrap.rs +++ b/consensus/types/src/light_client_bootstrap.rs @@ -29,7 +29,7 @@ impl LightClientBootstrap { pub fn from_beacon_state( chain_spec: &ChainSpec, beacon_state: &mut BeaconState, - block: SignedBeaconBlock, + block: &SignedBeaconBlock, ) -> Result { let mut header = beacon_state.latest_block_header().clone(); header.state_root = beacon_state.update_tree_hash_cache()?; diff --git a/consensus/types/src/light_client_finality_update.rs b/consensus/types/src/light_client_finality_update.rs index da9b1989ece..c7d3b966c2e 100644 --- a/consensus/types/src/light_client_finality_update.rs +++ b/consensus/types/src/light_client_finality_update.rs @@ -60,21 +60,21 @@ impl LightClientFinalityUpdate { { ForkName::Base => return Err(Error::AltairForkNotActive), ForkName::Altair | ForkName::Merge => ( - LightClientHeaderAltair::block_to_light_client_header(attested_block.to_owned())? + LightClientHeaderAltair::block_to_light_client_header(attested_block)? .into(), - LightClientHeaderAltair::block_to_light_client_header(finalized_block.to_owned())? + LightClientHeaderAltair::block_to_light_client_header(finalized_block)? .into(), ), ForkName::Capella => ( - LightClientHeaderCapella::block_to_light_client_header(attested_block.to_owned())? + LightClientHeaderCapella::block_to_light_client_header(attested_block)? .into(), - LightClientHeaderCapella::block_to_light_client_header(finalized_block.to_owned())? + LightClientHeaderCapella::block_to_light_client_header(finalized_block)? .into(), ), ForkName::Deneb => ( - LightClientHeaderDeneb::block_to_light_client_header(attested_block.to_owned())? + LightClientHeaderDeneb::block_to_light_client_header(attested_block)? .into(), - LightClientHeaderDeneb::block_to_light_client_header(finalized_block.to_owned())? + LightClientHeaderDeneb::block_to_light_client_header(finalized_block)? .into(), ), }; diff --git a/consensus/types/src/light_client_header.rs b/consensus/types/src/light_client_header.rs index 1bc01cc43a8..35df1db66de 100644 --- a/consensus/types/src/light_client_header.rs +++ b/consensus/types/src/light_client_header.rs @@ -54,7 +54,7 @@ pub struct LightClientHeader { } impl LightClientHeaderAltair { - pub fn block_to_light_client_header(block: SignedBeaconBlock) -> Result { + pub fn block_to_light_client_header(block: &SignedBeaconBlock) -> Result { Ok(LightClientHeaderAltair { beacon: block.message().block_header(), phantom_data: PhantomData, @@ -73,7 +73,7 @@ impl LightClientHeaderAltair { } impl LightClientHeaderCapella { - pub fn block_to_light_client_header(block: SignedBeaconBlock) -> Result { + pub fn block_to_light_client_header(block: &SignedBeaconBlock) -> Result { let payload = block .message() .execution_payload()? @@ -127,7 +127,7 @@ impl LightClientHeaderCapella { } impl LightClientHeaderDeneb { - pub fn block_to_light_client_header(block: SignedBeaconBlock) -> Result { + pub fn block_to_light_client_header(block: &SignedBeaconBlock) -> Result { let payload = block .message() .execution_payload()? diff --git a/consensus/types/src/light_client_optimistic_update.rs b/consensus/types/src/light_client_optimistic_update.rs index 219430b0d16..8b7201de6a3 100644 --- a/consensus/types/src/light_client_optimistic_update.rs +++ b/consensus/types/src/light_client_optimistic_update.rs @@ -29,7 +29,7 @@ impl LightClientOptimisticUpdate { chain_spec: &ChainSpec, block: &SignedBeaconBlock, attested_state: &BeaconState, - attested_block: SignedBeaconBlock, + attested_block: &SignedBeaconBlock, ) -> Result { let sync_aggregate = block.message().body().sync_aggregate()?; if sync_aggregate.num_set_bits() < chain_spec.min_sync_committee_participants as usize { diff --git a/consensus/types/src/light_client_update.rs b/consensus/types/src/light_client_update.rs index 1c8517affea..c29e9c1e116 100644 --- a/consensus/types/src/light_client_update.rs +++ b/consensus/types/src/light_client_update.rs @@ -90,8 +90,8 @@ impl LightClientUpdate { beacon_state: BeaconState, block: BeaconBlock, attested_state: &mut BeaconState, - attested_block: SignedBeaconBlock, - finalized_block: SignedBeaconBlock, + attested_block: &SignedBeaconBlock, + finalized_block: &SignedBeaconBlock, ) -> Result { let sync_aggregate = block.body().sync_aggregate()?; if sync_aggregate.num_set_bits() < chain_spec.min_sync_committee_participants as usize { From 932f440dab2886d8fb14022aad288be6a8186eb0 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Sat, 3 Feb 2024 18:11:55 +0200 Subject: [PATCH 51/71] rename merkle proof fn --- consensus/types/src/beacon_block_body.rs | 2 +- .../types/src/light_client_finality_update.rs | 39 ++++++++----------- consensus/types/src/light_client_header.rs | 6 ++- 3 files changed, 21 insertions(+), 26 deletions(-) diff --git a/consensus/types/src/beacon_block_body.rs b/consensus/types/src/beacon_block_body.rs index 906a1332c68..b12f57a2249 100644 --- a/consensus/types/src/beacon_block_body.rs +++ b/consensus/types/src/beacon_block_body.rs @@ -595,7 +595,7 @@ impl From>> } impl BeaconBlockBody { - pub fn compute_merkle_proof( + pub fn block_body_merkle_proof( &mut self, generalized_index: usize, ) -> Result, Error> { diff --git a/consensus/types/src/light_client_finality_update.rs b/consensus/types/src/light_client_finality_update.rs index c7d3b966c2e..a5cdc80c6a0 100644 --- a/consensus/types/src/light_client_finality_update.rs +++ b/consensus/types/src/light_client_finality_update.rs @@ -55,29 +55,22 @@ impl LightClientFinalityUpdate { 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::Altair | ForkName::Merge => ( - 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(), - ), - }; + 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::Altair | ForkName::Merge => ( + 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, diff --git a/consensus/types/src/light_client_header.rs b/consensus/types/src/light_client_header.rs index 35df1db66de..456b8df38ca 100644 --- a/consensus/types/src/light_client_header.rs +++ b/consensus/types/src/light_client_header.rs @@ -89,7 +89,8 @@ impl LightClientHeaderCapella { .to_owned(), ); - let execution_branch = beacon_block_body.compute_merkle_proof(EXECUTION_PAYLOAD_INDEX)?; + let execution_branch = + beacon_block_body.block_body_merkle_proof(EXECUTION_PAYLOAD_INDEX)?; return Ok(LightClientHeaderCapella { beacon: block.message().block_header(), @@ -143,7 +144,8 @@ impl LightClientHeaderDeneb { .to_owned(), ); - let execution_branch = beacon_block_body.compute_merkle_proof(EXECUTION_PAYLOAD_INDEX)?; + let execution_branch = + beacon_block_body.block_body_merkle_proof(EXECUTION_PAYLOAD_INDEX)?; Ok(LightClientHeaderDeneb { beacon: block.message().block_header(), From 55568911e3ae9f3df0e9b21f873a70e5f7fc90a3 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Mon, 5 Feb 2024 16:58:51 +0200 Subject: [PATCH 52/71] add FIXME --- beacon_node/lighthouse_network/src/rpc/methods.rs | 2 +- consensus/types/src/light_client_bootstrap.rs | 1 + consensus/types/src/light_client_finality_update.rs | 2 +- consensus/types/src/light_client_optimistic_update.rs | 2 +- consensus/types/src/light_client_update.rs | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/beacon_node/lighthouse_network/src/rpc/methods.rs b/beacon_node/lighthouse_network/src/rpc/methods.rs index 72903ad8e14..415a3ce9c92 100644 --- a/beacon_node/lighthouse_network/src/rpc/methods.rs +++ b/beacon_node/lighthouse_network/src/rpc/methods.rs @@ -384,7 +384,7 @@ pub enum RPCResponse { /// A response to a get BLOBS_BY_RANGE request BlobsByRange(Arc>), - /// A response to a get LIGHTCLIENT_BOOTSTRAP request. + /// A response to a get LIGHT_CLIENT_BOOTSTRAP request. LightClientBootstrap(Arc>), /// A response to a get BLOBS_BY_ROOT request. diff --git a/consensus/types/src/light_client_bootstrap.rs b/consensus/types/src/light_client_bootstrap.rs index 26a239101a1..91b85d78de0 100644 --- a/consensus/types/src/light_client_bootstrap.rs +++ b/consensus/types/src/light_client_bootstrap.rs @@ -75,6 +75,7 @@ impl ForkVersionDeserialize for LightClientBootstrap { } } +// FIXME type includes enum which isn't compatible w/ TestRandom derive // #[cfg(test)] // mod tests { // use super::*; diff --git a/consensus/types/src/light_client_finality_update.rs b/consensus/types/src/light_client_finality_update.rs index a5cdc80c6a0..bf8e0b72d9c 100644 --- a/consensus/types/src/light_client_finality_update.rs +++ b/consensus/types/src/light_client_finality_update.rs @@ -99,7 +99,7 @@ impl ForkVersionDeserialize for LightClientFinalityUpdate { } } } - +// FIXME type includes enum which isn't compatible w/ TestRandom derive // #[cfg(test)] // mod tests { // use super::*; diff --git a/consensus/types/src/light_client_optimistic_update.rs b/consensus/types/src/light_client_optimistic_update.rs index 8b7201de6a3..bbcdfcbb52c 100644 --- a/consensus/types/src/light_client_optimistic_update.rs +++ b/consensus/types/src/light_client_optimistic_update.rs @@ -80,7 +80,7 @@ impl ForkVersionDeserialize for LightClientOptimisticUpdate { } } } - +// FIXME type includes enum which isn't compatible w/ TestRandom derive // #[cfg(test)] // mod tests { // use super::*; diff --git a/consensus/types/src/light_client_update.rs b/consensus/types/src/light_client_update.rs index c29e9c1e116..4899702b683 100644 --- a/consensus/types/src/light_client_update.rs +++ b/consensus/types/src/light_client_update.rs @@ -176,7 +176,7 @@ mod tests { use super::*; // use crate::MainnetEthSpec; use ssz_types::typenum::Unsigned; - + // FIXME type includes enum which isn't compatible w/ TestRandom derive // ssz_tests!(LightClientUpdate); #[test] From 06da24a0f1b6f5a66dffe5da8611583a56f166a6 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Tue, 6 Feb 2024 18:02:42 +0200 Subject: [PATCH 53/71] LightClientHeader TestRandom --- consensus/types/src/light_client_bootstrap.rs | 27 ++++++++++++------ .../types/src/light_client_finality_update.rs | 28 +++++++++++++------ .../src/light_client_optimistic_update.rs | 28 +++++++++++++------ consensus/types/src/light_client_update.rs | 20 ++++++++++--- consensus/types/src/test_utils/test_random.rs | 1 + .../test_random/light_client_header.rs | 10 +++++++ 6 files changed, 86 insertions(+), 28 deletions(-) create mode 100644 consensus/types/src/test_utils/test_random/light_client_header.rs diff --git a/consensus/types/src/light_client_bootstrap.rs b/consensus/types/src/light_client_bootstrap.rs index 91b85d78de0..2e96d9d2af1 100644 --- a/consensus/types/src/light_client_bootstrap.rs +++ b/consensus/types/src/light_client_bootstrap.rs @@ -4,16 +4,28 @@ use crate::{ LightClientHeaderAltair, LightClientHeaderCapella, LightClientHeaderDeneb, }, light_client_update::*, + test_utils::TestRandom, ChainSpec, ForkName, ForkVersionDeserialize, LightClientHeader, SignedBeaconBlock, }; use serde::{Deserialize, Deserializer, Serialize}; use serde_json::Value; use ssz_derive::{Decode, Encode}; use std::sync::Arc; +use test_random_derive::TestRandom; /// A LightClientBootstrap is the initializer we send over to light_client nodes /// that are trying to generate their basic storage when booting up. -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Encode, Decode, arbitrary::Arbitrary)] +#[derive( + Debug, + Clone, + PartialEq, + Serialize, + Deserialize, + Encode, + Decode, + arbitrary::Arbitrary, + TestRandom, +)] #[serde(bound = "T: EthSpec")] #[arbitrary(bound = "T: EthSpec")] pub struct LightClientBootstrap { @@ -75,11 +87,10 @@ impl ForkVersionDeserialize for LightClientBootstrap { } } -// FIXME type includes enum which isn't compatible w/ TestRandom derive -// #[cfg(test)] -// mod tests { -// use super::*; -// use crate::MainnetEthSpec; +#[cfg(test)] +mod tests { + use super::*; + use crate::MainnetEthSpec; -// ssz_tests!(LightClientBootstrap); -// } + ssz_tests!(LightClientBootstrap); +} diff --git a/consensus/types/src/light_client_finality_update.rs b/consensus/types/src/light_client_finality_update.rs index bf8e0b72d9c..ee0059bac66 100644 --- a/consensus/types/src/light_client_finality_update.rs +++ b/consensus/types/src/light_client_finality_update.rs @@ -4,16 +4,28 @@ use crate::{ LightClientHeaderAltair, LightClientHeaderCapella, LightClientHeaderDeneb, }, light_client_update::*, + test_utils::TestRandom, BeaconState, ChainSpec, ForkName, ForkVersionDeserialize, LightClientHeader, SignedBeaconBlock, }; use serde::{Deserialize, Deserializer, Serialize}; use serde_json::Value; use ssz_derive::{Decode, Encode}; +use test_random_derive::TestRandom; use tree_hash::TreeHash; /// A LightClientFinalityUpdate is the update light_client request or received by a gossip that /// signal a new finalized beacon block header for the light client sync protocol. -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Encode, Decode, arbitrary::Arbitrary)] +#[derive( + Debug, + Clone, + PartialEq, + Serialize, + Deserialize, + Encode, + Decode, + arbitrary::Arbitrary, + TestRandom, +)] #[serde(bound = "T: EthSpec")] #[arbitrary(bound = "T: EthSpec")] pub struct LightClientFinalityUpdate { @@ -99,11 +111,11 @@ impl ForkVersionDeserialize for LightClientFinalityUpdate { } } } -// FIXME type includes enum which isn't compatible w/ TestRandom derive -// #[cfg(test)] -// mod tests { -// use super::*; -// use crate::MainnetEthSpec; -// ssz_tests!(LightClientFinalityUpdate); -// } +#[cfg(test)] +mod tests { + use super::*; + use crate::MainnetEthSpec; + + ssz_tests!(LightClientFinalityUpdate); +} diff --git a/consensus/types/src/light_client_optimistic_update.rs b/consensus/types/src/light_client_optimistic_update.rs index bbcdfcbb52c..a3217fbeb9a 100644 --- a/consensus/types/src/light_client_optimistic_update.rs +++ b/consensus/types/src/light_client_optimistic_update.rs @@ -3,16 +3,28 @@ 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 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. -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Encode, Decode, arbitrary::Arbitrary)] +#[derive( + Debug, + Clone, + PartialEq, + Serialize, + Deserialize, + Encode, + Decode, + arbitrary::Arbitrary, + TestRandom, +)] #[serde(bound = "T: EthSpec")] #[arbitrary(bound = "T: EthSpec")] pub struct LightClientOptimisticUpdate { @@ -80,11 +92,11 @@ impl ForkVersionDeserialize for LightClientOptimisticUpdate { } } } -// FIXME type includes enum which isn't compatible w/ TestRandom derive -// #[cfg(test)] -// mod tests { -// use super::*; -// use crate::MainnetEthSpec; -// ssz_tests!(LightClientOptimisticUpdate); -// } +#[cfg(test)] +mod tests { + use super::*; + use crate::MainnetEthSpec; + + ssz_tests!(LightClientOptimisticUpdate); +} diff --git a/consensus/types/src/light_client_update.rs b/consensus/types/src/light_client_update.rs index 4899702b683..0a72894c052 100644 --- a/consensus/types/src/light_client_update.rs +++ b/consensus/types/src/light_client_update.rs @@ -4,6 +4,7 @@ use crate::{ light_client_header::{ LightClientHeaderAltair, LightClientHeaderCapella, LightClientHeaderDeneb, }, + test_utils::TestRandom, BeaconBlock, BeaconState, ChainSpec, ForkName, ForkVersionDeserialize, LightClientHeader, SignedBeaconBlock, }; @@ -13,6 +14,7 @@ use serde_json::Value; 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; @@ -64,7 +66,17 @@ impl From for Error { /// A LightClientUpdate is the update we request solely to either complete the bootstraping process, /// or to sync up to the last committee period, we need to have one ready for each ALTAIR period /// we go over, note: there is no need to keep all of the updates from [ALTAIR_PERIOD, CURRENT_PERIOD]. -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Encode, Decode, arbitrary::Arbitrary)] +#[derive( + Debug, + Clone, + PartialEq, + Serialize, + Deserialize, + Encode, + Decode, + arbitrary::Arbitrary, + TestRandom, +)] #[serde(bound = "T: EthSpec")] #[arbitrary(bound = "T: EthSpec")] pub struct LightClientUpdate { @@ -174,10 +186,10 @@ impl ForkVersionDeserialize for LightClientUpdate { #[cfg(test)] mod tests { use super::*; - // use crate::MainnetEthSpec; + use crate::MainnetEthSpec; use ssz_types::typenum::Unsigned; - // FIXME type includes enum which isn't compatible w/ TestRandom derive - // ssz_tests!(LightClientUpdate); + + ssz_tests!(LightClientUpdate); #[test] fn finalized_root_params() { diff --git a/consensus/types/src/test_utils/test_random.rs b/consensus/types/src/test_utils/test_random.rs index f31df2ce1b6..9881b694e7b 100644 --- a/consensus/types/src/test_utils/test_random.rs +++ b/consensus/types/src/test_utils/test_random.rs @@ -12,6 +12,7 @@ mod bitfield; mod hash256; mod kzg_commitment; mod kzg_proof; +mod light_client_header; mod public_key; mod public_key_bytes; mod secret_key; diff --git a/consensus/types/src/test_utils/test_random/light_client_header.rs b/consensus/types/src/test_utils/test_random/light_client_header.rs new file mode 100644 index 00000000000..bff1f0004e2 --- /dev/null +++ b/consensus/types/src/test_utils/test_random/light_client_header.rs @@ -0,0 +1,10 @@ +use super::*; +use crate::{light_client_header::LightClientHeaderDeneb, LightClientHeader}; + +/// Implements `TestRandom` for the `LightClientHeader`` superstruct. +/// We choose `LightClientHeaderDeneb`` since it is a superset of all other variants +impl TestRandom for LightClientHeader { + fn random_for_test(rng: &mut impl RngCore) -> Self { + LightClientHeaderDeneb::::random_for_test(rng).into() + } +} From 453b4d24151726f52a1ac1b17ce6d52589f4029a Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Tue, 6 Feb 2024 18:10:17 +0200 Subject: [PATCH 54/71] fix comments --- .../types/src/test_utils/test_random/light_client_header.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/consensus/types/src/test_utils/test_random/light_client_header.rs b/consensus/types/src/test_utils/test_random/light_client_header.rs index bff1f0004e2..6a97aff0cd2 100644 --- a/consensus/types/src/test_utils/test_random/light_client_header.rs +++ b/consensus/types/src/test_utils/test_random/light_client_header.rs @@ -1,8 +1,8 @@ use super::*; use crate::{light_client_header::LightClientHeaderDeneb, LightClientHeader}; -/// Implements `TestRandom` for the `LightClientHeader`` superstruct. -/// We choose `LightClientHeaderDeneb`` since it is a superset of all other variants +/// Implements `TestRandom` for the `LightClientHeader` superstruct +/// We choose `LightClientHeaderDeneb` since it is a superset of all other variants impl TestRandom for LightClientHeader { fn random_for_test(rng: &mut impl RngCore) -> Self { LightClientHeaderDeneb::::random_for_test(rng).into() From d97d496f75edac92169881fde2fed792179ad7f5 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Thu, 29 Feb 2024 18:37:53 +0200 Subject: [PATCH 55/71] fork version deserialize --- consensus/cached_tree_hash/src/impls.rs | 4 ++-- consensus/types/src/light_client_header.rs | 25 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/consensus/cached_tree_hash/src/impls.rs b/consensus/cached_tree_hash/src/impls.rs index 0624bd20145..b2a640301d7 100644 --- a/consensus/cached_tree_hash/src/impls.rs +++ b/consensus/cached_tree_hash/src/impls.rs @@ -26,13 +26,13 @@ pub fn u64_leaf_count(len: usize) -> usize { pub fn hash256_iter( values: &[Hash256], -) -> impl Iterator + ExactSizeIterator + '_ { +) -> impl ExactSizeIterator + '_{ values.iter().copied().map(Hash256::to_fixed_bytes) } pub fn u64_iter( values: &[u64], -) -> impl Iterator + ExactSizeIterator + '_ { +) -> impl ExactSizeIterator + '_ { let type_size = size_of::(); let vals_per_chunk = BYTES_PER_CHUNK / type_size; values.chunks(vals_per_chunk).map(move |xs| { diff --git a/consensus/types/src/light_client_header.rs b/consensus/types/src/light_client_header.rs index 456b8df38ca..c3f2ceb48fb 100644 --- a/consensus/types/src/light_client_header.rs +++ b/consensus/types/src/light_client_header.rs @@ -1,4 +1,6 @@ use crate::beacon_block_body::NUM_BEACON_BLOCK_BODY_HASH_TREE_ROOT_LEAVES; +use crate::ForkVersionDeserialize; +use crate::ForkName; use crate::BeaconBlockHeader; use crate::{light_client_update::*, BeaconBlockBody}; use crate::{ @@ -12,6 +14,7 @@ use std::marker::PhantomData; use superstruct::superstruct; use test_random_derive::TestRandom; use tree_hash::TreeHash; +use serde_json; #[superstruct( variants(Altair, Capella, Deneb), @@ -181,3 +184,25 @@ impl LightClientHeaderDeneb { )) } } + +impl ForkVersionDeserialize for LightClientHeader { + fn deserialize_by_fork<'de, D: serde::Deserializer<'de>>( + value: serde_json::value::Value, + fork_name: ForkName, + ) -> Result { + match fork_name { + ForkName::Altair => serde_json::from_value(value) + .map(|light_client_header| Self::Altair(light_client_header)) + .map_err(serde::de::Error::custom), + ForkName::Capella => serde_json::from_value(value) + .map(|light_client_header| Self::Capella(light_client_header)) + .map_err(serde::de::Error::custom), + ForkName::Deneb => serde_json::from_value(value) + .map(|light_client_header| Self::Deneb(light_client_header)) + .map_err(serde::de::Error::custom), + ForkName::Base | ForkName::Merge => Err(serde::de::Error::custom(format!( + "LightClientHeader deserialization for {fork_name} not implemented" + ))), + } + } +} From b23c913605ccb4d565a3f687377954aaac6b7d47 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Sat, 2 Mar 2024 21:26:07 +0200 Subject: [PATCH 56/71] move fn arguments, fork name calc --- beacon_node/beacon_chain/src/beacon_chain.rs | 6 +++--- beacon_node/beacon_chain/src/light_client_server_cache.rs | 7 +++---- consensus/types/src/light_client_bootstrap.rs | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index 0774c0067fa..34e7847d51e 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -1348,12 +1348,12 @@ impl BeaconChain { (parent_root, slot, sync_aggregate): LightClientProducerEvent, ) -> Result<(), Error> { self.light_client_server_cache.recompute_and_cache_updates( - &self.log, - &self.spec, self.store.clone(), &parent_root, slot, &sync_aggregate, + &self.log, + &self.spec, ) } @@ -6636,7 +6636,7 @@ impl BeaconChain { match fork_name { ForkName::Altair | ForkName::Merge | ForkName::Capella | ForkName::Deneb => { - LightClientBootstrap::from_beacon_state(&self.spec, &mut state, &block) + LightClientBootstrap::from_beacon_state(&mut state, &block, &self.spec) .map(|bootstrap| Some((bootstrap, fork_name))) .map_err(Error::LightClientError) } diff --git a/beacon_node/beacon_chain/src/light_client_server_cache.rs b/beacon_node/beacon_chain/src/light_client_server_cache.rs index 7cb80dd3730..f44b44ca38f 100644 --- a/beacon_node/beacon_chain/src/light_client_server_cache.rs +++ b/beacon_node/beacon_chain/src/light_client_server_cache.rs @@ -75,12 +75,12 @@ impl LightClientServerCache { /// 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, - chain_spec: &ChainSpec, store: BeaconStore, block_parent_root: &Hash256, block_slot: Slot, sync_aggregate: &SyncAggregate, + log: &Logger, + chain_spec: &ChainSpec, ) -> Result<(), BeaconChainError> { let _timer = metrics::start_timer(&metrics::LIGHT_CLIENT_SERVER_CACHE_RECOMPUTE_UPDATES_TIMES); @@ -105,8 +105,7 @@ impl LightClientServerCache { let attested_slot = attested_block.slot(); - let fork_name = - chain_spec.fork_name_at_epoch(attested_slot.epoch(T::EthSpec::slots_per_epoch())); + let fork_name = attested_block.fork_name(chain_spec)?; // Spec: Full nodes SHOULD provide the LightClientOptimisticUpdate with the highest // attested_header.beacon.slot (if multiple, highest signature_slot) as selected by fork choice diff --git a/consensus/types/src/light_client_bootstrap.rs b/consensus/types/src/light_client_bootstrap.rs index 2e96d9d2af1..4b1995e8b10 100644 --- a/consensus/types/src/light_client_bootstrap.rs +++ b/consensus/types/src/light_client_bootstrap.rs @@ -39,9 +39,9 @@ pub struct LightClientBootstrap { impl LightClientBootstrap { pub fn from_beacon_state( - chain_spec: &ChainSpec, beacon_state: &mut BeaconState, block: &SignedBeaconBlock, + chain_spec: &ChainSpec, ) -> Result { let mut header = beacon_state.latest_block_header().clone(); header.state_root = beacon_state.update_tree_hash_cache()?; From dde9274240098e9c25d59b4961c904c85aa4d4c4 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Mon, 4 Mar 2024 01:22:09 +0200 Subject: [PATCH 57/71] use task executor --- beacon_node/beacon_chain/src/beacon_chain.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index 34e7847d51e..9feae713094 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -6618,9 +6618,12 @@ impl BeaconChain { &self, block_root: &Hash256, ) -> Result, ForkName)>, Error> { - let runtime = tokio::runtime::Runtime::new().map_err(|_| Error::RuntimeShutdown)?; + let handle = self + .task_executor + .handle() + .ok_or(BeaconChainError::RuntimeShutdown)?; - let Some(block) = runtime.block_on(async { self.get_block(block_root).await })? else { + let Some(block) = handle.block_on(async { self.get_block(block_root).await })? else { return Ok(None); }; From 38cdd77be695d194ad0ebc65fcc1156526779416 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Wed, 6 Mar 2024 00:28:26 +0200 Subject: [PATCH 58/71] remove unneeded fns --- .../types/src/light_client_finality_update.rs | 59 +--------------- consensus/types/src/light_client_header.rs | 69 +------------------ 2 files changed, 3 insertions(+), 125 deletions(-) diff --git a/consensus/types/src/light_client_finality_update.rs b/consensus/types/src/light_client_finality_update.rs index ee0059bac66..ac69986a825 100644 --- a/consensus/types/src/light_client_finality_update.rs +++ b/consensus/types/src/light_client_finality_update.rs @@ -1,17 +1,13 @@ use super::{EthSpec, FixedVector, Hash256, Slot, SyncAggregate}; use crate::{ - light_client_header::{ - LightClientHeaderAltair, LightClientHeaderCapella, LightClientHeaderDeneb, - }, light_client_update::*, test_utils::TestRandom, - BeaconState, ChainSpec, ForkName, ForkVersionDeserialize, LightClientHeader, SignedBeaconBlock, + ForkName, ForkVersionDeserialize, 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 LightClientFinalityUpdate is the update light_client request or received by a gossip that /// signal a new finalized beacon block header for the light client sync protocol. @@ -41,59 +37,6 @@ pub struct LightClientFinalityUpdate { pub signature_slot: Slot, } -impl LightClientFinalityUpdate { - pub fn new( - chain_spec: &ChainSpec, - beacon_state: &BeaconState, - block: &SignedBeaconBlock, - attested_state: &mut BeaconState, - attested_block: &SignedBeaconBlock, - finalized_block: &SignedBeaconBlock, - ) -> Result { - 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.update_tree_hash_cache()?; - // Build finalized header from finalized block - let finalized_header = finalized_block.message().block_header(); - - if finalized_header.tree_hash_root() != beacon_state.finalized_checkpoint().root { - return Err(Error::InvalidFinalizedBlock); - } - - 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::Altair | ForkName::Merge => ( - 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, - finalized_header, - finality_branch: FixedVector::new(finality_branch)?, - sync_aggregate: sync_aggregate.clone(), - signature_slot: block.slot(), - }) - } -} - impl ForkVersionDeserialize for LightClientFinalityUpdate { fn deserialize_by_fork<'de, D: Deserializer<'de>>( value: Value, diff --git a/consensus/types/src/light_client_header.rs b/consensus/types/src/light_client_header.rs index 182d3dc26fc..64d912bc08a 100644 --- a/consensus/types/src/light_client_header.rs +++ b/consensus/types/src/light_client_header.rs @@ -1,4 +1,3 @@ -use crate::beacon_block_body::NUM_BEACON_BLOCK_BODY_HASH_TREE_ROOT_LEAVES; use crate::BeaconBlockHeader; use crate::ForkName; use crate::ForkVersionDeserialize; @@ -7,14 +6,12 @@ use crate::{ test_utils::TestRandom, EthSpec, ExecutionPayloadHeaderCapella, ExecutionPayloadHeaderDeneb, FixedVector, Hash256, SignedBeaconBlock, }; -use merkle_proof::verify_merkle_proof; use serde::{Deserialize, Serialize}; use serde_json; use ssz_derive::{Decode, Encode}; use std::marker::PhantomData; use superstruct::superstruct; use test_random_derive::TestRandom; -use tree_hash::TreeHash; #[superstruct( variants(Altair, Capella, Deneb), @@ -63,16 +60,6 @@ impl LightClientHeaderAltair { phantom_data: PhantomData, }) } - - #[allow(dead_code)] - fn get_lc_execution_root(&self) -> Option { - None - } - - #[allow(dead_code)] - fn is_valid_light_client_header(&self) -> Result { - Ok(true) - } } impl LightClientHeaderCapella { @@ -102,32 +89,6 @@ impl LightClientHeaderCapella { phantom_data: PhantomData, }); } - - #[allow(dead_code)] - fn get_lc_execution_root(&self) -> Option { - Some(self.execution.tree_hash_root()) - } - - #[allow(dead_code)] - fn is_valid_light_client_header(&self) -> Result { - let Some(execution_root) = self.get_lc_execution_root() else { - return Ok(false); - }; - - let Some(field_index) = - EXECUTION_PAYLOAD_INDEX.checked_sub(NUM_BEACON_BLOCK_BODY_HASH_TREE_ROOT_LEAVES) - else { - return Ok(false); - }; - - Ok(verify_merkle_proof( - execution_root, - &self.execution_branch, - EXECUTION_PAYLOAD_PROOF_LEN, - field_index, - self.beacon.body_root, - )) - } } impl LightClientHeaderDeneb { @@ -157,32 +118,6 @@ impl LightClientHeaderDeneb { phantom_data: PhantomData, }) } - - #[allow(dead_code)] - fn get_lc_execution_root(&self) -> Option { - Some(self.execution.tree_hash_root()) - } - - #[allow(dead_code)] - fn is_valid_light_client_header(&self) -> Result { - let Some(execution_root) = self.get_lc_execution_root() else { - return Ok(false); - }; - - let Some(field_index) = - EXECUTION_PAYLOAD_INDEX.checked_sub(NUM_BEACON_BLOCK_BODY_HASH_TREE_ROOT_LEAVES) - else { - return Ok(false); - }; - - Ok(verify_merkle_proof( - execution_root, - &self.execution_branch, - EXECUTION_PAYLOAD_PROOF_LEN, - field_index, - self.beacon.body_root, - )) - } } impl ForkVersionDeserialize for LightClientHeader { @@ -191,7 +126,7 @@ impl ForkVersionDeserialize for LightClientHeader { fork_name: ForkName, ) -> Result { match fork_name { - ForkName::Altair => serde_json::from_value(value) + ForkName::Altair | ForkName::Merge => serde_json::from_value(value) .map(|light_client_header| Self::Altair(light_client_header)) .map_err(serde::de::Error::custom), ForkName::Capella => serde_json::from_value(value) @@ -200,7 +135,7 @@ impl ForkVersionDeserialize for LightClientHeader { ForkName::Deneb => serde_json::from_value(value) .map(|light_client_header| Self::Deneb(light_client_header)) .map_err(serde::de::Error::custom), - ForkName::Base | ForkName::Merge => Err(serde::de::Error::custom(format!( + ForkName::Base => Err(serde::de::Error::custom(format!( "LightClientHeader deserialization for {fork_name} not implemented" ))), } From c064c45dabc7f5d84e495e5162016a7be621f6aa Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Wed, 6 Mar 2024 12:19:10 +0200 Subject: [PATCH 59/71] remove dead code --- consensus/types/src/light_client_header.rs | 4 +- .../src/light_client_optimistic_update.rs | 47 +---------- consensus/types/src/light_client_update.rs | 78 +------------------ 3 files changed, 5 insertions(+), 124 deletions(-) diff --git a/consensus/types/src/light_client_header.rs b/consensus/types/src/light_client_header.rs index 64d912bc08a..58554904768 100644 --- a/consensus/types/src/light_client_header.rs +++ b/consensus/types/src/light_client_header.rs @@ -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 { #[superstruct(only(Deneb), partial_getter(rename = "execution_payload_header_deneb"))] pub execution: ExecutionPayloadHeaderDeneb, + #[serde(skip)] #[ssz(skip_serializing, skip_deserializing)] pub phantom_data: PhantomData, } diff --git a/consensus/types/src/light_client_optimistic_update.rs b/consensus/types/src/light_client_optimistic_update.rs index a3217fbeb9a..39be0d0f1b0 100644 --- a/consensus/types/src/light_client_optimistic_update.rs +++ b/consensus/types/src/light_client_optimistic_update.rs @@ -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 { pub signature_slot: Slot, } -impl LightClientOptimisticUpdate { - pub fn new( - chain_spec: &ChainSpec, - block: &SignedBeaconBlock, - attested_state: &BeaconState, - attested_block: &SignedBeaconBlock, - ) -> Result { - 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 = 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 ForkVersionDeserialize for LightClientOptimisticUpdate { fn deserialize_by_fork<'de, D: Deserializer<'de>>( value: Value, diff --git a/consensus/types/src/light_client_update.rs b/consensus/types/src/light_client_update.rs index 0a72894c052..6218a1672ed 100644 --- a/consensus/types/src/light_client_update.rs +++ b/consensus/types/src/light_client_update.rs @@ -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 { pub signature_slot: Slot, } -impl LightClientUpdate { - pub fn new( - chain_spec: ChainSpec, - beacon_state: BeaconState, - block: BeaconBlock, - attested_state: &mut BeaconState, - attested_block: &SignedBeaconBlock, - finalized_block: &SignedBeaconBlock, - ) -> Result { - 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 ForkVersionDeserialize for LightClientUpdate { fn deserialize_by_fork<'de, D: Deserializer<'de>>( value: Value, From b964f3fe1c2964685b573ac8ed17a5155d9f22ec Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Thu, 7 Mar 2024 20:37:04 +0200 Subject: [PATCH 60/71] add manual ssz decoding/encoding and add ssz_tests_by_fork macro --- .../src/rpc/codec/ssz_snappy.rs | 15 +++- .../lighthouse_network/src/types/pubsub.rs | 26 ++++-- consensus/types/src/light_client_bootstrap.rs | 59 +++++++------ .../types/src/light_client_finality_update.rs | 48 +++++++--- consensus/types/src/light_client_header.rs | 88 ++++++++++++++++++- .../src/light_client_optimistic_update.rs | 38 +++++--- consensus/types/src/light_client_update.rs | 55 ++++++++---- consensus/types/src/test_utils/macros.rs | 20 ++++- 8 files changed, 265 insertions(+), 84 deletions(-) diff --git a/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs b/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs index 58c5dd7c8c6..c7752098604 100644 --- a/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs +++ b/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs @@ -590,9 +590,18 @@ fn handle_rpc_response( SupportedProtocol::MetaDataV1 => Ok(Some(RPCResponse::MetaData(MetaData::V1( MetaDataV1::from_ssz_bytes(decoded_buffer)?, )))), - SupportedProtocol::LightClientBootstrapV1 => Ok(Some(RPCResponse::LightClientBootstrap( - Arc::new(LightClientBootstrap::from_ssz_bytes(decoded_buffer)?), - ))), + SupportedProtocol::LightClientBootstrapV1 => match fork_name { + Some(fork_name) => Ok(Some(RPCResponse::LightClientBootstrap(Arc::new( + LightClientBootstrap::from_ssz_bytes(decoded_buffer, fork_name)?, + )))), + None => Err(RPCError::ErrorResponse( + RPCResponseErrorCode::InvalidRequest, + format!( + "No context bytes provided for {:?} response", + versioned_protocol + ), + )), + }, // MetaData V2 responses have no context bytes, so behave similarly to V1 responses SupportedProtocol::MetaDataV2 => Ok(Some(RPCResponse::MetaData(MetaData::V2( MetaDataV2::from_ssz_bytes(decoded_buffer)?, diff --git a/beacon_node/lighthouse_network/src/types/pubsub.rs b/beacon_node/lighthouse_network/src/types/pubsub.rs index 9bbc7b2650a..a4e2782f9c2 100644 --- a/beacon_node/lighthouse_network/src/types/pubsub.rs +++ b/beacon_node/lighthouse_network/src/types/pubsub.rs @@ -265,17 +265,31 @@ impl PubsubMessage { ))) } GossipKind::LightClientFinalityUpdate => { - let light_client_finality_update = - LightClientFinalityUpdate::from_ssz_bytes(data) - .map_err(|e| format!("{:?}", e))?; + let light_client_finality_update = match fork_context.from_context_bytes(gossip_topic.fork_digest) { + Some(&fork_name) => { + LightClientFinalityUpdate::from_ssz_bytes(data, fork_name) + .map_err(|e| format!("{:?}", e))? + }, + None => return Err(format!( + "light_client_finality_update topic invalid for given fork digest {:?}", + gossip_topic.fork_digest + )), + }; Ok(PubsubMessage::LightClientFinalityUpdate(Box::new( light_client_finality_update, ))) } GossipKind::LightClientOptimisticUpdate => { - let light_client_optimistic_update = - LightClientOptimisticUpdate::from_ssz_bytes(data) - .map_err(|e| format!("{:?}", e))?; + let light_client_optimistic_update = match fork_context.from_context_bytes(gossip_topic.fork_digest) { + Some(&fork_name) => { + LightClientOptimisticUpdate::from_ssz_bytes(data, fork_name) + .map_err(|e| format!("{:?}", e))? + }, + None => return Err(format!( + "light_client_optimistic_update topic invalid for given fork digest {:?}", + gossip_topic.fork_digest + )), + }; Ok(PubsubMessage::LightClientOptimisticUpdate(Box::new( light_client_optimistic_update, ))) diff --git a/consensus/types/src/light_client_bootstrap.rs b/consensus/types/src/light_client_bootstrap.rs index 4b1995e8b10..205c69c0dcd 100644 --- a/consensus/types/src/light_client_bootstrap.rs +++ b/consensus/types/src/light_client_bootstrap.rs @@ -1,30 +1,19 @@ use super::{BeaconState, EthSpec, FixedVector, Hash256, SyncCommittee}; use crate::{ - light_client_header::{ - LightClientHeaderAltair, LightClientHeaderCapella, LightClientHeaderDeneb, - }, - light_client_update::*, - test_utils::TestRandom, - ChainSpec, ForkName, ForkVersionDeserialize, LightClientHeader, SignedBeaconBlock, + light_client_update::*, test_utils::TestRandom, ChainSpec, ForkName, ForkVersionDeserialize, + LightClientHeader, SignedBeaconBlock, }; use serde::{Deserialize, Deserializer, Serialize}; use serde_json::Value; -use ssz_derive::{Decode, Encode}; +use ssz::Decode; +use ssz_derive::Encode; use std::sync::Arc; use test_random_derive::TestRandom; /// A LightClientBootstrap is the initializer we send over to light_client nodes /// that are trying to generate their basic storage when booting up. #[derive( - Debug, - Clone, - PartialEq, - Serialize, - Deserialize, - Encode, - Decode, - arbitrary::Arbitrary, - TestRandom, + Debug, Clone, PartialEq, Serialize, Deserialize, Encode, arbitrary::Arbitrary, TestRandom, )] #[serde(bound = "T: EthSpec")] #[arbitrary(bound = "T: EthSpec")] @@ -48,18 +37,10 @@ impl LightClientBootstrap { let current_sync_committee_branch = beacon_state.compute_merkle_proof(CURRENT_SYNC_COMMITTEE_INDEX)?; - let header: LightClientHeader = match chain_spec - .fork_name_at_epoch(beacon_state.slot().epoch(T::slots_per_epoch())) - { - ForkName::Base => return Err(Error::AltairForkNotActive), - ForkName::Altair | ForkName::Merge => { - LightClientHeaderAltair::block_to_light_client_header(block)?.into() - } - ForkName::Capella => { - LightClientHeaderCapella::block_to_light_client_header(block)?.into() - } - ForkName::Deneb => LightClientHeaderDeneb::block_to_light_client_header(block)?.into(), - }; + let fork_name = + chain_spec.fork_name_at_epoch(beacon_state.slot().epoch(T::slots_per_epoch())); + + let header = LightClientHeader::::block_to_light_client_header(block, fork_name)?; Ok(LightClientBootstrap { header, @@ -67,6 +48,26 @@ impl LightClientBootstrap { current_sync_committee_branch: FixedVector::new(current_sync_committee_branch)?, }) } + + pub fn from_ssz_bytes(bytes: &[u8], fork_name: ForkName) -> Result { + let mut builder = ssz::SszDecoderBuilder::new(bytes); + builder.register_anonymous_variable_length_item()?; + builder.register_type::>()?; + builder.register_type::>()?; + let mut decoder = builder.build()?; + + let header = decoder + .decode_next_with(|bytes| LightClientHeader::from_ssz_bytes(bytes, fork_name))?; + let current_sync_committee = decoder.decode_next_with(SyncCommittee::from_ssz_bytes)?; + let current_sync_committee_branch = + decoder.decode_next_with(FixedVector::from_ssz_bytes)?; + + Ok(Self { + header, + current_sync_committee: Arc::new(current_sync_committee), + current_sync_committee_branch, + }) + } } impl ForkVersionDeserialize for LightClientBootstrap { @@ -92,5 +93,5 @@ mod tests { use super::*; use crate::MainnetEthSpec; - ssz_tests!(LightClientBootstrap); + ssz_tests_by_fork!(LightClientBootstrap, ForkName::Deneb); } diff --git a/consensus/types/src/light_client_finality_update.rs b/consensus/types/src/light_client_finality_update.rs index ac69986a825..f74deb3ba5b 100644 --- a/consensus/types/src/light_client_finality_update.rs +++ b/consensus/types/src/light_client_finality_update.rs @@ -1,26 +1,18 @@ use super::{EthSpec, FixedVector, Hash256, Slot, SyncAggregate}; use crate::{ - light_client_update::*, - test_utils::TestRandom, - ForkName, ForkVersionDeserialize, LightClientHeader + light_client_update::*, test_utils::TestRandom, ForkName, ForkVersionDeserialize, + LightClientHeader, }; use serde::{Deserialize, Deserializer, Serialize}; use serde_json::Value; -use ssz_derive::{Decode, Encode}; +use ssz::Decode; +use ssz_derive::Encode; use test_random_derive::TestRandom; /// A LightClientFinalityUpdate is the update light_client request or received by a gossip that /// signal a new finalized beacon block header for the light client sync protocol. #[derive( - Debug, - Clone, - PartialEq, - Serialize, - Deserialize, - Encode, - Decode, - arbitrary::Arbitrary, - TestRandom, + Debug, Clone, PartialEq, Serialize, Deserialize, Encode, arbitrary::Arbitrary, TestRandom, )] #[serde(bound = "T: EthSpec")] #[arbitrary(bound = "T: EthSpec")] @@ -37,6 +29,34 @@ pub struct LightClientFinalityUpdate { pub signature_slot: Slot, } +impl LightClientFinalityUpdate { + pub fn from_ssz_bytes(bytes: &[u8], fork_name: ForkName) -> Result { + let mut builder = ssz::SszDecoderBuilder::new(bytes); + builder.register_anonymous_variable_length_item()?; + builder.register_anonymous_variable_length_item()?; + builder.register_type::>()?; + builder.register_type::>()?; + builder.register_type::()?; + let mut decoder = builder.build()?; + + let attested_header = decoder + .decode_next_with(|bytes| LightClientHeader::from_ssz_bytes(bytes, fork_name))?; + let finalized_header = decoder + .decode_next_with(|bytes| LightClientHeader::from_ssz_bytes(bytes, fork_name))?; + let finality_branch = decoder.decode_next_with(FixedVector::from_ssz_bytes)?; + let sync_aggregate = decoder.decode_next_with(SyncAggregate::from_ssz_bytes)?; + let signature_slot = decoder.decode_next_with(Slot::from_ssz_bytes)?; + + Ok(Self { + attested_header, + finalized_header, + finality_branch, + sync_aggregate, + signature_slot, + }) + } +} + impl ForkVersionDeserialize for LightClientFinalityUpdate { fn deserialize_by_fork<'de, D: Deserializer<'de>>( value: Value, @@ -60,5 +80,5 @@ mod tests { use super::*; use crate::MainnetEthSpec; - ssz_tests!(LightClientFinalityUpdate); + ssz_tests_by_fork!(LightClientFinalityUpdate, ForkName::Deneb); } diff --git a/consensus/types/src/light_client_header.rs b/consensus/types/src/light_client_header.rs index 58554904768..84d57254b92 100644 --- a/consensus/types/src/light_client_header.rs +++ b/consensus/types/src/light_client_header.rs @@ -8,6 +8,7 @@ use crate::{ }; use serde::{Deserialize, Serialize}; use serde_json; +use ssz::{Decode, Encode}; use ssz_derive::{Decode, Encode}; use std::marker::PhantomData; use superstruct::superstruct; @@ -22,8 +23,8 @@ use test_random_derive::TestRandom; PartialEq, Serialize, Deserialize, - Encode, Decode, + Encode, TestRandom, arbitrary::Arbitrary, ), @@ -31,10 +32,10 @@ use test_random_derive::TestRandom; arbitrary(bound = "E: EthSpec"), ) )] -#[derive(Debug, Clone, Serialize, Deserialize, Decode, Encode, arbitrary::Arbitrary, PartialEq)] +#[derive(Debug, Clone, Serialize, Deserialize, arbitrary::Arbitrary, PartialEq)] #[serde(untagged)] +// #[ssz(enum_behaviour = "transparent")] #[serde(bound = "E: EthSpec", deny_unknown_fields)] -#[ssz(enum_behaviour = "union")] #[arbitrary(bound = "E: EthSpec")] pub struct LightClientHeader { pub beacon: BeaconBlockHeader, @@ -53,6 +54,85 @@ pub struct LightClientHeader { pub phantom_data: PhantomData, } +impl LightClientHeader { + pub fn block_to_light_client_header( + block: &SignedBeaconBlock, + fork_name: ForkName, + ) -> Result { + let header = match fork_name { + ForkName::Base => return Err(Error::AltairForkNotActive), + ForkName::Altair | ForkName::Merge => LightClientHeader::Altair( + LightClientHeaderAltair::block_to_light_client_header(block)?, + ), + ForkName::Capella => LightClientHeader::Capella( + LightClientHeaderCapella::block_to_light_client_header(block)?, + ), + ForkName::Deneb => LightClientHeader::Deneb( + LightClientHeaderDeneb::block_to_light_client_header(block)?, + ), + }; + Ok(header) + } + + pub fn from_ssz_bytes(bytes: &[u8], fork_name: ForkName) -> Result { + let header = match fork_name { + ForkName::Altair | ForkName::Merge => { + let header = LightClientHeaderAltair::from_ssz_bytes(bytes)?; + LightClientHeader::Altair(header) + } + ForkName::Capella => { + let header = LightClientHeaderCapella::from_ssz_bytes(bytes)?; + LightClientHeader::Capella(header) + } + ForkName::Deneb => { + let header = LightClientHeaderDeneb::from_ssz_bytes(bytes)?; + LightClientHeader::Deneb(header) + } + ForkName::Base => { + return Err(ssz::DecodeError::BytesInvalid(format!( + "LightClientHeader decoding for {fork_name} not implemented" + ))) + } + }; + + Ok(header) + } +} + +impl Encode for LightClientHeader { + fn is_ssz_fixed_len() -> bool { + false + } + + fn ssz_bytes_len(&self) -> usize { + match self { + LightClientHeader::Altair(header) => header.ssz_bytes_len(), + LightClientHeader::Capella(header) => header.ssz_bytes_len(), + LightClientHeader::Deneb(header) => header.ssz_bytes_len(), + } + } + + fn ssz_fixed_len() -> usize { + ssz::BYTES_PER_LENGTH_OFFSET + } + + fn as_ssz_bytes(&self) -> Vec { + match self { + LightClientHeader::Altair(header) => header.as_ssz_bytes(), + LightClientHeader::Capella(header) => header.as_ssz_bytes(), + LightClientHeader::Deneb(header) => header.as_ssz_bytes(), + } + } + + fn ssz_append(&self, buf: &mut Vec) { + match self { + LightClientHeader::Altair(header) => header.ssz_append(buf), + LightClientHeader::Capella(header) => header.ssz_append(buf), + LightClientHeader::Deneb(header) => header.ssz_append(buf), + } + } +} + impl LightClientHeaderAltair { pub fn block_to_light_client_header(block: &SignedBeaconBlock) -> Result { Ok(LightClientHeaderAltair { @@ -135,7 +215,7 @@ impl ForkVersionDeserialize for LightClientHeader { ForkName::Deneb => serde_json::from_value(value) .map(|light_client_header| Self::Deneb(light_client_header)) .map_err(serde::de::Error::custom), - ForkName::Base => Err(serde::de::Error::custom(format!( + ForkName::Base => Err(serde::de::Error::custom(format!( "LightClientHeader deserialization for {fork_name} not implemented" ))), } diff --git a/consensus/types/src/light_client_optimistic_update.rs b/consensus/types/src/light_client_optimistic_update.rs index 39be0d0f1b0..935a97aabe2 100644 --- a/consensus/types/src/light_client_optimistic_update.rs +++ b/consensus/types/src/light_client_optimistic_update.rs @@ -1,23 +1,16 @@ use super::{EthSpec, ForkName, ForkVersionDeserialize, Slot, SyncAggregate}; use crate::test_utils::TestRandom; -use crate::{light_client_header::LightClientHeader}; +use crate::LightClientHeader; use serde::{Deserialize, Deserializer, Serialize}; use serde_json::Value; -use ssz_derive::{Decode, Encode}; +use ssz::Decode; +use ssz_derive::Encode; use test_random_derive::TestRandom; /// A LightClientOptimisticUpdate is the update we send on each slot, /// it is based off the current unfinalized epoch is verified only against BLS signature. #[derive( - Debug, - Clone, - PartialEq, - Serialize, - Deserialize, - Encode, - Decode, - arbitrary::Arbitrary, - TestRandom, + Debug, Clone, PartialEq, Serialize, Deserialize, Encode, arbitrary::Arbitrary, TestRandom, )] #[serde(bound = "T: EthSpec")] #[arbitrary(bound = "T: EthSpec")] @@ -30,6 +23,27 @@ pub struct LightClientOptimisticUpdate { pub signature_slot: Slot, } +impl LightClientOptimisticUpdate { + pub fn from_ssz_bytes(bytes: &[u8], fork_name: ForkName) -> Result { + let mut builder = ssz::SszDecoderBuilder::new(bytes); + builder.register_anonymous_variable_length_item()?; + builder.register_type::>()?; + builder.register_type::()?; + let mut decoder = builder.build()?; + + let attested_header = decoder + .decode_next_with(|bytes| LightClientHeader::from_ssz_bytes(bytes, fork_name))?; + let sync_aggregate = decoder.decode_next_with(SyncAggregate::from_ssz_bytes)?; + let signature_slot = decoder.decode_next_with(Slot::from_ssz_bytes)?; + + Ok(Self { + attested_header, + sync_aggregate, + signature_slot, + }) + } +} + impl ForkVersionDeserialize for LightClientOptimisticUpdate { fn deserialize_by_fork<'de, D: Deserializer<'de>>( value: Value, @@ -53,5 +67,5 @@ mod tests { use super::*; use crate::MainnetEthSpec; - ssz_tests!(LightClientOptimisticUpdate); + ssz_tests_by_fork!(LightClientOptimisticUpdate, ForkName::Deneb); } diff --git a/consensus/types/src/light_client_update.rs b/consensus/types/src/light_client_update.rs index 6218a1672ed..0de5f54631f 100644 --- a/consensus/types/src/light_client_update.rs +++ b/consensus/types/src/light_client_update.rs @@ -1,13 +1,12 @@ use super::{EthSpec, FixedVector, Hash256, Slot, SyncAggregate, SyncCommittee}; use crate::{ - beacon_state, - test_utils::TestRandom, - ForkName, ForkVersionDeserialize, LightClientHeader, + beacon_state, test_utils::TestRandom, ForkName, ForkVersionDeserialize, LightClientHeader, }; use safe_arith::ArithError; use serde::{Deserialize, Deserializer, Serialize}; use serde_json::Value; -use ssz_derive::{Decode, Encode}; +use ssz::Decode; +use ssz_derive::Encode; use ssz_types::typenum::{U4, U5, U6}; use std::sync::Arc; use test_random_derive::TestRandom; @@ -58,19 +57,11 @@ impl From for Error { } } -/// A LightClientUpdate is the update we request solely to either complete the bootstraping process, +/// A LightClientUpdate is the update we request solely to either complete the bootstrapping process, /// or to sync up to the last committee period, we need to have one ready for each ALTAIR period /// we go over, note: there is no need to keep all of the updates from [ALTAIR_PERIOD, CURRENT_PERIOD]. #[derive( - Debug, - Clone, - PartialEq, - Serialize, - Deserialize, - Encode, - Decode, - arbitrary::Arbitrary, - TestRandom, + Debug, Clone, PartialEq, Serialize, Deserialize, Encode, arbitrary::Arbitrary, TestRandom, )] #[serde(bound = "T: EthSpec")] #[arbitrary(bound = "T: EthSpec")] @@ -109,13 +100,47 @@ impl ForkVersionDeserialize for LightClientUpdate { } } +impl LightClientUpdate { + pub fn from_ssz_bytes(bytes: &[u8], fork_name: ForkName) -> Result { + let mut builder = ssz::SszDecoderBuilder::new(bytes); + builder.register_anonymous_variable_length_item()?; + builder.register_type::>()?; + builder.register_type::>()?; + builder.register_anonymous_variable_length_item()?; + builder.register_type::>()?; + builder.register_type::>()?; + builder.register_type::()?; + let mut decoder = builder.build()?; + + let attested_header = decoder + .decode_next_with(|bytes| LightClientHeader::from_ssz_bytes(bytes, fork_name))?; + let next_sync_committee = decoder.decode_next_with(SyncCommittee::from_ssz_bytes)?; + let next_sync_committee_branch = decoder.decode_next_with(FixedVector::from_ssz_bytes)?; + let finalized_header = decoder + .decode_next_with(|bytes| LightClientHeader::from_ssz_bytes(bytes, fork_name))?; + let finality_branch = decoder.decode_next_with(FixedVector::from_ssz_bytes)?; + let sync_aggregate = decoder.decode_next_with(SyncAggregate::from_ssz_bytes)?; + let signature_slot = decoder.decode_next_with(Slot::from_ssz_bytes)?; + + Ok(Self { + attested_header, + next_sync_committee: Arc::new(next_sync_committee), + next_sync_committee_branch, + finalized_header, + finality_branch, + sync_aggregate, + signature_slot, + }) + } +} + #[cfg(test)] mod tests { use super::*; use crate::MainnetEthSpec; use ssz_types::typenum::Unsigned; - ssz_tests!(LightClientUpdate); + ssz_tests_by_fork!(LightClientUpdate, ForkName::Deneb); #[test] fn finalized_root_params() { diff --git a/consensus/types/src/test_utils/macros.rs b/consensus/types/src/test_utils/macros.rs index 1e275a5760e..c4615434aa2 100644 --- a/consensus/types/src/test_utils/macros.rs +++ b/consensus/types/src/test_utils/macros.rs @@ -20,7 +20,6 @@ macro_rules! ssz_tests { let original = <$type>::random_for_test(&mut rng); let bytes = ssz_encode(&original); - println!("bytes length: {}", bytes.len()); let decoded = <$type>::from_ssz_bytes(&bytes).unwrap(); assert_eq!(original, decoded); @@ -28,6 +27,25 @@ macro_rules! ssz_tests { }; } +#[macro_export] +macro_rules! ssz_tests_by_fork { + ($type: ty, $fork:expr) => { + #[test] + pub fn test_ssz_round_trip() { + use ssz::ssz_encode; + use $crate::test_utils::{SeedableRng, TestRandom, XorShiftRng}; + + let mut rng = XorShiftRng::from_seed([42; 16]); + let original = <$type>::random_for_test(&mut rng); + + let bytes = ssz_encode(&original); + let decoded = <$type>::from_ssz_bytes(&bytes, $fork).unwrap(); + + assert_eq!(original, decoded); + } + }; +} + #[macro_export] macro_rules! tree_hash_tests { ($type: ty) => { From 3a3616c18b331096744e30e568ae92a0aa48aa40 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Thu, 7 Mar 2024 22:13:08 +0200 Subject: [PATCH 61/71] merge ssz tests, revert code deletion, cleanup --- consensus/types/src/lib.rs | 4 +- consensus/types/src/light_client_bootstrap.rs | 20 +++--- .../types/src/light_client_finality_update.rs | 4 +- consensus/types/src/light_client_header.rs | 1 - consensus/types/src/light_client_update.rs | 67 ++++++++++++++++++- testing/ef_tests/src/type_name.rs | 5 +- 6 files changed, 83 insertions(+), 18 deletions(-) diff --git a/consensus/types/src/lib.rs b/consensus/types/src/lib.rs index b07b497a2ae..dad7ab9f999 100644 --- a/consensus/types/src/lib.rs +++ b/consensus/types/src/lib.rs @@ -154,7 +154,9 @@ pub use crate::historical_batch::HistoricalBatch; pub use crate::indexed_attestation::IndexedAttestation; pub use crate::light_client_bootstrap::LightClientBootstrap; pub use crate::light_client_finality_update::LightClientFinalityUpdate; -pub use crate::light_client_header::LightClientHeader; +pub use crate::light_client_header::{ + LightClientHeader, LightClientHeaderAltair, LightClientHeaderCapella, LightClientHeaderDeneb, +}; pub use crate::light_client_optimistic_update::LightClientOptimisticUpdate; pub use crate::light_client_update::{Error as LightClientError, LightClientUpdate}; pub use crate::participation_flags::ParticipationFlags; diff --git a/consensus/types/src/light_client_bootstrap.rs b/consensus/types/src/light_client_bootstrap.rs index 349603062a6..a02898c59ec 100644 --- a/consensus/types/src/light_client_bootstrap.rs +++ b/consensus/types/src/light_client_bootstrap.rs @@ -9,7 +9,6 @@ use ssz::Decode; use ssz_derive::Encode; use std::sync::Arc; use test_random_derive::TestRandom; -use tree_hash_derive::TreeHash; /// A LightClientBootstrap is the initializer we send over to light_client nodes /// that are trying to generate their basic storage when booting up. @@ -27,10 +26,10 @@ pub struct LightClientBootstrap { pub current_sync_committee_branch: FixedVector, } -impl LightClientBootstrap { +impl LightClientBootstrap { pub fn from_beacon_state( - beacon_state: &mut BeaconState, - block: &SignedBeaconBlock, + beacon_state: &mut BeaconState, + block: &SignedBeaconBlock, chain_spec: &ChainSpec, ) -> Result { let mut header = beacon_state.latest_block_header().clone(); @@ -38,10 +37,11 @@ impl LightClientBootstrap { let current_sync_committee_branch = beacon_state.compute_merkle_proof(CURRENT_SYNC_COMMITTEE_INDEX)?; - let fork_name = - chain_spec.fork_name_at_epoch(beacon_state.slot().epoch(T::slots_per_epoch())); + let fork_name = beacon_state + .fork_name(chain_spec) + .map_err(|_| Error::InconsistentFork)?; - let header = LightClientHeader::::block_to_light_client_header(block, fork_name)?; + let header = LightClientHeader::::block_to_light_client_header(block, fork_name)?; Ok(LightClientBootstrap { header, @@ -53,7 +53,7 @@ impl LightClientBootstrap { pub fn from_ssz_bytes(bytes: &[u8], fork_name: ForkName) -> Result { let mut builder = ssz::SszDecoderBuilder::new(bytes); builder.register_anonymous_variable_length_item()?; - builder.register_type::>()?; + builder.register_type::>()?; builder.register_type::>()?; let mut decoder = builder.build()?; @@ -71,14 +71,14 @@ impl LightClientBootstrap { } } -impl ForkVersionDeserialize for LightClientBootstrap { +impl ForkVersionDeserialize for LightClientBootstrap { fn deserialize_by_fork<'de, D: Deserializer<'de>>( value: Value, fork_name: ForkName, ) -> Result { match fork_name { ForkName::Altair | ForkName::Merge | ForkName::Capella | ForkName::Deneb => { - Ok(serde_json::from_value::>(value) + Ok(serde_json::from_value::>(value) .map_err(serde::de::Error::custom))? } ForkName::Base => Err(serde::de::Error::custom(format!( diff --git a/consensus/types/src/light_client_finality_update.rs b/consensus/types/src/light_client_finality_update.rs index f74deb3ba5b..91febfc5957 100644 --- a/consensus/types/src/light_client_finality_update.rs +++ b/consensus/types/src/light_client_finality_update.rs @@ -57,14 +57,14 @@ impl LightClientFinalityUpdate { } } -impl ForkVersionDeserialize for LightClientFinalityUpdate { +impl ForkVersionDeserialize for LightClientFinalityUpdate { fn deserialize_by_fork<'de, D: Deserializer<'de>>( value: Value, fork_name: ForkName, ) -> Result { match fork_name { ForkName::Altair | ForkName::Merge | ForkName::Capella | ForkName::Deneb => Ok( - serde_json::from_value::>(value) + serde_json::from_value::>(value) .map_err(serde::de::Error::custom), )?, ForkName::Base => Err(serde::de::Error::custom(format!( diff --git a/consensus/types/src/light_client_header.rs b/consensus/types/src/light_client_header.rs index 03de79db882..84d57254b92 100644 --- a/consensus/types/src/light_client_header.rs +++ b/consensus/types/src/light_client_header.rs @@ -13,7 +13,6 @@ use ssz_derive::{Decode, Encode}; use std::marker::PhantomData; use superstruct::superstruct; use test_random_derive::TestRandom; -use tree_hash_derive::TreeHash; #[superstruct( variants(Altair, Capella, Deneb), diff --git a/consensus/types/src/light_client_update.rs b/consensus/types/src/light_client_update.rs index 0de5f54631f..55915f7430c 100644 --- a/consensus/types/src/light_client_update.rs +++ b/consensus/types/src/light_client_update.rs @@ -1,6 +1,7 @@ use super::{EthSpec, FixedVector, Hash256, Slot, SyncAggregate, SyncCommittee}; use crate::{ - beacon_state, test_utils::TestRandom, ForkName, ForkVersionDeserialize, LightClientHeader, + beacon_state, test_utils::TestRandom, BeaconBlock, BeaconBlockHeader, BeaconState, ChainSpec, + ForkName, ForkVersionDeserialize, LightClientHeader, SignedBeaconBlock, }; use safe_arith::ArithError; use serde::{Deserialize, Deserializer, Serialize}; @@ -10,6 +11,7 @@ use ssz_derive::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; @@ -37,6 +39,7 @@ pub enum Error { MismatchingPeriods, InvalidFinalizedBlock, BeaconBlockBodyError, + InconsistentFork, } impl From for Error { @@ -82,14 +85,14 @@ pub struct LightClientUpdate { pub signature_slot: Slot, } -impl ForkVersionDeserialize for LightClientUpdate { +impl ForkVersionDeserialize for LightClientUpdate { fn deserialize_by_fork<'de, D: Deserializer<'de>>( value: Value, fork_name: ForkName, ) -> Result { match fork_name { ForkName::Altair | ForkName::Merge | ForkName::Capella | ForkName::Deneb => { - Ok(serde_json::from_value::>(value) + Ok(serde_json::from_value::>(value) .map_err(serde::de::Error::custom))? } ForkName::Base => Err(serde::de::Error::custom(format!( @@ -101,6 +104,64 @@ impl ForkVersionDeserialize for LightClientUpdate { } impl LightClientUpdate { + pub fn new( + chain_spec: ChainSpec, + beacon_state: BeaconState, + block: BeaconBlock, + attested_state: &mut BeaconState, + attested_block: &SignedBeaconBlock, + finalized_block: &SignedBeaconBlock, + ) -> Result { + 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(E::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 fork_name = beacon_state + .fork_name(&chain_spec) + .map_err(|_| Error::InconsistentFork)?; + + let attested_header = + LightClientHeader::block_to_light_client_header(attested_block, fork_name)?; + let finalized_header = + LightClientHeader::block_to_light_client_header(finalized_block, fork_name)?; + + 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(), + }) + } + pub fn from_ssz_bytes(bytes: &[u8], fork_name: ForkName) -> Result { let mut builder = ssz::SszDecoderBuilder::new(bytes); builder.register_anonymous_variable_length_item()?; diff --git a/testing/ef_tests/src/type_name.rs b/testing/ef_tests/src/type_name.rs index 9c56db8f286..62bba571d76 100644 --- a/testing/ef_tests/src/type_name.rs +++ b/testing/ef_tests/src/type_name.rs @@ -75,7 +75,10 @@ type_name_generic!(HistoricalBatch); type_name_generic!(IndexedAttestation); type_name_generic!(LightClientBootstrap); type_name_generic!(LightClientFinalityUpdate); -type_name!(LightClientHeader); +type_name_generic!(LightClientHeader); +type_name_generic!(LightClientHeaderDeneb, "LightClientHeader"); +type_name_generic!(LightClientHeaderCapella, "LightClientHeader"); +type_name_generic!(LightClientHeaderAltair, "LightClientHeader"); type_name_generic!(LightClientOptimisticUpdate); type_name_generic!(LightClientUpdate); type_name_generic!(PendingAttestation); From 6ddfe7e11ef3355af2dae80d91bba18278e6cc11 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Thu, 7 Mar 2024 22:34:19 +0200 Subject: [PATCH 62/71] move chainspec --- consensus/types/src/light_client_update.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/consensus/types/src/light_client_update.rs b/consensus/types/src/light_client_update.rs index 55915f7430c..51e254b36e5 100644 --- a/consensus/types/src/light_client_update.rs +++ b/consensus/types/src/light_client_update.rs @@ -105,12 +105,12 @@ impl ForkVersionDeserialize for LightClientUpdate { impl LightClientUpdate { pub fn new( - chain_spec: ChainSpec, beacon_state: BeaconState, block: BeaconBlock, attested_state: &mut BeaconState, attested_block: &SignedBeaconBlock, finalized_block: &SignedBeaconBlock, + chain_spec: ChainSpec, ) -> Result { let sync_aggregate = block.body().sync_aggregate()?; if sync_aggregate.num_set_bits() < chain_spec.min_sync_committee_participants as usize { From 258f51bbb924a31f9c178baacd3ba41059c518ed Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Fri, 8 Mar 2024 16:16:20 +0200 Subject: [PATCH 63/71] update ssz tests --- consensus/types/src/light_client_bootstrap.rs | 24 +++--- .../types/src/light_client_finality_update.rs | 13 ++- consensus/types/src/light_client_header.rs | 35 +++++--- .../src/light_client_optimistic_update.rs | 11 ++- consensus/types/src/light_client_update.rs | 30 ++++--- testing/ef_tests/tests/tests.rs | 79 ++++++++++--------- 6 files changed, 117 insertions(+), 75 deletions(-) diff --git a/consensus/types/src/light_client_bootstrap.rs b/consensus/types/src/light_client_bootstrap.rs index a02898c59ec..449d6e20db3 100644 --- a/consensus/types/src/light_client_bootstrap.rs +++ b/consensus/types/src/light_client_bootstrap.rs @@ -5,15 +5,16 @@ use crate::{ }; use serde::{Deserialize, Deserializer, Serialize}; use serde_json::Value; -use ssz::Decode; use ssz_derive::Encode; use std::sync::Arc; use test_random_derive::TestRandom; +use tree_hash_derive::TreeHash; +use derivative::Derivative; /// A LightClientBootstrap is the initializer we send over to light_client nodes /// that are trying to generate their basic storage when booting up. #[derive( - Debug, Clone, PartialEq, Serialize, Deserialize, Encode, arbitrary::Arbitrary, TestRandom, + Debug, Clone, PartialEq, Serialize, Deserialize, Encode, Derivative, TreeHash, arbitrary::Arbitrary, TestRandom, )] #[serde(bound = "T: EthSpec")] #[arbitrary(bound = "T: EthSpec")] @@ -37,11 +38,7 @@ impl LightClientBootstrap { let current_sync_committee_branch = beacon_state.compute_merkle_proof(CURRENT_SYNC_COMMITTEE_INDEX)?; - let fork_name = beacon_state - .fork_name(chain_spec) - .map_err(|_| Error::InconsistentFork)?; - - let header = LightClientHeader::::block_to_light_client_header(block, fork_name)?; + let header = LightClientHeader::::block_to_light_client_header(block, chain_spec)?; Ok(LightClientBootstrap { header, @@ -56,12 +53,10 @@ impl LightClientBootstrap { builder.register_type::>()?; builder.register_type::>()?; let mut decoder = builder.build()?; - let header = decoder .decode_next_with(|bytes| LightClientHeader::from_ssz_bytes(bytes, fork_name))?; - let current_sync_committee = decoder.decode_next_with(SyncCommittee::from_ssz_bytes)?; - let current_sync_committee_branch = - decoder.decode_next_with(FixedVector::from_ssz_bytes)?; + let current_sync_committee = decoder.decode_next()?; + let current_sync_committee_branch = decoder.decode_next()?; Ok(Self { header, @@ -69,6 +64,13 @@ impl LightClientBootstrap { current_sync_committee_branch, }) } + + pub fn from_ssz_bytes_for_fork( + bytes: &[u8], + fork_name: ForkName, + ) -> Result { + Self::from_ssz_bytes(bytes, fork_name) + } } impl ForkVersionDeserialize for LightClientBootstrap { diff --git a/consensus/types/src/light_client_finality_update.rs b/consensus/types/src/light_client_finality_update.rs index 91febfc5957..f6a9c37925a 100644 --- a/consensus/types/src/light_client_finality_update.rs +++ b/consensus/types/src/light_client_finality_update.rs @@ -43,9 +43,9 @@ impl LightClientFinalityUpdate { .decode_next_with(|bytes| LightClientHeader::from_ssz_bytes(bytes, fork_name))?; let finalized_header = decoder .decode_next_with(|bytes| LightClientHeader::from_ssz_bytes(bytes, fork_name))?; - let finality_branch = decoder.decode_next_with(FixedVector::from_ssz_bytes)?; - let sync_aggregate = decoder.decode_next_with(SyncAggregate::from_ssz_bytes)?; - let signature_slot = decoder.decode_next_with(Slot::from_ssz_bytes)?; + let finality_branch = decoder.decode_next()?; + let sync_aggregate = decoder.decode_next()?; + let signature_slot = decoder.decode_next()?; Ok(Self { attested_header, @@ -55,6 +55,13 @@ impl LightClientFinalityUpdate { signature_slot, }) } + + pub fn from_ssz_bytes_for_fork( + bytes: &[u8], + fork_name: ForkName, + ) -> Result { + Self::from_ssz_bytes(bytes, fork_name) + } } impl ForkVersionDeserialize for LightClientFinalityUpdate { diff --git a/consensus/types/src/light_client_header.rs b/consensus/types/src/light_client_header.rs index 84d57254b92..163f1bf9c72 100644 --- a/consensus/types/src/light_client_header.rs +++ b/consensus/types/src/light_client_header.rs @@ -1,10 +1,11 @@ use crate::BeaconBlockHeader; +use crate::ChainSpec; use crate::ForkName; use crate::ForkVersionDeserialize; use crate::{light_client_update::*, BeaconBlockBody}; use crate::{ test_utils::TestRandom, EthSpec, ExecutionPayloadHeaderCapella, ExecutionPayloadHeaderDeneb, - FixedVector, Hash256, SignedBeaconBlock, + FixedVector, Hash256, SignedBeaconBlock }; use serde::{Deserialize, Serialize}; use serde_json; @@ -13,6 +14,8 @@ use ssz_derive::{Decode, Encode}; use std::marker::PhantomData; use superstruct::superstruct; use test_random_derive::TestRandom; +use derivative::Derivative; +use tree_hash_derive::TreeHash; #[superstruct( variants(Altair, Capella, Deneb), @@ -23,18 +26,20 @@ use test_random_derive::TestRandom; PartialEq, Serialize, Deserialize, + Derivative, Decode, Encode, TestRandom, arbitrary::Arbitrary, + TreeHash, ), serde(bound = "E: EthSpec", deny_unknown_fields), arbitrary(bound = "E: EthSpec"), ) )] -#[derive(Debug, Clone, Serialize, Deserialize, arbitrary::Arbitrary, PartialEq)] +#[derive(Debug, Clone, Serialize, TreeHash, Deserialize, arbitrary::Arbitrary, PartialEq)] #[serde(untagged)] -// #[ssz(enum_behaviour = "transparent")] +#[tree_hash(enum_behaviour = "transparent")] #[serde(bound = "E: EthSpec", deny_unknown_fields)] #[arbitrary(bound = "E: EthSpec")] pub struct LightClientHeader { @@ -49,17 +54,19 @@ pub struct LightClientHeader { #[superstruct(only(Deneb), partial_getter(rename = "execution_payload_header_deneb"))] pub execution: ExecutionPayloadHeaderDeneb, - #[serde(skip)] #[ssz(skip_serializing, skip_deserializing)] - pub phantom_data: PhantomData, + #[tree_hash(skip_hashing)] + #[serde(skip)] + #[arbitrary(default)] + pub _phantom_data: PhantomData, } impl LightClientHeader { pub fn block_to_light_client_header( block: &SignedBeaconBlock, - fork_name: ForkName, + chain_spec: &ChainSpec, ) -> Result { - let header = match fork_name { + let header = match block.fork_name(chain_spec).map_err(|_| Error::InconsistentFork)? { ForkName::Base => return Err(Error::AltairForkNotActive), ForkName::Altair | ForkName::Merge => LightClientHeader::Altair( LightClientHeaderAltair::block_to_light_client_header(block)?, @@ -97,6 +104,14 @@ impl LightClientHeader { Ok(header) } + + /// Custom SSZ decoder that takes a `ForkName` as context. + pub fn from_ssz_bytes_for_fork( + bytes: &[u8], + fork_name: ForkName, + ) -> Result { + Self::from_ssz_bytes(bytes, fork_name) + } } impl Encode for LightClientHeader { @@ -137,7 +152,7 @@ impl LightClientHeaderAltair { pub fn block_to_light_client_header(block: &SignedBeaconBlock) -> Result { Ok(LightClientHeaderAltair { beacon: block.message().block_header(), - phantom_data: PhantomData, + _phantom_data: PhantomData, }) } } @@ -166,7 +181,7 @@ impl LightClientHeaderCapella { beacon: block.message().block_header(), execution: header, execution_branch: FixedVector::new(execution_branch)?, - phantom_data: PhantomData, + _phantom_data: PhantomData, }); } } @@ -195,7 +210,7 @@ impl LightClientHeaderDeneb { beacon: block.message().block_header(), execution: header, execution_branch: FixedVector::new(execution_branch)?, - phantom_data: PhantomData, + _phantom_data: PhantomData, }) } } diff --git a/consensus/types/src/light_client_optimistic_update.rs b/consensus/types/src/light_client_optimistic_update.rs index 935a97aabe2..4de87989a15 100644 --- a/consensus/types/src/light_client_optimistic_update.rs +++ b/consensus/types/src/light_client_optimistic_update.rs @@ -33,8 +33,8 @@ impl LightClientOptimisticUpdate { let attested_header = decoder .decode_next_with(|bytes| LightClientHeader::from_ssz_bytes(bytes, fork_name))?; - let sync_aggregate = decoder.decode_next_with(SyncAggregate::from_ssz_bytes)?; - let signature_slot = decoder.decode_next_with(Slot::from_ssz_bytes)?; + let sync_aggregate = decoder.decode_next()?; + let signature_slot = decoder.decode_next()?; Ok(Self { attested_header, @@ -42,6 +42,13 @@ impl LightClientOptimisticUpdate { signature_slot, }) } + + pub fn from_ssz_bytes_for_fork( + bytes: &[u8], + fork_name: ForkName, + ) -> Result { + Self::from_ssz_bytes(bytes, fork_name) + } } impl ForkVersionDeserialize for LightClientOptimisticUpdate { diff --git a/consensus/types/src/light_client_update.rs b/consensus/types/src/light_client_update.rs index 51e254b36e5..a7704d1728b 100644 --- a/consensus/types/src/light_client_update.rs +++ b/consensus/types/src/light_client_update.rs @@ -110,21 +110,21 @@ impl LightClientUpdate { attested_state: &mut BeaconState, attested_block: &SignedBeaconBlock, finalized_block: &SignedBeaconBlock, - chain_spec: ChainSpec, + chain_spec: &ChainSpec, ) -> Result { 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)?; + 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(E::slots_per_epoch()) - .sync_committee_period(&chain_spec)?; + .sync_committee_period(chain_spec)?; if attested_period != signature_period { return Err(Error::MismatchingPeriods); } @@ -142,14 +142,11 @@ impl LightClientUpdate { 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 fork_name = beacon_state - .fork_name(&chain_spec) - .map_err(|_| Error::InconsistentFork)?; let attested_header = - LightClientHeader::block_to_light_client_header(attested_block, fork_name)?; + LightClientHeader::block_to_light_client_header(attested_block, chain_spec)?; let finalized_header = - LightClientHeader::block_to_light_client_header(finalized_block, fork_name)?; + LightClientHeader::block_to_light_client_header(finalized_block, chain_spec)?; Ok(Self { attested_header, @@ -175,13 +172,13 @@ impl LightClientUpdate { let attested_header = decoder .decode_next_with(|bytes| LightClientHeader::from_ssz_bytes(bytes, fork_name))?; - let next_sync_committee = decoder.decode_next_with(SyncCommittee::from_ssz_bytes)?; - let next_sync_committee_branch = decoder.decode_next_with(FixedVector::from_ssz_bytes)?; + let next_sync_committee = decoder.decode_next()?; + let next_sync_committee_branch = decoder.decode_next()?; let finalized_header = decoder .decode_next_with(|bytes| LightClientHeader::from_ssz_bytes(bytes, fork_name))?; - let finality_branch = decoder.decode_next_with(FixedVector::from_ssz_bytes)?; - let sync_aggregate = decoder.decode_next_with(SyncAggregate::from_ssz_bytes)?; - let signature_slot = decoder.decode_next_with(Slot::from_ssz_bytes)?; + let finality_branch = decoder.decode_next()?; + let sync_aggregate = decoder.decode_next()?; + let signature_slot = decoder.decode_next()?; Ok(Self { attested_header, @@ -193,6 +190,13 @@ impl LightClientUpdate { signature_slot, }) } + + pub fn from_ssz_bytes_for_fork( + bytes: &[u8], + fork_name: ForkName, + ) -> Result { + Self::from_ssz_bytes(bytes, fork_name) + } } #[cfg(test)] diff --git a/testing/ef_tests/tests/tests.rs b/testing/ef_tests/tests/tests.rs index f2c2ffe31f7..9168d8178e9 100644 --- a/testing/ef_tests/tests/tests.rs +++ b/testing/ef_tests/tests/tests.rs @@ -217,7 +217,7 @@ mod ssz_static { use ef_tests::{Handler, SszStaticHandler, SszStaticTHCHandler, SszStaticWithSpecHandler}; use types::blob_sidecar::BlobIdentifier; use types::historical_summary::HistoricalSummary; - use types::*; + use types::{LightClientHeaderAltair, *}; ssz_static_test!(aggregate_and_proof, AggregateAndProof<_>); ssz_static_test!(attestation, Attestation<_>); @@ -249,6 +249,7 @@ mod ssz_static { ssz_static_test!(signing_data, SigningData); ssz_static_test!(validator, Validator); ssz_static_test!(voluntary_exit, VoluntaryExit); + // ssz_static_test!(light_client_bootstrap, SszStaticWithSpecHandler, LightClientBootstrap<_>); // BeaconBlockBody has no internal indicator of which fork it is for, so we test it separately. #[test] @@ -276,54 +277,60 @@ mod ssz_static { // Altair and later #[test] fn contribution_and_proof() { - SszStaticHandler::, MinimalEthSpec>::altair_and_later( + SszStaticHandler::, MinimalEthSpec>::altair_only( ) .run(); - SszStaticHandler::, MainnetEthSpec>::altair_and_later( + SszStaticHandler::, MainnetEthSpec>::altair_only( ) .run(); } - #[test] - fn light_client_bootstrap() { - SszStaticHandler::, MinimalEthSpec>::altair_only() - .run(); - SszStaticHandler::, MainnetEthSpec>::altair_only() - .run(); - } - - #[test] - fn light_client_finality_update() { - SszStaticHandler::, MinimalEthSpec>::altair_only( - ) - .run(); - SszStaticHandler::, MainnetEthSpec>::altair_only( - ) - .run(); - } + // #[test] + // fn light_client_bootstrap() { + // SszStaticHandler::, MinimalEthSpec>::altair_and_later() + // .run(); + // SszStaticHandler::, MainnetEthSpec>::altair_and_later() + // .run(); + // } + + // #[test] + // fn light_client_finality_update() { + // SszStaticHandler::, MinimalEthSpec>::altair_and_later( + // ) + // .run(); + // SszStaticHandler::, MainnetEthSpec>::altair_and_later( + // ) + // .run(); + // } #[test] fn light_client_header() { - SszStaticHandler::::altair_only().run(); - SszStaticHandler::::altair_only().run(); - } + SszStaticHandler::, MinimalEthSpec>::altair_only().run(); + SszStaticHandler::, MainnetEthSpec>::altair_only().run(); - #[test] - fn light_client_optimistic_update() { - SszStaticHandler::, MinimalEthSpec>::altair_only( - ) - .run(); - SszStaticHandler::, MainnetEthSpec>::altair_only( - ) - .run(); - } + SszStaticHandler::, MinimalEthSpec>::capella_only().run(); + SszStaticHandler::, MainnetEthSpec>::capella_only().run(); - #[test] - fn light_client_update() { - SszStaticHandler::, MinimalEthSpec>::altair_only().run(); - SszStaticHandler::, MainnetEthSpec>::altair_only().run(); + SszStaticHandler::, MinimalEthSpec>::deneb_only().run(); + SszStaticHandler::, MainnetEthSpec>::deneb_only().run(); } + // #[test] + // fn light_client_optimistic_update() { + // SszStaticHandler::, MinimalEthSpec>::altair_and_later( + // ) + // .run(); + // SszStaticHandler::, MainnetEthSpec>::altair_and_later( + // ) + // .run(); + // } + + // #[test] + // fn light_client_update() { + // SszStaticHandler::, MinimalEthSpec>::altair_and_later().run(); + // SszStaticHandler::, MainnetEthSpec>::altair_and_later().run(); + // } + #[test] fn signed_contribution_and_proof() { SszStaticHandler::, MinimalEthSpec>::altair_and_later().run(); From cb41899b6cde714f316cf45d71520a36473e748f Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Fri, 8 Mar 2024 16:26:09 +0200 Subject: [PATCH 64/71] fmt --- consensus/types/src/light_client_bootstrap.rs | 13 ++++++-- .../types/src/light_client_finality_update.rs | 1 - consensus/types/src/light_client_header.rs | 9 ++++-- .../src/light_client_optimistic_update.rs | 1 - consensus/types/src/light_client_update.rs | 1 - testing/ef_tests/tests/tests.rs | 30 +++++++++++-------- 6 files changed, 35 insertions(+), 20 deletions(-) diff --git a/consensus/types/src/light_client_bootstrap.rs b/consensus/types/src/light_client_bootstrap.rs index 449d6e20db3..7f3340cb992 100644 --- a/consensus/types/src/light_client_bootstrap.rs +++ b/consensus/types/src/light_client_bootstrap.rs @@ -3,18 +3,27 @@ use crate::{ light_client_update::*, test_utils::TestRandom, ChainSpec, ForkName, ForkVersionDeserialize, LightClientHeader, SignedBeaconBlock, }; +use derivative::Derivative; use serde::{Deserialize, Deserializer, Serialize}; use serde_json::Value; use ssz_derive::Encode; use std::sync::Arc; use test_random_derive::TestRandom; use tree_hash_derive::TreeHash; -use derivative::Derivative; /// A LightClientBootstrap is the initializer we send over to light_client nodes /// that are trying to generate their basic storage when booting up. #[derive( - Debug, Clone, PartialEq, Serialize, Deserialize, Encode, Derivative, TreeHash, arbitrary::Arbitrary, TestRandom, + Debug, + Clone, + PartialEq, + Serialize, + Deserialize, + Encode, + Derivative, + TreeHash, + arbitrary::Arbitrary, + TestRandom, )] #[serde(bound = "T: EthSpec")] #[arbitrary(bound = "T: EthSpec")] diff --git a/consensus/types/src/light_client_finality_update.rs b/consensus/types/src/light_client_finality_update.rs index f6a9c37925a..10bb0b24946 100644 --- a/consensus/types/src/light_client_finality_update.rs +++ b/consensus/types/src/light_client_finality_update.rs @@ -5,7 +5,6 @@ use crate::{ }; use serde::{Deserialize, Deserializer, Serialize}; use serde_json::Value; -use ssz::Decode; use ssz_derive::Encode; use test_random_derive::TestRandom; diff --git a/consensus/types/src/light_client_header.rs b/consensus/types/src/light_client_header.rs index 163f1bf9c72..70a62369a34 100644 --- a/consensus/types/src/light_client_header.rs +++ b/consensus/types/src/light_client_header.rs @@ -5,8 +5,9 @@ use crate::ForkVersionDeserialize; use crate::{light_client_update::*, BeaconBlockBody}; use crate::{ test_utils::TestRandom, EthSpec, ExecutionPayloadHeaderCapella, ExecutionPayloadHeaderDeneb, - FixedVector, Hash256, SignedBeaconBlock + FixedVector, Hash256, SignedBeaconBlock, }; +use derivative::Derivative; use serde::{Deserialize, Serialize}; use serde_json; use ssz::{Decode, Encode}; @@ -14,7 +15,6 @@ use ssz_derive::{Decode, Encode}; use std::marker::PhantomData; use superstruct::superstruct; use test_random_derive::TestRandom; -use derivative::Derivative; use tree_hash_derive::TreeHash; #[superstruct( @@ -66,7 +66,10 @@ impl LightClientHeader { block: &SignedBeaconBlock, chain_spec: &ChainSpec, ) -> Result { - let header = match block.fork_name(chain_spec).map_err(|_| Error::InconsistentFork)? { + let header = match block + .fork_name(chain_spec) + .map_err(|_| Error::InconsistentFork)? + { ForkName::Base => return Err(Error::AltairForkNotActive), ForkName::Altair | ForkName::Merge => LightClientHeader::Altair( LightClientHeaderAltair::block_to_light_client_header(block)?, diff --git a/consensus/types/src/light_client_optimistic_update.rs b/consensus/types/src/light_client_optimistic_update.rs index 4de87989a15..a2aaf497fc1 100644 --- a/consensus/types/src/light_client_optimistic_update.rs +++ b/consensus/types/src/light_client_optimistic_update.rs @@ -3,7 +3,6 @@ use crate::test_utils::TestRandom; use crate::LightClientHeader; use serde::{Deserialize, Deserializer, Serialize}; use serde_json::Value; -use ssz::Decode; use ssz_derive::Encode; use test_random_derive::TestRandom; diff --git a/consensus/types/src/light_client_update.rs b/consensus/types/src/light_client_update.rs index a7704d1728b..1d8c81cfed4 100644 --- a/consensus/types/src/light_client_update.rs +++ b/consensus/types/src/light_client_update.rs @@ -6,7 +6,6 @@ use crate::{ use safe_arith::ArithError; use serde::{Deserialize, Deserializer, Serialize}; use serde_json::Value; -use ssz::Decode; use ssz_derive::Encode; use ssz_types::typenum::{U4, U5, U6}; use std::sync::Arc; diff --git a/testing/ef_tests/tests/tests.rs b/testing/ef_tests/tests/tests.rs index 9168d8178e9..88c1459b2ea 100644 --- a/testing/ef_tests/tests/tests.rs +++ b/testing/ef_tests/tests/tests.rs @@ -277,12 +277,10 @@ mod ssz_static { // Altair and later #[test] fn contribution_and_proof() { - SszStaticHandler::, MinimalEthSpec>::altair_only( - ) - .run(); - SszStaticHandler::, MainnetEthSpec>::altair_only( - ) - .run(); + SszStaticHandler::, MinimalEthSpec>::altair_only() + .run(); + SszStaticHandler::, MainnetEthSpec>::altair_only() + .run(); } // #[test] @@ -305,14 +303,22 @@ mod ssz_static { #[test] fn light_client_header() { - SszStaticHandler::, MinimalEthSpec>::altair_only().run(); - SszStaticHandler::, MainnetEthSpec>::altair_only().run(); + SszStaticHandler::, MinimalEthSpec>::altair_only() + .run(); + SszStaticHandler::, MainnetEthSpec>::altair_only() + .run(); - SszStaticHandler::, MinimalEthSpec>::capella_only().run(); - SszStaticHandler::, MainnetEthSpec>::capella_only().run(); + SszStaticHandler::, MinimalEthSpec>::capella_only( + ) + .run(); + SszStaticHandler::, MainnetEthSpec>::capella_only( + ) + .run(); - SszStaticHandler::, MinimalEthSpec>::deneb_only().run(); - SszStaticHandler::, MainnetEthSpec>::deneb_only().run(); + SszStaticHandler::, MinimalEthSpec>::deneb_only() + .run(); + SszStaticHandler::, MainnetEthSpec>::deneb_only() + .run(); } // #[test] From 57d90fe87c4aad0952fac615bb16aca9e7a73b4c Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Mon, 11 Mar 2024 14:59:58 +0200 Subject: [PATCH 65/71] light client ssz tests --- .../types/src/light_client_finality_update.rs | 11 +- consensus/types/src/light_client_header.rs | 34 +++--- .../src/light_client_optimistic_update.rs | 12 ++- consensus/types/src/light_client_update.rs | 11 +- testing/ef_tests/check_all_files_accessed.py | 4 + testing/ef_tests/src/cases/ssz_static.rs | 49 ++++++++- testing/ef_tests/src/handler.rs | 50 ++++++++- testing/ef_tests/tests/tests.rs | 100 ++++++++++++------ 8 files changed, 216 insertions(+), 55 deletions(-) diff --git a/consensus/types/src/light_client_finality_update.rs b/consensus/types/src/light_client_finality_update.rs index 10bb0b24946..520ef205f00 100644 --- a/consensus/types/src/light_client_finality_update.rs +++ b/consensus/types/src/light_client_finality_update.rs @@ -7,11 +7,20 @@ use serde::{Deserialize, Deserializer, Serialize}; use serde_json::Value; use ssz_derive::Encode; use test_random_derive::TestRandom; +use tree_hash_derive::TreeHash; /// A LightClientFinalityUpdate is the update light_client request or received by a gossip that /// signal a new finalized beacon block header for the light client sync protocol. #[derive( - Debug, Clone, PartialEq, Serialize, Deserialize, Encode, arbitrary::Arbitrary, TestRandom, + Debug, + Clone, + PartialEq, + Serialize, + Deserialize, + Encode, + arbitrary::Arbitrary, + TestRandom, + TreeHash, )] #[serde(bound = "T: EthSpec")] #[arbitrary(bound = "T: EthSpec")] diff --git a/consensus/types/src/light_client_header.rs b/consensus/types/src/light_client_header.rs index 70a62369a34..e667b3101d5 100644 --- a/consensus/types/src/light_client_header.rs +++ b/consensus/types/src/light_client_header.rs @@ -44,8 +44,7 @@ use tree_hash_derive::TreeHash; #[arbitrary(bound = "E: EthSpec")] pub struct LightClientHeader { pub beacon: BeaconBlockHeader, - #[superstruct(only(Capella, Deneb))] - pub execution_branch: FixedVector, + #[superstruct( only(Capella), partial_getter(rename = "execution_payload_header_capella") @@ -54,6 +53,9 @@ pub struct LightClientHeader { #[superstruct(only(Deneb), partial_getter(rename = "execution_payload_header_deneb"))] pub execution: ExecutionPayloadHeaderDeneb, + #[superstruct(only(Capella, Deneb))] + pub execution_branch: FixedVector, + #[ssz(skip_serializing, skip_deserializing)] #[tree_hash(skip_hashing)] #[serde(skip)] @@ -122,27 +124,29 @@ impl Encode for LightClientHeader { false } - fn ssz_bytes_len(&self) -> usize { - match self { - LightClientHeader::Altair(header) => header.ssz_bytes_len(), - LightClientHeader::Capella(header) => header.ssz_bytes_len(), - LightClientHeader::Deneb(header) => header.ssz_bytes_len(), - } + fn ssz_bytes_len<'a>(&'a self) -> usize { + map_light_client_header_ref!(&'a _, self.to_ref(), |inner, cons| { + cons(inner); + inner.ssz_bytes_len() + }) } fn ssz_fixed_len() -> usize { ssz::BYTES_PER_LENGTH_OFFSET } - fn as_ssz_bytes(&self) -> Vec { - match self { - LightClientHeader::Altair(header) => header.as_ssz_bytes(), - LightClientHeader::Capella(header) => header.as_ssz_bytes(), - LightClientHeader::Deneb(header) => header.as_ssz_bytes(), - } + fn as_ssz_bytes<'a>(&'a self) -> Vec { + map_light_client_header_ref!(&'a _, self.to_ref(), |inner, cons| { + cons(inner); + inner.as_ssz_bytes() + }) } - fn ssz_append(&self, buf: &mut Vec) { + fn ssz_append<'a>(&'a self, buf: &mut Vec) { + // map_light_client_header_ref!(&'a _, self.to_ref(), move |inner, cons| { + // cons(inner); + // inner.ssz_append(buf) + // }); match self { LightClientHeader::Altair(header) => header.ssz_append(buf), LightClientHeader::Capella(header) => header.ssz_append(buf), diff --git a/consensus/types/src/light_client_optimistic_update.rs b/consensus/types/src/light_client_optimistic_update.rs index a2aaf497fc1..c6e47271e60 100644 --- a/consensus/types/src/light_client_optimistic_update.rs +++ b/consensus/types/src/light_client_optimistic_update.rs @@ -5,11 +5,19 @@ use serde::{Deserialize, Deserializer, Serialize}; use serde_json::Value; use ssz_derive::Encode; use test_random_derive::TestRandom; - +use tree_hash_derive::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. #[derive( - Debug, Clone, PartialEq, Serialize, Deserialize, Encode, arbitrary::Arbitrary, TestRandom, + Debug, + Clone, + PartialEq, + Serialize, + Deserialize, + Encode, + arbitrary::Arbitrary, + TestRandom, + TreeHash, )] #[serde(bound = "T: EthSpec")] #[arbitrary(bound = "T: EthSpec")] diff --git a/consensus/types/src/light_client_update.rs b/consensus/types/src/light_client_update.rs index 1d8c81cfed4..5cc224aa53e 100644 --- a/consensus/types/src/light_client_update.rs +++ b/consensus/types/src/light_client_update.rs @@ -11,6 +11,7 @@ use ssz_types::typenum::{U4, U5, U6}; use std::sync::Arc; use test_random_derive::TestRandom; use tree_hash::TreeHash; +use tree_hash_derive::TreeHash; pub const FINALIZED_ROOT_INDEX: usize = 105; pub const CURRENT_SYNC_COMMITTEE_INDEX: usize = 54; @@ -63,7 +64,15 @@ impl From for Error { /// or to sync up to the last committee period, we need to have one ready for each ALTAIR period /// we go over, note: there is no need to keep all of the updates from [ALTAIR_PERIOD, CURRENT_PERIOD]. #[derive( - Debug, Clone, PartialEq, Serialize, Deserialize, Encode, arbitrary::Arbitrary, TestRandom, + Debug, + Clone, + PartialEq, + Serialize, + Deserialize, + Encode, + arbitrary::Arbitrary, + TestRandom, + TreeHash, )] #[serde(bound = "T: EthSpec")] #[arbitrary(bound = "T: EthSpec")] diff --git a/testing/ef_tests/check_all_files_accessed.py b/testing/ef_tests/check_all_files_accessed.py index 68e1fce4141..7629d61827f 100755 --- a/testing/ef_tests/check_all_files_accessed.py +++ b/testing/ef_tests/check_all_files_accessed.py @@ -27,6 +27,10 @@ "tests/.*/.*/ssz_static/PowBlock/", # light_client "tests/.*/.*/light_client", + # LightClientStore + "tests/.*/.*/ssz_static/LightClientStore", + # LightClientSnapshot + "tests/.*/.*/ssz_static/LightClientSnapshot", # One of the EF researchers likes to pack the tarballs on a Mac ".*\.DS_Store.*", # More Mac weirdness. diff --git a/testing/ef_tests/src/cases/ssz_static.rs b/testing/ef_tests/src/cases/ssz_static.rs index 423dc31528f..137410d6986 100644 --- a/testing/ef_tests/src/cases/ssz_static.rs +++ b/testing/ef_tests/src/cases/ssz_static.rs @@ -5,7 +5,10 @@ use crate::decode::{snappy_decode_file, yaml_decode_file}; use serde::Deserialize; use ssz::Decode; use tree_hash::TreeHash; -use types::{BeaconBlock, BeaconState, ForkName, Hash256, SignedBeaconBlock}; +use types::{ + BeaconBlock, BeaconState, ForkName, Hash256, LightClientBootstrap, LightClientFinalityUpdate, + LightClientOptimisticUpdate, LightClientUpdate, SignedBeaconBlock, +}; #[derive(Debug, Clone, Deserialize)] struct SszStaticRoots { @@ -148,3 +151,47 @@ impl Case for SszStaticWithSpec> { Ok(()) } } + +impl Case for SszStaticWithSpec> { + fn result(&self, _case_index: usize, fork_name: ForkName) -> Result<(), Error> { + check_serialization(&self.value, &self.serialized, |bytes| { + LightClientBootstrap::from_ssz_bytes(bytes, fork_name) + })?; + check_tree_hash(&self.roots.root, self.value.tree_hash_root().as_bytes())?; + Ok(()) + } +} + +impl Case for SszStaticWithSpec> { + fn result(&self, _case_index: usize, fork_name: ForkName) -> Result<(), Error> { + check_serialization(&self.value, &self.serialized, |bytes| { + LightClientFinalityUpdate::from_ssz_bytes(bytes, fork_name) + })?; + check_tree_hash(&self.roots.root, self.value.tree_hash_root().as_bytes())?; + Ok(()) + } +} + +impl Case for SszStaticWithSpec> { + fn result(&self, _case_index: usize, fork_name: ForkName) -> Result<(), Error> { + check_serialization(&self.value, &self.serialized, |bytes| { + LightClientOptimisticUpdate::from_ssz_bytes(bytes, fork_name) + })?; + check_tree_hash(&self.roots.root, self.value.tree_hash_root().as_bytes())?; + Ok(()) + } +} + +impl Case for SszStaticWithSpec> { + fn result(&self, _case_index: usize, fork_name: ForkName) -> Result<(), Error> { + match fork_name { + ForkName::Base | ForkName::Merge => return Ok(()), + _ => {} + }; + check_serialization(&self.value, &self.serialized, |bytes| { + LightClientUpdate::from_ssz_bytes(bytes, fork_name) + })?; + check_tree_hash(&self.roots.root, self.value.tree_hash_root().as_bytes())?; + Ok(()) + } +} diff --git a/testing/ef_tests/src/handler.rs b/testing/ef_tests/src/handler.rs index 0295ff1bd49..d262a116266 100644 --- a/testing/ef_tests/src/handler.rs +++ b/testing/ef_tests/src/handler.rs @@ -243,7 +243,51 @@ pub struct SszStaticTHCHandler(PhantomData<(T, E)>); /// Handler for SSZ types that don't implement `ssz::Decode`. #[derive(Derivative)] #[derivative(Default(bound = ""))] -pub struct SszStaticWithSpecHandler(PhantomData<(T, E)>); +pub struct SszStaticWithSpecHandler { + supported_forks: Vec, + _phantom: PhantomData<(T, E)>, +} + +impl SszStaticWithSpecHandler { + pub fn for_forks(supported_forks: Vec) -> Self { + SszStaticWithSpecHandler { + supported_forks, + _phantom: PhantomData, + } + } + + pub fn base_only() -> Self { + Self::for_forks(vec![ForkName::Base]) + } + + pub fn altair_only() -> Self { + Self::for_forks(vec![ForkName::Altair]) + } + + pub fn merge_only() -> Self { + Self::for_forks(vec![ForkName::Merge]) + } + + pub fn capella_only() -> Self { + Self::for_forks(vec![ForkName::Capella]) + } + + pub fn deneb_only() -> Self { + Self::for_forks(vec![ForkName::Deneb]) + } + + pub fn altair_and_later() -> Self { + Self::for_forks(ForkName::list_all()[1..].to_vec()) + } + + pub fn merge_and_later() -> Self { + Self::for_forks(ForkName::list_all()[2..].to_vec()) + } + + pub fn capella_and_later() -> Self { + Self::for_forks(ForkName::list_all()[3..].to_vec()) + } +} impl Handler for SszStaticHandler where @@ -307,6 +351,10 @@ where fn handler_name(&self) -> String { T::name().into() } + + fn is_enabled_for_fork(&self, fork_name: ForkName) -> bool { + self.supported_forks.contains(&fork_name) + } } #[derive(Derivative)] diff --git a/testing/ef_tests/tests/tests.rs b/testing/ef_tests/tests/tests.rs index 88c1459b2ea..2791adb3826 100644 --- a/testing/ef_tests/tests/tests.rs +++ b/testing/ef_tests/tests/tests.rs @@ -248,9 +248,11 @@ mod ssz_static { ssz_static_test!(signed_voluntary_exit, SignedVoluntaryExit); ssz_static_test!(signing_data, SigningData); ssz_static_test!(validator, Validator); - ssz_static_test!(voluntary_exit, VoluntaryExit); + // ssz_static_test!(voluntary_exit, VoluntaryExit); // ssz_static_test!(light_client_bootstrap, SszStaticWithSpecHandler, LightClientBootstrap<_>); - + // ssz_static_test!(light_client_update, SszStaticWithSpecHandler, LightClientUpdate<_>); + // ssz_static_test!(light_client_finality_update, SszStaticWithSpecHandler, LightClientFinalityUpdate<_>); + // ssz_static_test!(light_client_optimistic_update, SszStaticWithSpecHandler, LightClientOptimisticUpdate<_>); // BeaconBlockBody has no internal indicator of which fork it is for, so we test it separately. #[test] fn beacon_block_body() { @@ -283,23 +285,37 @@ mod ssz_static { .run(); } - // #[test] - // fn light_client_bootstrap() { - // SszStaticHandler::, MinimalEthSpec>::altair_and_later() - // .run(); - // SszStaticHandler::, MainnetEthSpec>::altair_and_later() - // .run(); - // } - - // #[test] - // fn light_client_finality_update() { - // SszStaticHandler::, MinimalEthSpec>::altair_and_later( - // ) - // .run(); - // SszStaticHandler::, MainnetEthSpec>::altair_and_later( - // ) - // .run(); - // } + #[test] + fn light_client_bootstrap() { + // SszStaticWithSpecHandler::, MinimalEthSpec>::altair_only() + // .run(); + // SszStaticWithSpecHandler::, MainnetEthSpec>::altair_only() + // .run(); + SszStaticWithSpecHandler::, MinimalEthSpec>::capella_only() + .run(); + SszStaticWithSpecHandler::, MainnetEthSpec>::capella_only() + .run(); + SszStaticWithSpecHandler::, MinimalEthSpec>::deneb_only() + .run(); + SszStaticWithSpecHandler::, MainnetEthSpec>::deneb_only() + .run(); + } + + #[test] + fn light_client_finality_update() { + // SszStaticWithSpecHandler::, MinimalEthSpec>::altair_only() + // .run(); + // SszStaticWithSpecHandler::, MainnetEthSpec>::altair_only() + // .run(); + SszStaticWithSpecHandler::, MinimalEthSpec>::capella_only() + .run(); + SszStaticWithSpecHandler::, MainnetEthSpec>::capella_only() + .run(); + SszStaticWithSpecHandler::, MinimalEthSpec>::deneb_only() + .run(); + SszStaticWithSpecHandler::, MainnetEthSpec>::deneb_only() + .run(); + } #[test] fn light_client_header() { @@ -321,21 +337,37 @@ mod ssz_static { .run(); } - // #[test] - // fn light_client_optimistic_update() { - // SszStaticHandler::, MinimalEthSpec>::altair_and_later( - // ) - // .run(); - // SszStaticHandler::, MainnetEthSpec>::altair_and_later( - // ) - // .run(); - // } - - // #[test] - // fn light_client_update() { - // SszStaticHandler::, MinimalEthSpec>::altair_and_later().run(); - // SszStaticHandler::, MainnetEthSpec>::altair_and_later().run(); - // } + #[test] + fn light_client_optimistic_update() { + // SszStaticWithSpecHandler::, MinimalEthSpec>::altair_only( + // ) + // .run(); + // SszStaticWithSpecHandler::, MainnetEthSpec>::altair_only( + // ) + // .run(); + SszStaticWithSpecHandler::, MinimalEthSpec>::capella_only( + ) + .run(); + SszStaticWithSpecHandler::, MainnetEthSpec>::capella_only( + ) + .run(); + SszStaticWithSpecHandler::, MinimalEthSpec>::deneb_only( + ) + .run(); + SszStaticWithSpecHandler::, MainnetEthSpec>::deneb_only( + ) + .run(); + } + + #[test] + fn light_client_update() { + // SszStaticWithSpecHandler::, MinimalEthSpec>::altair_only().run(); + // SszStaticWithSpecHandler::, MainnetEthSpec>::altair_only().run(); + SszStaticWithSpecHandler::, MinimalEthSpec>::capella_only().run(); + SszStaticWithSpecHandler::, MainnetEthSpec>::capella_only().run(); + SszStaticWithSpecHandler::, MinimalEthSpec>::deneb_only().run(); + SszStaticWithSpecHandler::, MainnetEthSpec>::deneb_only().run(); + } #[test] fn signed_contribution_and_proof() { From 534e80828dc332f9e0799b3443ce1f287c8e50e3 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Mon, 11 Mar 2024 19:26:09 +0200 Subject: [PATCH 66/71] change to superstruct --- ...ght_client_finality_update_verification.rs | 2 +- ...t_client_optimistic_update_verification.rs | 9 +- .../src/light_client_server_cache.rs | 58 ++---- beacon_node/http_api/src/lib.rs | 4 +- .../src/rpc/codec/ssz_snappy.rs | 2 +- .../lighthouse_network/src/rpc/methods.rs | 6 +- consensus/types/src/lib.rs | 20 +- consensus/types/src/light_client_bootstrap.rs | 154 +++++++++------ .../types/src/light_client_finality_update.rs | 178 ++++++++++++----- consensus/types/src/light_client_header.rs | 41 +--- .../src/light_client_optimistic_update.rs | 167 ++++++++++++---- consensus/types/src/light_client_update.rs | 186 ++++++++++++------ testing/ef_tests/check_all_files_accessed.py | 4 - testing/ef_tests/src/handler.rs | 50 +---- testing/ef_tests/src/type_name.rs | 12 ++ testing/ef_tests/tests/tests.rs | 123 ++++++++---- testing/simulator/src/checks.rs | 8 +- 17 files changed, 625 insertions(+), 399 deletions(-) diff --git a/beacon_node/beacon_chain/src/light_client_finality_update_verification.rs b/beacon_node/beacon_chain/src/light_client_finality_update_verification.rs index 35863aa05ff..879fa02f7d9 100644 --- a/beacon_node/beacon_chain/src/light_client_finality_update_verification.rs +++ b/beacon_node/beacon_chain/src/light_client_finality_update_verification.rs @@ -48,7 +48,7 @@ impl VerifiedLightClientFinalityUpdate { // 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() diff --git a/beacon_node/beacon_chain/src/light_client_optimistic_update_verification.rs b/beacon_node/beacon_chain/src/light_client_optimistic_update_verification.rs index ad5458945a6..5665adc3ed9 100644 --- a/beacon_node/beacon_chain/src/light_client_optimistic_update_verification.rs +++ b/beacon_node/beacon_chain/src/light_client_optimistic_update_verification.rs @@ -52,7 +52,7 @@ impl VerifiedLightClientOptimisticUpdate { // 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() @@ -65,10 +65,7 @@ impl VerifiedLightClientOptimisticUpdate { 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)); @@ -84,7 +81,7 @@ impl VerifiedLightClientOptimisticUpdate { 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, diff --git a/beacon_node/beacon_chain/src/light_client_server_cache.rs b/beacon_node/beacon_chain/src/light_client_server_cache.rs index f44b44ca38f..325f06da44c 100644 --- a/beacon_node/beacon_chain/src/light_client_server_cache.rs +++ b/beacon_node/beacon_chain/src/light_client_server_cache.rs @@ -4,15 +4,11 @@ use parking_lot::{Mutex, RwLock}; use slog::{debug, Logger}; use ssz_types::FixedVector; use std::num::NonZeroUsize; -use types::light_client_header::{ - LightClientHeaderAltair, LightClientHeaderCapella, LightClientHeaderDeneb, -}; use types::light_client_update::{FinalizedRootProofLen, FINALIZED_ROOT_INDEX}; use types::non_zero_usize::new_non_zero_usize; use types::{ - light_client_update::Error as LightClientError, BeaconBlockRef, BeaconState, ChainSpec, - EthSpec, ForkName, Hash256, LightClientFinalityUpdate, LightClientHeader, - LightClientOptimisticUpdate, SignedBeaconBlock, Slot, SyncAggregate, + BeaconBlockRef, BeaconState, ChainSpec, EthSpec, ForkName, Hash256, LightClientFinalityUpdate, + LightClientOptimisticUpdate, Slot, SyncAggregate, }; /// A prev block cache miss requires to re-generate the state of the post-parent block. Items in the @@ -117,11 +113,12 @@ impl LightClientServerCache { }; 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(fork_name, &attested_block)?, - sync_aggregate: sync_aggregate.clone(), + *self.latest_optimistic_update.write() = Some(LightClientOptimisticUpdate::new( + &attested_block, + sync_aggregate.clone(), signature_slot, - }); + fork_name, + )?); }; // Spec: Full nodes SHOULD provide the LightClientFinalityUpdate with the highest @@ -137,15 +134,14 @@ impl LightClientServerCache { if let Some(finalized_block) = 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(fork_name, &attested_block)?, - finalized_header: block_to_light_client_header(fork_name, &finalized_block)?, - 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, - }); + fork_name, + )?); } else { debug!( log, @@ -231,10 +227,11 @@ fn is_latest_finality_update( 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 + attested_slot == prev_slot && signature_slot > *prev.signature_slot() } } @@ -247,25 +244,10 @@ fn is_latest_optimistic_update( 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 + attested_slot == prev_slot && signature_slot > *prev.signature_slot() } } - -fn block_to_light_client_header( - fork_name: ForkName, - block: &SignedBeaconBlock, -) -> Result, BeaconChainError> { - let light_client_header = match fork_name { - ForkName::Base => return Err(LightClientError::AltairForkNotActive.into()), - ForkName::Merge | ForkName::Altair => { - LightClientHeaderAltair::block_to_light_client_header(block)?.into() - } - ForkName::Capella => LightClientHeaderCapella::block_to_light_client_header(block)?.into(), - ForkName::Deneb => LightClientHeaderDeneb::block_to_light_client_header(block)?.into(), - }; - - Ok(light_client_header) -} diff --git a/beacon_node/http_api/src/lib.rs b/beacon_node/http_api/src/lib.rs index b39450d7354..dbd720e425d 100644 --- a/beacon_node/http_api/src/lib.rs +++ b/beacon_node/http_api/src/lib.rs @@ -2337,7 +2337,7 @@ pub fn serve( let fork_name = chain .spec - .fork_name_at_slot::(update.signature_slot); + .fork_name_at_slot::(*update.signature_slot()); match accept_header { Some(api_types::Accept::Ssz) => Response::builder() .status(200) @@ -2384,7 +2384,7 @@ pub fn serve( let fork_name = chain .spec - .fork_name_at_slot::(update.signature_slot); + .fork_name_at_slot::(*update.signature_slot()); match accept_header { Some(api_types::Accept::Ssz) => Response::builder() .status(200) diff --git a/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs b/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs index c7752098604..bdd566cce6b 100644 --- a/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs +++ b/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs @@ -592,7 +592,7 @@ fn handle_rpc_response( )))), SupportedProtocol::LightClientBootstrapV1 => match fork_name { Some(fork_name) => Ok(Some(RPCResponse::LightClientBootstrap(Arc::new( - LightClientBootstrap::from_ssz_bytes(decoded_buffer, fork_name)?, + LightClientBootstrap::from_ssz_bytes_for_fork(decoded_buffer, fork_name)?, )))), None => Err(RPCError::ErrorResponse( RPCResponseErrorCode::InvalidRequest, diff --git a/beacon_node/lighthouse_network/src/rpc/methods.rs b/beacon_node/lighthouse_network/src/rpc/methods.rs index 415a3ce9c92..9afa1d0f7ef 100644 --- a/beacon_node/lighthouse_network/src/rpc/methods.rs +++ b/beacon_node/lighthouse_network/src/rpc/methods.rs @@ -566,11 +566,7 @@ impl std::fmt::Display for RPCResponse { RPCResponse::Pong(ping) => write!(f, "Pong: {}", ping.data), RPCResponse::MetaData(metadata) => write!(f, "Metadata: {}", metadata.seq_number()), RPCResponse::LightClientBootstrap(bootstrap) => { - write!( - f, - "LightClientBootstrap Slot: {}", - bootstrap.header.beacon().slot - ) + write!(f, "LightClientBootstrap Slot: {}", bootstrap.get_slot()) } } } diff --git a/consensus/types/src/lib.rs b/consensus/types/src/lib.rs index dad7ab9f999..e216a5da66b 100644 --- a/consensus/types/src/lib.rs +++ b/consensus/types/src/lib.rs @@ -152,13 +152,25 @@ 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::indexed_attestation::IndexedAttestation; -pub use crate::light_client_bootstrap::LightClientBootstrap; -pub use crate::light_client_finality_update::LightClientFinalityUpdate; +pub use crate::light_client_bootstrap::{ + LightClientBootstrap, LightClientBootstrapAltair, LightClientBootstrapCapella, + LightClientBootstrapDeneb, +}; +pub use crate::light_client_finality_update::{ + LightClientFinalityUpdate, LightClientFinalityUpdateAltair, LightClientFinalityUpdateCapella, + LightClientFinalityUpdateDeneb, +}; pub use crate::light_client_header::{ LightClientHeader, LightClientHeaderAltair, LightClientHeaderCapella, LightClientHeaderDeneb, }; -pub use crate::light_client_optimistic_update::LightClientOptimisticUpdate; -pub use crate::light_client_update::{Error as LightClientError, LightClientUpdate}; +pub use crate::light_client_optimistic_update::{ + LightClientOptimisticUpdate, LightClientOptimisticUpdateAltair, + LightClientOptimisticUpdateCapella, LightClientOptimisticUpdateDeneb, +}; +pub use crate::light_client_update::{ + Error as LightClientError, LightClientUpdate, LightClientUpdateAltair, + LightClientUpdateCapella, LightClientUpdateDeneb, +}; pub use crate::participation_flags::ParticipationFlags; pub use crate::participation_list::ParticipationList; pub use crate::payload::{ diff --git a/consensus/types/src/light_client_bootstrap.rs b/consensus/types/src/light_client_bootstrap.rs index 7f3340cb992..1a3e2049c32 100644 --- a/consensus/types/src/light_client_bootstrap.rs +++ b/consensus/types/src/light_client_bootstrap.rs @@ -1,85 +1,137 @@ use super::{BeaconState, EthSpec, FixedVector, Hash256, SyncCommittee}; use crate::{ light_client_update::*, test_utils::TestRandom, ChainSpec, ForkName, ForkVersionDeserialize, - LightClientHeader, SignedBeaconBlock, + LightClientHeaderAltair, LightClientHeaderCapella, LightClientHeaderDeneb, SignedBeaconBlock, + Slot, }; use derivative::Derivative; use serde::{Deserialize, Deserializer, Serialize}; use serde_json::Value; -use ssz_derive::Encode; +use ssz::Decode; +use ssz_derive::{Decode, Encode}; use std::sync::Arc; +use superstruct::superstruct; use test_random_derive::TestRandom; use tree_hash_derive::TreeHash; /// A LightClientBootstrap is the initializer we send over to light_client nodes /// that are trying to generate their basic storage when booting up. +#[superstruct( + variants(Altair, Capella, Deneb), + variant_attributes( + derive( + Debug, + Clone, + PartialEq, + Serialize, + Deserialize, + Derivative, + Decode, + Encode, + TestRandom, + arbitrary::Arbitrary, + TreeHash, + ), + serde(bound = "E: EthSpec", deny_unknown_fields), + arbitrary(bound = "E: EthSpec"), + ) +)] #[derive( - Debug, - Clone, - PartialEq, - Serialize, - Deserialize, - Encode, - Derivative, - TreeHash, - arbitrary::Arbitrary, - TestRandom, + Debug, Clone, Serialize, TreeHash, Encode, Deserialize, arbitrary::Arbitrary, PartialEq, )] -#[serde(bound = "T: EthSpec")] -#[arbitrary(bound = "T: EthSpec")] -pub struct LightClientBootstrap { +#[serde(untagged)] +#[tree_hash(enum_behaviour = "transparent")] +#[ssz(enum_behaviour = "transparent")] +#[serde(bound = "E: EthSpec", deny_unknown_fields)] +#[arbitrary(bound = "E: EthSpec")] +pub struct LightClientBootstrap { /// The requested beacon block header. - pub header: LightClientHeader, + #[superstruct(only(Altair), partial_getter(rename = "header_altair"))] + pub header: LightClientHeaderAltair, + #[superstruct(only(Capella), partial_getter(rename = "header_capella"))] + pub header: LightClientHeaderCapella, + #[superstruct(only(Deneb), partial_getter(rename = "header_deneb"))] + pub header: LightClientHeaderDeneb, /// The `SyncCommittee` used in the requested period. - pub current_sync_committee: Arc>, + pub current_sync_committee: Arc>, /// Merkle proof for sync committee pub current_sync_committee_branch: FixedVector, } impl LightClientBootstrap { - pub fn from_beacon_state( - beacon_state: &mut BeaconState, - block: &SignedBeaconBlock, - chain_spec: &ChainSpec, - ) -> Result { - let mut header = beacon_state.latest_block_header().clone(); - header.state_root = beacon_state.update_tree_hash_cache()?; - let current_sync_committee_branch = - beacon_state.compute_merkle_proof(CURRENT_SYNC_COMMITTEE_INDEX)?; - - let header = LightClientHeader::::block_to_light_client_header(block, chain_spec)?; - - Ok(LightClientBootstrap { - header, - current_sync_committee: beacon_state.current_sync_committee()?.clone(), - current_sync_committee_branch: FixedVector::new(current_sync_committee_branch)?, + pub fn get_slot<'a>(&'a self) -> Slot { + map_light_client_bootstrap_ref!(&'a _, self.to_ref(), |inner, cons| { + cons(inner); + inner.header.beacon.slot }) } pub fn from_ssz_bytes(bytes: &[u8], fork_name: ForkName) -> Result { - let mut builder = ssz::SszDecoderBuilder::new(bytes); - builder.register_anonymous_variable_length_item()?; - builder.register_type::>()?; - builder.register_type::>()?; - let mut decoder = builder.build()?; - let header = decoder - .decode_next_with(|bytes| LightClientHeader::from_ssz_bytes(bytes, fork_name))?; - let current_sync_committee = decoder.decode_next()?; - let current_sync_committee_branch = decoder.decode_next()?; + let bootstrap = match fork_name { + ForkName::Altair | ForkName::Merge => { + let header = LightClientBootstrapAltair::from_ssz_bytes(bytes)?; + Self::Altair(header) + } + ForkName::Capella => { + let header = LightClientBootstrapCapella::from_ssz_bytes(bytes)?; + Self::Capella(header) + } + ForkName::Deneb => { + let header = LightClientBootstrapDeneb::from_ssz_bytes(bytes)?; + Self::Deneb(header) + } + ForkName::Base => { + return Err(ssz::DecodeError::BytesInvalid(format!( + "LightClientBootstrap decoding for {fork_name} not implemented" + ))) + } + }; - Ok(Self { - header, - current_sync_committee: Arc::new(current_sync_committee), - current_sync_committee_branch, - }) + Ok(bootstrap) } + /// Custom SSZ decoder that takes a `ForkName` as context. pub fn from_ssz_bytes_for_fork( bytes: &[u8], fork_name: ForkName, ) -> Result { Self::from_ssz_bytes(bytes, fork_name) } + + pub fn from_beacon_state( + beacon_state: &mut BeaconState, + block: &SignedBeaconBlock, + chain_spec: &ChainSpec, + ) -> Result { + let mut header = beacon_state.latest_block_header().clone(); + header.state_root = beacon_state.update_tree_hash_cache()?; + let current_sync_committee_branch = + beacon_state.compute_merkle_proof(CURRENT_SYNC_COMMITTEE_INDEX)?; + + let light_client_bootstrap = match block + .fork_name(chain_spec) + .map_err(|_| Error::InconsistentFork)? + { + ForkName::Base => return Err(Error::AltairForkNotActive), + ForkName::Altair | ForkName::Merge => Self::Altair(LightClientBootstrapAltair { + header: LightClientHeaderAltair::block_to_light_client_header(block)?, + current_sync_committee: beacon_state.current_sync_committee()?.clone(), + current_sync_committee_branch: FixedVector::new(current_sync_committee_branch)?, + }), + ForkName::Capella => Self::Capella(LightClientBootstrapCapella { + header: LightClientHeaderCapella::block_to_light_client_header(block)?, + current_sync_committee: beacon_state.current_sync_committee()?.clone(), + current_sync_committee_branch: FixedVector::new(current_sync_committee_branch)?, + }), + ForkName::Deneb => Self::Deneb(LightClientBootstrapDeneb { + header: LightClientHeaderDeneb::block_to_light_client_header(block)?, + current_sync_committee: beacon_state.current_sync_committee()?.clone(), + current_sync_committee_branch: FixedVector::new(current_sync_committee_branch)?, + }), + }; + + Ok(light_client_bootstrap) + } } impl ForkVersionDeserialize for LightClientBootstrap { @@ -99,11 +151,3 @@ impl ForkVersionDeserialize for LightClientBootstrap { } } } - -#[cfg(test)] -mod tests { - use super::*; - use crate::MainnetEthSpec; - - ssz_tests_by_fork!(LightClientBootstrap, ForkName::Deneb); -} diff --git a/consensus/types/src/light_client_finality_update.rs b/consensus/types/src/light_client_finality_update.rs index 520ef205f00..bdd23c453b4 100644 --- a/consensus/types/src/light_client_finality_update.rs +++ b/consensus/types/src/light_client_finality_update.rs @@ -1,69 +1,159 @@ use super::{EthSpec, FixedVector, Hash256, Slot, SyncAggregate}; use crate::{ light_client_update::*, test_utils::TestRandom, ForkName, ForkVersionDeserialize, - LightClientHeader, + LightClientHeaderAltair, LightClientHeaderCapella, LightClientHeaderDeneb, SignedBeaconBlock, }; +use derivative::Derivative; use serde::{Deserialize, Deserializer, Serialize}; use serde_json::Value; +use ssz::Decode; +use ssz_derive::Decode; use ssz_derive::Encode; +use superstruct::superstruct; use test_random_derive::TestRandom; use tree_hash_derive::TreeHash; -/// A LightClientFinalityUpdate is the update light_client request or received by a gossip that -/// signal a new finalized beacon block header for the light client sync protocol. +#[superstruct( + variants(Altair, Capella, Deneb), + variant_attributes( + derive( + Debug, + Clone, + PartialEq, + Serialize, + Deserialize, + Derivative, + Decode, + Encode, + TestRandom, + arbitrary::Arbitrary, + TreeHash, + ), + serde(bound = "E: EthSpec", deny_unknown_fields), + arbitrary(bound = "E: EthSpec"), + ) +)] #[derive( - Debug, - Clone, - PartialEq, - Serialize, - Deserialize, - Encode, - arbitrary::Arbitrary, - TestRandom, - TreeHash, + Debug, Clone, Serialize, Encode, TreeHash, Deserialize, arbitrary::Arbitrary, PartialEq, )] -#[serde(bound = "T: EthSpec")] -#[arbitrary(bound = "T: EthSpec")] -pub struct LightClientFinalityUpdate { +#[serde(untagged)] +#[tree_hash(enum_behaviour = "transparent")] +#[ssz(enum_behaviour = "transparent")] +#[serde(bound = "E: EthSpec", deny_unknown_fields)] +#[arbitrary(bound = "E: EthSpec")] +pub struct LightClientFinalityUpdate { /// The last `BeaconBlockHeader` from the last attested block by the sync committee. - pub attested_header: LightClientHeader, + #[superstruct(only(Altair), partial_getter(rename = "attested_header_altair"))] + pub attested_header: LightClientHeaderAltair, + #[superstruct(only(Capella), partial_getter(rename = "attested_header_capella"))] + pub attested_header: LightClientHeaderCapella, + #[superstruct(only(Deneb), partial_getter(rename = "attested_header_deneb"))] + pub attested_header: LightClientHeaderDeneb, /// The last `BeaconBlockHeader` from the last attested finalized block (end of epoch). - pub finalized_header: LightClientHeader, + #[superstruct(only(Altair), partial_getter(rename = "finalized_header_altair"))] + pub finalized_header: LightClientHeaderAltair, + #[superstruct(only(Capella), partial_getter(rename = "finalized_header_capella"))] + pub finalized_header: LightClientHeaderCapella, + #[superstruct(only(Deneb), partial_getter(rename = "finalized_header_deneb"))] + pub finalized_header: LightClientHeaderDeneb, /// Merkle proof attesting finalized header. pub finality_branch: FixedVector, /// current sync aggreggate - pub sync_aggregate: SyncAggregate, + pub sync_aggregate: SyncAggregate, /// Slot of the sync aggregated singature pub signature_slot: Slot, } impl LightClientFinalityUpdate { - pub fn from_ssz_bytes(bytes: &[u8], fork_name: ForkName) -> Result { - let mut builder = ssz::SszDecoderBuilder::new(bytes); - builder.register_anonymous_variable_length_item()?; - builder.register_anonymous_variable_length_item()?; - builder.register_type::>()?; - builder.register_type::>()?; - builder.register_type::()?; - let mut decoder = builder.build()?; + pub fn new( + attested_block: &SignedBeaconBlock, + finalized_block: &SignedBeaconBlock, + finality_branch: FixedVector, + sync_aggregate: SyncAggregate, + signature_slot: Slot, + fork_name: ForkName, + ) -> Result { + let finality_update = match fork_name { + ForkName::Altair | ForkName::Merge => { + let finality_update = LightClientFinalityUpdateAltair { + attested_header: LightClientHeaderAltair::block_to_light_client_header( + attested_block, + )?, + finalized_header: LightClientHeaderAltair::block_to_light_client_header( + finalized_block, + )?, + finality_branch, + sync_aggregate, + signature_slot, + }; + Self::Altair(finality_update) + } + ForkName::Capella => { + let finality_update = LightClientFinalityUpdateCapella { + attested_header: LightClientHeaderCapella::block_to_light_client_header( + attested_block, + )?, + finalized_header: LightClientHeaderCapella::block_to_light_client_header( + finalized_block, + )?, + finality_branch, + sync_aggregate, + signature_slot, + }; + Self::Capella(finality_update) + } + ForkName::Deneb => { + let finality_update = LightClientFinalityUpdateDeneb { + attested_header: LightClientHeaderDeneb::block_to_light_client_header( + attested_block, + )?, + finalized_header: LightClientHeaderDeneb::block_to_light_client_header( + finalized_block, + )?, + finality_branch, + sync_aggregate, + signature_slot, + }; + Self::Deneb(finality_update) + } + ForkName::Base => return Err(Error::AltairForkNotActive), + }; - let attested_header = decoder - .decode_next_with(|bytes| LightClientHeader::from_ssz_bytes(bytes, fork_name))?; - let finalized_header = decoder - .decode_next_with(|bytes| LightClientHeader::from_ssz_bytes(bytes, fork_name))?; - let finality_branch = decoder.decode_next()?; - let sync_aggregate = decoder.decode_next()?; - let signature_slot = decoder.decode_next()?; + Ok(finality_update) + } - Ok(Self { - attested_header, - finalized_header, - finality_branch, - sync_aggregate, - signature_slot, + pub fn get_slot<'a>(&'a self) -> Slot { + map_light_client_finality_update_ref!(&'a _, self.to_ref(), |inner, cons| { + cons(inner); + inner.attested_header.beacon.slot }) } + pub fn from_ssz_bytes(bytes: &[u8], fork_name: ForkName) -> Result { + let finality_update = match fork_name { + ForkName::Altair | ForkName::Merge => { + let finality_update = LightClientFinalityUpdateAltair::from_ssz_bytes(bytes)?; + Self::Altair(finality_update) + } + ForkName::Capella => { + let finality_update = LightClientFinalityUpdateCapella::from_ssz_bytes(bytes)?; + Self::Capella(finality_update) + } + ForkName::Deneb => { + let finality_update = LightClientFinalityUpdateDeneb::from_ssz_bytes(bytes)?; + Self::Deneb(finality_update) + } + ForkName::Base => { + return Err(ssz::DecodeError::BytesInvalid(format!( + "LightClientFinalityUpdate decoding for {fork_name} not implemented" + ))) + } + }; + + Ok(finality_update) + } + + /// Custom SSZ decoder that takes a `ForkName` as context. pub fn from_ssz_bytes_for_fork( bytes: &[u8], fork_name: ForkName, @@ -88,12 +178,4 @@ impl ForkVersionDeserialize for LightClientFinalityUpdate { ))), } } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::MainnetEthSpec; - - ssz_tests_by_fork!(LightClientFinalityUpdate, ForkName::Deneb); -} +} \ No newline at end of file diff --git a/consensus/types/src/light_client_header.rs b/consensus/types/src/light_client_header.rs index e667b3101d5..6f49fed5cbb 100644 --- a/consensus/types/src/light_client_header.rs +++ b/consensus/types/src/light_client_header.rs @@ -10,7 +10,7 @@ use crate::{ use derivative::Derivative; use serde::{Deserialize, Serialize}; use serde_json; -use ssz::{Decode, Encode}; +use ssz::Decode; use ssz_derive::{Decode, Encode}; use std::marker::PhantomData; use superstruct::superstruct; @@ -37,9 +37,10 @@ use tree_hash_derive::TreeHash; arbitrary(bound = "E: EthSpec"), ) )] -#[derive(Debug, Clone, Serialize, TreeHash, Deserialize, arbitrary::Arbitrary, PartialEq)] +#[derive(Debug, Clone, Serialize, TreeHash, Encode, Deserialize, arbitrary::Arbitrary, PartialEq)] #[serde(untagged)] #[tree_hash(enum_behaviour = "transparent")] +#[ssz(enum_behaviour = "transparent")] #[serde(bound = "E: EthSpec", deny_unknown_fields)] #[arbitrary(bound = "E: EthSpec")] pub struct LightClientHeader { @@ -119,42 +120,6 @@ impl LightClientHeader { } } -impl Encode for LightClientHeader { - fn is_ssz_fixed_len() -> bool { - false - } - - fn ssz_bytes_len<'a>(&'a self) -> usize { - map_light_client_header_ref!(&'a _, self.to_ref(), |inner, cons| { - cons(inner); - inner.ssz_bytes_len() - }) - } - - fn ssz_fixed_len() -> usize { - ssz::BYTES_PER_LENGTH_OFFSET - } - - fn as_ssz_bytes<'a>(&'a self) -> Vec { - map_light_client_header_ref!(&'a _, self.to_ref(), |inner, cons| { - cons(inner); - inner.as_ssz_bytes() - }) - } - - fn ssz_append<'a>(&'a self, buf: &mut Vec) { - // map_light_client_header_ref!(&'a _, self.to_ref(), move |inner, cons| { - // cons(inner); - // inner.ssz_append(buf) - // }); - match self { - LightClientHeader::Altair(header) => header.ssz_append(buf), - LightClientHeader::Capella(header) => header.ssz_append(buf), - LightClientHeader::Deneb(header) => header.ssz_append(buf), - } - } -} - impl LightClientHeaderAltair { pub fn block_to_light_client_header(block: &SignedBeaconBlock) -> Result { Ok(LightClientHeaderAltair { diff --git a/consensus/types/src/light_client_optimistic_update.rs b/consensus/types/src/light_client_optimistic_update.rs index c6e47271e60..9206fedc193 100644 --- a/consensus/types/src/light_client_optimistic_update.rs +++ b/consensus/types/src/light_client_optimistic_update.rs @@ -1,55 +1,154 @@ use super::{EthSpec, ForkName, ForkVersionDeserialize, Slot, SyncAggregate}; use crate::test_utils::TestRandom; -use crate::LightClientHeader; +use crate::{ + light_client_update::*, LightClientHeaderAltair, LightClientHeaderCapella, + LightClientHeaderDeneb, SignedBeaconBlock, +}; +use derivative::Derivative; use serde::{Deserialize, Deserializer, Serialize}; use serde_json::Value; +use ssz::Decode; +use ssz_derive::Decode; use ssz_derive::Encode; +use superstruct::superstruct; use test_random_derive::TestRandom; +use tree_hash::Hash256; use tree_hash_derive::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. +#[superstruct( + variants(Altair, Capella, Deneb), + variant_attributes( + derive( + Debug, + Clone, + PartialEq, + Serialize, + Deserialize, + Derivative, + Decode, + Encode, + TestRandom, + arbitrary::Arbitrary, + TreeHash, + ), + serde(bound = "E: EthSpec", deny_unknown_fields), + arbitrary(bound = "E: EthSpec"), + ) +)] #[derive( - Debug, - Clone, - PartialEq, - Serialize, - Deserialize, - Encode, - arbitrary::Arbitrary, - TestRandom, - TreeHash, + Debug, Clone, Serialize, Encode, TreeHash, Deserialize, arbitrary::Arbitrary, PartialEq, )] -#[serde(bound = "T: EthSpec")] -#[arbitrary(bound = "T: EthSpec")] -pub struct LightClientOptimisticUpdate { +#[serde(untagged)] +#[tree_hash(enum_behaviour = "transparent")] +#[ssz(enum_behaviour = "transparent")] +#[serde(bound = "E: EthSpec", deny_unknown_fields)] +#[arbitrary(bound = "E: EthSpec")] +pub struct LightClientOptimisticUpdate { /// The last `BeaconBlockHeader` from the last attested block by the sync committee. - pub attested_header: LightClientHeader, + #[superstruct(only(Altair), partial_getter(rename = "attested_header_altair"))] + pub attested_header: LightClientHeaderAltair, + #[superstruct(only(Capella), partial_getter(rename = "attested_header_capella"))] + pub attested_header: LightClientHeaderCapella, + #[superstruct(only(Deneb), partial_getter(rename = "attested_header_deneb"))] + pub attested_header: LightClientHeaderDeneb, /// current sync aggreggate - pub sync_aggregate: SyncAggregate, + pub sync_aggregate: SyncAggregate, /// Slot of the sync aggregated singature pub signature_slot: Slot, } impl LightClientOptimisticUpdate { - pub fn from_ssz_bytes(bytes: &[u8], fork_name: ForkName) -> Result { - let mut builder = ssz::SszDecoderBuilder::new(bytes); - builder.register_anonymous_variable_length_item()?; - builder.register_type::>()?; - builder.register_type::()?; - let mut decoder = builder.build()?; + pub fn new( + attested_block: &SignedBeaconBlock, + sync_aggregate: SyncAggregate, + signature_slot: Slot, + fork_name: ForkName, + ) -> Result { + let optimistic_update = match fork_name { + ForkName::Altair | ForkName::Merge => { + let optimistic_update = LightClientOptimisticUpdateAltair { + attested_header: LightClientHeaderAltair::block_to_light_client_header( + attested_block, + )?, + sync_aggregate, + signature_slot, + }; + Self::Altair(optimistic_update) + } + ForkName::Capella => { + let optimistic_update = LightClientOptimisticUpdateCapella { + attested_header: LightClientHeaderCapella::block_to_light_client_header( + attested_block, + )?, + sync_aggregate, + signature_slot, + }; + Self::Capella(optimistic_update) + } + ForkName::Deneb => { + let optimistic_update = LightClientOptimisticUpdateDeneb { + attested_header: LightClientHeaderDeneb::block_to_light_client_header( + attested_block, + )?, + sync_aggregate, + signature_slot, + }; + Self::Deneb(optimistic_update) + } + ForkName::Base => return Err(Error::AltairForkNotActive), + }; + + Ok(optimistic_update) + } - let attested_header = decoder - .decode_next_with(|bytes| LightClientHeader::from_ssz_bytes(bytes, fork_name))?; - let sync_aggregate = decoder.decode_next()?; - let signature_slot = decoder.decode_next()?; + pub fn get_slot<'a>(&'a self) -> Slot { + map_light_client_optimistic_update_ref!(&'a _, self.to_ref(), |inner, cons| { + cons(inner); + inner.attested_header.beacon.slot + }) + } - Ok(Self { - attested_header, - sync_aggregate, - signature_slot, + pub fn get_canonical_root<'a>(&'a self) -> Hash256 { + map_light_client_optimistic_update_ref!(&'a _, self.to_ref(), |inner, cons| { + cons(inner); + inner.attested_header.beacon.canonical_root() }) } + pub fn get_parent_root<'a>(&'a self) -> Hash256 { + map_light_client_optimistic_update_ref!(&'a _, self.to_ref(), |inner, cons| { + cons(inner); + inner.attested_header.beacon.parent_root + }) + } + + pub fn from_ssz_bytes(bytes: &[u8], fork_name: ForkName) -> Result { + let optimistic_update = match fork_name { + ForkName::Altair | ForkName::Merge => { + let optimistic_update = LightClientOptimisticUpdateAltair::from_ssz_bytes(bytes)?; + Self::Altair(optimistic_update) + } + ForkName::Capella => { + let optimistic_update = LightClientOptimisticUpdateCapella::from_ssz_bytes(bytes)?; + Self::Capella(optimistic_update) + } + ForkName::Deneb => { + let optimistic_update = LightClientOptimisticUpdateDeneb::from_ssz_bytes(bytes)?; + Self::Deneb(optimistic_update) + } + ForkName::Base => { + return Err(ssz::DecodeError::BytesInvalid(format!( + "LightClientOptimisticUpdate decoding for {fork_name} not implemented" + ))) + } + }; + + Ok(optimistic_update) + } + + /// Custom SSZ decoder that takes a `ForkName` as context. pub fn from_ssz_bytes_for_fork( bytes: &[u8], fork_name: ForkName, @@ -74,12 +173,4 @@ impl ForkVersionDeserialize for LightClientOptimisticUpdate { ))), } } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::MainnetEthSpec; - - ssz_tests_by_fork!(LightClientOptimisticUpdate, ForkName::Deneb); -} +} \ No newline at end of file diff --git a/consensus/types/src/light_client_update.rs b/consensus/types/src/light_client_update.rs index 5cc224aa53e..32b1fe76ecf 100644 --- a/consensus/types/src/light_client_update.rs +++ b/consensus/types/src/light_client_update.rs @@ -1,14 +1,19 @@ use super::{EthSpec, FixedVector, Hash256, Slot, SyncAggregate, SyncCommittee}; use crate::{ beacon_state, test_utils::TestRandom, BeaconBlock, BeaconBlockHeader, BeaconState, ChainSpec, - ForkName, ForkVersionDeserialize, LightClientHeader, SignedBeaconBlock, + ForkName, ForkVersionDeserialize, LightClientHeaderAltair, LightClientHeaderCapella, + LightClientHeaderDeneb, SignedBeaconBlock, }; +use derivative::Derivative; use safe_arith::ArithError; use serde::{Deserialize, Deserializer, Serialize}; use serde_json::Value; +use ssz::Decode; +use ssz_derive::Decode; use ssz_derive::Encode; use ssz_types::typenum::{U4, U5, U6}; use std::sync::Arc; +use superstruct::superstruct; use test_random_derive::TestRandom; use tree_hash::TreeHash; use tree_hash_derive::TreeHash; @@ -63,33 +68,58 @@ impl From for Error { /// A LightClientUpdate is the update we request solely to either complete the bootstrapping process, /// or to sync up to the last committee period, we need to have one ready for each ALTAIR period /// we go over, note: there is no need to keep all of the updates from [ALTAIR_PERIOD, CURRENT_PERIOD]. +#[superstruct( + variants(Altair, Capella, Deneb), + variant_attributes( + derive( + Debug, + Clone, + PartialEq, + Serialize, + Deserialize, + Derivative, + Decode, + Encode, + TestRandom, + arbitrary::Arbitrary, + TreeHash, + ), + serde(bound = "E: EthSpec", deny_unknown_fields), + arbitrary(bound = "E: EthSpec"), + ) +)] #[derive( - Debug, - Clone, - PartialEq, - Serialize, - Deserialize, - Encode, - arbitrary::Arbitrary, - TestRandom, - TreeHash, + Debug, Clone, Serialize, Encode, TreeHash, Deserialize, arbitrary::Arbitrary, PartialEq, )] -#[serde(bound = "T: EthSpec")] -#[arbitrary(bound = "T: EthSpec")] -pub struct LightClientUpdate { +#[serde(untagged)] +#[tree_hash(enum_behaviour = "transparent")] +#[ssz(enum_behaviour = "transparent")] +#[serde(bound = "E: EthSpec", deny_unknown_fields)] +#[arbitrary(bound = "E: EthSpec")] +pub struct LightClientUpdate { /// The last `BeaconBlockHeader` from the last attested block by the sync committee. - pub attested_header: LightClientHeader, + #[superstruct(only(Altair), partial_getter(rename = "attested_header_altair"))] + pub attested_header: LightClientHeaderAltair, + #[superstruct(only(Capella), partial_getter(rename = "attested_header_capella"))] + pub attested_header: LightClientHeaderCapella, + #[superstruct(only(Deneb), partial_getter(rename = "attested_header_deneb"))] + pub attested_header: LightClientHeaderDeneb, /// The `SyncCommittee` used in the next period. - pub next_sync_committee: Arc>, + pub next_sync_committee: Arc>, /// Merkle proof for next sync committee pub next_sync_committee_branch: FixedVector, /// The last `BeaconBlockHeader` from the last attested finalized block (end of epoch). - pub finalized_header: LightClientHeader, + #[superstruct(only(Altair), partial_getter(rename = "finalized_header_altair"))] + pub finalized_header: LightClientHeaderAltair, + #[superstruct(only(Capella), partial_getter(rename = "finalized_header_capella"))] + pub finalized_header: LightClientHeaderCapella, + #[superstruct(only(Deneb), partial_getter(rename = "finalized_header_deneb"))] + pub finalized_header: LightClientHeaderDeneb, /// Merkle proof attesting finalized header. pub finality_branch: FixedVector, /// current sync aggreggate - pub sync_aggregate: SyncAggregate, - /// Slot of the sync aggregated singature + pub sync_aggregate: SyncAggregate, + /// Slot of the sync aggregated signature pub signature_slot: Slot, } @@ -151,52 +181,83 @@ impl LightClientUpdate { attested_state.compute_merkle_proof(NEXT_SYNC_COMMITTEE_INDEX)?; let finality_branch = attested_state.compute_merkle_proof(FINALIZED_ROOT_INDEX)?; - let attested_header = - LightClientHeader::block_to_light_client_header(attested_block, chain_spec)?; - let finalized_header = - LightClientHeader::block_to_light_client_header(finalized_block, chain_spec)?; - - 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(), - }) + let light_client_update = match attested_block + .fork_name(chain_spec) + .map_err(|_| Error::InconsistentFork)? + { + ForkName::Base => return Err(Error::AltairForkNotActive), + ForkName::Altair | ForkName::Merge => { + let attested_header = + LightClientHeaderAltair::block_to_light_client_header(attested_block)?; + let finalized_header = + LightClientHeaderAltair::block_to_light_client_header(finalized_block)?; + Self::Altair(LightClientUpdateAltair { + 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(), + }) + } + ForkName::Capella => { + let attested_header = + LightClientHeaderCapella::block_to_light_client_header(attested_block)?; + let finalized_header = + LightClientHeaderCapella::block_to_light_client_header(finalized_block)?; + Self::Capella(LightClientUpdateCapella { + 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(), + }) + } + ForkName::Deneb => { + let attested_header = + LightClientHeaderDeneb::block_to_light_client_header(attested_block)?; + let finalized_header = + LightClientHeaderDeneb::block_to_light_client_header(finalized_block)?; + Self::Deneb(LightClientUpdateDeneb { + 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(), + }) + } + }; + + Ok(light_client_update) } pub fn from_ssz_bytes(bytes: &[u8], fork_name: ForkName) -> Result { - let mut builder = ssz::SszDecoderBuilder::new(bytes); - builder.register_anonymous_variable_length_item()?; - builder.register_type::>()?; - builder.register_type::>()?; - builder.register_anonymous_variable_length_item()?; - builder.register_type::>()?; - builder.register_type::>()?; - builder.register_type::()?; - let mut decoder = builder.build()?; - - let attested_header = decoder - .decode_next_with(|bytes| LightClientHeader::from_ssz_bytes(bytes, fork_name))?; - let next_sync_committee = decoder.decode_next()?; - let next_sync_committee_branch = decoder.decode_next()?; - let finalized_header = decoder - .decode_next_with(|bytes| LightClientHeader::from_ssz_bytes(bytes, fork_name))?; - let finality_branch = decoder.decode_next()?; - let sync_aggregate = decoder.decode_next()?; - let signature_slot = decoder.decode_next()?; - - Ok(Self { - attested_header, - next_sync_committee: Arc::new(next_sync_committee), - next_sync_committee_branch, - finalized_header, - finality_branch, - sync_aggregate, - signature_slot, - }) + let update = match fork_name { + ForkName::Altair | ForkName::Merge => { + let update = LightClientUpdateAltair::from_ssz_bytes(bytes)?; + Self::Altair(update) + } + ForkName::Capella => { + let update = LightClientUpdateCapella::from_ssz_bytes(bytes)?; + Self::Capella(update) + } + ForkName::Deneb => { + let update = LightClientUpdateDeneb::from_ssz_bytes(bytes)?; + Self::Deneb(update) + } + ForkName::Base => { + return Err(ssz::DecodeError::BytesInvalid(format!( + "LightClientUpdate decoding for {fork_name} not implemented" + ))) + } + }; + + Ok(update) } pub fn from_ssz_bytes_for_fork( @@ -210,11 +271,8 @@ impl LightClientUpdate { #[cfg(test)] mod tests { use super::*; - use crate::MainnetEthSpec; use ssz_types::typenum::Unsigned; - ssz_tests_by_fork!(LightClientUpdate, ForkName::Deneb); - #[test] fn finalized_root_params() { assert!(2usize.pow(FINALIZED_ROOT_PROOF_LEN as u32) <= FINALIZED_ROOT_INDEX); diff --git a/testing/ef_tests/check_all_files_accessed.py b/testing/ef_tests/check_all_files_accessed.py index 7629d61827f..68e1fce4141 100755 --- a/testing/ef_tests/check_all_files_accessed.py +++ b/testing/ef_tests/check_all_files_accessed.py @@ -27,10 +27,6 @@ "tests/.*/.*/ssz_static/PowBlock/", # light_client "tests/.*/.*/light_client", - # LightClientStore - "tests/.*/.*/ssz_static/LightClientStore", - # LightClientSnapshot - "tests/.*/.*/ssz_static/LightClientSnapshot", # One of the EF researchers likes to pack the tarballs on a Mac ".*\.DS_Store.*", # More Mac weirdness. diff --git a/testing/ef_tests/src/handler.rs b/testing/ef_tests/src/handler.rs index d262a116266..0295ff1bd49 100644 --- a/testing/ef_tests/src/handler.rs +++ b/testing/ef_tests/src/handler.rs @@ -243,51 +243,7 @@ pub struct SszStaticTHCHandler(PhantomData<(T, E)>); /// Handler for SSZ types that don't implement `ssz::Decode`. #[derive(Derivative)] #[derivative(Default(bound = ""))] -pub struct SszStaticWithSpecHandler { - supported_forks: Vec, - _phantom: PhantomData<(T, E)>, -} - -impl SszStaticWithSpecHandler { - pub fn for_forks(supported_forks: Vec) -> Self { - SszStaticWithSpecHandler { - supported_forks, - _phantom: PhantomData, - } - } - - pub fn base_only() -> Self { - Self::for_forks(vec![ForkName::Base]) - } - - pub fn altair_only() -> Self { - Self::for_forks(vec![ForkName::Altair]) - } - - pub fn merge_only() -> Self { - Self::for_forks(vec![ForkName::Merge]) - } - - pub fn capella_only() -> Self { - Self::for_forks(vec![ForkName::Capella]) - } - - pub fn deneb_only() -> Self { - Self::for_forks(vec![ForkName::Deneb]) - } - - pub fn altair_and_later() -> Self { - Self::for_forks(ForkName::list_all()[1..].to_vec()) - } - - pub fn merge_and_later() -> Self { - Self::for_forks(ForkName::list_all()[2..].to_vec()) - } - - pub fn capella_and_later() -> Self { - Self::for_forks(ForkName::list_all()[3..].to_vec()) - } -} +pub struct SszStaticWithSpecHandler(PhantomData<(T, E)>); impl Handler for SszStaticHandler where @@ -351,10 +307,6 @@ where fn handler_name(&self) -> String { T::name().into() } - - fn is_enabled_for_fork(&self, fork_name: ForkName) -> bool { - self.supported_forks.contains(&fork_name) - } } #[derive(Derivative)] diff --git a/testing/ef_tests/src/type_name.rs b/testing/ef_tests/src/type_name.rs index 62bba571d76..947f88ef964 100644 --- a/testing/ef_tests/src/type_name.rs +++ b/testing/ef_tests/src/type_name.rs @@ -74,13 +74,25 @@ type_name!(ForkData); type_name_generic!(HistoricalBatch); type_name_generic!(IndexedAttestation); type_name_generic!(LightClientBootstrap); +type_name_generic!(LightClientBootstrapAltair, "LightClientBootstrap"); +type_name_generic!(LightClientBootstrapCapella, "LightClientBootstrap"); +type_name_generic!(LightClientBootstrapDeneb, "LightClientBootstrap"); type_name_generic!(LightClientFinalityUpdate); +type_name_generic!(LightClientFinalityUpdateAltair, "LightClientFinalityUpdate"); +type_name_generic!(LightClientFinalityUpdateCapella, "LightClientFinalityUpdate"); +type_name_generic!(LightClientFinalityUpdateDeneb, "LightClientFinalityUpdate"); type_name_generic!(LightClientHeader); type_name_generic!(LightClientHeaderDeneb, "LightClientHeader"); type_name_generic!(LightClientHeaderCapella, "LightClientHeader"); type_name_generic!(LightClientHeaderAltair, "LightClientHeader"); type_name_generic!(LightClientOptimisticUpdate); +type_name_generic!(LightClientOptimisticUpdateAltair, "LightClientOptimisticUpdate"); +type_name_generic!(LightClientOptimisticUpdateCapella, "LightClientOptimisticUpdate"); +type_name_generic!(LightClientOptimisticUpdateDeneb, "LightClientOptimisticUpdate"); type_name_generic!(LightClientUpdate); +type_name_generic!(LightClientUpdateAltair, "LightClientUpdate"); +type_name_generic!(LightClientUpdateCapella, "LightClientUpdate"); +type_name_generic!(LightClientUpdateDeneb, "LightClientUpdate"); type_name_generic!(PendingAttestation); type_name!(ProposerSlashing); type_name_generic!(SignedAggregateAndProof); diff --git a/testing/ef_tests/tests/tests.rs b/testing/ef_tests/tests/tests.rs index 2791adb3826..c81819f3dad 100644 --- a/testing/ef_tests/tests/tests.rs +++ b/testing/ef_tests/tests/tests.rs @@ -217,7 +217,7 @@ mod ssz_static { use ef_tests::{Handler, SszStaticHandler, SszStaticTHCHandler, SszStaticWithSpecHandler}; use types::blob_sidecar::BlobIdentifier; use types::historical_summary::HistoricalSummary; - use types::{LightClientHeaderAltair, *}; + use types::{LightClientBootstrapAltair, *}; ssz_static_test!(aggregate_and_proof, AggregateAndProof<_>); ssz_static_test!(attestation, Attestation<_>); @@ -248,11 +248,7 @@ mod ssz_static { ssz_static_test!(signed_voluntary_exit, SignedVoluntaryExit); ssz_static_test!(signing_data, SigningData); ssz_static_test!(validator, Validator); - // ssz_static_test!(voluntary_exit, VoluntaryExit); - // ssz_static_test!(light_client_bootstrap, SszStaticWithSpecHandler, LightClientBootstrap<_>); - // ssz_static_test!(light_client_update, SszStaticWithSpecHandler, LightClientUpdate<_>); - // ssz_static_test!(light_client_finality_update, SszStaticWithSpecHandler, LightClientFinalityUpdate<_>); - // ssz_static_test!(light_client_optimistic_update, SszStaticWithSpecHandler, LightClientOptimisticUpdate<_>); + ssz_static_test!(voluntary_exit, VoluntaryExit); // BeaconBlockBody has no internal indicator of which fork it is for, so we test it separately. #[test] fn beacon_block_body() { @@ -285,44 +281,38 @@ mod ssz_static { .run(); } + // LightClientBootstrap has no internal indicator of which fork it is for, so we test it separately. #[test] fn light_client_bootstrap() { - // SszStaticWithSpecHandler::, MinimalEthSpec>::altair_only() - // .run(); - // SszStaticWithSpecHandler::, MainnetEthSpec>::altair_only() - // .run(); - SszStaticWithSpecHandler::, MinimalEthSpec>::capella_only() + SszStaticHandler::, MinimalEthSpec>::altair_only() .run(); - SszStaticWithSpecHandler::, MainnetEthSpec>::capella_only() + SszStaticHandler::, MainnetEthSpec>::altair_only() .run(); - SszStaticWithSpecHandler::, MinimalEthSpec>::deneb_only() + SszStaticHandler::, MinimalEthSpec>::merge_only() .run(); - SszStaticWithSpecHandler::, MainnetEthSpec>::deneb_only() + SszStaticHandler::, MainnetEthSpec>::merge_only() .run(); - } - - #[test] - fn light_client_finality_update() { - // SszStaticWithSpecHandler::, MinimalEthSpec>::altair_only() - // .run(); - // SszStaticWithSpecHandler::, MainnetEthSpec>::altair_only() - // .run(); - SszStaticWithSpecHandler::, MinimalEthSpec>::capella_only() + SszStaticHandler::, MinimalEthSpec>::capella_only() .run(); - SszStaticWithSpecHandler::, MainnetEthSpec>::capella_only() + SszStaticHandler::, MainnetEthSpec>::capella_only() .run(); - SszStaticWithSpecHandler::, MinimalEthSpec>::deneb_only() + SszStaticHandler::, MinimalEthSpec>::deneb_only() .run(); - SszStaticWithSpecHandler::, MainnetEthSpec>::deneb_only() + SszStaticHandler::, MainnetEthSpec>::deneb_only() .run(); } + // LightClientHeader has no internal indicator of which fork it is for, so we test it separately. #[test] fn light_client_header() { SszStaticHandler::, MinimalEthSpec>::altair_only() .run(); SszStaticHandler::, MainnetEthSpec>::altair_only() .run(); + SszStaticHandler::, MinimalEthSpec>::merge_only() + .run(); + SszStaticHandler::, MainnetEthSpec>::merge_only() + .run(); SszStaticHandler::, MinimalEthSpec>::capella_only( ) @@ -337,36 +327,85 @@ mod ssz_static { .run(); } + // LightClientOptimisticUpdate has no internal indicator of which fork it is for, so we test it separately. #[test] fn light_client_optimistic_update() { - // SszStaticWithSpecHandler::, MinimalEthSpec>::altair_only( - // ) - // .run(); - // SszStaticWithSpecHandler::, MainnetEthSpec>::altair_only( - // ) - // .run(); - SszStaticWithSpecHandler::, MinimalEthSpec>::capella_only( + SszStaticHandler::, MinimalEthSpec>::altair_only( + ) + .run(); + SszStaticHandler::, MainnetEthSpec>::altair_only( + ) + .run(); + SszStaticHandler::, MinimalEthSpec>::merge_only( + ) + .run(); + SszStaticHandler::, MainnetEthSpec>::merge_only( + ) + .run(); + SszStaticHandler::, MinimalEthSpec>::capella_only( + ) + .run(); + SszStaticHandler::, MainnetEthSpec>::capella_only( + ) + .run(); + SszStaticHandler::, MinimalEthSpec>::deneb_only( + ) + .run(); + SszStaticHandler::, MainnetEthSpec>::deneb_only( + ) + .run(); + } + + // LightClientFinalityUpdate has no internal indicator of which fork it is for, so we test it separately. + #[test] + fn light_client_finality_update() { + SszStaticHandler::, MinimalEthSpec>::altair_only( + ) + .run(); + SszStaticHandler::, MainnetEthSpec>::altair_only( + ) + .run(); + SszStaticHandler::, MinimalEthSpec>::merge_only( + ) + .run(); + SszStaticHandler::, MainnetEthSpec>::merge_only( + ) + .run(); + SszStaticHandler::, MinimalEthSpec>::capella_only( ) .run(); - SszStaticWithSpecHandler::, MainnetEthSpec>::capella_only( + SszStaticHandler::, MainnetEthSpec>::capella_only( ) .run(); - SszStaticWithSpecHandler::, MinimalEthSpec>::deneb_only( + SszStaticHandler::, MinimalEthSpec>::deneb_only( ) .run(); - SszStaticWithSpecHandler::, MainnetEthSpec>::deneb_only( + SszStaticHandler::, MainnetEthSpec>::deneb_only( ) .run(); } + // LightClientUpdate has no internal indicator of which fork it is for, so we test it separately. #[test] fn light_client_update() { - // SszStaticWithSpecHandler::, MinimalEthSpec>::altair_only().run(); - // SszStaticWithSpecHandler::, MainnetEthSpec>::altair_only().run(); - SszStaticWithSpecHandler::, MinimalEthSpec>::capella_only().run(); - SszStaticWithSpecHandler::, MainnetEthSpec>::capella_only().run(); - SszStaticWithSpecHandler::, MinimalEthSpec>::deneb_only().run(); - SszStaticWithSpecHandler::, MainnetEthSpec>::deneb_only().run(); + SszStaticHandler::, MinimalEthSpec>::altair_only() + .run(); + SszStaticHandler::, MainnetEthSpec>::altair_only() + .run(); + SszStaticHandler::, MinimalEthSpec>::merge_only() + .run(); + SszStaticHandler::, MainnetEthSpec>::merge_only() + .run(); + SszStaticHandler::, MinimalEthSpec>::capella_only( + ) + .run(); + SszStaticHandler::, MainnetEthSpec>::capella_only( + ) + .run(); + SszStaticHandler::, MinimalEthSpec>::deneb_only() + .run(); + SszStaticHandler::, MainnetEthSpec>::deneb_only() + .run(); } #[test] diff --git a/testing/simulator/src/checks.rs b/testing/simulator/src/checks.rs index f38eacc394a..d30e44a1174 100644 --- a/testing/simulator/src/checks.rs +++ b/testing/simulator/src/checks.rs @@ -287,13 +287,13 @@ pub(crate) async fn verify_light_client_updates( } // Verify light client optimistic update. `signature_slot_distance` should be 1 in the ideal scenario. - let signature_slot = client + let signature_slot = *client .get_beacon_light_client_optimistic_update::() .await .map_err(|e| format!("Error while getting light client updates: {:?}", e))? .ok_or(format!("Light client optimistic update not found {slot:?}"))? .data - .signature_slot; + .signature_slot(); let signature_slot_distance = slot - signature_slot; if signature_slot_distance > light_client_update_slot_tolerance { return Err(format!("Existing optimistic update too old: signature slot {signature_slot}, current slot {slot:?}")); @@ -316,13 +316,13 @@ pub(crate) async fn verify_light_client_updates( } continue; } - let signature_slot = client + let signature_slot = *client .get_beacon_light_client_finality_update::() .await .map_err(|e| format!("Error while getting light client updates: {:?}", e))? .ok_or(format!("Light client finality update not found {slot:?}"))? .data - .signature_slot; + .signature_slot(); let signature_slot_distance = slot - signature_slot; if signature_slot_distance > light_client_update_slot_tolerance { return Err(format!( From dd43c1251a11a2dff9cdec13f2d4b887423393e9 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Tue, 12 Mar 2024 11:01:40 +0200 Subject: [PATCH 67/71] changes from feedback --- .../src/light_client_server_cache.rs | 8 ++- .../src/rpc/codec/ssz_snappy.rs | 2 +- consensus/types/src/light_client_bootstrap.rs | 24 ++++----- .../types/src/light_client_finality_update.rs | 17 ++----- consensus/types/src/light_client_header.rs | 4 +- .../src/light_client_optimistic_update.rs | 19 +++---- consensus/types/src/light_client_update.rs | 7 --- testing/ef_tests/src/cases/ssz_static.rs | 49 +------------------ testing/ef_tests/src/type_name.rs | 20 ++++++-- testing/ef_tests/tests/tests.rs | 22 +++++---- 10 files changed, 58 insertions(+), 114 deletions(-) diff --git a/beacon_node/beacon_chain/src/light_client_server_cache.rs b/beacon_node/beacon_chain/src/light_client_server_cache.rs index 325f06da44c..d480a6b56b2 100644 --- a/beacon_node/beacon_chain/src/light_client_server_cache.rs +++ b/beacon_node/beacon_chain/src/light_client_server_cache.rs @@ -101,8 +101,6 @@ impl LightClientServerCache { let attested_slot = attested_block.slot(); - let fork_name = attested_block.fork_name(chain_spec)?; - // Spec: Full nodes SHOULD provide the LightClientOptimisticUpdate with the highest // attested_header.beacon.slot (if multiple, highest signature_slot) as selected by fork choice let is_latest_optimistic = match &self.latest_optimistic_update.read().clone() { @@ -117,7 +115,7 @@ impl LightClientServerCache { &attested_block, sync_aggregate.clone(), signature_slot, - fork_name, + chain_spec, )?); }; @@ -140,7 +138,7 @@ impl LightClientServerCache { cached_parts.finality_branch.clone(), sync_aggregate.clone(), signature_slot, - fork_name, + chain_spec, )?); } else { debug!( @@ -227,7 +225,7 @@ fn is_latest_finality_update( attested_slot: Slot, signature_slot: Slot, ) -> bool { - let prev_slot = prev.get_slot(); + let prev_slot = prev.get_attested_header_slot(); if attested_slot > prev_slot { true } else { diff --git a/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs b/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs index bdd566cce6b..c7752098604 100644 --- a/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs +++ b/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs @@ -592,7 +592,7 @@ fn handle_rpc_response( )))), SupportedProtocol::LightClientBootstrapV1 => match fork_name { Some(fork_name) => Ok(Some(RPCResponse::LightClientBootstrap(Arc::new( - LightClientBootstrap::from_ssz_bytes_for_fork(decoded_buffer, fork_name)?, + LightClientBootstrap::from_ssz_bytes(decoded_buffer, fork_name)?, )))), None => Err(RPCError::ErrorResponse( RPCResponseErrorCode::InvalidRequest, diff --git a/consensus/types/src/light_client_bootstrap.rs b/consensus/types/src/light_client_bootstrap.rs index 1a3e2049c32..9966b5b90ea 100644 --- a/consensus/types/src/light_client_bootstrap.rs +++ b/consensus/types/src/light_client_bootstrap.rs @@ -90,14 +90,6 @@ impl LightClientBootstrap { Ok(bootstrap) } - /// Custom SSZ decoder that takes a `ForkName` as context. - pub fn from_ssz_bytes_for_fork( - bytes: &[u8], - fork_name: ForkName, - ) -> Result { - Self::from_ssz_bytes(bytes, fork_name) - } - pub fn from_beacon_state( beacon_state: &mut BeaconState, block: &SignedBeaconBlock, @@ -106,7 +98,9 @@ impl LightClientBootstrap { let mut header = beacon_state.latest_block_header().clone(); header.state_root = beacon_state.update_tree_hash_cache()?; let current_sync_committee_branch = - beacon_state.compute_merkle_proof(CURRENT_SYNC_COMMITTEE_INDEX)?; + FixedVector::new(beacon_state.compute_merkle_proof(CURRENT_SYNC_COMMITTEE_INDEX)?)?; + + let current_sync_committee = beacon_state.current_sync_committee()?.clone(); let light_client_bootstrap = match block .fork_name(chain_spec) @@ -115,18 +109,18 @@ impl LightClientBootstrap { ForkName::Base => return Err(Error::AltairForkNotActive), ForkName::Altair | ForkName::Merge => Self::Altair(LightClientBootstrapAltair { header: LightClientHeaderAltair::block_to_light_client_header(block)?, - current_sync_committee: beacon_state.current_sync_committee()?.clone(), - current_sync_committee_branch: FixedVector::new(current_sync_committee_branch)?, + current_sync_committee, + current_sync_committee_branch, }), ForkName::Capella => Self::Capella(LightClientBootstrapCapella { header: LightClientHeaderCapella::block_to_light_client_header(block)?, - current_sync_committee: beacon_state.current_sync_committee()?.clone(), - current_sync_committee_branch: FixedVector::new(current_sync_committee_branch)?, + current_sync_committee, + current_sync_committee_branch, }), ForkName::Deneb => Self::Deneb(LightClientBootstrapDeneb { header: LightClientHeaderDeneb::block_to_light_client_header(block)?, - current_sync_committee: beacon_state.current_sync_committee()?.clone(), - current_sync_committee_branch: FixedVector::new(current_sync_committee_branch)?, + current_sync_committee, + current_sync_committee_branch, }), }; diff --git a/consensus/types/src/light_client_finality_update.rs b/consensus/types/src/light_client_finality_update.rs index bdd23c453b4..ace03821750 100644 --- a/consensus/types/src/light_client_finality_update.rs +++ b/consensus/types/src/light_client_finality_update.rs @@ -1,4 +1,5 @@ use super::{EthSpec, FixedVector, Hash256, Slot, SyncAggregate}; +use crate::ChainSpec; use crate::{ light_client_update::*, test_utils::TestRandom, ForkName, ForkVersionDeserialize, LightClientHeaderAltair, LightClientHeaderCapella, LightClientHeaderDeneb, SignedBeaconBlock, @@ -71,9 +72,9 @@ impl LightClientFinalityUpdate { finality_branch: FixedVector, sync_aggregate: SyncAggregate, signature_slot: Slot, - fork_name: ForkName, + chain_spec: &ChainSpec, ) -> Result { - let finality_update = match fork_name { + let finality_update = match attested_block.fork_name(chain_spec).map_err(|_| Error::InconsistentFork)? { ForkName::Altair | ForkName::Merge => { let finality_update = LightClientFinalityUpdateAltair { attested_header: LightClientHeaderAltair::block_to_light_client_header( @@ -122,7 +123,7 @@ impl LightClientFinalityUpdate { Ok(finality_update) } - pub fn get_slot<'a>(&'a self) -> Slot { + pub fn get_attested_header_slot<'a>(&'a self) -> Slot { map_light_client_finality_update_ref!(&'a _, self.to_ref(), |inner, cons| { cons(inner); inner.attested_header.beacon.slot @@ -152,14 +153,6 @@ impl LightClientFinalityUpdate { Ok(finality_update) } - - /// Custom SSZ decoder that takes a `ForkName` as context. - pub fn from_ssz_bytes_for_fork( - bytes: &[u8], - fork_name: ForkName, - ) -> Result { - Self::from_ssz_bytes(bytes, fork_name) - } } impl ForkVersionDeserialize for LightClientFinalityUpdate { @@ -178,4 +171,4 @@ impl ForkVersionDeserialize for LightClientFinalityUpdate { ))), } } -} \ No newline at end of file +} diff --git a/consensus/types/src/light_client_header.rs b/consensus/types/src/light_client_header.rs index 6f49fed5cbb..8e8e07e8a91 100644 --- a/consensus/types/src/light_client_header.rs +++ b/consensus/types/src/light_client_header.rs @@ -37,7 +37,9 @@ use tree_hash_derive::TreeHash; arbitrary(bound = "E: EthSpec"), ) )] -#[derive(Debug, Clone, Serialize, TreeHash, Encode, Deserialize, arbitrary::Arbitrary, PartialEq)] +#[derive( + Debug, Clone, Serialize, TreeHash, Encode, Deserialize, arbitrary::Arbitrary, PartialEq, +)] #[serde(untagged)] #[tree_hash(enum_behaviour = "transparent")] #[ssz(enum_behaviour = "transparent")] diff --git a/consensus/types/src/light_client_optimistic_update.rs b/consensus/types/src/light_client_optimistic_update.rs index 9206fedc193..4a7a08b9c59 100644 --- a/consensus/types/src/light_client_optimistic_update.rs +++ b/consensus/types/src/light_client_optimistic_update.rs @@ -1,7 +1,7 @@ use super::{EthSpec, ForkName, ForkVersionDeserialize, Slot, SyncAggregate}; use crate::test_utils::TestRandom; use crate::{ - light_client_update::*, LightClientHeaderAltair, LightClientHeaderCapella, + light_client_update::*, ChainSpec, LightClientHeaderAltair, LightClientHeaderCapella, LightClientHeaderDeneb, SignedBeaconBlock, }; use derivative::Derivative; @@ -64,9 +64,12 @@ impl LightClientOptimisticUpdate { attested_block: &SignedBeaconBlock, sync_aggregate: SyncAggregate, signature_slot: Slot, - fork_name: ForkName, + chain_spec: &ChainSpec, ) -> Result { - let optimistic_update = match fork_name { + let optimistic_update = match attested_block + .fork_name(chain_spec) + .map_err(|_| Error::InconsistentFork)? + { ForkName::Altair | ForkName::Merge => { let optimistic_update = LightClientOptimisticUpdateAltair { attested_header: LightClientHeaderAltair::block_to_light_client_header( @@ -147,14 +150,6 @@ impl LightClientOptimisticUpdate { Ok(optimistic_update) } - - /// Custom SSZ decoder that takes a `ForkName` as context. - pub fn from_ssz_bytes_for_fork( - bytes: &[u8], - fork_name: ForkName, - ) -> Result { - Self::from_ssz_bytes(bytes, fork_name) - } } impl ForkVersionDeserialize for LightClientOptimisticUpdate { @@ -173,4 +168,4 @@ impl ForkVersionDeserialize for LightClientOptimisticUpdate { ))), } } -} \ No newline at end of file +} diff --git a/consensus/types/src/light_client_update.rs b/consensus/types/src/light_client_update.rs index 32b1fe76ecf..809b8ab8dac 100644 --- a/consensus/types/src/light_client_update.rs +++ b/consensus/types/src/light_client_update.rs @@ -259,13 +259,6 @@ impl LightClientUpdate { Ok(update) } - - pub fn from_ssz_bytes_for_fork( - bytes: &[u8], - fork_name: ForkName, - ) -> Result { - Self::from_ssz_bytes(bytes, fork_name) - } } #[cfg(test)] diff --git a/testing/ef_tests/src/cases/ssz_static.rs b/testing/ef_tests/src/cases/ssz_static.rs index 137410d6986..423dc31528f 100644 --- a/testing/ef_tests/src/cases/ssz_static.rs +++ b/testing/ef_tests/src/cases/ssz_static.rs @@ -5,10 +5,7 @@ use crate::decode::{snappy_decode_file, yaml_decode_file}; use serde::Deserialize; use ssz::Decode; use tree_hash::TreeHash; -use types::{ - BeaconBlock, BeaconState, ForkName, Hash256, LightClientBootstrap, LightClientFinalityUpdate, - LightClientOptimisticUpdate, LightClientUpdate, SignedBeaconBlock, -}; +use types::{BeaconBlock, BeaconState, ForkName, Hash256, SignedBeaconBlock}; #[derive(Debug, Clone, Deserialize)] struct SszStaticRoots { @@ -151,47 +148,3 @@ impl Case for SszStaticWithSpec> { Ok(()) } } - -impl Case for SszStaticWithSpec> { - fn result(&self, _case_index: usize, fork_name: ForkName) -> Result<(), Error> { - check_serialization(&self.value, &self.serialized, |bytes| { - LightClientBootstrap::from_ssz_bytes(bytes, fork_name) - })?; - check_tree_hash(&self.roots.root, self.value.tree_hash_root().as_bytes())?; - Ok(()) - } -} - -impl Case for SszStaticWithSpec> { - fn result(&self, _case_index: usize, fork_name: ForkName) -> Result<(), Error> { - check_serialization(&self.value, &self.serialized, |bytes| { - LightClientFinalityUpdate::from_ssz_bytes(bytes, fork_name) - })?; - check_tree_hash(&self.roots.root, self.value.tree_hash_root().as_bytes())?; - Ok(()) - } -} - -impl Case for SszStaticWithSpec> { - fn result(&self, _case_index: usize, fork_name: ForkName) -> Result<(), Error> { - check_serialization(&self.value, &self.serialized, |bytes| { - LightClientOptimisticUpdate::from_ssz_bytes(bytes, fork_name) - })?; - check_tree_hash(&self.roots.root, self.value.tree_hash_root().as_bytes())?; - Ok(()) - } -} - -impl Case for SszStaticWithSpec> { - fn result(&self, _case_index: usize, fork_name: ForkName) -> Result<(), Error> { - match fork_name { - ForkName::Base | ForkName::Merge => return Ok(()), - _ => {} - }; - check_serialization(&self.value, &self.serialized, |bytes| { - LightClientUpdate::from_ssz_bytes(bytes, fork_name) - })?; - check_tree_hash(&self.roots.root, self.value.tree_hash_root().as_bytes())?; - Ok(()) - } -} diff --git a/testing/ef_tests/src/type_name.rs b/testing/ef_tests/src/type_name.rs index 947f88ef964..ef5d7eb001c 100644 --- a/testing/ef_tests/src/type_name.rs +++ b/testing/ef_tests/src/type_name.rs @@ -79,16 +79,28 @@ type_name_generic!(LightClientBootstrapCapella, "LightClientBootstrap"); type_name_generic!(LightClientBootstrapDeneb, "LightClientBootstrap"); type_name_generic!(LightClientFinalityUpdate); type_name_generic!(LightClientFinalityUpdateAltair, "LightClientFinalityUpdate"); -type_name_generic!(LightClientFinalityUpdateCapella, "LightClientFinalityUpdate"); +type_name_generic!( + LightClientFinalityUpdateCapella, + "LightClientFinalityUpdate" +); type_name_generic!(LightClientFinalityUpdateDeneb, "LightClientFinalityUpdate"); type_name_generic!(LightClientHeader); type_name_generic!(LightClientHeaderDeneb, "LightClientHeader"); type_name_generic!(LightClientHeaderCapella, "LightClientHeader"); type_name_generic!(LightClientHeaderAltair, "LightClientHeader"); type_name_generic!(LightClientOptimisticUpdate); -type_name_generic!(LightClientOptimisticUpdateAltair, "LightClientOptimisticUpdate"); -type_name_generic!(LightClientOptimisticUpdateCapella, "LightClientOptimisticUpdate"); -type_name_generic!(LightClientOptimisticUpdateDeneb, "LightClientOptimisticUpdate"); +type_name_generic!( + LightClientOptimisticUpdateAltair, + "LightClientOptimisticUpdate" +); +type_name_generic!( + LightClientOptimisticUpdateCapella, + "LightClientOptimisticUpdate" +); +type_name_generic!( + LightClientOptimisticUpdateDeneb, + "LightClientOptimisticUpdate" +); type_name_generic!(LightClientUpdate); type_name_generic!(LightClientUpdateAltair, "LightClientUpdate"); type_name_generic!(LightClientUpdateCapella, "LightClientUpdate"); diff --git a/testing/ef_tests/tests/tests.rs b/testing/ef_tests/tests/tests.rs index c81819f3dad..3093239f7fd 100644 --- a/testing/ef_tests/tests/tests.rs +++ b/testing/ef_tests/tests/tests.rs @@ -275,23 +275,27 @@ mod ssz_static { // Altair and later #[test] fn contribution_and_proof() { - SszStaticHandler::, MinimalEthSpec>::altair_only() - .run(); - SszStaticHandler::, MainnetEthSpec>::altair_only() - .run(); + SszStaticHandler::, MinimalEthSpec>::altair_and_later( + ) + .run(); + SszStaticHandler::, MainnetEthSpec>::altair_and_later( + ) + .run(); } - // LightClientBootstrap has no internal indicator of which fork it is for, so we test it separately. + // LightClientBootstrap has no internal indicator of which fork it is for, so we test it separately. #[test] fn light_client_bootstrap() { SszStaticHandler::, MinimalEthSpec>::altair_only() .run(); SszStaticHandler::, MainnetEthSpec>::altair_only() .run(); - SszStaticHandler::, MinimalEthSpec>::merge_only() - .run(); - SszStaticHandler::, MainnetEthSpec>::merge_only() - .run(); + SszStaticHandler::, MinimalEthSpec>::merge_only( + ) + .run(); + SszStaticHandler::, MainnetEthSpec>::merge_only( + ) + .run(); SszStaticHandler::, MinimalEthSpec>::capella_only() .run(); SszStaticHandler::, MainnetEthSpec>::capella_only() From aba14758bf5c7b3a879c900ec452ff12fa522023 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Tue, 12 Mar 2024 11:29:29 +0200 Subject: [PATCH 68/71] linting --- consensus/types/src/beacon_block_body.rs | 5 +---- .../types/src/light_client_finality_update.rs | 5 ++++- consensus/types/src/light_client_header.rs | 14 ++++++-------- testing/ef_tests/check_all_files_accessed.py | 4 ++++ 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/consensus/types/src/beacon_block_body.rs b/consensus/types/src/beacon_block_body.rs index 3da072debfc..cdac9bbf506 100644 --- a/consensus/types/src/beacon_block_body.rs +++ b/consensus/types/src/beacon_block_body.rs @@ -601,10 +601,7 @@ impl From>> } impl BeaconBlockBody { - pub fn block_body_merkle_proof( - &mut self, - generalized_index: usize, - ) -> Result, Error> { + pub fn block_body_merkle_proof(&self, generalized_index: usize) -> Result, Error> { let field_index = match generalized_index { light_client_update::EXECUTION_PAYLOAD_INDEX => { // Execution payload is a top-level field, subtract off the generalized indices diff --git a/consensus/types/src/light_client_finality_update.rs b/consensus/types/src/light_client_finality_update.rs index ace03821750..469a6cce3db 100644 --- a/consensus/types/src/light_client_finality_update.rs +++ b/consensus/types/src/light_client_finality_update.rs @@ -74,7 +74,10 @@ impl LightClientFinalityUpdate { signature_slot: Slot, chain_spec: &ChainSpec, ) -> Result { - let finality_update = match attested_block.fork_name(chain_spec).map_err(|_| Error::InconsistentFork)? { + let finality_update = match attested_block + .fork_name(chain_spec) + .map_err(|_| Error::InconsistentFork)? + { ForkName::Altair | ForkName::Merge => { let finality_update = LightClientFinalityUpdateAltair { attested_header: LightClientHeaderAltair::block_to_light_client_header( diff --git a/consensus/types/src/light_client_header.rs b/consensus/types/src/light_client_header.rs index 8e8e07e8a91..ce640b94ab6 100644 --- a/consensus/types/src/light_client_header.rs +++ b/consensus/types/src/light_client_header.rs @@ -136,11 +136,10 @@ impl LightClientHeaderCapella { let payload = block .message() .execution_payload()? - .execution_payload_capella()? - .to_owned(); + .execution_payload_capella()?; - let header = ExecutionPayloadHeaderCapella::from(&payload); - let mut beacon_block_body = BeaconBlockBody::from( + let header = ExecutionPayloadHeaderCapella::from(payload); + let beacon_block_body = BeaconBlockBody::from( block .message() .body_capella() @@ -165,11 +164,10 @@ impl LightClientHeaderDeneb { let payload = block .message() .execution_payload()? - .execution_payload_deneb()? - .to_owned(); + .execution_payload_deneb()?; - let header = ExecutionPayloadHeaderDeneb::from(&payload); - let mut beacon_block_body = BeaconBlockBody::from( + let header = ExecutionPayloadHeaderDeneb::from(payload); + let beacon_block_body = BeaconBlockBody::from( block .message() .body_deneb() diff --git a/testing/ef_tests/check_all_files_accessed.py b/testing/ef_tests/check_all_files_accessed.py index 68e1fce4141..7629d61827f 100755 --- a/testing/ef_tests/check_all_files_accessed.py +++ b/testing/ef_tests/check_all_files_accessed.py @@ -27,6 +27,10 @@ "tests/.*/.*/ssz_static/PowBlock/", # light_client "tests/.*/.*/light_client", + # LightClientStore + "tests/.*/.*/ssz_static/LightClientStore", + # LightClientSnapshot + "tests/.*/.*/ssz_static/LightClientSnapshot", # One of the EF researchers likes to pack the tarballs on a Mac ".*\.DS_Store.*", # More Mac weirdness. From b3f7b81d14cdf4f4baf95cbe36794468c7e8d595 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Tue, 12 Mar 2024 16:32:40 +0200 Subject: [PATCH 69/71] test fix --- beacon_node/http_api/tests/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beacon_node/http_api/tests/tests.rs b/beacon_node/http_api/tests/tests.rs index 39f2b9d48c1..ae109f93241 100644 --- a/beacon_node/http_api/tests/tests.rs +++ b/beacon_node/http_api/tests/tests.rs @@ -1717,7 +1717,7 @@ impl ApiTester { }; let expected = block.slot(); - assert_eq!(result.header.beacon().slot, expected); + assert_eq!(result.get_slot(), expected); self } From 8a7b2bc3363bca090320eeec88fdd0d3a27ba1dd Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Tue, 12 Mar 2024 19:55:47 +0200 Subject: [PATCH 70/71] cleanup --- consensus/types/src/light_client_bootstrap.rs | 8 ++++++++ .../types/src/light_client_finality_update.rs | 8 ++++++++ .../src/light_client_optimistic_update.rs | 8 ++++++++ consensus/types/src/light_client_update.rs | 3 +++ consensus/types/src/test_utils/macros.rs | 19 ------------------- consensus/types/src/test_utils/test_random.rs | 1 - .../test_random/light_client_header.rs | 10 ---------- 7 files changed, 27 insertions(+), 30 deletions(-) delete mode 100644 consensus/types/src/test_utils/test_random/light_client_header.rs diff --git a/consensus/types/src/light_client_bootstrap.rs b/consensus/types/src/light_client_bootstrap.rs index 9966b5b90ea..d4e85a351d5 100644 --- a/consensus/types/src/light_client_bootstrap.rs +++ b/consensus/types/src/light_client_bootstrap.rs @@ -145,3 +145,11 @@ impl ForkVersionDeserialize for LightClientBootstrap { } } } + +#[cfg(test)] +mod tests { + use super::*; + use crate::MainnetEthSpec; + + ssz_tests!(LightClientBootstrapDeneb); +} diff --git a/consensus/types/src/light_client_finality_update.rs b/consensus/types/src/light_client_finality_update.rs index 469a6cce3db..247ec87cde1 100644 --- a/consensus/types/src/light_client_finality_update.rs +++ b/consensus/types/src/light_client_finality_update.rs @@ -175,3 +175,11 @@ impl ForkVersionDeserialize for LightClientFinalityUpdate { } } } + +#[cfg(test)] +mod tests { + use super::*; + use crate::MainnetEthSpec; + + ssz_tests!(LightClientFinalityUpdateDeneb); +} diff --git a/consensus/types/src/light_client_optimistic_update.rs b/consensus/types/src/light_client_optimistic_update.rs index 4a7a08b9c59..88f287d753e 100644 --- a/consensus/types/src/light_client_optimistic_update.rs +++ b/consensus/types/src/light_client_optimistic_update.rs @@ -169,3 +169,11 @@ impl ForkVersionDeserialize for LightClientOptimisticUpdate { } } } + +#[cfg(test)] +mod tests { + use super::*; + use crate::MainnetEthSpec; + + ssz_tests!(LightClientOptimisticUpdateDeneb); +} diff --git a/consensus/types/src/light_client_update.rs b/consensus/types/src/light_client_update.rs index 809b8ab8dac..09cc1950990 100644 --- a/consensus/types/src/light_client_update.rs +++ b/consensus/types/src/light_client_update.rs @@ -264,8 +264,11 @@ impl LightClientUpdate { #[cfg(test)] mod tests { use super::*; + use crate::MainnetEthSpec; use ssz_types::typenum::Unsigned; + ssz_tests!(LightClientUpdateDeneb); + #[test] fn finalized_root_params() { assert!(2usize.pow(FINALIZED_ROOT_PROOF_LEN as u32) <= FINALIZED_ROOT_INDEX); diff --git a/consensus/types/src/test_utils/macros.rs b/consensus/types/src/test_utils/macros.rs index c4615434aa2..4fd7720689d 100644 --- a/consensus/types/src/test_utils/macros.rs +++ b/consensus/types/src/test_utils/macros.rs @@ -27,25 +27,6 @@ macro_rules! ssz_tests { }; } -#[macro_export] -macro_rules! ssz_tests_by_fork { - ($type: ty, $fork:expr) => { - #[test] - pub fn test_ssz_round_trip() { - use ssz::ssz_encode; - use $crate::test_utils::{SeedableRng, TestRandom, XorShiftRng}; - - let mut rng = XorShiftRng::from_seed([42; 16]); - let original = <$type>::random_for_test(&mut rng); - - let bytes = ssz_encode(&original); - let decoded = <$type>::from_ssz_bytes(&bytes, $fork).unwrap(); - - assert_eq!(original, decoded); - } - }; -} - #[macro_export] macro_rules! tree_hash_tests { ($type: ty) => { diff --git a/consensus/types/src/test_utils/test_random.rs b/consensus/types/src/test_utils/test_random.rs index 9881b694e7b..f31df2ce1b6 100644 --- a/consensus/types/src/test_utils/test_random.rs +++ b/consensus/types/src/test_utils/test_random.rs @@ -12,7 +12,6 @@ mod bitfield; mod hash256; mod kzg_commitment; mod kzg_proof; -mod light_client_header; mod public_key; mod public_key_bytes; mod secret_key; diff --git a/consensus/types/src/test_utils/test_random/light_client_header.rs b/consensus/types/src/test_utils/test_random/light_client_header.rs deleted file mode 100644 index 6a97aff0cd2..00000000000 --- a/consensus/types/src/test_utils/test_random/light_client_header.rs +++ /dev/null @@ -1,10 +0,0 @@ -use super::*; -use crate::{light_client_header::LightClientHeaderDeneb, LightClientHeader}; - -/// Implements `TestRandom` for the `LightClientHeader` superstruct -/// We choose `LightClientHeaderDeneb` since it is a superset of all other variants -impl TestRandom for LightClientHeader { - fn random_for_test(rng: &mut impl RngCore) -> Self { - LightClientHeaderDeneb::::random_for_test(rng).into() - } -} From d314d12a0f23b65df1d953e18778fdf59d327bfb Mon Sep 17 00:00:00 2001 From: Jimmy Chen Date: Wed, 13 Mar 2024 15:01:40 +1100 Subject: [PATCH 71/71] Remove unused `derive`. --- consensus/types/src/beacon_block_body.rs | 3 +-- consensus/types/src/beacon_block_header.rs | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/consensus/types/src/beacon_block_body.rs b/consensus/types/src/beacon_block_body.rs index cdac9bbf506..9524ceb6283 100644 --- a/consensus/types/src/beacon_block_body.rs +++ b/consensus/types/src/beacon_block_body.rs @@ -54,12 +54,11 @@ pub const BLOB_KZG_COMMITMENTS_INDEX: usize = 11; cast_error(ty = "Error", expr = "Error::IncorrectStateVariant"), partial_getter_error(ty = "Error", expr = "Error::IncorrectStateVariant") )] -#[derive(Debug, Clone, Serialize, Deserialize, Derivative, TreeHash, arbitrary::Arbitrary)] +#[derive(Debug, Clone, Serialize, Deserialize, Derivative, arbitrary::Arbitrary)] #[derivative(PartialEq, Hash(bound = "T: EthSpec"))] #[serde(untagged)] #[serde(bound = "T: EthSpec, Payload: AbstractExecPayload")] #[arbitrary(bound = "T: EthSpec, Payload: AbstractExecPayload")] -#[tree_hash(enum_behaviour = "transparent")] pub struct BeaconBlockBody = FullPayload> { pub randao_reveal: Signature, pub eth1_data: Eth1Data, diff --git a/consensus/types/src/beacon_block_header.rs b/consensus/types/src/beacon_block_header.rs index b5e4fd38aae..b382359313c 100644 --- a/consensus/types/src/beacon_block_header.rs +++ b/consensus/types/src/beacon_block_header.rs @@ -13,7 +13,6 @@ use tree_hash_derive::TreeHash; #[derive( arbitrary::Arbitrary, Debug, - Default, PartialEq, Eq, Hash,