-
Notifications
You must be signed in to change notification settings - Fork 33
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] Initial libp2p integration #500
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Closed
6 tasks
cca88a7
to
f37f302
Compare
bryanchriswhite
commented
Feb 9, 2023
bryanchriswhite
commented
Feb 9, 2023
f37f302
to
e1991fa
Compare
0562356
to
c1fb339
Compare
c1fb339
to
b9cbab1
Compare
71dca01
to
dc3d31b
Compare
Closing in preparation for splitting. |
This was referenced Feb 22, 2023
This was referenced Feb 27, 2023
bryanchriswhite
added a commit
that referenced
this pull request
Mar 1, 2023
## Description This is another of a series of PRs split out from #500. Here we update the base and P2P configs in preparation for the addition of the libp2p module. ## Issue #347 ## 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 - Replace `consensus_port` with `port` in P2P config. - Update default P2P config `port` to from `8080` to `42069`. - Add `use_libp2p` field to base config. - Add `hostname` field to P2P config. - Update state hash test after modifying genesis (updated port numbers). ## Testing - [x] `make develop_test` - [x] [LocalNet](https://github.com/pokt-network/pocket/blob/main/docs/development/README.md) w/ all of the steps outlined in the `README` ## Required Checklist - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have tested my changes using the available tooling - [x] I have updated the corresponding CHANGELOG ### If Applicable Checklist - [ ] I have updated the corresponding README(s); local and/or global - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] 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)
bryanchriswhite
added a commit
that referenced
this pull request
Mar 2, 2023
## Description This is the first of a series of PRs split out from #500. Here we set up the new libp2p module directory structure and add crypto and identity / network helpers. ## Issue #347 ## 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 - prepare pocket repo new libp2p module - add pocket / libp2p identity helpers - add url <--> multiaddr conversion helpers for use with libp2p (see: https://github.com/multiformats/go-multiaddr) - add pokt --> libp2p crypto helpers ## Testing - [x] `make develop_test` - [x] [LocalNet](https://github.com/pokt-network/pocket/blob/main/docs/development/README.md) w/ all of the steps outlined in the `README` <!-- REMOVE this comment block after following the instructions If you added additional tests or infrastructure, describe it here. Bonus points for images and videos or gifs. --> ## 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 tested my changes using the available tooling - [x] I have updated the corresponding CHANGELOG ### If Applicable Checklist - [ ] 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 - [ ] 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: Alessandro De Blasis <[email protected]>
bryanchriswhite
added a commit
that referenced
this pull request
Mar 3, 2023
## Description This is another of a series of PRs split out from #500. Here we add a new implementation of `typesP2P.Network` in terms of libp2p abstractions, utilizing the helpers which were added in #534. ## Issue #347 ## 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 - Added a new `typesP2P.Network` implementation to the `libp2p` module directory - Added embedded `modules.InitializableModule` to the P2P `AddrBookProvider` interface so that it can be dependency injected as a `modules.Module` via the bus registry. - Added `PoktProtocolID` for use within the libp2p module or by public API consumers ## Testing - [x] `make develop_test` - [x] [LocalNet](https://github.com/pokt-network/pocket/blob/main/docs/development/README.md) w/ all of the steps outlined in the `README` ## 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 - [ ] I have tested my changes using the available tooling - [x] I have updated the corresponding CHANGELOG ### If Applicable Checklist - [ ] 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 - [ ] 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: Alessandro De Blasis <[email protected]>
bryanchriswhite
added a commit
that referenced
this pull request
Mar 3, 2023
## Description This is another of a series of PRs split out from #500. Here we add a new `modules.P2PModule` implementation which utilizes the `typesP2P.Network` implementation which was added in #540. It will be utilized together with the config changes introduced by #535 in forthcoming changes to the node and debug CLI. ## Issue #347 ## 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 - Added a new `modules.P2PModule` implementation to the `libp2p` module directory ## Testing - [x] `make develop_test` - [x] [LocalNet](https://github.com/pokt-network/pocket/blob/main/docs/development/README.md) w/ all of the steps outlined in the `README` ## 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 - [ ] I have tested my changes using the available tooling - [x] I have updated the corresponding CHANGELOG ### If Applicable Checklist - [ ] I have updated the corresponding README(s); local and/or global - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] 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)
bryanchriswhite
added a commit
that referenced
this pull request
Mar 3, 2023
## Description This is another (last, probably) in a series of PRs split out from #500. Here we finally enable support for use of the new libp2p module (and dependent packages) by considering the config changes made in #535 in the node and debug CLI. ## Issue #347 ## 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 - Support libp2p module in node - Support libp2p module in debug CLI ## Testing - [x] `make develop_test` - [x] [LocalNet](https://github.com/pokt-network/pocket/blob/main/docs/development/README.md) w/ all of the steps outlined in the `README` <!-- REMOVE this comment block after following the instructions If you added additional tests or infrastructure, describe it here. Bonus points for images and videos or gifs. --> ## 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 tested my changes using the available tooling - [x] I have updated the corresponding CHANGELOG ### If Applicable Checklist - [ ] I have updated the corresponding README(s); local and/or global - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] 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)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Adds a new P2P module implementation which wraps libp2p abstractions (mainly
host.Host
andpubsub.Pubsub
) and adapts them to the current interfaces (modules.Module
,types.Network
,types.Transport
).Network Implementation
For "broadcast" messages (i.e. send to the network), the network implementation utilizes go-libp2p-pubsub to establish a publish / subscribe relationship between network nodes. A pubsub router implementation is used to determine which nodes to send which messages. For simplicity, this initial implementation uses the basic
FloodSubRouter
, which causes each node to contact every other node directly (i.e. fully-connected network); however, more sophisticated options are available, such asRandomSubRouter
andGossipSubRouter
.For "direct" messages (i.e. send to specific node by identity), the network implementation opens a new stream to the desired peer, writes the network level message, establishing a connection to the peer if one does not already exist in the libp2p-managed connection pool, and then closes the stream. On the receiving side, peers watch for incoming streams on network start. When a new stream is opened by a remote peer, it's read from until
EOF
(i.e. stream closes) or until the read deadline times out.Address Book
The network interface makes its API responsible for managing the address book (i.e. adding / removing peers). As this is encapsulated by the
host.Host
implementation in the libp2p regime, the new network implementation maintains a map of pocket peers by pocket "address", analogous to other network implementations; however, the pocket peers retrieved from this map are subsequently converted to their respective libp2p representations (peer.AddrInfo
) for use by libp2p. The "pocket address book" is also updated when a remote peer opens a new stream, keeping it in sync with libp2p's.Next Steps
rainTreeNetwork
shouldn't depend on any concrete p2p typesTransport
interface likely reduces to nothingNetwork
interface can be simplified(NB: could be replaced in future iterations with a "raintree pubsub router")
Issue
Relates to #347
Type of change
Please mark the relevant option(s):
List of changes
modules.Module
implementation in p2p/libp2p.types.Network
implemenation.types.Transport
.use_lib_p2p
to switch between the two P2P modules.hostname
to specify a registered name or IP address to listen on.Testing
make develop_test
README
Required Checklist
If Applicable Checklist
shared/docs/*
if I updatedshared/*
README(s)