mirror of
https://github.com/tappollo/quorum-examples.git
synced 2026-01-12 17:03:08 +08:00
@@ -6,10 +6,15 @@ This example configures 7 nodes, each with their own PrivateTransactionManager.
|
||||
- `start.sh`: Launch `constellation` and `geth` nodes, then send a private transaction
|
||||
- `stop.sh`: Stop all `constellation` and `geth` nodes
|
||||
|
||||
There are corresponding commands for running in Raft mode (`stop.sh` stays the same).
|
||||
|
||||
- `raft-init.sh`
|
||||
- `raft-start.sh`
|
||||
|
||||
All logs and temporary data will be written to the `qdata` folder.
|
||||
|
||||
## Testing Privacy
|
||||
You can run the 7node example to test the privacy features of Quorum. As described in the Quick Start section of the [README](https://github.com/jpmorganchase/quorum), the final step of the 7node `start.sh` script was the sending of a private transaction to generate a (private) smart contract (SimpleStorage) sent from node 1 "for" node 7 (denoted by the public key passed via privateFor: ["ROAZBWtSacxXQrOe3FGAqJDyJjFePR5ce4TSIzmJ0Bc="] in the sendTransaction call). We'll begin by demonstrating only nodes 1 and 7 are able to view the initial state of the contract. Next we have node 1 update the state of this contract and again verify only nodes 1 and 7 are able to see the updated state of the contract after the block containing the update transaction is validated by the network.
|
||||
You can run the 7node example to test the privacy features of Quorum. As described in the Quick Start section of the [README](https://github.com/jpmorganchase/quorum), the final step of the 7node `start.sh` script was the sending of a private transaction to generate a (private) smart contract (SimpleStorage) sent from node 1 "for" node 7 (denoted by the public key passed via privateFor: ["ROAZBWtSacxXQrOe3FGAqJDyJjFePR5ce4TSIzmJ0Bc="] in the sendTransaction call). We'll begin by demonstrating only nodes 1 and 7 are able to view the initial state of the contract. Next we have node 1 update the state of this contract and again verify only nodes 1 and 7 are able to see the updated state of the contract after the block containing the update transaction is validated by the network.
|
||||
|
||||
For this test it is recommended to use separate terminal windows running geth JavaScript console attached to node 1, node 7, and any node 2-6 (in our example we'll choose node 4).
|
||||
|
||||
@@ -29,8 +34,8 @@ Next we'll use ```eth.contract``` to define a contract class with the simpleStor
|
||||
> var abi = [{"constant":true,"inputs":[],"name":"storedData","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"x","type":"uint256"}],"name":"set","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"retVal","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[{"name":"initVal","type":"uint256"}],"type":"constructor"}];
|
||||
> var private = eth.contract(abi).at(address)
|
||||
```
|
||||
The function calls are now available on the contract instance and you can call those methods on the contract. Let's start by examining the initial value of the contract to make sure that only nodes 1 and 7 can see the initialized value.
|
||||
* In terminal window 1 (node 1)
|
||||
The function calls are now available on the contract instance and you can call those methods on the contract. Let's start by examining the initial value of the contract to make sure that only nodes 1 and 7 can see the initialized value.
|
||||
* In terminal window 1 (node 1)
|
||||
```
|
||||
> private.get()
|
||||
42
|
||||
@@ -42,7 +47,7 @@ The function calls are now available on the contract instance and you can call t
|
||||
```
|
||||
* In terminal window 3 (node 7)
|
||||
```
|
||||
> private.get()
|
||||
> private.get()
|
||||
42
|
||||
```
|
||||
|
||||
|
||||
54
examples/7nodes/raft-init.sh
Executable file
54
examples/7nodes/raft-init.sh
Executable file
@@ -0,0 +1,54 @@
|
||||
#!/bin/bash
|
||||
set -u
|
||||
set -e
|
||||
|
||||
echo "[*] Cleaning up temporary data directories"
|
||||
rm -rf qdata
|
||||
mkdir -p qdata/logs
|
||||
|
||||
echo "[*] Configuring node 1"
|
||||
mkdir -p qdata/dd1/{keystore,geth}
|
||||
cp raft/static-nodes.json qdata/dd1
|
||||
cp keys/key1 qdata/dd1/keystore
|
||||
cp raft/nodekey1 qdata/dd1/geth/nodekey
|
||||
geth --datadir qdata/dd1 init genesis.json
|
||||
|
||||
echo "[*] Configuring node 2"
|
||||
mkdir -p qdata/dd2/{keystore,geth}
|
||||
cp raft/static-nodes.json qdata/dd2
|
||||
cp keys/key2 qdata/dd2/keystore
|
||||
cp keys/key3 qdata/dd2/keystore
|
||||
cp raft/nodekey2 qdata/dd2/geth/nodekey
|
||||
geth --datadir qdata/dd2 init genesis.json
|
||||
|
||||
echo "[*] Configuring node 3"
|
||||
mkdir -p qdata/dd3/{keystore,geth}
|
||||
cp raft/static-nodes.json qdata/dd3
|
||||
cp raft/nodekey3 qdata/dd3/geth/nodekey
|
||||
geth --datadir qdata/dd3 init genesis.json
|
||||
|
||||
echo "[*] Configuring node 4 as voter"
|
||||
mkdir -p qdata/dd4/{keystore,geth}
|
||||
cp raft/static-nodes.json qdata/dd4
|
||||
cp keys/key4 qdata/dd4/keystore
|
||||
cp raft/nodekey4 qdata/dd4/geth/nodekey
|
||||
geth --datadir qdata/dd4 init genesis.json
|
||||
|
||||
echo "[*] Configuring node 5 as voter"
|
||||
mkdir -p qdata/dd5/{keystore,geth}
|
||||
cp raft/static-nodes.json qdata/dd5
|
||||
cp keys/key5 qdata/dd5/keystore
|
||||
cp raft/nodekey5 qdata/dd5/geth/nodekey
|
||||
geth --datadir qdata/dd5 init genesis.json
|
||||
|
||||
echo "[*] Configuring node 6"
|
||||
mkdir -p qdata/dd6/{keystore,geth}
|
||||
cp raft/static-nodes.json qdata/dd6
|
||||
cp raft/nodekey6 qdata/dd6/geth/nodekey
|
||||
geth --datadir qdata/dd6 init genesis.json
|
||||
|
||||
echo "[*] Configuring node 7"
|
||||
mkdir -p qdata/dd7/{keystore,geth}
|
||||
cp raft/static-nodes.json qdata/dd7
|
||||
cp raft/nodekey7 qdata/dd7/geth/nodekey
|
||||
geth --datadir qdata/dd7 init genesis.json
|
||||
45
examples/7nodes/raft-start.sh
Executable file
45
examples/7nodes/raft-start.sh
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
set -u
|
||||
set -e
|
||||
|
||||
GLOBAL_ARGS="--raft --rpc --rpcaddr 0.0.0.0 --rpcapi admin,db,eth,debug,miner,net,shh,txpool,personal,web3,quorum"
|
||||
|
||||
echo "[*] Starting Constellation nodes"
|
||||
nohup constellation-node tm1.conf 2>> qdata/logs/constellation1.log &
|
||||
sleep 1
|
||||
nohup constellation-node tm2.conf 2>> qdata/logs/constellation2.log &
|
||||
nohup constellation-node tm3.conf 2>> qdata/logs/constellation3.log &
|
||||
nohup constellation-node tm4.conf 2>> qdata/logs/constellation4.log &
|
||||
nohup constellation-node tm5.conf 2>> qdata/logs/constellation5.log &
|
||||
nohup constellation-node tm6.conf 2>> qdata/logs/constellation6.log &
|
||||
nohup constellation-node tm7.conf 2>> qdata/logs/constellation7.log &
|
||||
|
||||
sleep 1
|
||||
|
||||
echo "[*] Starting node 1"
|
||||
PRIVATE_CONFIG=tm1.conf nohup geth --datadir qdata/dd1 $GLOBAL_ARGS --rpcport 22000 --port 21000 --unlock 0 --password passwords.txt 2>>qdata/logs/1.log &
|
||||
|
||||
echo "[*] Starting node 2"
|
||||
PRIVATE_CONFIG=tm2.conf nohup geth --datadir qdata/dd2 $GLOBAL_ARGS --rpcport 22001 --port 21001 2>>qdata/logs/2.log &
|
||||
|
||||
echo "[*] Starting node 3"
|
||||
PRIVATE_CONFIG=tm3.conf nohup geth --datadir qdata/dd3 $GLOBAL_ARGS --rpcport 22002 --port 21002 2>>qdata/logs/3.log &
|
||||
|
||||
echo "[*] Starting node 4"
|
||||
PRIVATE_CONFIG=tm4.conf nohup geth --datadir qdata/dd4 $GLOBAL_ARGS --rpcport 22003 --port 21003 2>>qdata/logs/4.log &
|
||||
|
||||
echo "[*] Starting node 5"
|
||||
PRIVATE_CONFIG=tm5.conf nohup geth --datadir qdata/dd5 $GLOBAL_ARGS --rpcport 22004 --port 21004 2>>qdata/logs/5.log &
|
||||
|
||||
echo "[*] Starting node 6"
|
||||
PRIVATE_CONFIG=tm6.conf nohup geth --datadir qdata/dd6 $GLOBAL_ARGS --rpcport 22005 --port 21005 2>>qdata/logs/6.log &
|
||||
|
||||
echo "[*] Starting node 7"
|
||||
PRIVATE_CONFIG=tm7.conf nohup geth --datadir qdata/dd7 $GLOBAL_ARGS --rpcport 22006 --port 21006 2>>qdata/logs/7.log &
|
||||
|
||||
echo "[*] Waiting for nodes to start"
|
||||
sleep 10
|
||||
echo "[*] Sending first transaction"
|
||||
PRIVATE_CONFIG=tm1.conf geth --exec 'loadScript("script1.js")' attach ipc:qdata/dd1/geth.ipc
|
||||
|
||||
echo "All nodes configured. See 'qdata/logs' for logs, and run e.g. 'geth attach qdata/dd1/geth.ipc' to attach to the first Geth node"
|
||||
1
examples/7nodes/raft/nodekey1
Normal file
1
examples/7nodes/raft/nodekey1
Normal file
@@ -0,0 +1 @@
|
||||
1be3b50b31734be48452c29d714941ba165ef0cbf3ccea8ca16c45e3d8d45fb0
|
||||
1
examples/7nodes/raft/nodekey2
Normal file
1
examples/7nodes/raft/nodekey2
Normal file
@@ -0,0 +1 @@
|
||||
9bdd6a2e7cc1ca4a4019029df3834d2633ea6e14034d6dcc3b944396fe13a08b
|
||||
1
examples/7nodes/raft/nodekey3
Normal file
1
examples/7nodes/raft/nodekey3
Normal file
@@ -0,0 +1 @@
|
||||
722f11686b2277dcbd72713d8a3c81c666b585c337d47f503c3c1f3c17cf001d
|
||||
1
examples/7nodes/raft/nodekey4
Normal file
1
examples/7nodes/raft/nodekey4
Normal file
@@ -0,0 +1 @@
|
||||
6af685c4de99d44c620ccd9464d19bdeb62a750b9ae49b1740fb28d68a0e5c7d
|
||||
1
examples/7nodes/raft/nodekey5
Normal file
1
examples/7nodes/raft/nodekey5
Normal file
@@ -0,0 +1 @@
|
||||
103bb5d20384b9af9f693d4287822fef6da7d79cb2317ed815f0081c7ea8d17d
|
||||
1
examples/7nodes/raft/nodekey6
Normal file
1
examples/7nodes/raft/nodekey6
Normal file
@@ -0,0 +1 @@
|
||||
79999aef8d5197446b6051df47f01fd4d6dd1997aec3f5282e77ea27b6727346
|
||||
1
examples/7nodes/raft/nodekey7
Normal file
1
examples/7nodes/raft/nodekey7
Normal file
@@ -0,0 +1 @@
|
||||
e85dae073b504871ffd7946bf5f45e6fa8dc09eb1536a48c4b6822332008973d
|
||||
9
examples/7nodes/raft/static-nodes.json
Normal file
9
examples/7nodes/raft/static-nodes.json
Normal file
@@ -0,0 +1,9 @@
|
||||
[
|
||||
"enode://ac6b1096ca56b9f6d004b779ae3728bf83f8e22453404cc3cef16a3d9b96608bc67c4b30db88e0a5a6c6390213f7acbe1153ff6d23ce57380104288ae19373ef@127.0.0.1:21000?discport=0",
|
||||
"enode://0ba6b9f606a43a95edc6247cdb1c1e105145817be7bcafd6b2c0ba15d58145f0dc1a194f70ba73cd6f4cdd6864edc7687f311254c7555cc32e4d45aeb1b80416@127.0.0.1:21001?discport=0",
|
||||
"enode://579f786d4e2830bbcc02815a27e8a9bacccc9605df4dc6f20bcc1a6eb391e7225fff7cb83e5b4ecd1f3a94d8b733803f2f66b7e871961e7b029e22c155c3a778@127.0.0.1:21002?discport=0",
|
||||
"enode://3d9ca5956b38557aba991e31cf510d4df641dce9cc26bfeb7de082f0c07abb6ede3a58410c8f249dabeecee4ad3979929ac4c7c496ad20b8cfdd061b7401b4f5@127.0.0.1:21003?discport=0",
|
||||
"enode://3701f007bfa4cb26512d7df18e6bbd202e8484a6e11d387af6e482b525fa25542d46ff9c99db87bd419b980c24a086117a397f6d8f88e74351b41693880ea0cb@127.0.0.1:21004?discport=0",
|
||||
"enode://eacaa74c4b0e7a9e12d2fe5fee6595eda841d6d992c35dbbcc50fcee4aa86dfbbdeff7dc7e72c2305d5a62257f82737a8cffc80474c15c611c037f52db1a3a7b@127.0.0.1:21005?discport=0",
|
||||
"enode://239c1f044a2b03b6c4713109af036b775c5418fe4ca63b04b1ce00124af00ddab7cc088fc46020cdc783b6207efe624551be4c06a994993d8d70f684688fb7cf@127.0.0.1:21006?discport=0"
|
||||
]
|
||||
Reference in New Issue
Block a user