Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean Up Client Project, Update Docs, Eliminate Unnecessary Items #399

Merged
merged 6 commits into from
Aug 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 42 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Also, read our [Sharding Reference Implementation Doc](https://github.com/prysma
# Table of Contents

- [Installation](#installation)
- [Sharding Instructions](#sharding-instructions)
- [Instructions](#instructions)
- [Testing](#testing)
- [Contributing](#contributing)
- [License](#license)
Expand Down Expand Up @@ -44,7 +44,7 @@ bazel version

Bazel manages all of the dependencies for you (including go and necessary compilers) so you are all set to build prysm.

# Sharding Instructions
# Instructions

To get started with running the project, follow the instructions to initialize your own private Ethereum blockchain and geth node, as they will be required to run before you can begin running our system

Expand Down Expand Up @@ -72,8 +72,10 @@ The `alloc` portion specifies account addresses with prefunded ETH when the Ethe

Then, you can build and init a new instance of a local, Ethereum blockchain as follows:

$ geth init /path/to/genesis.json -datadir /path/to/your/datadir
$ geth --nodiscover console --datadir /path/to/your/datadir --networkid 12345
```
geth init /path/to/genesis.json -datadir /path/to/your/datadir
geth --nodiscover console --datadir /path/to/your/datadir --networkid 12345
````

It is **important** to note that the `--networkid` flag must match the `chainId` property in the genesis file.

Expand All @@ -86,46 +88,59 @@ Then, the geth console can start up and you can start a miner as follows:
Now, save the passphrase you used in the geth node into a text file called password.txt. Then, once you have this private geth node running on your local network, we will need to generate test, pending transactions that can then be processed into collations by proposers. For this, we have created an in-house transaction generator CLI tool.


# Sharding Minimal Protocol
# Running Ethereum 2.0

**NOTE**: This section is in flux: will be deprecated in favor of a beacon chain)
**NOTE**: This section is in flux, much of this will likely change as the beacon chain spec evolves.

Build our system first

```
$ bazel build //client/...
bazel build //...
```

## Becoming a Attester
## Step 1: Deploy a Validator Registation Contract

Deploy the Validator Registration Contract into the chain of the running geth node by following the instructions [here](https://github.com/prysmaticlabs/prysm/blob/master/contracts/validator-registration-contract/deployVRC/README.md).

## Step 2: Running a Beacon Node

Make sure a geth node is running as a separate process according to the instructions from the previous section. Then, you can run a full beacon node as follows:

```
bazel run //beacon-chain --\
--web3provider ws://127.0.0.1:8546 \
--datadir /path/to/your/datadir \
--rpc-port 5000
```

This will spin up a full beacon node that connects to your running geth node, opens up an RPC connection for sharding clients to connect to it, and begins listening for p2p events.

Make sure a geth node is running as a separate process. Then, to deposit ETH and join as a attester in the Sharding Manager Contract, run the following command:
To try out the beacon node in development by simulating incoming blocks, run the same command above but enable the `--simulator` and a debug level, log verbosity with `--verbosity debug` to see everything happening underneath the hood.

```
bazel run //client -- \
--actor "attester" \
--deposit \
--datadir /path/to/your/datadir \
--password /path/to/your/password.txt \
--networkid 12345
bazel run //beacon-chain --\
--web3provider ws://127.0.0.1:8546 \
--datadir /path/to/your/datadir \
--rpc-port 5000 \
--simulator \
--verbosity debug
```

This will extract 1000ETH from your account balance and insert you into the SMC's attesters. Then, the program will listen for incoming block headers and notify you when you have been selected as to vote on proposals for a certain shard in a given period. Once you are selected, your sharding node will download collation information to check for data availability on vote on proposals that have been submitted via the `addHeader` function on the SMC.
Now, deposit ETH to become a validator in the contract using instructions [here](https://github.com/prysmaticlabs/prysm/blob/master/beacon-chain/VALIDATOR_REGISTER.md)

## Step 3: Running a Sharding Client

Concurrently, you will need to run another service that is tasked with processing transactions into collations and submitting them to the SMC via the `addHeader` function.
Once your beacon node is up, you'll need to attach a sharding client as a separate process. This client is in charge of running attester/proposer responsibilities and handling shards (shards to be designed in phase 2). This client will listen for incoming beacon blocks and crystallized states and determine when its time to perform attester/proposer responsibilities accordingly.

## Running a Collation Proposal Node
Run as follows:

```
bazel run //client -- \
--actor "proposer" \
--datadir /path/to/your/datadir \
--password /path/to/your/password.txt \
--shardid 0 \
--networkid 12345
bazel run //client --\
--beacon-rpc-provider http://localhost:4000 \
--verbosity debug
```

This node is tasked with processing pending transactions into blobs within collations by serializing data into collation bodies. It is responsible for submitting proposals on shard 0 (collation headers) to the SMC via the `addHeader` function.
Then, the beacon node will update this client with new blocks + crystallized states in order for the client to act as an attester or proposer.

## Running via Docker

Expand Down Expand Up @@ -154,28 +169,18 @@ targets for the container images such that they can be pulled from GCR or
dockerhub.


# Making Changes

## Rebuilding the Sharding Manager Contract Bindings

The Sharding Manager Contract is built in Solidity and deployed to a running geth node upon launch of the sharding node if it does not exist in the network at a specified address. If there are any changes to the SMC's code, the Golang bindigs must be rebuilt with the following command.

go generate github.com/prysmaticlabs/prysm/client/contracts
# OR
cd client/contracts && go generate

# Testing

To run the unit tests of our system do:

```
$ bazel test //...
bazel test //...
```

To run our linter, make sure you have [gometalinter](https://github.com/alecthomas/gometalinter) installed and then run

```
$ gometalinter ./...
gometalinter ./...
```

# Contributing
Expand Down
10 changes: 1 addition & 9 deletions client/internal/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,12 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
testonly = True,
srcs = [
"beacon_service_mock.go",
"client_helper.go",
],
srcs = ["beacon_service_mock.go"],
importpath = "github.com/prysmaticlabs/prysm/client/internal",
visibility = ["//client:__subpackages__"],
deps = [
"//proto/beacon/p2p/v1:go_default_library",
"//proto/beacon/rpc/v1:go_default_library",
"@com_github_ethereum_go_ethereum//accounts/abi/bind:go_default_library",
"@com_github_ethereum_go_ethereum//accounts/abi/bind/backends:go_default_library",
"@com_github_ethereum_go_ethereum//common:go_default_library",
"@com_github_ethereum_go_ethereum//core/types:go_default_library",
"@com_github_ethereum_go_ethereum//crypto:go_default_library",
"@com_github_golang_mock//gomock:go_default_library",
"@io_bazel_rules_go//proto/wkt:empty_go_proto",
"@org_golang_google_grpc//:go_default_library",
Expand Down
4 changes: 2 additions & 2 deletions client/internal/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Sharding Internal Package
# Client Internal Package

This package should be used for test helpers and non-production code only!
This package should be used for test helpers and non-production code only! Mocks generated with gomock and omckgen will go in this package.
42 changes: 0 additions & 42 deletions client/internal/client_helper.go

This file was deleted.

20 changes: 18 additions & 2 deletions client/main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Package client defines the required functionalities for the sharding client.
package main

import (
Expand All @@ -15,6 +14,13 @@ import (
)

func startNode(ctx *cli.Context) error {
verbosity := ctx.GlobalString(cmd.VerbosityFlag.Name)
level, err := logrus.ParseLevel(verbosity)
if err != nil {
return err
}
logrus.SetLevel(level)

shardingNode, err := node.NewShardInstance(ctx)
if err != nil {
return err
Expand Down Expand Up @@ -55,7 +61,17 @@ VERSION:
app.Usage = `launches a sharding client that interacts with a beacon chain, starts proposer services, shardp2p connections, and more
`
app.Action = startNode
app.Flags = []cli.Flag{types.ActorFlag, types.BeaconRPCProviderFlag, cmd.VerbosityFlag, cmd.DataDirFlag, debug.PProfFlag, debug.PProfAddrFlag, debug.PProfPortFlag, debug.MemProfileRateFlag, debug.CPUProfileFlag, debug.TraceFlag}
app.Flags = []cli.Flag{
types.BeaconRPCProviderFlag,
cmd.VerbosityFlag,
cmd.DataDirFlag,
debug.PProfFlag,
debug.PProfAddrFlag,
debug.PProfPortFlag,
debug.MemProfileRateFlag,
debug.CPUProfileFlag,
debug.TraceFlag,
}

app.Before = func(ctx *cli.Context) error {
runtime.GOMAXPROCS(runtime.NumCPU())
Expand Down
1 change: 0 additions & 1 deletion client/node/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ go_library(
deps = [
"//client/attester:go_default_library",
"//client/beacon:go_default_library",
"//client/params:go_default_library",
"//client/proposer:go_default_library",
"//client/rpcclient:go_default_library",
"//client/txpool:go_default_library",
Expand Down
Loading