Skip to content

Add ValidatorInfo to PeerContacts. - #3039

Open
nibhar wants to merge 20 commits into
albatrossfrom
nibhar/validator-discovery
Open

Add ValidatorInfo to PeerContacts.#3039
nibhar wants to merge 20 commits into
albatrossfrom
nibhar/validator-discovery

Conversation

@nibhar

@nibhar nibhar commented Nov 12, 2024

Copy link
Copy Markdown
Member

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.

@nibhar
nibhar force-pushed the nibhar/validator-discovery branch 4 times, most recently from bac56d8 to 2c0c433 Compare November 12, 2024 03:14
@nibhar
nibhar force-pushed the nibhar/validator-discovery branch from 2c0c433 to 4d66caa Compare November 25, 2024 06:51
@ii-cruz
ii-cruz force-pushed the nibhar/validator-discovery branch 2 times, most recently from aad39ad to 145c075 Compare November 25, 2024 09:20
@nibhar
nibhar force-pushed the nibhar/validator-discovery branch from d1915ac to afaa762 Compare November 25, 2024 10:58
Comment thread validator-network/src/network_impl.rs
Comment thread network-libp2p/src/discovery/peer_contacts.rs Outdated
@nibhar
nibhar force-pushed the nibhar/validator-discovery branch from 42e4099 to 10e9372 Compare November 25, 2024 18:07
@nibhar
nibhar marked this pull request as ready for review November 25, 2024 18:28
Comment thread validator/src/validator.rs Outdated
Comment thread network-libp2p/src/discovery/peer_contacts.rs Outdated
if let Some(validator_info) = &info.contact.inner.validator_info {
self.validator_peer_ids
.entry(validator_info.validator_address.clone())
.or_insert(HashSet::new())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.or_insert(HashSet::new())
.or_default()

Comment thread network-libp2p/src/discovery/peer_contacts.rs Outdated
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(),
})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

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"),

Copy link
Copy Markdown
Member

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 🤔

Comment thread network-libp2p/src/discovery/handler.rs Outdated
let peer_contacts: Vec<SignedPeerContact> = peer_contacts
.into_iter()
.filter_map(filter_contact(
0,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why zero?

Comment thread network-libp2p/src/discovery/handler.rs Outdated
let peer_contacts: Vec<SignedPeerContact> = peer_contacts
.into_iter()
.filter_map(filter_contact(
0,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why zero?

Comment thread network-libp2p/src/discovery/handler.rs Outdated
// Check the peer contact for a valid signature.
if !peer_contact.verify() {
let Some(peer_contact) = filter_contact(
0,

Copy link
Copy Markdown
Member

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()) {

Copy link
Copy Markdown
Member

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?

}

fn get_peers_by_validator(&self, _validator_address: &Address) -> Vec<Self::PeerId> {
// TODO

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// TODO
unimplemented!()

&self,
_callback: impl Fn(Self::PeerId, u64) -> TaggedSigned<ValidatorRecord<Self::PeerId>, KeyPair>,
) {
// TODO

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// TODO
unimplemented!()

/// Timer to do house-keeping in the peer address book.
house_keeping_timer: Interval,

/// dht verifier TODO

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// dht verifier TODO
/// DHT validator record verifier.

@ii-cruz ii-cruz left a comment

Copy link
Copy Markdown
Member

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.

@styppo
styppo force-pushed the nibhar/validator-discovery branch from 2722eee to a84c105 Compare January 22, 2025 15:07
@styppo
styppo force-pushed the nibhar/validator-discovery branch from 14a7780 to 7fdc909 Compare January 30, 2025 23:18
@styppo
styppo force-pushed the nibhar/validator-discovery branch from 7fdc909 to 7b39268 Compare January 31, 2025 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants