From 198c4a873def4da47699226871a622195e75824a Mon Sep 17 00:00:00 2001 From: Age Manning Date: Wed, 25 Nov 2020 22:48:07 +0000 Subject: [PATCH] Update ENR construction and mainnet bootnodes (#1968) ## Issue Addressed Boot nodes were being successfully created and publishing valid ENRs however the `eth2` field was not being saved to disk leading to a discrepancy between published ENR and disk ENR. If the `eth2` field is known, it is now constructed in the initial ENR and saved to disk. Previous mainnet bootnodes did not contain the `eth2` field and these have also been updated. --- boot_node/src/config.rs | 33 ++++++++++++------- .../mainnet/boot_enr.yaml | 4 +-- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/boot_node/src/config.rs b/boot_node/src/config.rs index ec89b4e14..e557f4008 100644 --- a/boot_node/src/config.rs +++ b/boot_node/src/config.rs @@ -79,14 +79,8 @@ impl TryFrom<&ArgMatches<'_>> for BootNodeConfig { let private_key = load_private_key(&network_config, &logger); let local_key = CombinedKey::from_libp2p(&private_key)?; - let mut local_enr = create_enr_builder_from_config(&network_config, false) - .build(&local_key) - .map_err(|e| format!("Failed to build ENR: {:?}", e))?; - - use_or_load_enr(&local_key, &mut local_enr, &network_config, &logger)?; - // build the enr_fork_id and add it to the local_enr if it exists - if let Some(config) = eth2_testnet_config.as_ref() { + let enr_fork = if let Some(config) = eth2_testnet_config.as_ref() { let spec = config .yaml_config .as_ref() @@ -103,22 +97,37 @@ impl TryFrom<&ArgMatches<'_>> for BootNodeConfig { genesis_state.genesis_validators_root, ); - // add to the local_enr - if let Err(e) = local_enr.insert("eth2", &enr_fork.as_ssz_bytes(), &local_key) { - slog::warn!(logger, "Could not update eth2 field"; "error" => ?e); - } + Some(enr_fork.as_ssz_bytes()) } else { slog::warn!( logger, "No genesis state provided. No Eth2 field added to the ENR" ); + None } } else { slog::warn!( logger, "No testnet config provided. Not setting an eth2 field" ); - } + None + }; + + // Build the local ENR + + let mut local_enr = { + let mut builder = create_enr_builder_from_config(&network_config, false); + + // If we know of the ENR field, add it to the initial construction + if let Some(enr_fork_bytes) = enr_fork { + builder.add_value("eth2", &enr_fork_bytes); + } + builder + .build(&local_key) + .map_err(|e| format!("Failed to build ENR: {:?}", e))? + }; + + use_or_load_enr(&local_key, &mut local_enr, &network_config, &logger)?; let auto_update = matches.is_present("enable-enr_auto_update"); diff --git a/common/eth2_testnet_config/built_in_testnet_configs/mainnet/boot_enr.yaml b/common/eth2_testnet_config/built_in_testnet_configs/mainnet/boot_enr.yaml index 9d4d090b6..2f1b0980f 100644 --- a/common/eth2_testnet_config/built_in_testnet_configs/mainnet/boot_enr.yaml +++ b/common/eth2_testnet_config/built_in_testnet_configs/mainnet/boot_enr.yaml @@ -1,6 +1,6 @@ # Lighthouse Team (Sigma Prime) -- enr:-IS4QLkKqDMy_ExrpOEWa59NiClemOnor-krjp4qoeZwIw2QduPC-q7Kz4u1IOWf3DDbdxqQIgC4fejavBOuUPy-HE4BgmlkgnY0gmlwhCLzAHqJc2VjcDI1NmsxoQLQSJfEAHZApkm5edTCZ_4qps_1k_ub2CxHFxi-gr2JMIN1ZHCCIyg -- enr:-IS4QDAyibHCzYZmIYZCjXwU9BqpotWmv2BsFlIq1V31BwDDMJPFEbox1ijT5c2Ou3kvieOKejxuaCqIcjxBjJ_3j_cBgmlkgnY0gmlwhAMaHiCJc2VjcDI1NmsxoQJIdpj_foZ02MXz4It8xKD7yUHTBx7lVFn3oeRP21KRV4N1ZHCCIyg +- enr:-Jq4QN6_FzIYyfJET9hiLcGUsg_EVOwCQ4bwsBwe0S4ElrfXUXufSYLtQAHU9_LuO9uice7EAaLbDlMK8QEhtyg8Oh4BhGV0aDKQtTA_KgAAAAD__________4JpZIJ2NIJpcIQDGh4giXNlY3AyNTZrMaECSHaY_36GdNjF8-CLfMSg-8lB0wce5VRZ96HkT9tSkVeDdWRwgiMo +- enr:-Jq4QMOjjkLYSN7GVAf_zBSS5c_MokSPMZZvmjLUYiuHrPLHInjeBtF1IfskuYlmhglGan2ECmPk89SRXr4FY1jVp5YBhGV0aDKQtTA_KgAAAAD__________4JpZIJ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