Skip to content

Commit 95b3183

Browse files
committed
Make /config/spec backwards compat for VC (#2934)
## Proposed Changes Restore compatibility with beacon nodes using the `MERGE` naming by: 1. Adding defaults for the Bellatrix `Config` fields 2. Not attempting to read (or serve) the Bellatrix preset on `/config/spec`. I've confirmed that this works with Infura, and just logs a warning: ``` Jan 20 10:51:31.078 INFO Connected to beacon node endpoint: https://eth2-beacon-mainnet.infura.io/, version: teku/v22.1.0/linux-x86_64/-eclipseadoptium-openjdk64bitservervm-java-17 Jan 20 10:51:31.344 WARN Beacon node config does not match exactly, advice: check that the BN is updated and configured for any upcoming forks, endpoint: https://eth2-beacon-mainnet.infura.io/ Jan 20 10:51:31.344 INFO Initialized beacon node connections available: 1, total: 1 ```
1 parent ef7351d commit 95b3183

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

consensus/types/src/chain_spec.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,12 @@ pub struct Config {
631631
#[serde(deserialize_with = "deserialize_fork_epoch")]
632632
pub altair_fork_epoch: Option<MaybeQuoted<Epoch>>,
633633

634+
// TODO(merge): remove this default
635+
#[serde(default = "default_bellatrix_fork_version")]
634636
#[serde(with = "eth2_serde_utils::bytes_4_hex")]
635637
bellatrix_fork_version: [u8; 4],
638+
// TODO(merge): remove this default
639+
#[serde(default = "default_bellatrix_fork_epoch")]
636640
#[serde(serialize_with = "serialize_fork_epoch")]
637641
#[serde(deserialize_with = "deserialize_fork_epoch")]
638642
pub bellatrix_fork_epoch: Option<MaybeQuoted<Epoch>>,
@@ -669,6 +673,15 @@ pub struct Config {
669673
deposit_contract_address: Address,
670674
}
671675

676+
fn default_bellatrix_fork_version() -> [u8; 4] {
677+
// This value shouldn't be used.
678+
[0xff, 0xff, 0xff, 0xff]
679+
}
680+
681+
fn default_bellatrix_fork_epoch() -> Option<MaybeQuoted<Epoch>> {
682+
None
683+
}
684+
672685
impl Default for Config {
673686
fn default() -> Self {
674687
let chain_spec = MainnetEthSpec::default_spec();

consensus/types/src/config_and_preset.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ pub struct ConfigAndPreset {
1414
pub base_preset: BasePreset,
1515
#[serde(flatten)]
1616
pub altair_preset: AltairPreset,
17-
#[serde(flatten)]
18-
pub bellatrix_preset: BellatrixPreset,
19-
17+
// TODO(merge): re-enable
18+
// #[serde(flatten)]
19+
// pub bellatrix_preset: BellatrixPreset,
2020
/// The `extra_fields` map allows us to gracefully decode fields intended for future hard forks.
2121
#[serde(flatten)]
2222
pub extra_fields: HashMap<String, String>,
@@ -27,14 +27,14 @@ impl ConfigAndPreset {
2727
let config = Config::from_chain_spec::<T>(spec);
2828
let base_preset = BasePreset::from_chain_spec::<T>(spec);
2929
let altair_preset = AltairPreset::from_chain_spec::<T>(spec);
30-
let bellatrix_preset = BellatrixPreset::from_chain_spec::<T>(spec);
30+
// TODO(merge): re-enable
31+
let _bellatrix_preset = BellatrixPreset::from_chain_spec::<T>(spec);
3132
let extra_fields = HashMap::new();
3233

3334
Self {
3435
config,
3536
base_preset,
3637
altair_preset,
37-
bellatrix_preset,
3838
extra_fields,
3939
}
4040
}

0 commit comments

Comments
 (0)