ethresearch / sharding-p2p-poc

Proof of Concept of Ethereum Serenity Peer-to-Peer Layer on libp2p PubSub System
40 stars 19 forks source link
ethereum libp2p pubsub serenity

sharding-p2p-poc

Build Status

This is a proof of concept of Ethereum sharding peer to peer layer with PubSub in libp2p, based on the idea from the slide.

For more information, please check out the document.

Getting Started

Prerequisites

Build

$ git clone https://github.com/ethresearch/sharding-p2p-poc.git
$ cd sharding-p2p-poc
$ make build

Testing

$ go test -v

Usage

$ ./sharding-p2p-poc --help
Usage of ./sharding-p2p-poc:
  -bootnodes string
        multiaddresses of the bootnodes
  -bootstrap
        whether to do bootstrapping or not
  -client
        is RPC client or server
  -ip string
        ip listened by the process for incoming connections (default "127.0.0.1")
  -notifierport int
        notifier port listened by the event rpc server
  -port int
        port listened by the node for incoming connections (default 10000)
  -rpcip string
        ip listened by the RPC server (default "127.0.0.1")
  -rpcport int
        RPC port listened by the RPC server (default 13000)
  -seed int
        set random seed for id generation
  -verbose
        verbose output, i.e., log level is set to DEBUG, otherwise it's set to ERROR

Note

Example

Spin up a node with a running RPC server

$ ./sharding-p2p-poc -seed=1 -port=10001 -rpcport=13001 -bootstrap -bootnodes=/ip4/127.0.0.1/tcp/5566/ipfs/QmS5QmciTXXnCUCyxud5eWFenUMAmvAWSDa1c7dvdXRMZ7,/ip4/127.0.0.1/tcp/10001/ipfs/QmexAnfpHrhMmAC5UNQVS8iBuUUgDrMbMY17Cck2gKrqeX

This command spins up a node with seed 1, listening to new connections at port 10001, listening to RPC requests at port 13001, turning on bootstrapping mode with the flag-bootstrap, with the bootstrapping nodes /ip4/127.0.0.1/tcp/5566/ipfs/QmS5QmciTXXnCUCyxud5eWFenUMAmvAWSDa1c7dvdXRMZ7 and /ip4/127.0.0.1/tcp/10001/ipfs/QmexAnfpHrhMmAC5UNQVS8iBuUUgDrMbMY17Cck2gKrqeX.

Note: /ip4/127.0.0.1/tcp/10001/ipfs/QmexAnfpHrhMmAC5UNQVS8iBuUUgDrMbMY17Cck2gKrqeX is the format of ipfs address, which is in the form of /ip4/{ip}/tcp/{port}/{peerID}.

Command Line Interface

To give commands to the node you have spun up, you can run the command in this format:

$ ./sharding-p2p-poc -client -rpcport={rpcport} {method_name} {params}

The flag -rpcport is important since it is used to specify which node you are going to communicate with. If you don't specify it, the current default rpcport is 13000.

Since they are still subject to changes, please check out the documentations for further reference to the RPC methods. You can also check out the examples here.

Using Docker

make docker-build

Setting up tracer

See tracer in the document.

Contributing

Issues, PRs, or any kind of help are definitely welcomed.