Uh oh!
There was an error while loading. Please reload this page.
P2P bootstrapping - #14
Conversation
Codecov Report
@@ Coverage Diff @@## main #14 +/- ##
=========================================
+ Coverage 0 72.09% +72.09%
=========================================
Files 0 3 +3 Lines 0 43 +43 =========================================
+ Hits 0 31 +31 - Misses 0 6 +6 - Partials 0 6 +6
Continue to review full report at Codecov.
|
| func (n *Node) loadPrivateKey(nodeKey p2p.NodeKey) error { | ||
| switch nodeKey.PrivKey.Type() { | ||
| case "ed25519": | ||
| privKey, err := crypto.UnmarshalEd25519PrivateKey(nodeKey.PrivKey.Bytes()) |
There was a problem hiding this comment.
We should at least consider if doesn't make more sense, to directly generate a libp2p/crypto key in startInProcess and pass it into optimint directly instead. It seems like we have to modify that file (server/start.go) in the sdk anyway. For now that shouldn't matter to much until we have a clearer picture of the other changes in the sdk (if any).
There was a problem hiding this comment.
Very good comment. I was focusing on minimizing changes in cosmos-sdk, but probably I went to far.
Created tracking issue for this: #15.
Libp2p private key is added to Node struct. Constructor accepts NodeKey (from Tendermint) because it is used by cosmos-sdk.
It was a placeholder from initial commit.
faf5e50 to
504f90fCompareType conversion from Tendermint/cosmos-sdk to libp2p/Optimint types is extracted to `conv` package. Conversion functions can be used directly in SDK, so Optimint is called with proper types, API is not cluttered with different types.
This is just a beginning, more fields will be added as needed.
liamsi
commented
Mar 4, 2021
So nice to see this coming together! Can you briefly explain what the current scope of this PR is? As far as I understand, it connects to a bunch of seed (aka bootstrap) nodes? |
| var err error | ||
| var p2pId multiaddr.Multiaddr | ||
| if at := strings.IndexRune(addr, '@'); at != -1 { | ||
| p2pId, err = multiaddr.NewMultiaddr("/p2p/" + addr[:at]) |
There was a problem hiding this comment.
/p2p/Is that really a valid MultiAddr? NVM, it's valid. I need to go and read more about multiaddrs myslef. preferred over /ipfs is not a really helpful description of the protocol here: https://github.com/multiformats/multiaddr/blob/master/protocols.csv
There was a problem hiding this comment.
/p2p is something we can use without "registering" protocol, and it supports IDs - it's basically what we need, without reinventing the wheel.
| {"ip only", "127.0.0.1", nil, ErrInvalidAddress.Error()}, | ||
| {"with invalid id", "deadbeef@127.0.0.1:1234", nil, "failed to parse multiaddr"}, | ||
| {"valid", "127.0.0.1:1234", valid, ""}, | ||
| {"valid with id", "k2k4r8oqamigqdo6o7hsbfwd45y70oyynp98usk7zmyfrzpqxh1pohl7@127.0.0.1:1234", withId, ""}, |
There was a problem hiding this comment.
Thinking about this further: While it is right that SDK users will be used to the "@-format", we will likely use the public libp2p bootstrap nodes for some first actual experiments (let's say you and me want to run a node and see if they find each other). Then, we would go find the libp2p bootstrap nodes, translate those addrs to the @-format to use them in the local config, only for them to be translated back to the original format. So maybe we should actually just use the libp2p-style addrs directly 🤔
evan-forbes
commented
Mar 5, 2021
Just to make sure I'm understanding everything, the libp2p |
tzdybal
commented
Mar 5, 2021
@evan-forbes yes, |
| t.Parallel() | ||
| valid := mustGetMultiaddr(t, "/ip4/127.0.0.1/tcp/1234") | ||
| withId := mustGetMultiaddr(t, "/ip4/127.0.0.1/tcp/1234/p2p/k2k4r8oqamigqdo6o7hsbfwd45y70oyynp98usk7zmyfrzpqxh1pohl7") |
There was a problem hiding this comment.
What is this address? It's in the multiaddr repo too.
There was a problem hiding this comment.
I just used some example to from multiaddr repo to ensure that this address is valid.
evan-forbes
left a comment
There was a problem hiding this comment.
I appreciate how strictly contained this PR is, and learned a thing or two about libp2p. LGTM 👍
63118f1 to
bb1da59Compare
First step in implementation of P2P layer will be connection bootstrapping.
This work is related to #2.