mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-02 16:21:42 +00:00
Simplify ConfigAndPreset (#7777)
I noticed that we are serving preset values for Fulu on mainnet nodes prior to the fork. This has already gone live in v7.1.0, but should hopefully be handled in a graceful way by API consumers. This PR _reverts_ the serving of Fulu data prior to Fulu, by serving Fulu data only if Fulu is scheduled.
This commit is contained in:
@@ -315,7 +315,7 @@ pub fn serve<T: 'static + SlotClock + Clone, E: EthSpec>(
|
||||
.and(spec_filter.clone())
|
||||
.then(|spec: Arc<_>| {
|
||||
blocking_json_task(move || {
|
||||
let config = ConfigAndPreset::from_chain_spec::<E>(&spec, None);
|
||||
let config = ConfigAndPreset::from_chain_spec::<E>(&spec);
|
||||
Ok(api_types::GenericResponse::from(config))
|
||||
})
|
||||
});
|
||||
|
||||
@@ -260,7 +260,7 @@ impl ApiTester {
|
||||
.await
|
||||
.map(|res| ConfigAndPreset::Fulu(res.data))
|
||||
.unwrap();
|
||||
let expected = ConfigAndPreset::from_chain_spec::<E>(&E::default_spec(), None);
|
||||
let expected = ConfigAndPreset::from_chain_spec::<E>(&E::default_spec());
|
||||
|
||||
assert_eq!(result, expected);
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ struct ApiTester {
|
||||
validator_store: Arc<LighthouseValidatorStore<TestingSlotClock, E>>,
|
||||
url: SensitiveUrl,
|
||||
slot_clock: TestingSlotClock,
|
||||
spec: Arc<ChainSpec>,
|
||||
_validator_dir: TempDir,
|
||||
_secrets_dir: TempDir,
|
||||
_test_runtime: TestRuntime,
|
||||
@@ -117,7 +118,7 @@ impl ApiTester {
|
||||
validator_store: Some(validator_store.clone()),
|
||||
graffiti_file: None,
|
||||
graffiti_flag: Some(Graffiti::default()),
|
||||
spec: E::default_spec().into(),
|
||||
spec: spec.clone(),
|
||||
config: HttpConfig {
|
||||
enabled: true,
|
||||
listen_addr: IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)),
|
||||
@@ -152,6 +153,7 @@ impl ApiTester {
|
||||
validator_store,
|
||||
url,
|
||||
slot_clock,
|
||||
spec,
|
||||
_validator_dir: validator_dir,
|
||||
_secrets_dir: secrets_dir,
|
||||
_test_runtime: test_runtime,
|
||||
@@ -206,13 +208,19 @@ impl ApiTester {
|
||||
}
|
||||
|
||||
pub async fn test_get_lighthouse_spec(self) -> Self {
|
||||
let result = self
|
||||
.client
|
||||
.get_lighthouse_spec::<ConfigAndPresetFulu>()
|
||||
.await
|
||||
.map(|res| ConfigAndPreset::Fulu(res.data))
|
||||
.unwrap();
|
||||
let expected = ConfigAndPreset::from_chain_spec::<E>(&E::default_spec(), None);
|
||||
let result = if self.spec.is_fulu_scheduled() {
|
||||
self.client
|
||||
.get_lighthouse_spec::<ConfigAndPresetFulu>()
|
||||
.await
|
||||
.map(|res| ConfigAndPreset::Fulu(res.data))
|
||||
} else {
|
||||
self.client
|
||||
.get_lighthouse_spec::<ConfigAndPresetElectra>()
|
||||
.await
|
||||
.map(|res| ConfigAndPreset::Electra(res.data))
|
||||
}
|
||||
.unwrap();
|
||||
let expected = ConfigAndPreset::from_chain_spec::<E>(&self.spec);
|
||||
|
||||
assert_eq!(result, expected);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user