-
Notifications
You must be signed in to change notification settings - Fork 17
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
cmd: allow to set the retrieval peerID, not just the retrieval multiaddr #430
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -372,6 +372,22 @@ func WithRetrievalAddrs(addrs ...string) Option { | |
} | ||
} | ||
|
||
// WithRetrievalPeerID sets the peerID of where to get the content corresponding to an indexing advertisement. | ||
// If unspecified, the libp2p host peer ID are used. | ||
// See: WithHost | ||
func WithRetrievalPeerID(peerID string) Option { | ||
return func(o *options) error { | ||
if len(peerID) != 0 { | ||
pId, err := peer.Decode(peerID) | ||
if err != nil { | ||
return fmt.Errorf("bad peer ID %q: %w", peerID, err) | ||
} | ||
o.provider.ID = pId | ||
} | ||
return nil | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This functionality is already available by using the Setting the provider ID should also be accompanied by a call to The only reason this PR currently works is because the indexer is currently configured to allow any ID to publish on behalf of a provider. This means the advertisement will be accepted if it has a valid signature from anyone. This configuration is long overdue for being locked down so that the indexer only accepts advertisements signed by the provider or signed by a peer from a specific list of delegated publishers for that provider. |
||
} | ||
|
||
func WithSyncPolicy(syncPolicy *policy.Policy) Option { | ||
return func(o *options) error { | ||
o.syncPolicy = syncPolicy | ||
|
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 is bound to provider libp2p host, since the identity is needed for signing of advertisements.
Have you considered setting the engine host option instead?
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.
You mean just using
WithHost
and set the full retrieval host? Wouldn't that cause problems?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.
It shouldn't. The identity of a provider is tied to what it uses to sign advertisements and where chain is retrievable from.
The reason for
RetrievalAddrs
option existing is that a libp2p node may have any public addr through DNS for example, that may not directly be known by it. This is similar to setting public hostname in a traditional HTTP server.But the peer ID (or identity by extension) must be known to the host itself and must match the ID other peers expect to encounter when fetching ad chain from it.
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.
For a bite more ctx, we have this PR deployed and it generates the following advertisements:
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.
@EnchanterIO What other options are set in the engine that is deployed? I suspect the reason that works is that the peer ID set via option introduced by this PR matches the host identity?
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.
It does not match the identity, contrary, the problem we try to address with this PR is that if
retrievalAddr
is not empty, the host id (identity of index provider) is inserted into adv - but we want our separate p2p-server bitswap provider peer id coming from this option to be inserted into adv instead.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.
Got it thank you
In IPNI terminology they are referred to as "Provider" and "Publisher". Provider provides the actual downloadable content , and Publisher tells the network of what is available for download from where i.e. expose the advertisement chain.
IIUC what you'd like to be able to do is to use the engine as a publisher for providers that may reside elsewhere. Right?
Related note: I recommend looking at Extended Providers in IPNI spec.
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.
That is correct.