spacemeshos / local-testnet

A local testnet of go-spacemesh full nodes running the Spacemesh protocol and a functional CLI wallet. 💾⏰
https://spacemesh.io
MIT License
14 stars 4 forks source link

Support libp2p in local-testnet #53

Closed dshulyak closed 2 years ago

dshulyak commented 3 years ago

Identity file is stored at {DATADIR}/p2p/p2p.key, for example -d /tmp/libp2pnew/ location of the identity file is at /tmp/libp2pnew/777/p2p/p2p.key. Example content of the file: {"Key":"CAESQNAuhFOHKi2bEXArgW3Lx9ZcDOsBe+cmlmoMR8cbadEzdva7QJzXS+dLqOoxhJOz1Zkz2q/hPSnBwTFJD8XfzKk=","ID":"12D3KooWHpkVErtj1XrPq2hybPHrQpmE5Yuck8XxeQ7wVpcagCnc"}

Key is a ed25519 private key, marshalled together with a key type. Identity is a public key marshalled to be usable with libp2p library.

This is an example of the new p2p config:

"p2p": {
        "bootnodes": [
            "/ip4/34.122.69.143/tcp/5005/p2p/12D3KooWNZQZuCf2Db4duHnS2KJGkhUK1T4gzoDMVbMyUsxoqbhb",
            "/ip4/34.133.65.156/tcp/5002/p2p/12D3KooWRUrcXbrtABRzyTH3SuVfgWWSwfJd4fsvqAc4bEXm8av1",
            "/ip4/35.224.29.146/tcp/5003/p2p/12D3KooWSFUJgnAttimJj85XY78fGLrgmuyNCfruYMFwCZUpLe3Q",
            "/ip4/104.198.136.180/tcp/5004/p2p/12D3KooWSyYG3BaG8QE2y1fiZQPPKgvpZettxpfxjaSxBKDkAyBV",
            "/ip4/34.69.148.253/tcp/5006/p2p/12D3KooWEV6jQokbutEaL7khrNrXR248U1KpMwjtxVHRKcp4n1E7",
            "/ip4/35.232.92.86/tcp/5007/p2p/12D3KooWMbh117QvwZdiVjneRHAQYYmDFVTbwVLW32BJ4BnXnTjA"
        ],
        "network-id": 777,
        "target-outbound": 10
}

The highlighted part of the /ip4/34.122.69.143/tcp/5005/p2p/12D3KooWNZQZuCf2Db4duHnS2KJGkhUK1T4gzoDMVbMyUsxoqbhb is the Identity field.

changes in spacecraft to support this: https://github.com/spacemeshos/go-spacecraft/pull/12/commits/e0308cb1b8179feace609c2e660da2919ee47850

dshulyak commented 3 years ago

cc @sudachen @moshababo