-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ValidatorInfo to PeerContacts. #3039
base: albatross
Are you sure you want to change the base?
Conversation
bac56d8
to
2c0c433
Compare
2c0c433
to
4d66caa
Compare
aad39ad
to
145c075
Compare
d1915ac
to
afaa762
Compare
…m the contact book
42e4099
to
10e9372
Compare
if let Some(validator_info) = &info.contact.inner.validator_info { | ||
self.validator_peer_ids | ||
.entry(validator_info.validator_address.clone()) | ||
.or_insert(HashSet::new()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.or_insert(HashSet::new()) | |
.or_default() |
contact.validator_info = self.validator_record_signing.as_ref().and_then(|callback| { | ||
let tagged_signed = (callback)(contact.peer_id(), contact.timestamp); | ||
Some(ValidatorInfo { | ||
validator_address: tagged_signed.record.validator_address.clone(), | ||
signature: tagged_signed.signature.clone(), | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contact.validator_info = self.validator_record_signing.as_ref().and_then(|callback| { | |
let tagged_signed = (callback)(contact.peer_id(), contact.timestamp); | |
Some(ValidatorInfo { | |
validator_address: tagged_signed.record.validator_address.clone(), | |
signature: tagged_signed.signature.clone(), | |
}) | |
contact.validator_info = self.validator_record_signing.as_ref().map(|callback| { | |
let tagged_signed = (callback)(contact.peer_id(), contact.timestamp); | |
ValidatorInfo { | |
validator_address: tagged_signed.record.validator_address.clone(), | |
signature: tagged_signed.signature.clone(), | |
} |
@@ -115,13 +115,18 @@ pub struct Behaviour { | |||
|
|||
/// Timer to do house-keeping in the peer address book. | |||
house_keeping_timer: Interval, | |||
|
|||
/// dht verifier TODO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this TODO?
connection: CloseConnection::All, | ||
}), | ||
// Errors must not result in a closed connection as light clients are unable to verify ValidatorRecord. | ||
HandlerOutEvent::Error(error) => log::trace!(?error, "Received invalid contact"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmm, but we panic if a light client tries to verify a validator record 🤔
let peer_contacts: Vec<SignedPeerContact> = peer_contacts | ||
.into_iter() | ||
.filter_map(filter_contact( | ||
0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why zero?
let peer_contacts: Vec<SignedPeerContact> = peer_contacts | ||
.into_iter() | ||
.filter_map(filter_contact( | ||
0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why zero?
@@ -526,7 +575,13 @@ impl ConnectionHandler for Handler { | |||
peer_contacts, | |||
} => { | |||
// Check the peer contact for a valid signature. | |||
if !peer_contact.verify() { | |||
let Some(peer_contact) = filter_contact( | |||
0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why zero?
} | ||
|
||
let results = futures.collect::<Vec<Result<(), RequestError>>>().await; | ||
if results.iter().any(|result| result.is_ok()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about clearing the peers that didn't work?
@@ -652,4 +654,16 @@ impl Network for MockNetwork { | |||
) -> Result<Vec<Self::PeerId>, MockNetworkError> { | |||
Ok(self.get_peers()) | |||
} | |||
|
|||
fn get_peers_by_validator(&self, _validator_address: &Address) -> Vec<Self::PeerId> { | |||
// TODO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// TODO | |
unimplemented!() |
&self, | ||
_callback: impl Fn(Self::PeerId, u64) -> TaggedSigned<ValidatorRecord<Self::PeerId>, KeyPair>, | ||
) { | ||
// TODO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// TODO | |
unimplemented!() |
@@ -115,13 +115,18 @@ pub struct Behaviour { | |||
|
|||
/// Timer to do house-keeping in the peer address book. | |||
house_keeping_timer: Interval, | |||
|
|||
/// dht verifier TODO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// dht verifier TODO | |
/// DHT validator record verifier. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is failing on the Build crate features. Haven't looked at it yet.
This PR adds Validators information to the PeerContacts exchanged during discovery. In this PR the information is not populated, neither is it utilized. It is intended as an additional means of retrieving validator information aside from just the dht.
In addition to that it changes how peer contact information gets discarded in case it is faulty. Not discarding everything, but only the faulty piece of data instead. As Validator contacts can only be verified when the state is complete, and only if the respective key has not been rotated out (or in) yet, an entry in the address book can be flagged as
local_only
in those cases where verification is not (yet) possible. They should be re-evaluated at a time, when the verification is possible. Local_only entries will not be put into discovery messages.