Skip to content

Commit 80ff555

Browse files
committed
Misc fixes.
- log cleanup - move http_api config mutation to `config::get_config` for consistency - fix light client API responses
1 parent d90df3f commit 80ff555

File tree

5 files changed

+25
-21
lines changed

5 files changed

+25
-21
lines changed

beacon_node/beacon_chain/src/events.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -117,21 +117,11 @@ impl<T: EthSpec> ServerSentEventHandler<T> {
117117
EventKind::LightClientFinalityUpdate(_) => self
118118
.light_client_finality_update_tx
119119
.send(kind)
120-
.map(|count| {
121-
log_count(
122-
"Registering server-sent light client finality update event",
123-
count,
124-
)
125-
}),
120+
.map(|count| log_count("light client finality update", count)),
126121
EventKind::LightClientOptimisticUpdate(_) => self
127122
.light_client_optimistic_update_tx
128123
.send(kind)
129-
.map(|count| {
130-
log_count(
131-
"Registering server-sent light client optimistic update event",
132-
count,
133-
)
134-
}),
124+
.map(|count| log_count("light client optimistic update", count)),
135125
EventKind::BlockReward(_) => self
136126
.block_reward_tx
137127
.send(kind)

beacon_node/client/src/builder.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ where
165165
} else {
166166
None
167167
};
168-
self.http_api_config.enable_light_client_server = config.network.enable_light_client_server;
169168

170169
let execution_layer = if let Some(config) = config.execution_layer.clone() {
171170
let context = runtime_context.service_context("exec".into());

beacon_node/http_api/src/lib.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2397,15 +2397,15 @@ pub fn serve<T: BeaconChainTypes>(
23972397
);
23982398

23992399
/*
2400-
* beacon/rewards
2400+
* beacon/light_client
24012401
*/
24022402

24032403
let beacon_light_client_path = eth_v1
24042404
.and(warp::path("beacon"))
24052405
.and(warp::path("light_client"))
24062406
.and(chain_filter.clone());
24072407

2408-
// GET beacon/light_client/bootrap/{block_root}
2408+
// GET beacon/light_client/bootstrap/{block_root}
24092409
let get_beacon_light_client_bootstrap = beacon_light_client_path
24102410
.clone()
24112411
.and(task_spawner_filter.clone())
@@ -2496,8 +2496,11 @@ pub fn serve<T: BeaconChainTypes>(
24962496
e
24972497
))
24982498
}),
2499-
_ => Ok(warp::reply::json(&api_types::GenericResponse::from(update))
2500-
.into_response()),
2499+
_ => Ok(warp::reply::json(&ForkVersionedResponse {
2500+
version: Some(fork_name),
2501+
data: update,
2502+
})
2503+
.into_response()),
25012504
}
25022505
.map(|resp| add_consensus_version_header(resp, fork_name))
25032506
})
@@ -2540,8 +2543,11 @@ pub fn serve<T: BeaconChainTypes>(
25402543
e
25412544
))
25422545
}),
2543-
_ => Ok(warp::reply::json(&api_types::GenericResponse::from(update))
2544-
.into_response()),
2546+
_ => Ok(warp::reply::json(&ForkVersionedResponse {
2547+
version: Some(fork_name),
2548+
data: update,
2549+
})
2550+
.into_response()),
25452551
}
25462552
.map(|resp| add_consensus_version_header(resp, fork_name))
25472553
})

beacon_node/src/config.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ pub fn get_config<E: EthSpec>(
151151

152152
client_config.http_api.duplicate_block_status_code =
153153
parse_required(cli_args, "http-duplicate-block-status")?;
154+
155+
client_config.http_api.enable_light_client_server =
156+
cli_args.is_present("light-client-server");
154157
}
155158

156159
if let Some(cache_size) = clap_utils::parse_optional(cli_args, "shuffling-cache-size")? {

lighthouse/tests/beacon_node.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2346,15 +2346,21 @@ fn sync_eth1_chain_disable_deposit_contract_sync_flag() {
23462346
fn light_client_server_default() {
23472347
CommandLineTest::new()
23482348
.run_with_zero_port()
2349-
.with_config(|config| assert_eq!(config.network.enable_light_client_server, false));
2349+
.with_config(|config| {
2350+
assert_eq!(config.network.enable_light_client_server, false);
2351+
assert_eq!(config.http_api.enable_light_client_server, false);
2352+
});
23502353
}
23512354

23522355
#[test]
23532356
fn light_client_server_enabled() {
23542357
CommandLineTest::new()
23552358
.flag("light-client-server", None)
23562359
.run_with_zero_port()
2357-
.with_config(|config| assert_eq!(config.network.enable_light_client_server, true));
2360+
.with_config(|config| {
2361+
assert_eq!(config.network.enable_light_client_server, true);
2362+
assert_eq!(config.http_api.enable_light_client_server, true);
2363+
});
23582364
}
23592365

23602366
#[test]

0 commit comments

Comments
 (0)