Skip to content


Repository files navigation


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


  • go with 1.11.x or above is installed and properly configured on your machine.
    • $GOPATH variable has been specified.
    • $GOPATH/bin/ is part of your $PATH.
  • If you modify *.proto files, you will also need protoc to compile them to *.pb.go.


$ git clone
$ cd sharding-p2p-poc
$ make build


$ go test -v


$ ./sharding-p2p-poc --help
Usage of ./sharding-p2p-poc:
  -bootnodes string
    	multiaddresses of the bootnodes
    	whether to do bootstrapping or not
    	is RPC client or server
  -ip string
    	ip listened by the process for incoming connections (default "")
  -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 "")
  -rpcport int
    	RPC port listened by the RPC server (default 13000)
  -seed int
    	set random seed for id generation
    	verbose output, i.e., log level is set to DEBUG, otherwise it's set to ERROR


  • -bootstrap controls whether to spin up a bootstrap routine, which periodically queries its peers for new peers. There will be no effect if you feed -bootnodes without specifying the flag -bootstrap.
  • -client indicates we are running a client of sharding-p2p-poc. If not specifying the flag it will be run as the server by default. Details can be found in this section.


Spin up a node with a running RPC server

$ ./sharding-p2p-poc -seed=1 -port=10001 -rpcport=13001 -bootstrap -bootnodes=/ip4/,/ip4/

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/ and /ip4/

Note: /ip4/ 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.


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