Add ValidatorInfo to PeerContacts. - #3039
Open
nibhar wants to merge 20 commits into
Open
Conversation
nibhar
force-pushed
the
nibhar/validator-discovery
branch
4 times, most recently
from
November 12, 2024 03:14
bac56d8 to
2c0c433
Compare
nibhar
force-pushed
the
nibhar/validator-discovery
branch
from
November 25, 2024 06:51
2c0c433 to
4d66caa
Compare
ii-cruz
force-pushed
the
nibhar/validator-discovery
branch
2 times, most recently
from
November 25, 2024 09:20
aad39ad to
145c075
Compare
nibhar
force-pushed
the
nibhar/validator-discovery
branch
from
November 25, 2024 10:58
d1915ac to
afaa762
Compare
paberr
reviewed
Nov 25, 2024
nibhar
force-pushed
the
nibhar/validator-discovery
branch
from
November 25, 2024 18:07
42e4099 to
10e9372
Compare
nibhar
marked this pull request as ready for review
November 25, 2024 18:28
jsdanielh
reviewed
Nov 25, 2024
| if let Some(validator_info) = &info.contact.inner.validator_info { | ||
| self.validator_peer_ids | ||
| .entry(validator_info.validator_address.clone()) | ||
| .or_insert(HashSet::new()) |
Member
There was a problem hiding this comment.
Suggested change
| .or_insert(HashSet::new()) | |
| .or_default() |
Comment on lines
+731
to
+744
| 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(), | ||
| }) |
Member
There was a problem hiding this comment.
Suggested change
| 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(), | |
| } |
| /// Timer to do house-keeping in the peer address book. | ||
| house_keeping_timer: Interval, | ||
|
|
||
| /// dht verifier 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"), |
Member
There was a problem hiding this comment.
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, |
| let peer_contacts: Vec<SignedPeerContact> = peer_contacts | ||
| .into_iter() | ||
| .filter_map(filter_contact( | ||
| 0, |
| // Check the peer contact for a valid signature. | ||
| if !peer_contact.verify() { | ||
| let Some(peer_contact) = filter_contact( | ||
| 0, |
ii-cruz
reviewed
Nov 25, 2024
| } | ||
|
|
||
| let results = futures.collect::<Vec<Result<(), RequestError>>>().await; | ||
| if results.iter().any(|result| result.is_ok()) { |
Member
There was a problem hiding this comment.
what about clearing the peers that didn't work?
| } | ||
|
|
||
| fn get_peers_by_validator(&self, _validator_address: &Address) -> Vec<Self::PeerId> { | ||
| // TODO |
Member
There was a problem hiding this comment.
Suggested change
| // TODO | |
| unimplemented!() |
| &self, | ||
| _callback: impl Fn(Self::PeerId, u64) -> TaggedSigned<ValidatorRecord<Self::PeerId>, KeyPair>, | ||
| ) { | ||
| // TODO |
Member
There was a problem hiding this comment.
Suggested change
| // TODO | |
| unimplemented!() |
| /// Timer to do house-keeping in the peer address book. | ||
| house_keeping_timer: Interval, | ||
|
|
||
| /// dht verifier TODO |
Member
There was a problem hiding this comment.
Suggested change
| /// dht verifier TODO | |
| /// DHT validator record verifier. |
ii-cruz
reviewed
Nov 26, 2024
ii-cruz
left a comment
Member
There was a problem hiding this comment.
This PR is failing on the Build crate features. Haven't looked at it yet.
…m the contact book
styppo
force-pushed
the
nibhar/validator-discovery
branch
from
January 22, 2025 15:07
2722eee to
a84c105
Compare
styppo
force-pushed
the
nibhar/validator-discovery
branch
from
January 30, 2025 23:18
14a7780 to
7fdc909
Compare
styppo
force-pushed
the
nibhar/validator-discovery
branch
from
January 31, 2025 14:24
7fdc909 to
7b39268
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_onlyin 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.