mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-18 05:18:30 +00:00
Final changes for fusaka-devnet-2 (#7655)
Closes #7467. This PR primarily addresses [the P2P changes](https://github.com/ethereum/EIPs/pull/9840) in [fusaka-devnet-2](https://fusaka-devnet-2.ethpandaops.io/). Specifically: * [the new `nfd` parameter added to the `ENR`](https://github.com/ethereum/EIPs/pull/9840) * [the modified `compute_fork_digest()` changes for every BPO fork](https://github.com/ethereum/EIPs/pull/9840) 90% of this PR was absolutely hacked together as fast as possible during the Berlinterop as fast as I could while running between Glamsterdam debates. Luckily, it seems to work. But I was unable to be as careful in avoiding bugs as I usually am. I've cleaned up the things *I remember* wanting to come back and have a closer look at. But still working on this. Progress: * [x] get it working on `fusaka-devnet-2` * [ ] [*optional* disconnect from peers with incorrect `nfd` at the fork boundary](https://github.com/ethereum/consensus-specs/pull/4407) - Can be addressed in a future PR if necessary * [x] first pass clean-up * [x] fix up all the broken tests * [x] final self-review * [x] more thorough review from people more familiar with affected code
This commit is contained in:
@@ -49,7 +49,7 @@ use tracing::{debug, error, info, trace, warn};
|
||||
use types::{ChainSpec, EnrForkId, EthSpec};
|
||||
|
||||
mod subnet_predicate;
|
||||
use crate::discovery::enr::PEERDAS_CUSTODY_GROUP_COUNT_ENR_KEY;
|
||||
use crate::discovery::enr::{NEXT_FORK_DIGEST_ENR_KEY, PEERDAS_CUSTODY_GROUP_COUNT_ENR_KEY};
|
||||
pub use subnet_predicate::subnet_predicate;
|
||||
use types::non_zero_usize::new_non_zero_usize;
|
||||
|
||||
@@ -570,6 +570,19 @@ impl<E: EthSpec> Discovery<E> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn update_enr_nfd(&mut self, nfd: [u8; 4]) -> Result<(), String> {
|
||||
self.discv5
|
||||
.enr_insert::<Bytes>(NEXT_FORK_DIGEST_ENR_KEY, &nfd.as_ssz_bytes().into())
|
||||
.map_err(|e| format!("{:?}", e))?;
|
||||
info!(
|
||||
next_fork_digest = ?nfd,
|
||||
"Updating the ENR nfd"
|
||||
);
|
||||
enr::save_enr_to_disk(Path::new(&self.enr_dir), &self.local_enr());
|
||||
*self.network_globals.local_enr.write() = self.discv5.local_enr();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Updates the `eth2` field of our local ENR.
|
||||
pub fn update_eth2_enr(&mut self, enr_fork_id: EnrForkId) {
|
||||
// to avoid having a reference to the spec constant, for the logging we assume
|
||||
@@ -1217,7 +1230,15 @@ mod tests {
|
||||
config.set_listening_addr(crate::ListenAddress::unused_v4_ports());
|
||||
let config = Arc::new(config);
|
||||
let enr_key: CombinedKey = CombinedKey::from_secp256k1(&keypair);
|
||||
let enr: Enr = build_enr::<E>(&enr_key, &config, &EnrForkId::default(), &spec).unwrap();
|
||||
let next_fork_digest = [0; 4];
|
||||
let enr: Enr = build_enr::<E>(
|
||||
&enr_key,
|
||||
&config,
|
||||
&EnrForkId::default(),
|
||||
next_fork_digest,
|
||||
&spec,
|
||||
)
|
||||
.unwrap();
|
||||
let globals = NetworkGlobals::new(
|
||||
enr,
|
||||
MetaData::V2(MetaDataV2 {
|
||||
|
||||
Reference in New Issue
Block a user