Skip to content

Commit

Permalink
Updated for Quorum developer quickstart (#543)
Browse files Browse the repository at this point in the history
* WIP

Signed-off-by: Madeline Murray <madeline.taylor@gmail.com>

* updated for quorum developer quickstart

Signed-off-by: Madeline Murray <madeline.taylor@gmail.com>

* build

Signed-off-by: Madeline Murray <madeline.taylor@gmail.com>

* lint

Signed-off-by: Madeline Murray <madeline.taylor@gmail.com>

Co-authored-by: Madeline Murray <madeline.taylor@gmail.com>
  • Loading branch information
MadelineMurray and MadelineAu authored Nov 5, 2020
1 parent 152f6ed commit 617726b
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 143 deletions.
70 changes: 31 additions & 39 deletions docs/Tutorials/Examples/Privacy-Example.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
description: Hyperledger Besu privacy-enabled private network tutorial
---

# Privacy-enabled private network example tutorial
# Privacy-enabled Quorum Developer Quickstart tutorial

The privacy-enabled private network example runs a private network of Hyperledger Besu and Orion
nodes managed by Docker Compose. It's an expanded version of the
[private network example](Private-Network-Example.md).
[Quorum Developer Quickstart tutorial](Private-Network-Example.md).

You can use the [Block Explorer](Private-Network-Example.md#block-explorer), make
[JSON-RPC requests](Private-Network-Example.md#run-json-rpc-requests), and
[create transactions using Metamask] as described in the
[private network example](Private-Network-Example.md). This tutorial describes how to use the
[Quorum Developer Quickstart tutorial](Private-Network-Example.md). This tutorial describes how to use the
examples provided in the web3js-eea library to
[create and send private transactions](#send-private-transactions-and-read-values).

Expand All @@ -36,26 +36,25 @@ To run this tutorial, you must have the following installed:
* [Git command line](https://git-scm.com/)
* [Curl command line](https://curl.haxx.se/download.html).

## Clone Besu sample networks source code
## Create Docker-compose file

Clone the repository from the `besu-` repository.
## Usage

=== "Linux/MacOS"
To create the docker-compose file and artifacts, run:

```bash
git clone https://github.com/PegaSysEng/besu-sample-networks.git
```

!!!note
```bash
npx quorum-dev-quickstart
```

To use a specific version of Hyperledger Besu, set the `BESU_VERSION` environment variable.
Follow the prompts displayed to run Hyperledger Besu, private transactions, and [logging with ELK](../../HowTo/Monitor/Elastic-Stack.md).
Enter `n` for [Codefi Orchestrate](https://docs.orchestrate.consensys.net/en/stable/).

## Clone web3js-eea libraries

Clone the `PegaSysEng/web3js-eea` library:
Clone the `ConsenSys/web3js-eea` library:

```bash
git clone https://github.com/PegaSysEng/web3js-eea.git
git clone https://github.com/ConsenSys/web3js-eea.git
```

In the `web3js-eea` directory:
Expand All @@ -70,32 +69,31 @@ npm install

If running in Windows, please run commands from the GitBash shell

In the `besu-sample-networks` directory, start the network with privacy enabled:
In the installation directory, start the network:

```bash
./run-privacy.sh
./run.sh
```

The script pulls the Docker images starts the network. Pulling the images takes a few minutes the
first time. The network details display.

```bash
Name Command State Ports
--------------------------------------------------------------------------------------------------------------------------
privacy_bootnode_1 /opt/besu/bootnode_sta ... Up 30303/tcp, 8545/tcp, 8546/tcp
privacy_explorer_1 nginx -g daemon off; Up 0.0.0.0:25000->80/tcp
privacy_minernode_1 /opt/besu/node_start.s ... Up 30303/tcp, 8545/tcp, 8546/tcp
privacy_node1_1 /opt/besu/node_start.s ... Up 30303/tcp, 0.0.0.0:20000->8545/tcp, 0.0.0.0:20001->8546/tcp
privacy_node2_1 /opt/besu/node_start.s ... Up 30303/tcp, 0.0.0.0:20002->8545/tcp, 0.0.0.0:20003->8546/tcp
privacy_node3_1 /opt/besu/node_start.s ... Up 30303/tcp, 0.0.0.0:20004->8545/tcp, 0.0.0.0:20005->8546/tcp
privacy_orion1_1 /orion/bin/orion data/data ... Up
privacy_orion2_1 /orion/bin/orion data/data ... Up
privacy_orion3_1 /orion/bin/orion data/data ... Up
privacy_rpcnode_1 /opt/besu/node_start.s ... Up 30303/tcp, 8545/tcp, 8546/tcp
****************************************************************
JSON-RPC HTTP service endpoint : http://localhost:8545 *
JSON-RPC WebSocket service endpoint : ws://localhost:8546 *
Web block explorer address : http://localhost:25000 *
*************************************
Quorum Dev Quickstart
*************************************
Setting up the index patterns in kibana .................
----------------------------------
List endpoints and services
----------------------------------
JSON-RPC HTTP service endpoint : http://localhost:8545
JSON-RPC WebSocket service endpoint : ws://localhost:8546
Web block explorer address : http://localhost:25000/
Prometheus address : http://localhost:9090/graph
Grafana address : http://localhost:3000/d/XE4V0WGZz/besu-overview?orgId=1&refresh=10s&from=now-30m&to=now&var-system=All
Collated logs using Kibana endpoint : http://localhost:5601/app/kibana#/discover

For more information on the endpoints and services, refer to README.md in the installation directory.
****************************************************************
```

Expand Down Expand Up @@ -147,7 +145,7 @@ Call [`eth_getTransactionReceipt`](../../Reference/API-Methods.md#eth_gettransac
=== "curl HTTP request"
```bash
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionReceipt","params":["<TransactionHash>"],"id":1}' <JSON-RPC Endpoint>
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionReceipt","params":["<TransactionHash>"],"id":1}' http://localhost:8545
```
=== "Example"
Expand Down Expand Up @@ -197,11 +195,5 @@ Do one of the following to stop the network:
./remove.sh
```
* Stop the network and delete the Docker images:
```bash
./delete.sh
```
<!-- Links -->
[create transactions using Metamask]: Private-Network-Example.md#create-a-transaction-using-metamask
151 changes: 47 additions & 104 deletions docs/Tutorials/Examples/Private-Network-Example.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
description: Hyperledger Besu private network example tutorial
description: Quorum dev quickstart tutorial
---

# Private network example tutorial
# Quorum Developer Quickstart tutorial

The private network example uses the Hyperledger Besu Docker image to run a private network of Besu
The Quorum Developer Quickstart uses the Hyperledger Besu Docker image to run a private network of Besu
nodes managed by Docker Compose.

!!! important
Expand All @@ -14,44 +14,39 @@ nodes managed by Docker Compose.

## Prerequisites

To run this tutorial, you must have the following installed:

* [Docker and Docker-compose](https://docs.docker.com/compose/install/)
* [Nodejs](https://nodejs.org/en/download/)
* On Windows:
* Windows Subsystem for Linux 2
* Docker desktop configured to use the WSL2-based engine.

!!! important

If using [MacOS](https://docs.docker.com/docker-for-mac/) or
[Windows](https://docs.docker.com/docker-for-windows/), set Docker to use up to 6GB of
memory on the _Advanced_ tab in _Preferences_.
!!! important
Ensure you allow Docker up to 4G of memory or 6G if running the privacy examples.
Refer to the _Resources_ section in [Docker for Mac](https://docs.docker.com/docker-for-mac/) and
[Docker Desktop](https://docs.docker.com/docker-for-windows/) for details.

* [Git command line](https://git-scm.com/)
* [Curl command line](https://curl.haxx.se/download.html)
* A web browser that supports [Metamask](https://metamask.io/) (currently Chrome, Firefox, Opera,
and Brave), and has the MetaMask plug-in installed. This tutorial uses screenshots from Brave.

## Clone Besu sample networks source code
## Create Docker-compose file

Clone the repository from the `besu-sample-networks` repository:

=== "Linux/MacOS"
## Usage

```bash
git clone https://github.com/PegaSysEng/besu-sample-networks.git
```
To create the docker-compose file and artifacts, run:

!!!note
```bash
npx quorum-dev-quickstart
```

To use a specific version of Hyperledger Besu, set the `BESU_VERSION` environment variable.
Follow the prompts displayed to run Hyperledger Besu and [logging with ELK](../../HowTo/Monitor/Elastic-Stack.md).
Enter `n` for [Codefi Orchestrate](https://docs.orchestrate.consensys.net/en/stable/) and
[private transactions](../../Concepts/Privacy/Privacy-Overview.md).

## Start the network

!!!important

If running in Windows, run commands from the GitBash shell.

This tutorial uses [Docker Compose](https://docs.docker.com/compose/) to assemble the images and
run the private network. To build the docker images and run the containers, go to the
`besu-sample-networks` directory and run:
To start the network, go to the installation directory and run:

=== "Linux/MacOS"

Expand All @@ -68,51 +63,40 @@ When the process ends, it lists the running services:

```log
*************************************
Sample Network for Besu at latest
Quorum Dev Quickstart
*************************************
Setting up the index patterns in kibana............
{"type":"index-pattern","id":"metricbeat","attributes":{"title":"metricbeat-*","timeFieldName":"@timestamp"},
"references":[],"migrationVersion":{"index-pattern":"7.6.0"},"updated_at":"2020-11-04T10:43:34.252Z",
"version":"WzgsMV0=","namespaces":["default"]}{"success":true,"successCount":7}{"type":"index-pattern",
"id":"besu","attributes":{"title":"besu-*","timeFieldName":"@timestamp"},"references":[],"migrationVersion":
{"index-pattern":"7.6.0"},"updated_at":"2020-11-04T10:43:36.927Z","version":"WzE2LDFd","namespaces":
["default"]}{"type":"index-pattern","id":"orion","attributes":{"title":"orion-*","timeFieldName":"@timestamp"},
"references":[],"migrationVersion":{"index-pattern":"7.6.0"},"updated_at":"2020-11-04T10:43:37.982Z","version":
"WzE3LDFd","namespaces":["default"]}{"type":"index-pattern","id":"quorum","attributes":{"title":"quorum-*",
"timeFieldName":"@timestamp"},"references":[],"migrationVersion":{"index-pattern":"7.6.0"},"updated_at":
"2020-11-04T10:43:39.003Z","version":"WzE4LDFd","namespaces":["default"]}{"type":"index-pattern","id":
"tessera","attributes":{"title":"tessera-*","timeFieldName":"@timestamp"},"references":[],"migrationVersion":
{"index-pattern":"7.6.0"},"updated_at":"2020-11-04T10:43:40.053Z","version":"WzE5LDFd","namespaces":
["default"]}

List endpoints and services
----------------------------------
Name Command State Ports
-----------------------------------------------------------------------------------------------------------------------------------------------------------
besu-sample-network_bootnode_1 /opt/besu/bootnode_start.s ... Up 0.0.0.0:30303->30303/tcp, 0.0.0.0:30303->30303/udp, 8545/tcp, 8546/tcp, 8547/tcp
besu-sample-network_elasticsearch_1 /usr/local/bin/docker-entr ... Up 9200/tcp, 9300/tcp
besu-sample-network_explorer_1 nginx -g daemon off; Up 0.0.0.0:25000->80/tcp
besu-sample-network_filebeat_1 /usr/local/bin/docker-entr ... Up
besu-sample-network_grafana_1 /run.sh Up 0.0.0.0:3000->3000/tcp
besu-sample-network_kibana_1 /usr/local/bin/dumb-init - ... Up 0.0.0.0:5601->5601/tcp
besu-sample-network_logstash_1 /usr/local/bin/docker-entr ... Up 5044/tcp, 9600/tcp
besu-sample-network_minernode_1 /opt/besu/node_start.sh -- ... Up 30303/tcp, 8545/tcp, 8546/tcp, 8547/tcp
besu-sample-network_node_1 /opt/besu/node_start.sh -- ... Up 30303/tcp, 8545/tcp, 8546/tcp, 8547/tcp
besu-sample-network_prometheus_1 /bin/prometheus --config.f ... Up 0.0.0.0:9090->9090/tcp
besu-sample-network_redis_1 docker-entrypoint.sh redis ... Up 6379/tcp
besu-sample-network_rpcnode_1 /opt/besu/node_start.sh -- ... Up 30303/tcp, 0.0.0.0:8545->8545/tcp, 8546/tcp, 8547/tcp
Setting up the besu index pattern in kibana
{"type":"index-pattern","id":"besu","attributes":{"title":"besu-*","timeFieldName":"@timestamp"},"references":[],"migrationVersion":{"index-pattern":"6.5.0"},"updated_at":"2019-12-27T04:41:07.665Z","version":"WzMsMV0="}
Orion not running, skipping the orion index pattern in kibana.
```

Followed by a list of the endpoints:

!!! example "Endpoint list example"

```log
****************************************************************
JSON-RPC HTTP service endpoint : http://localhost:8545
JSON-RPC WebSocket service endpoint : ws://localhost:8546
GraphQL HTTP service endpoint : http://localhost:8547
Web block explorer address : http://localhost:25000/
Prometheus address : http://localhost:9090/graph
Grafana address : http://localhost:3000/d/XE4V0WGZz/besu-overview?orgId=1&refresh=10s&from=now-30m&to=now&var-system=All
Kibana logs address : http://localhost:5601/app/kibana#/discover

For more information on the endpoints and services, refer to README.md in the installation directory.
****************************************************************
```

* Use the **JSON-RPC HTTP service endpoint** to access the RPC node service from your Dapp or from
cryptocurrency wallets such as Metamask.
* Use the **JSON-RPC WebSocket service endpoint** to access the web socket node service from your
Dapp.
* Use the **GraphQL HTTP service endpoint** to access the
[HTTP GraphQL](../../HowTo/Interact/APIs/GraphQL.md) node service from your Dapp.
* Use the **Web block explorer address** to display the block explorer web application. View the
block explorer by entering the URL in your web browser.
* Use the **Prometheus address** to access the
Expand All @@ -139,12 +123,7 @@ This tutorial uses the Alethio Ethereum Lite Explorer.
Access the explorer by copying and pasting the `Web block explorer address` displayed when starting
the private network to your browser.

The block explorer displays a summary of the private network:

![Block Explorer](../../images/ExplorerSummary.png)

See that the explorer indicates six peers: the four regular nodes, the mining node, and the
bootnode.
The block explorer displays a summary of the private network, indicating four peers.

Click the block number to the right of **Best Block** to display the block details:

Expand Down Expand Up @@ -187,7 +166,7 @@ time you run the network.
Run the following command from the host shell:

```bash
curl -X POST --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":1}' <http-rpc-endpoint>
curl -X POST --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":1}' http://localhost:8545
```

The result specifies the client version:
Expand All @@ -213,29 +192,27 @@ Peers are the number of other nodes connected to the RPC node.
Poll the peer count using `net_peerCount`:

```bash
curl -X POST --data '{"jsonrpc":"2.0","method":"net_peerCount","params":[],"id":1}' <http-rpc-endpoint>
curl -X POST --data '{"jsonrpc":"2.0","method":"net_peerCount","params":[],"id":1}' http://localhost:8545
```

The result indicates that there are six peers:
The result indicates that there are four peers:

```json
{
"jsonrpc" : "2.0",
"id" : 1,
"result" : "0x6"
"result" : "0x4"
}
```

### Request the most recently mined block number
### Request the most recent block number

Call `eth_blockNumber` to retrieve the number of the most recent block:

```bash
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' <http-rpc-endpoint>
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' http://localhost:8545
```

The result provides the most recently mined block:

```json
{
"jsonrpc" : "2.0",
Expand All @@ -244,41 +221,7 @@ The result provides the most recently mined block:
}
```

The hexadecimal value `0x8b8` translates to `2232` in decimal, the number of mined blocks so far.

### Check the miner account balance

Call `eth_getBalance` to retrieve the balance of the mining address (coinbase) defined in the miner
node:

```bash
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0xfe3b557e8fb62b89f4916b721be55ceb828dbd73","latest"],"id":1}' <http-rpc-endpoint>
```

The result specifies the miner account balance:

```json
{
"jsonrpc" : "2.0",
"id" : 1,
"result" : "0x79f905c6fd34e80000"
}
```

!!!info

0x79f905c6fd34e80000 = 2250000000000000000000 Wei (2250 Ether).

!!!tip

Use a [unit converter](https://www.etherchain.org/tools/unitConverter) to translate values from
Wei to Ether.

Wait a few seconds until there are new mined blocks then call `eth_getBalance` again. The balance
increases, meaning the miner address successfully received the mining reward.

You can also view this information in the block explorer. It does exactly the same thing as this
call, connecting to the RPC node using HTTP JSON-RPC, and displaying information on a web page.
The hexadecimal value `0x8b8` translates to `2232` in decimal, the number of blocks so far.

## Create a transaction using MetaMask

Expand Down

0 comments on commit 617726b

Please sign in to comment.