Skip to content
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

Cache DSN peers for subspace-gateway #3311

Open
teor2345 opened this issue Dec 11, 2024 · 7 comments
Open

Cache DSN peers for subspace-gateway #3311

teor2345 opened this issue Dec 11, 2024 · 7 comments
Assignees
Labels
enhancement New feature or request networking Subspace networking (DSN)

Comments

@teor2345
Copy link
Contributor

teor2345 commented Dec 11, 2024

Currently, the gateway is stateless between restarts: it doesn’t store any data on disk.

If it used a DSN peer cache, it would be more resilient to bootstrap node downtime (and network connectivity or censorship).

There are a few different ways to do this:

  • query the connected/cached DSN peers from the connected node (by creating a GatewayAppInfo RPC)
  • add the address of the connected node to the bootstrap peers sent by the node over RPC (and then get its cached peers from it)
    • this would effectively share the cached peers between the farmer, node, and gateway
  • cache the DSN peers in a gateway data directory
@teor2345 teor2345 added enhancement New feature or request networking Subspace networking (DSN) labels Dec 11, 2024
@teor2345 teor2345 self-assigned this Dec 11, 2024
@nazar-pc
Copy link
Member

We already have KnownPeersRegistry trait and KnownPeersManager implementation for it (the name isn't great), is that what you're looking for?

@teor2345
Copy link
Contributor Author

We already have KnownPeersRegistry trait and KnownPeersManager implementation for it (the name isn't great), is that what you're looking for?

Yeah that could work, but maybe having the node send its own address as a bootstrap node to the farmer and gateway would work just as well?

(Then they’d effectively be using the node’s cache via the DSN protocol, rather than their own.)

@nazar-pc
Copy link
Member

Node currently sends it bootstrap nodes to the farmer for bootstrapping and if none are provided (like in local dev environment) then it will send its own address. Farmer also allows to override bootstrap nodes via CLI explicitly and if possible will use previously known peers stored in a file using above mentioned implementation instead of bootstrap nodes from either CLI or those provided by the node.

I'd expect a similar behavior from the gateway, but maybe you meant something else.

@teor2345
Copy link
Contributor Author

Node currently sends it bootstrap nodes to the farmer for bootstrapping and if none are provided (like in local dev environment) then it will send its own address.

Why not add its own address all the time?

@nazar-pc
Copy link
Member

Why not add its own address all the time?

Good question, it will most likely not be helpful unless you enable --allow-private-ips, which is not the default.

@teor2345
Copy link
Contributor Author

Why not add its own address all the time?

Good question, it will most likely not be helpful unless you enable --allow-private-ips, which is not the default.

Fair point, I was thinking of adding the detected external address, rather than the internal socket address. But I guess that then causes potential security issues if peers lie about the external address.

@nazar-pc
Copy link
Member

It'll also complicate things since right now subspace-service only waits for the first listen address if bootstrap nodes were not present and deals with fixed list of bootstrap nodes afterwards. With tracking of external addresses it'll have to share a data structure behind Mutex and combine multiple data sources at request, making things more complex for not so clear benefit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request networking Subspace networking (DSN)
Projects
None yet
Development

No branches or pull requests

2 participants