mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-22 06:14:38 +00:00
Correct ENR decoding on extension trait (#6402)
* Correct enr extension encodings * Clippy my ol friend * Correct all encoding and comparisons * Found some more encodings * Fix remaining tests
This commit is contained in:
@@ -15,6 +15,7 @@ pub use enr::{build_enr, load_enr_from_disk, use_or_load_enr, CombinedKey, Eth2E
|
||||
pub use enr_ext::{peer_id_to_node_id, CombinedKeyExt, EnrExt};
|
||||
pub use libp2p::identity::{Keypair, PublicKey};
|
||||
|
||||
use alloy_rlp::bytes::Bytes;
|
||||
use enr::{ATTESTATION_BITFIELD_ENR_KEY, ETH2_ENR_KEY, SYNC_COMMITTEE_BITFIELD_ENR_KEY};
|
||||
use futures::prelude::*;
|
||||
use futures::stream::FuturesUnordered;
|
||||
@@ -512,9 +513,9 @@ impl<E: EthSpec> Discovery<E> {
|
||||
|
||||
// insert the bitfield into the ENR record
|
||||
self.discv5
|
||||
.enr_insert(
|
||||
.enr_insert::<Bytes>(
|
||||
ATTESTATION_BITFIELD_ENR_KEY,
|
||||
¤t_bitfield.as_ssz_bytes(),
|
||||
¤t_bitfield.as_ssz_bytes().into(),
|
||||
)
|
||||
.map_err(|e| format!("{:?}", e))?;
|
||||
}
|
||||
@@ -546,9 +547,9 @@ impl<E: EthSpec> Discovery<E> {
|
||||
|
||||
// insert the bitfield into the ENR record
|
||||
self.discv5
|
||||
.enr_insert(
|
||||
.enr_insert::<Bytes>(
|
||||
SYNC_COMMITTEE_BITFIELD_ENR_KEY,
|
||||
¤t_bitfield.as_ssz_bytes(),
|
||||
¤t_bitfield.as_ssz_bytes().into(),
|
||||
)
|
||||
.map_err(|e| format!("{:?}", e))?;
|
||||
}
|
||||
@@ -582,7 +583,7 @@ impl<E: EthSpec> Discovery<E> {
|
||||
|
||||
let _ = self
|
||||
.discv5
|
||||
.enr_insert(ETH2_ENR_KEY, &enr_fork_id.as_ssz_bytes())
|
||||
.enr_insert::<Bytes>(ETH2_ENR_KEY, &enr_fork_id.as_ssz_bytes().into())
|
||||
.map_err(|e| {
|
||||
warn!(
|
||||
self.log,
|
||||
@@ -1289,7 +1290,10 @@ mod tests {
|
||||
bitfield.set(id, true).unwrap();
|
||||
}
|
||||
|
||||
builder.add_value(ATTESTATION_BITFIELD_ENR_KEY, &bitfield.as_ssz_bytes());
|
||||
builder.add_value::<Bytes>(
|
||||
ATTESTATION_BITFIELD_ENR_KEY,
|
||||
&bitfield.as_ssz_bytes().into(),
|
||||
);
|
||||
builder.build(&enr_key).unwrap()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user