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

feat: seed-based automatic peering #111

Merged
merged 4 commits into from
Apr 24, 2024
Merged

feat: seed-based automatic peering #111

merged 4 commits into from
Apr 24, 2024

Conversation

hacdias
Copy link
Member

@hacdias hacdias commented Apr 5, 2024

Closes #109. This PR adds seed-based automatic peering. This works by either leveraging the already-running DHT (if DHT is enabled with shared host), or running a parallel DHT with the main host only for peer routing.

I've added tests that you can run on your machine, but disabled on the CI. The time it takes to connect can vary and I thought it could be a bit flaky to run in the CI. In addition, it would maybe pollute the Amino DHT with all ephemeral peers that are created in each test.

Depends on #114.
Closes #27

@hacdias hacdias force-pushed the peering-cache branch 4 times, most recently from b81f0cc to 493f7d8 Compare April 5, 2024 12:36
@hacdias hacdias changed the title WIP: cache across multiple instances Automatic peering and caching Apr 5, 2024
@hacdias hacdias force-pushed the peering-cache branch 2 times, most recently from 347dedf to 21cf001 Compare April 5, 2024 13:28
main.go Outdated Show resolved Hide resolved
@lidel lidel changed the title Automatic peering and caching feat: seed-based automatic peering and cache sharing Apr 5, 2024
main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
@hacdias hacdias changed the title feat: seed-based automatic peering and cache sharing feat: seed-based automatic peering Apr 8, 2024
@hacdias hacdias force-pushed the peering-cache branch 2 times, most recently from 90369b4 to 430702d Compare April 9, 2024 12:33
@hacdias hacdias changed the base branch from main to feat/shared-cache April 17, 2024 09:28
@hacdias hacdias force-pushed the peering-cache branch 2 times, most recently from c100c2f to 3b34fc8 Compare April 17, 2024 10:56
setup.go Outdated
Comment on lines 546 to 507
pr, err = dht.New(ctx, h,
dht.Datastore(ds),
dht.BootstrapPeers(dht.GetDefaultBootstrapPeerAddrInfos()...),
dht.Mode(dht.ModeClient),
)
Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe there's other options that would be useful here to make this as light as possible, but I haven't found anything that would seem useful. Do you have any idea? @aschmahmann @lidel

@hacdias
Copy link
Member Author

hacdias commented Apr 17, 2024

@lidel @aschmahmann I have reworked this PR on top of #114. In addition, we now run a parallel DHT just for peer routing if DHT is disabled and the host is not shared.

I also extracted some parts of the setup as their own functions - this will simplify #88.

@hacdias hacdias marked this pull request as ready for review April 17, 2024 10:59
@hacdias hacdias self-assigned this Apr 17, 2024
@hacdias hacdias force-pushed the peering-cache branch 2 times, most recently from 5461d81 to ea4b238 Compare April 17, 2024 12:39
@hacdias hacdias mentioned this pull request Apr 17, 2024
@lidel lidel added this to the v1.2 milestone Apr 19, 2024
Base automatically changed from feat/shared-cache to main April 22, 2024 06:18
@hacdias hacdias force-pushed the peering-cache branch 2 times, most recently from ec9b54f to 17cb3e8 Compare April 22, 2024 11:58
Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

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

Thank you for doing the cleanup while at it!

Lgtm, I think we can ship this as v1.2 (moved remote backends to v1.3).
This is opt-in experimental feature – we will see how connectivity behaves in our infra, and refine if needed.

(pushed some docs for all involved envs)

setup.go Show resolved Hide resolved
setup.go Outdated Show resolved Hide resolved
setup.go Outdated Show resolved Hide resolved
@hacdias hacdias enabled auto-merge (squash) April 24, 2024 08:18
@hacdias hacdias merged commit 7f4d883 into main Apr 24, 2024
11 checks passed
@hacdias hacdias deleted the peering-cache branch April 24, 2024 08:31
Instead, it will set up peering with peers that share the same seed (requires `RAINBOW_SEED_INDEX` to be set up).

> [!NOTE]
> Runs a separate light DHT for peer routing with the main host if DHT routing is disabled.
Copy link
Member

Choose a reason for hiding this comment

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

What do light DHT and main host mean?

Is the light DHT a DHT instance that will only publish the peer records of the rainbow instance?

Copy link
Member Author

Choose a reason for hiding this comment

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

By default, Rainbow runs with two DHT hosts:

  • The "main host" which gives the identity of the Rainbow peer.
  • The "dht host" that is only used for DHT lookups.

I don't have the full context on why this was decided but maybe @aschmahmann can give more information (he made #5 after all).


If the DHT shared host is enabled, the main host is used for the DHT.


To find peers using the seed-based peering, we need the DHT. This DHT instance must run with the main host, since this is the one that really identifies the Rainbow peer. If DHT shared host is enabled, we can just use that DHT. Otherwise, we need to run a DHT instance in parallel with the DHT host just for peer routing.

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

Successfully merging this pull request may close these issues.

4 participants