Skip to content

Conversation

dmitry-markin
Copy link
Collaborator

@dmitry-markin dmitry-markin commented Sep 5, 2025

Track success of ADD_PROVIDER queries and emit AddProviderSuccess & QueryFailed events.

This PR adds tracking of the last stage of ADD_PROVIDER query: putting provider records to the target peers. Because libp2p spec doesn't have ADD_PROVIDER ACK messages, we track only that the requests were sent out to the target peers without errors. Quorum is respected when determining whether the query was successful or not.

Builds upon #430.

@@ -1,5 +1,3 @@
// Copyright 2023 litep2p developers
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Should we do the same for all other files and just keep the copyright without the year?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually, accidentally deleted these lines. Will revert.

Yes, we can live without a year as in polkadot-sdk.


/// Kademlia message.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, EnumDisplay)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

dq: This is used to display the message in the logs?

context.register_response_failure(peer);
}
Some(QueryType::PutRecordToFoundNodes { context, .. }) => {
Some(QueryType::PutRecordToFoundNodes { context }) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Maybe we can introduce a fn context() on the QueryType, such that we can turn this code into:

match self.queries.get_mut(&query) {
    None => ...,

    Some(query) => query.context.register_response_failure(peer);
}

Copy link
Collaborator

@lexnv lexnv left a comment

Choose a reason for hiding this comment

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

Nice job here! The changes look solid to me!

Just a tiny bit more testing on the kusama validators and we are good to go and include them in a litep2p release 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants