Skip to content

Support WithIgnoreProviders() in provider query manager #10765

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

Merged
merged 2 commits into from
Apr 1, 2025

Conversation

hsanjuan
Copy link
Contributor

Adds Routing.IgnoreProviders.

This requires initializing a custom providerQueryManager and using it instead of the default created internally in Bitswap. Since the default is created with some internal default configuration options (MaxProviders), this hardcodes it.

@hsanjuan hsanjuan self-assigned this Mar 24, 2025
Adds `Routing.IgnoreProviders`.

This requires initializing a custom providerQueryManager and using it instead
of the default created internally in Bitswap. Since the default is created
with some internal default configuration options (MaxProviders), this hardcodes it.
@hsanjuan hsanjuan marked this pull request as ready for review March 27, 2025 16:17
@hsanjuan hsanjuan requested a review from a team as a code owner March 27, 2025 16:17
@hsanjuan hsanjuan enabled auto-merge April 1, 2025 07:54
@hsanjuan hsanjuan merged commit 8b54407 into master Apr 1, 2025
16 checks passed
@hsanjuan hsanjuan deleted the ignore-providers branch April 1, 2025 08:03
// internal setting in boxo.
pqm, err := rpqm.New(bitswapNetwork,
in.Rt,
rpqm.WithMaxProviders(10),
Copy link
Member

@lidel lidel Apr 2, 2025

Choose a reason for hiding this comment

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

@hsanjuan why do we hardcode 10 here?

Wasn't previous default DefaultMaxProviders = 0 (unlimited) from boxo/routing/providerquerymanager/providerquerymanager.go?

limiting to 10 feels like DoS vector, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this is the value we always used:
https://github.com/ipfs/boxo/blob/main/bitswap/client/client.go#L209

When passing in the pqm explicitally we need to set it...

No change on that front. As to why 10... 🤷 In rainbow we do unlimited, but in Kubo we never ventured to change the default of 10.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks! Feels we should avoid hardcoding magic numbers without docs, opened #10773 to sort this out + maybe align with rainbow.

lidel added a commit that referenced this pull request May 5, 2025
this fixes two regressions:

(1) introduced in #10717
    where we only used bitswapLib2p query manager
    (this is why E2E did not act on http provider)

(2) introduced in #10765
    where it was not possible to set binary peerID in IgnoreProviders
    (we changed to []string)
@@ -41,6 +43,8 @@ type Routing struct {

LoopbackAddressesOnLanDHT Flag `json:",omitempty"`

IgnoreProviders []peer.ID
Copy link
Member

Choose a reason for hiding this comment

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

Something I realized while testing #10772 is that user is unable to set PeerID in json when this field type id peer.ID.

even tho peer.ID type in go is string, the value stored there is binary and not base-encoded 🙃

Proof: peer.ID.String() requires extra conversion from binary to base58: https://github.com/libp2p/go-libp2p/blob/50d714c94c043f2a326c6c8e16c7a3c4821b87ad/core/peer/peer.go#L52C8-L52C31

This means we we need to:

  1. store base-encoded values in JSON
  2. add conversion step from base-encoded to binary peer.ID

I've fixed that in 3c24a60#diff-6ef0b54f0ea8496cf31cb4bca6c5e8ca92facee272e34097201d832894bf9d7bR116, but good to keep that in mind in future config changes.

cc @gammazero for visibility

lidel added a commit that referenced this pull request May 6, 2025
* Feat: http retrieval as experimental feature

This introduces the http-retrieval capability as an experimental feature.

It can be enabled in the configuration `Experimental.HTTPRetrieval.Enabled = true`.

Documentation and changelog to be added later.

* refactor: HTTPRetrieval.Enabled as Flag

* docs(config): HTTPRetrieval section

* refactor: reusable MockHTTPContentRouter

* feat: HTTPRetrieval.TLSInsecureSkipVerify

allows self-signed certificates in tests

* feat(config): HTTPRetrieval.MaxBlockSize

* test: end-to-end HTTPRetrieval.Enabled

this spawns two http services on localhost:
1. HTTP router that returns HTTP provider when /routing/v1/providers/cid  i queried
2. HTTP provider that returns a block when /ipfs/cid is queried
3. Configures Kubo to use (1) instead of cid.contact

this seems to work (running test with DEBUG=true shows (1) was queried
for the test CID and returned multiaddr of (2), but Kubo never requested
test CID block from (2) – needs investigation

* fix: enable /routing/v1/peers for non-cid.contact

we artificially limited every delegated routing endpoint because of
cid.contact being limited to one endpoint

* feat: Routing.DelegatedRouters

make it easy to override the hardcoded implicit HTTP routeur URL
without having to set the entire custom Router.Routers and
Router.Methods

(http_retrieval_client_test.go still needs to be fixed in future commit)

* test: flag remaining work

* docs: review feedback

* refactor: providerQueryMgr with bitswapNetworks

this fixes two regressions:

(1) introduced in #10717
    where we only used bitswapLib2p query manager
    (this is why E2E did not act on http provider)

(2) introduced in #10765
    where it was not possible to set binary peerID in IgnoreProviders
    (we changed to []string)

* refactor: Bitswap.Libp2pEnabled

replaces Bitswap.Enabled with Bitswap.Libp2pEnabled
adds tests that confirm it is possible to disable libp2p bitswap fully
and only keep http in client mode

also, removes the need for passing empty blockstore in client-only mode

* docs: changelog

---------

Co-authored-by: Marcin Rataj <[email protected]>
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.

3 participants