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

[P2P] Background router peer discovery #712

Open
3 of 11 tasks
jessicadaugherty opened this issue May 1, 2023 · 2 comments · May be fixed by #793
Open
3 of 11 tasks

[P2P] Background router peer discovery #712

jessicadaugherty opened this issue May 1, 2023 · 2 comments · May be fixed by #793
Assignees
Labels
p2p P2P specific changes triage It requires some decision-making at team level (it can't be worked on as it stands)

Comments

@jessicadaugherty
Copy link
Contributor

jessicadaugherty commented May 1, 2023

Objective

Implement peer discovery using LibP2P's Kademlia algorithm and investigate if dynamic peer churn is included in LibP2P by default or needs to be implemented separately.

Origin Document

V1 P2P Specification

LibP2P research

LibP2P Implementation

Goals

  • Integrate LibP2P's Kademlia algorithm for peer discovery, ensuring seamless peer joining and fallback to basic discovery
    • Allowing new peers to contact existing bootstrap peers and retrieve peer lists
    • Allowing peers to disconnect and rely on the maintenance routine for broadcasting unavailability
  • Investigate and document if dynamic peer churn comes by default with LibP2P or if it needs to be implemented separately

Deliverable

  • Implement LibP2P's Kademlia algorithm for peer discovery
    • Implement the join process for new peers, enabling them to contact bootstrap peers and retrieve peer lists, followed by raintree propagation of a Join Message
    • Implement the leave process, allowing peers to disconnect and relying on the maintenance routine for broadcasting unavailability
  • Determine whether dynamic peer churn comes by default with the Kademlia algorithm, or if it needs to be implemented separately

Non-goals / Non-deliverables

  • Modification of the Kademlia algorithm itself
  • Implementing other peer discovery methods outside of the Kademlia algorithm

General issue deliverables

  • Update the appropriate CHANGELOG
  • Update any relevant READMEs (local and/or global)
  • Update any relevant global documentation & references
  • If applicable, update the source code tree explanation
  • If applicable, add or update a state, sequence or flowchart diagram using mermaid

Testing Methodology

  • All tests: make test_all
  • LocalNet: verify a LocalNet is still functioning correctly by following the instructions at docs/development/README.md

Creator: @jessicadaugherty

@jessicadaugherty jessicadaugherty converted this from a draft issue May 1, 2023
@jessicadaugherty jessicadaugherty added p2p P2P specific changes triage It requires some decision-making at team level (it can't be worked on as it stands) labels May 1, 2023
@jessicadaugherty jessicadaugherty changed the title [P2P] Peer discovery [P2P][LibP2P] Implement peer discovery using Kademlia May 1, 2023
@jessicadaugherty jessicadaugherty moved this to Up Next in V1 Dashboard May 1, 2023
bryanchriswhite added a commit that referenced this issue May 8, 2023
## @Reviewer
This PR may be more digestible / reviewable on a commit-by-commit basis.
Commits are organized logically and any given line is only modified in a
single commit, with few exceptions*.

*(In the interest of preserving the git-time-continuum
:police_officer::rotating_light:, this applies in batches of commits
between comments or reviews *by humans*)

---

## Description

Implements a "background router" to work alongside raintree (to be
integrated in a future PR) which uses a kademlia DHT for peer discovery
and a gossipsub pubsub router for broadcasting and listening.

## Issue

Part 1 of #505 
Part 1 of #712 

## Type of change

Please mark the relevant option(s):

- [x] New feature, functionality or library
- [ ] Bug fix
- [ ] Code health or cleanup
- [ ] Major breaking change
- [ ] Documentation
- [ ] Other <!-- add details here if it a different type of change -->

## List of changes

- Removed unused `Transport` interface
- Moved and renamed `raintree.RainTreeConfig` to `util.RouterConfig`
- Renamed `protocol.DefaultTopicStr` to `protocol.BackgroundTopicStr`
- Added `protocol.PeerDiscoveryNamespace`
- Added kademlia peer discovery baseline test
- Added background router (kad + gossipsub)
- Renamed `P2PConfig#MaxMempoolCount` to `P2PConfig#MaxNonces`
- Renamed `DefaultP2PMaxMempoolCount` to `DefaultP2PMaxNonces`
- Updated Dockerfiles using outdated go version to 1.19
- Updated P2P README

## Testing

- [ ] `make develop_test`; if any code changes were made
- [x] [Docker Compose
LocalNet](https://github.com/pokt-network/pocket/blob/main/docs/development/README.md);
if any major functionality was changed or introduced
- [x] [k8s
LocalNet](https://github.com/pokt-network/pocket/blob/main/build/localnet/README.md);
if any infrastructure or configuration changes were made


## Required Checklist

- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have added, or updated, [`godoc` format
comments](https://go.dev/blog/godoc) on touched members (see:
[tip.golang.org/doc/comment](https://tip.golang.org/doc/comment))
- [x] I have tested my changes using the available tooling
- [x] I have updated the corresponding CHANGELOG

### If Applicable Checklist

- [x] I have updated the corresponding README(s); local and/or global
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] I have added, or updated,
[mermaid.js](https://mermaid-js.github.io) diagrams in the corresponding
README(s)
- [ ] I have added, or updated, documentation and
[mermaid.js](https://mermaid-js.github.io) diagrams in `shared/docs/*`
if I updated `shared/*`README(s)

---------

Co-authored-by: Daniel Olshansky <[email protected]>
@jessicadaugherty jessicadaugherty moved this from Up Next to In Progress in V1 Dashboard May 15, 2023
@bryanchriswhite bryanchriswhite linked a pull request May 29, 2023 that will close this issue
20 tasks
@bryanchriswhite bryanchriswhite linked a pull request May 31, 2023 that will close this issue
20 tasks
@bryanchriswhite bryanchriswhite changed the title [P2P][LibP2P] Implement peer discovery using Kademlia [P2P] Implement background peer discovery using May 31, 2023
@bryanchriswhite bryanchriswhite changed the title [P2P] Implement background peer discovery using [P2P] Background peer discovery using May 31, 2023
@bryanchriswhite bryanchriswhite changed the title [P2P] Background peer discovery using [P2P] Background peer discovery May 31, 2023
@bryanchriswhite bryanchriswhite changed the title [P2P] Background peer discovery [P2P] Background router peer discovery May 31, 2023
@bryanchriswhite
Copy link
Contributor

Given what we now know about go-libp2p-kad-dht peer advertising and TTLs, I think it's safe to say that churn is addressed by this implementation.

I would like to have added some tests which prove it though before we close this issue.

@Olshansk
Copy link
Member

Given what we now know about go-libp2p-kad-dht peer advertising and TTLs, I think it's safe to say that churn is addressed by this implementation.

I would like to have added some tests which prove it though before we close this issue.

Appreciate the update. How about we update the deliverable to simply include the test you mentioned?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2p P2P specific changes triage It requires some decision-making at team level (it can't be worked on as it stands)
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

3 participants