-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 658f166
Showing
103 changed files
with
5,811 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#!/bin/sh | ||
|
||
me=`basename "$0"` | ||
|
||
if [ "$me" = ".common.sh" ];then | ||
echo >&2 "This script is not expected to be run separately." | ||
exit 1 | ||
fi | ||
|
||
bold=$(tput bold) | ||
normal=$(tput sgr0) | ||
|
||
hash docker 2>/dev/null || { | ||
echo >&2 "This script requires Docker but it's not installed." | ||
echo >&2 "Refer to documentation to fulfill requirements." | ||
exit 1 | ||
} | ||
|
||
hash docker-compose 2>/dev/null || { | ||
echo >&2 "This script requires Docker compose but it's not installed." | ||
echo >&2 "Refer to documentation to fulfill requirements." | ||
exit 1 | ||
} | ||
|
||
docker info &>/dev/null | ||
if [ "$?" -eq "1" ];then | ||
echo >&2 "This script requires Docker daemon to run. Start Docker and try again." | ||
echo >&2 "Refer to documentation to fulfill requirements." | ||
exit 1 | ||
fi | ||
|
||
# We use "SI" measures here because the measurement in the UI and actual bytes | ||
# do not align exactly | ||
PRIVACY_MINIMUM=$(( 6 * 1000 * 1000 * 1000 )) | ||
NORMAL_MINIMUM=$(( 4 * 1000 * 1000 * 1000 )) | ||
dockermem=$(docker info --format '{{.MemTotal}}') | ||
|
||
case "$me" in | ||
*privacy* ) | ||
if [ $dockermem -lt $PRIVACY_MINIMUM ]; then | ||
echo >&2 "This script requires that docker has at least 6GB of memory available."; | ||
echo >&2 "Refer to documentation to fulfill requirements." | ||
exit 1 | ||
fi; | ||
;; | ||
* ) | ||
if [ $dockermem -lt $NORMAL_MINIMUM ]; then | ||
echo >&2 "This script requires that docker has at least 4GB of memory available." | ||
echo >&2 "Refer to documentation to fulfill requirements." | ||
exit 1 | ||
fi | ||
;; | ||
esac | ||
|
||
if [ "${NO_LOCK_REQUIRED}" = "true" ];then | ||
if [ -f ${LOCK_FILE} ];then | ||
echo "Network already in use (${LOCK_FILE} present)." >&2 | ||
echo "Restart with ./resume.sh or remove with ./remove.sh before running again." >&2 | ||
exit 1 | ||
fi | ||
else | ||
composeFile="" | ||
if [ -f ${LOCK_FILE} ]; then | ||
#read the first line of the lock file and store the value as it's the compose file option | ||
composeFile=`sed '1q;d' ${LOCK_FILE}` | ||
else | ||
echo "Network is not running (${LOCK_FILE} not present)." >&2 | ||
echo "Run it with ./run.sh first" >&2 | ||
exit 1 | ||
fi | ||
fi | ||
|
||
current_dir=${PWD##*/} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# This file defines environment variables defaults for Docker-compose | ||
# but we also use it for shell scripts as a sourced file | ||
|
||
BESU_VERSION=21.1.2 | ||
QUORUM_VERSION=21.1.0 | ||
QUORUM_TESSERA_VERSION=21.1.0 | ||
QUORUM_ETHSIGNER_VERSION=21.1.0 | ||
QUORUM_ORION_VERSION=21.1.1 | ||
QUORUM_CAKESHOP_VERSION=0.11.0 | ||
|
||
LOCK_FILE=.quorumDevQuickstart.lock | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
# Quorum Dev Quickstart | ||
|
||
## Table of Contents | ||
1. [Prerequisites](#prerequisites) | ||
2. [Usage](#usage) | ||
3. [Dev Network Setups](#dev-network-setups) | ||
1. [POA Network](#poa-network) | ||
2. [POA Network with Privacy](#poa-network-privacy) | ||
3. [Smart Contracts & DApps](#poa-network-dapps) | ||
|
||
|
||
## Prerequisites | ||
|
||
To run these tutorials, you must have the following installed: | ||
|
||
- [Docker and Docker-compose](https://docs.docker.com/compose/install/) | ||
|
||
| ⚠️ **Note**: If on MacOS or Windows, please ensure that you allow docker to use upto 4G of memory or 6G if running Privacy examples under the _Resources_ section. The [Docker for Mac](https://docs.docker.com/docker-for-mac/) and [Docker Desktop](https://docs.docker.com/docker-for-windows/) sites have details on how to do this at the "Resources" heading | | ||
| --- | | ||
|
||
|
||
| ⚠️ **Note**: This has only been tested on Windows 10 Build 18362 and Docker >= 17.12.2 | | ||
| --- | | ||
|
||
- On Windows ensure that the drive that this repo is cloned onto is a "Shared Drive" with Docker Desktop | ||
- On Windows we recommend running all commands from GitBash | ||
- [Nodejs](https://nodejs.org/en/download/) or [Yarn](https://yarnpkg.com/cli/node) | ||
|
||
|
||
|
||
## Usage | ||
|
||
Change directory to the artifacts folder: | ||
|
||
`cd quorum-test-network` (default folder location) | ||
|
||
**To start services and the network:** | ||
|
||
`./run.sh` starts all the docker containers | ||
|
||
**To stop services :** | ||
|
||
`./stop.sh` stops the entire network, and you can resume where it left off with `./resume.sh` | ||
|
||
`./remove.sh ` will first stop and then remove all containers and images | ||
|
||
|
||
## Dev Network Setups | ||
All our documentation can be found on the [Besu documentation site](https://besu.hyperledger.org/Tutorials/Examples/Private-Network-Example/). | ||
|
||
Each quickstart setup is comprised of 4 validators, one RPC node and some monitoring tools like: | ||
- [Alethio Lite Explorer](https://besu.hyperledger.org/en/stable/HowTo/Deploy/Lite-Block-Explorer/) to explore blockchain data at the block, transaction, and account level | ||
- [Metrics monitoring](https://besu.hyperledger.org/en/stable/HowTo/Monitor/Metrics/) via Prometheus and Grafana to give you insights into how the chain is progressing (only with Besu based Quorum) | ||
- Optional [logs monitoring](https://besu.hyperledger.org/en/latest/HowTo/Monitor/Elastic-Stack/) to give you real time logs of the nodes. This feature is enabled with a `-e` flag when starting the sample network | ||
|
||
The overall architecture diagrams to visually show components of the blockchain networks is shown below. | ||
**Consensus Algorithm**: The Besu based Quorum variant uses the `IBFT2` consensus mechanism. | ||
**Private TX Manager**: The Besu based Quorum variant uses [Orion](https://github.com/PegaSysEng/orion) | ||
|
||
![Image blockchain](./static/blockchain-network.png) | ||
|
||
|
||
### i. POA Network <a name="poa-network"></a> | ||
|
||
This is the simplest of the networks available and will spin up a blockchain network comprising 4 validators, 1 RPC | ||
node which has an [EthSinger](http://docs.ethsigner.consensys.net/) proxy container linked to it so you can optionally sign transactions. To view the progress | ||
of the network, the Alethio block explorer can be used and is available on `http://localhost:25000`. | ||
Hyperledger Besu based Quorum also deploys metrics monitoring via Prometheus available on `http://localhost:9090`, | ||
paired with Grafana with custom dashboards available on `http://localhost:3000`. | ||
|
||
Essentially you get everything in the architecture diagram above, bar the yellow privacy block | ||
|
||
Use cases: | ||
- you are learning about how Ethereum works | ||
- you are looking to create a Mainnet or Ropsten node but want to see how it works on a smaller scale | ||
- you are a DApp Developer looking for a robust, simple network to use as an experimental testing ground for POCs. | ||
|
||
|
||
### ii. POA Network with Privacy <a name="poa-network-privacy"></a> | ||
|
||
This network is slightly more advanced than the former and you get everything from the POA network above and a few | ||
Ethereum clients each paired with a Private Transaction Mananger. The Besu based Quorum variant uses [Orion](https://github.com/PegaSysEng/orion) for it's Private Transaction Mananger. | ||
|
||
As before, to view the progress of the network, the Alethio block explorer can be used and is available on `http://localhost:25000`. | ||
Hyperledger Besu based Quorum also deploys metrics monitoring via Prometheus available on `http://localhost:9090`, | ||
paired with Grafana with custom dashboards available on `http://localhost:3000`. | ||
|
||
Essentially you get everything in the architecture diagram above. | ||
|
||
Use cases: | ||
- you are learning about how Ethereum works | ||
- you are a user looking to execute private transactions at least one other party | ||
- you are looking to create a private Ethereum network with private transactions between two or more parties. | ||
|
||
Once the network is up and running you can send a private transaction between members and verify that other nodes do not see it. | ||
Under the smart_contracts folder there is an `EventEmitter` contract which can be deployed and tested by running: | ||
``` | ||
cd smart_contracts | ||
npm install | ||
node scripts/deploy.js | ||
``` | ||
which deploys the contract and sends an arbitrary value (47) from `Member1` to `Member3`. Once done, it queries all three members (orion) | ||
to check the value at an address, and you should observe that only `Member1` & `Member3` have this information as they were involved in the transaction | ||
and that `Member2` responds with a `0x` to indicate it is unaware of the transaction. | ||
|
||
``` | ||
node scripts/deploy.js | ||
Creating contract... | ||
Getting contractAddress from txHash: 0x10e8e9f46c7043f87f92224e065279638523f5b2d9139c28195e1c7e5ac02c72 | ||
Waiting for transaction to be mined ... | ||
Contract deployed at address: 0x649f1dff9ca6dfbdd27135c94171334ea0fab5ee | ||
Transaction Hash: 0x30b53a533afe909aee59df716e07f7003c0605075a13f97799b29cdd3c2c42a7 | ||
Waiting for transaction to be mined ... | ||
Transaction Hash: 0x181e37e64cdfb8d3cb0f076ee63045981436f3273942bac47820c7ec1aad0c23 | ||
Transaction Hash: 0xa27db2772689fe8ca995d32d1753d2695421120c9f171d6d32eb0873f2b96466 | ||
Waiting for transaction to be mined ... | ||
Waiting for transaction to be mined ... | ||
Member3 value from deployed contract is: 0x000000000000000000000000000000000000000000000000000000000000002f | ||
Member1 value from deployed contract is: 0x000000000000000000000000000000000000000000000000000000000000002f | ||
Member2 value from deployed contract is: 0x | ||
``` | ||
|
||
Further [documentation](https://besu.hyperledger.org/en/stable/Tutorials/Privacy/eeajs-Multinode-example/) for this example and a [video tutorial](https://www.youtube.com/watch?v=Menekt6-TEQ) | ||
is also available. | ||
|
||
There is an additional erc20 token example that you can also test with: executing `node example/erc20.js` deploys a `HumanStandardToken` contract and transfers 1 token to Node2. | ||
|
||
This can be verified from the `data` field of the `logs` which is `1`. | ||
|
||
### iii. Smart Contracts & DApps <a name="poa-network-dapps"></a> | ||
- Once you have a network up and running from above, install [metamask](https://metamask.io/) as an extension in your browser | ||
- Once you have setup your own private account, select 'My Accounts' by clicking on the avatar pic and then 'Import Account' and enter the valid private_key | ||
- You can now deploy contracts and connect DApps to the network. | ||
![Image dapp](./static/qs-dapp.png) | ||
|
||
As seen in the architecture overview diagram you can extend the network with monitoring, logging, smart contracts, DApps and so on | ||
|
||
As an example we've included the Truffle Pet-Shop Dapp in the `dapps` folder and here is a [video tutorial](https://www.youtube.com/watch?v=_3E9FRJldj8) you | ||
can follow of deployment to the network and using it. Please import the private key `0xc87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3` to | ||
Metmask **before** proceeding to build and run the DApp with `run-dapp.sh`. Behind the scenes, this has used a smart contract that is compiled and then | ||
deployed (via a migration) to our test network. The source code for the smart contract and the DApp can be found in the folder `dapps/pet-shop` | ||
|
||
When that completes open a new tab in your browser and go to `http://localhost:3001` which opens the Truffle pet-shop box app | ||
and you can adopt a pet from there. NOTE: Once you have adopted a pet, you can also go to the block explorer `http://localhost:25000` | ||
and search for the transaction where you can see its details recorded. Metamask will also have a record of any transactions. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FROM nginx:alpine | ||
COPY dist /usr/share/nginx/html | ||
RUN sed -i 's@NODE_ENV:"production",BASE_URL:"/"@NODE_URL:"/rpcnode/jsonrpc",CONNECTION_TYPE:"json_rpc"@g' /usr/share/nginx/html/js/*.js | ||
COPY default.nginx /etc/nginx/conf.d/default.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
server { | ||
listen 80; | ||
server_name localhost; | ||
|
||
#charset koi8-r; | ||
#access_log /var/log/nginx/host.access.log main; | ||
|
||
# a common HTTP RPC entrypoint mainly for the explorer service | ||
location /jsonrpc { | ||
rewrite /jsonrpc/?(.*) /$1 break; | ||
proxy_pass http://rpcnode:8545; | ||
proxy_redirect off; | ||
proxy_set_header Host $host; | ||
} | ||
|
||
# a common WS RPC entrypoint mainly for the explorer service | ||
location /jsonws { | ||
rewrite /jsonws/?(.*) /$1 break; | ||
proxy_pass http://rpcnode:8546; | ||
proxy_http_version 1.1; | ||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_set_header Connection "Upgrade"; | ||
} | ||
|
||
# a common HTTP GraphQL entrypoint | ||
location /graphql { | ||
proxy_pass http://rpcnode:8547; | ||
proxy_redirect off; | ||
proxy_set_header Host $host; | ||
} | ||
|
||
# a generic HTTP RPC entrypoint pointing to each available node | ||
location ~* /(?<serviceName>(.*))/jsonrpc { | ||
# Use Docker default local network DNS IP as resolver | ||
resolver 127.0.0.11 ipv6=off; | ||
rewrite /jsonrpc/?(.*) /$1 break; | ||
proxy_pass http://${serviceName}:8545; | ||
proxy_redirect off; | ||
proxy_set_header Host $host; | ||
} | ||
|
||
# a generic WS RPC entrypoint pointing to each available node | ||
location ~* /(?<serviceName>(.*))/jsonws { | ||
# Use Docker default local network DNS IP as resolver | ||
resolver 127.0.0.11 ipv6=off; | ||
rewrite /jsonws/?(.*) /$1 break; | ||
proxy_pass http://${serviceName}:8546; | ||
proxy_http_version 1.1; | ||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_set_header Connection "Upgrade"; | ||
} | ||
|
||
location / { | ||
root /usr/share/nginx/html; | ||
try_files $uri /index.html; | ||
index index.html index.htm; | ||
} | ||
|
||
#error_page 404 /404.html; | ||
|
||
# redirect server error pages to the static page /50x.html | ||
# | ||
error_page 500 502 503 504 /50x.html; | ||
location = /50x.html { | ||
root /usr/share/nginx/html; | ||
} | ||
} |
Oops, something went wrong.