Improve ENR logic for ipv6 (#4395)
Currently, the ENR of the node may not be correctly updated when specifying ipv6 fields through the CLI if an ENR exists on disk. This remedies a bug where we were not checking for ipv6 fields when comparing whether to use an on-disk ENR or updating based on CLI configuration parameters.
This commit is contained in:
parent
2bb62b7f7d
commit
6621e1d0c5
@ -213,12 +213,16 @@ pub fn build_enr<T: EthSpec>(
|
|||||||
fn compare_enr(local_enr: &Enr, disk_enr: &Enr) -> bool {
|
fn compare_enr(local_enr: &Enr, disk_enr: &Enr) -> bool {
|
||||||
// take preference over disk_enr address if one is not specified
|
// take preference over disk_enr address if one is not specified
|
||||||
(local_enr.ip4().is_none() || local_enr.ip4() == disk_enr.ip4())
|
(local_enr.ip4().is_none() || local_enr.ip4() == disk_enr.ip4())
|
||||||
|
&&
|
||||||
|
(local_enr.ip6().is_none() || local_enr.ip6() == disk_enr.ip6())
|
||||||
// tcp ports must match
|
// tcp ports must match
|
||||||
&& local_enr.tcp4() == disk_enr.tcp4()
|
&& local_enr.tcp4() == disk_enr.tcp4()
|
||||||
|
&& local_enr.tcp6() == disk_enr.tcp6()
|
||||||
// must match on the same fork
|
// must match on the same fork
|
||||||
&& local_enr.get(ETH2_ENR_KEY) == disk_enr.get(ETH2_ENR_KEY)
|
&& local_enr.get(ETH2_ENR_KEY) == disk_enr.get(ETH2_ENR_KEY)
|
||||||
// take preference over disk udp port if one is not specified
|
// take preference over disk udp port if one is not specified
|
||||||
&& (local_enr.udp4().is_none() || local_enr.udp4() == disk_enr.udp4())
|
&& (local_enr.udp4().is_none() || local_enr.udp4() == disk_enr.udp4())
|
||||||
|
&& (local_enr.udp6().is_none() || local_enr.udp6() == disk_enr.udp6())
|
||||||
// we need the ATTESTATION_BITFIELD_ENR_KEY and SYNC_COMMITTEE_BITFIELD_ENR_KEY key to match,
|
// we need the ATTESTATION_BITFIELD_ENR_KEY and SYNC_COMMITTEE_BITFIELD_ENR_KEY key to match,
|
||||||
// otherwise we use a new ENR. This will likely only be true for non-validating nodes
|
// otherwise we use a new ENR. This will likely only be true for non-validating nodes
|
||||||
&& local_enr.get(ATTESTATION_BITFIELD_ENR_KEY) == disk_enr.get(ATTESTATION_BITFIELD_ENR_KEY)
|
&& local_enr.get(ATTESTATION_BITFIELD_ENR_KEY) == disk_enr.get(ATTESTATION_BITFIELD_ENR_KEY)
|
||||||
|
@ -102,7 +102,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
|||||||
Arg::with_name("network-dir")
|
Arg::with_name("network-dir")
|
||||||
.value_name("NETWORK_DIR")
|
.value_name("NETWORK_DIR")
|
||||||
.long("network-dir")
|
.long("network-dir")
|
||||||
.help("The directory which contains the enr and it's assoicated private key")
|
.help("The directory which contains the enr and it's associated private key")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user