Skip to content

Proof of Concept of Ethereum Serenity Peer-to-Peer Layer on libp2p PubSub System

Notifications You must be signed in to change notification settings

ethresearch/sharding-p2p-poc

Repository files navigation

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

  • 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.

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

  • -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.

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.