1.第一个《Quorum企业以太坊环境搭建教程》
- 链接:Quorum企业以太坊环境搭建教程
- 注意事项:事先安装好docker和docker-compose;
$ git clone https://github.com/jpmorganchase/quorum-examples.git
正克隆到 'quorum-examples'...
remote: Enumerating objects: 52, done.
remote: Counting objects: 100% (52/52), done.
remote: Compressing objects: 100% (37/37), done.
remote: Total 1464 (delta 23), reused 32 (delta 14), pack-reused 1412
接收对象中: 100% (1464/1464), 449.31 KiB | 3.00 KiB/s, 完成.
处理 delta 中: 100% (740/740), 完成.
$ cd quorum-examples/
$ QUORUM_CONSENSUS=raft docker-compose up -d
Creating network "quorum-examples-net" with driver "bridge"
Creating volume "quorum-examples_vol1" with default driver
Creating volume "quorum-examples_vol2" with default driver
Creating volume "quorum-examples_vol3" with default driver
Creating volume "quorum-examples_vol4" with default driver
Creating volume "quorum-examples_vol5" with default driver
Creating volume "quorum-examples_vol6" with default driver
Creating volume "quorum-examples_vol7" with default driver
Creating volume "quorum-examples_cakeshopvol" with default driver
Pulling txmanager1 (quorumengineering/tessera:0.10.6)...
0.10.6: Pulling from quorumengineering/tessera
df20fa9351a1: Pull complete
229610c13af7: Pull complete
53a69ff98873: Pull complete
9e5df38775f2: Pull complete
Digest: sha256:4970e47b9abe289ef4957ad9c9fd289ddf7159e6116572bde9cf2462c074f399
Status: Downloaded newer image for quorumengineering/tessera:0.10.6
Pulling node1 (quorumengineering/quorum:2.6.0)...
2.6.0: Pulling from quorumengineering/quorum
cbdbe7a5bc2a: Pull complete
8670dd5a125f: Pull complete
4ab85e523a6a: Pull complete
82deb08554a0: Pull complete
Digest: sha256:947b24ace4106eb940e45a2683889e80a594819edc2ec99d5f552320482e4f6b
Status: Downloaded newer image for quorumengineering/quorum:2.6.0
Pulling cakeshop (quorumengineering/cakeshop:0.11.0)...
0.11.0: Pulling from quorumengineering/cakeshop
50e431f79093: Pull complete
dd8c6d374ea5: Pull complete
c85513200d84: Pull complete
55769680e827: Pull complete
e27ce2095ec2: Pull complete
3eb0840c2dae: Pull complete
491685d1af8c: Pull complete
4980b616cdb2: Pull complete
02c8d73a4499: Pull complete
44563a8f7352: Pull complete
Digest: sha256:738ab7f409064ca94ba14369e50db11d38eb25b8f494770def57fea45f296107
Status: Downloaded newer image for quorumengineering/cakeshop:0.11.0
Creating quorum-examples_txmanager6_1 ... done
Creating quorum-examples_txmanager3_1 ... done
Creating quorum-examples_txmanager5_1 ... done
Creating quorum-examples_txmanager1_1 ... done
Creating quorum-examples_txmanager7_1 ... done
Creating quorum-examples_txmanager4_1 ... done
Creating quorum-examples_cakeshop_1 ... done
Creating quorum-examples_txmanager2_1 ... done
Creating quorum-examples_node5_1 ... done
Creating quorum-examples_node3_1 ... done
Creating quorum-examples_node4_1 ... done
Creating quorum-examples_node7_1 ... done
Creating quorum-examples_node2_1 ... done
Creating quorum-examples_node6_1 ... done
Creating quorum-examples_node1_1 ... done
$ docker exec -it quorum-examples_node1_1 geth attach /qdata/dd/geth.ipc
Welcome to the Geth JavaScript console!
instance: Geth/node1-raft/v1.9.7-stable-9339be03(quorum-v2.6.0)/linux-amd64/go1.13.10
coinbase: 0xed9d02e382b34818e88b88a309c7fe71e65f419d
at block: 0 (Thu, 01 Jan 1970 00:00:00 UTC)
datadir: /qdata/dd
modules: admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 raft:1.0 rpc:1.0 txpool:1.0 web3:1.0
> loadScript('/examples/private-contract.js')
Contract transaction send: TransactionHash: 0x35feaf2d2d486eee40bad7907b0d59a6a1349c22d2a554824a994499dab3a0de waiting to be mined...
true
> Contract mined! Address: 0x1932c48b2bf8102ba33b4a6b545c32236e342f34
[object Object]
再开节点2的客户端时:
$ docker exec -it quorum-examples_node2_1 geth attach /qdata/dd/geth.ipc
Welcome to the Geth JavaScript console!
instance: Geth/node2-raft/v1.9.7-stable-9339be03(quorum-v2.6.0)/linux-amd64/go1.13.10
coinbase: 0xca843569e3427144cead5e4d5999a3d0ccf92b8e
at block: 1 (Sat, 15 Aug 2020 17:45:22 UTC)
datadir: /qdata/dd
modules: admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 raft:1.0 rpc:1.0 txpool:1.0 web3:1.0
接下来理论上:
> var abi=<Paste ABI here>;
> var address="<paste Contract Address here>";
> var contract=eth.contract(abi).at(address);
>contract.get() //calling get() method
0
但问题是abi如何获取?
2.第二个《以太坊联盟链quorum搭建(一)》
- 链接:以太坊联盟链quorum搭建(一)
- 第一步很慢
安装quorum:
git clone --recursive https://github.com/jpmorganchase/quorum.git
$ git clone --recursive https://github.com/jpmorganchase/quorum.git
正克隆到 'quorum'...
remote: Enumerating objects: 99305, done.
remote: Total 99305 (delta 0), reused 0 (delta 0), pack-reused 99305
接收对象中: 100% (99305/99305), 156.12 MiB | 27.00 KiB/s, 完成.
处理 delta 中: 100% (68668/68668), 完成.
子模组 'tests'(https://github.com/ethereum/tests)未对路径 'tests/testdata' 注册
正克隆到 '/home/yanhao/quorum/tests/testdata'...
remote: Enumerating objects: 2880, done.
remote: Counting objects: 100% (2880/2880), done.
remote: Compressing objects: 100% (280/280), done.
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: The remote end hung up unexpectedly
fatal: 过早的文件结束符(EOF)
fatal: index-pack 失败
fatal: 无法克隆 'https://github.com/ethereum/tests' 到子模组路径 '/home/yanhao/quorum/tests/testdata'
克隆 'tests/testdata' 失败。按计划重试
正克隆到 '/home/yanhao/quorum/tests/testdata'...
remote: Enumerating objects: 2880, done.
remote: Counting objects: 100% (2880/2880), done.
remote: Compressing objects: 100% (280/280), done.
error: RPC failed; curl 56 GnuTLS recv error (-54): Error in the pull function.
fatal: The remote end hung up unexpectedly
fatal: 过早的文件结束符(EOF)
fatal: index-pack 失败
fatal: 无法克隆 'https://github.com/ethereum/tests' 到子模组路径 '/home/yanhao/quorum/tests/testdata'
第二次尝试克隆 'tests/testdata' 失败,退出
到这里有一定的错误,先继续进行。
$ cd quorum
~/quorum$ make all
build/env.sh go run build/ci.go install
build/env.sh: 30: exec: go: not found
Makefile:24: recipe for target 'all' failed
make: *** [all] Error 127
依然存在错误,所以清除quorum之后重新git。
git clone一直失败。
3.官网https://docs.goquorum.consensys.net/en/latest/
- 20200818
yanhao@yanhao-ThinkPad-T480:~/quorum$ mkdir fromscratch
yanhao@yanhao-ThinkPad-T480:~/quorum$ cd fromscratch/
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch$ mkdir new-node-1
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch$ geth --datadir new-node-1 account new
INFO [08-18|23:21:16.043] Maximum peer count ETH=50 LES=0 total=50
INFO [08-18|23:21:16.052] Smartcard socket not found, disabling err="stat /run/pcscd/pcscd.comm: no such file or directory"
Your new account is locked with a password. Please give a password. Do not forget this password.
Password:
Repeat password:
Your new key was generated
Public address of the key: 0xBA67181B1b83386c707Bf9b063C964c486d57b7c
Path of the secret key file: new-node-1/keystore/UTC--2020-08-18T15-22-00.476888534Z--ba67181b1b83386c707bf9b063c964c486d57b7c
- You can share your public address with anyone. Others need it to interact with you.
- You must NEVER share the secret key with anyone! The key controls access to your funds!
- You must BACKUP your key file! Without the key, it's impossible to access account funds!
- You must REMEMBER your password! Without the password, it's impossible to decrypt the key!
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch$ ls new-node-1/keystore
UTC--2020-08-18T15-22-00.476888534Z--ba67181b1b83386c707bf9b063c964c486d57b7c
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch$ vim genesis.json
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch$ bootnode --genkey=nodekey
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch$ cp nodekey new-node-1
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch$ bootnode --nodekey=new-node-1/nodekey --writeaddress > new-node-1/enode
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch$ cat new-node-1/enode
a872bd0662d1afc0e2046e9cd441fc834941f4ed87bb9d1e382595e087fa829917d42f4790f69aa2f436628ceaabc794a10710a4d2adec3f37eba923bbd48a05
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch$ vim static-nodes.json
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch$ cp static-nodes.json new-node-1
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch$ geth --datadir new-node-1 init genesis.json
INFO [08-18|23:35:44.101] Maximum peer count ETH=50 LES=0 total=50
INFO [08-18|23:35:44.101] Smartcard socket not found, disabling err="stat /run/pcscd/pcscd.comm: no such file or directory"
INFO [08-18|23:35:44.123] Allocated cache and file handles database=/home/yanhao/quorum/fromscratch/new-node-1/geth/chaindata cache=16.00MiB handles=16
INFO [08-18|23:35:44.315] Writing custom genesis block
INFO [08-18|23:35:44.315] Persisted trie from memory database nodes=1 size=152.00B time=163.328µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [08-18|23:35:44.316] Successfully wrote genesis state database=chaindata hash=a1f478…305de6
INFO [08-18|23:35:44.316] Allocated cache and file handles database=/home/yanhao/quorum/fromscratch/new-node-1/geth/lightchaindata cache=16.00MiB handles=16
INFO [08-18|23:35:44.495] Writing custom genesis block
INFO [08-18|23:35:44.496] Persisted trie from memory database nodes=1 size=152.00B time=197.181µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [08-18|23:35:44.497] Successfully wrote genesis state database=lightchaindata hash=a1f478…305de6
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch$ vim startnode1.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch$ chmod +x startnode1.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch$ ./startnode1.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch$ geth attach new-node-1/geth.ipc
Fatal: Unable to attach to remote geth: dial unix new-node-1/geth.ipc: connect: no such file or directory
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch$ geth attach new-node-1/geth.ipc
Fatal: Unable to attach to remote geth: dial unix new-node-1/geth.ipc: connect: no such file or directory
到第九步链接到节点时报错。
geth attach new-node-1/geth.ipc
Fatal: Unable to attach to remote geth: dial unix new-node-1/geth.ipc: connect: no such file or directory
回头看找错,发现在第7步,忘记在enode后面加上端口号和IP等信息,即@127.0.0.1:21000?discport=0&raftport=50000。
依然报错。
- 20200819
同样的错误。 - 另外的:
Fatal: Failed to write genesis block: database contains incompatible genesis (have a1f4787986564357c63dc6a330555a13d7d1255f176fe34db41afe7bc7305de6, new 7bf5ab835f65dbe0c9a3acc82da7f2a2cd76e2018f8c3a616f1d8e9c06a75cf8)
4.联盟链Quorum(基于raft共识)部署流程(一)
- 20200819
同样的结果:找不到ipc文件。
目前的搜索:
IPC文件只有在geth运行时才会存在。所以当开启geth时侯,才会出现geth.ipc。
通过查看node1.log日志文件,发现端口22001被占用:
Fatal: Error starting protocol stack: listen tcp 0.0.0.0:22001: bind: address already in use
于是通过下面的命令找到该进程并kill:
$ netstat -nap|grep 22001
tcp6 0 0 :::22001 :::* LISTEN 19738/docker-proxy
$ kill 19738
然后再重新运行即可:
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-new$ ./startnode1.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-new$ geth attach node1/geth.ipc
Welcome to the Geth JavaScript console!
instance: Geth/v1.9.7-stable-de45c9bb(quorum-v2.7.0)/linux-amd64/go1.12.6
coinbase: 0xebd5a70b86f838e963b71a44b2dde66656ddf2f2
at block: 0 (Thu, 01 Jan 1970 08:00:00 CST)
datadir: /home/yanhao/quorum/fromscratch-new/node1
modules: admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 raft:1.0 rpc:1.0 txpool:1.0 web3:1.0
> raft.cluster
[]
但是其中的raft.cluster输出为空,目前不确定是否影响后面的执行。
接下来将node2添加为node1的peer,raft.cluster仍然为空;raft.addPeer成功返回了2。
在我们输入raft.addPeer得到了一个值“2”,这个是我们节点的raft ID值,这个值很重要,在我们编辑节点2的startnode2.sh文件时这是个重要参数。
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-new$ geth attach node1/geth.ipc
Welcome to the Geth JavaScript console!
instance: Geth/v1.9.7-stable-de45c9bb(quorum-v2.7.0)/linux-amd64/go1.12.6
coinbase: 0xebd5a70b86f838e963b71a44b2dde66656ddf2f2
at block: 0 (Thu, 01 Jan 1970 08:00:00 CST)
datadir: /home/yanhao/quorum/fromscratch-new/node1
modules: admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 raft:1.0 rpc:1.0 txpool:1.0 web3:1.0
> raft.addPeer('enode://04b38095ff404e4421ed6c8a29d89fb41c796d6ff429d72c1de6c46a26bed473e5903c2bd1d9e261515c7082457d2866cf7a3173311f028ba7bd035397ee62f5@127.0.0.1:21002?discport=0&raftport=50002')
2
> raft.cluster
[]
>
5.重来一次官网的from scratch
- 第二步
yanhao@yanhao-ThinkPad-T480:~$ cd quorum
yanhao@yanhao-ThinkPad-T480:~/quorum$ mkdir fromscratch-again
yanhao@yanhao-ThinkPad-T480:~/quorum$ cd fromscratch-again/
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ mkdir new-node-1
- 第三步
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ geth --datadir new-node-1 account new
INFO [08-19|17:38:18.308] Maximum peer count ETH=50 LES=0 total=50
INFO [08-19|17:38:18.308] Smartcard socket not found, disabling err="stat /run/pcscd/pcscd.comm: no such file or directory"
Your new account is locked with a password. Please give a password. Do not forget this password.
Password:
Repeat password:
Your new key was generated
Public address of the key: 0x03af8E050A5F40aec7a16EefeFD9082aa89c038a
Path of the secret key file: new-node-1/keystore/UTC--2020-08-19T09-38-25.001097925Z--03af8e050a5f40aec7a16eefefd9082aa89c038a
- You can share your public address with anyone. Others need it to interact with you.
- You must NEVER share the secret key with anyone! The key controls access to your funds!
- You must BACKUP your key file! Without the key, it's impossible to access account funds!
- You must REMEMBER your password! Without the password, it's impossible to decrypt the key!
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ls new-node-1/keystore
UTC--2020-08-19T09-38-25.001097925Z--03af8e050a5f40aec7a16eefefd9082aa89c038a
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ geth --datadir new-node-1 account new
INFO [08-19|17:39:36.962] Maximum peer count ETH=50 LES=0 total=50
INFO [08-19|17:39:36.963] Smartcard socket not found, disabling err="stat /run/pcscd/pcscd.comm: no such file or directory"
Your new account is locked with a password. Please give a password. Do not forget this password.
Password:
Repeat password:
Your new key was generated
Public address of the key: 0xE754B58a7147619D70B49DdeD8BdDfB2B66366B4
Path of the secret key file: new-node-1/keystore/UTC--2020-08-19T09-39-42.247894682Z--e754b58a7147619d70b49dded8bddfb2b66366b4
- You can share your public address with anyone. Others need it to interact with you.
- You must NEVER share the secret key with anyone! The key controls access to your funds!
- You must BACKUP your key file! Without the key, it's impossible to access account funds!
- You must REMEMBER your password! Without the password, it's impossible to decrypt the key!
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ls new-node-1/keystore
UTC--2020-08-19T09-38-25.001097925Z--03af8e050a5f40aec7a16eefefd9082aa89c038a
UTC--2020-08-19T09-39-42.247894682Z--e754b58a7147619d70b49dded8bddfb2b66366b4
- 第四步
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ vim genesis.json
{
"alloc": {
"0x03af8e050a5f40aec7a16eefefd9082aa89c038a": {
"balance": "1000000000000000000000000000"
},
"0xe754b58a7147619d70b49dded8bddfb2b66366b4": {
"balance": "1000000000000000000000000000"
}
},
"coinbase": "0x0000000000000000000000000000000000000000",
"config": {
"homesteadBlock": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"chainId": 10,
"eip150Block": 0,
"eip155Block": 0,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip158Block": 0,
"maxCodeSizeConfig": [
{
"block": 0,
"size": 35
}
],
"e754b58a7147619d70b49dded8bddfb2b66366b4isQuorum": true
},
"difficulty": "0x0",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0xE0000000",
"mixhash": "0x00000000000000000000000000000000000000647572616c65787365646c6578",
"nonce": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp": "0x00"
}
- 第五步
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ bootnode --genkey=nodekey
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ cp nodekey new-node-1
- 第六步
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ bootnode --nodekey=new-node-1/nodekey --writeaddress > new-node-1/enode
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ cat new-node-1/enode
5974b603488f3bfcf117b34dca2106100c1d6986f8859e08e72827ad075aa7791869c073dcbb01335b918e7938f12c05eb6455faa05be44f4aea324c99f8f165
- 第七步
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ vim static-nodes.json
[
"enode://5974b603488f3bfcf117b34dca2106100c1d6986f8859e08e72827ad075aa7791869c073dcbb01335b918e7938f12c05eb6455faa05be44f4aea324c99f8f165@127.0.0.1:21000?discport=0&raftport=50000"
]
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ cp static-nodes.json new-node-1
- 第八步
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ geth --datadir new-node-1 init genesis.json
INFO [08-19|17:54:41.105] Maximum peer count ETH=50 LES=0 total=50
INFO [08-19|17:54:41.105] Smartcard socket not found, disabling err="stat /run/pcscd/pcscd.comm: no such file or directory"
INFO [08-19|17:54:41.107] Allocated cache and file handles database=/home/yanhao/quorum/fromscratch-again/new-node-1/geth/chaindata cache=16.00MiB handles=16
INFO [08-19|17:54:41.337] Writing custom genesis block
INFO [08-19|17:54:41.338] Persisted trie from memory database nodes=3 size=417.00B time=191.772µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [08-19|17:54:41.339] Successfully wrote genesis state database=chaindata hash=8fda1d…12de4d
INFO [08-19|17:54:41.339] Allocated cache and file handles database=/home/yanhao/quorum/fromscratch-again/new-node-1/geth/lightchaindata cache=16.00MiB handles=16
INFO [08-19|17:54:41.662] Writing custom genesis block
INFO [08-19|17:54:41.663] Persisted trie from memory database nodes=3 size=417.00B time=188.832µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [08-19|17:54:41.663] Successfully wrote genesis state database=lightchaindata hash=8fda1d…12de4d
- 第九步
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ vim startnode1.sh
PRIVATE_CONFIG=ignore nohup geth --datadir new-node-1 --nodiscover --verbosity 5 --networkid 31337 --raft --raftport 50000 --rpc --rpcaddr 0.0.0.0 --rpcport 22000 --rpcapi admin,db,eth,debug,miner,net,shh,txpool,personal,web3,quorum,raft --emitcheckpoints --port 21000 >> node.log 2>&1 &
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ chmod +x startnode1.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ./startnode1.sh
确认ipc文件存在:
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ cd new-node-1/
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-1$ ls
enode geth.ipc nodekey raft-snap static-nodes.json
geth keystore quorum-raft-state raft-wal
- 第十步
终于成功了!!!
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ geth attach new-node-1/geth.ipc
Welcome to the Geth JavaScript console!
instance: Geth/v1.9.7-stable-de45c9bb(quorum-v2.7.0)/linux-amd64/go1.12.6
coinbase: 0x03af8e050a5f40aec7a16eefefd9082aa89c038a
at block: 0 (Thu, 01 Jan 1970 08:00:00 CST)
datadir: /home/yanhao/quorum/fromscratch-again/new-node-1
modules: admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 raft:1.0 rpc:1.0 txpool:1.0 web3:1.0
> raft
{
cluster: [{
hostname: "127.0.0.1",
nodeActive: true,
nodeId: "5974b603488f3bfcf117b34dca2106100c1d6986f8859e08e72827ad075aa7791869c073dcbb01335b918e7938f12c05eb6455faa05be44f4aea324c99f8f165",
p2pPort: 21000,
raftId: 1,
raftPort: 50000,
role: "minter"
}],
leader: "5974b603488f3bfcf117b34dca2106100c1d6986f8859e08e72827ad075aa7791869c073dcbb01335b918e7938f12c05eb6455faa05be44f4aea324c99f8f165",
role: "minter",
addLearner: function(),
addPeer: function(),
getCluster: function(callback),
getLeader: function(callback),
getRole: function(callback),
promoteToPeer: function(),
removePeer: function()
}
> raft.cluster
[{
hostname: "127.0.0.1",
nodeActive: true,
nodeId: "5974b603488f3bfcf117b34dca2106100c1d6986f8859e08e72827ad075aa7791869c073dcbb01335b918e7938f12c05eb6455faa05be44f4aea324c99f8f165",
p2pPort: 21000,
raftId: 1,
raftPort: 50000,
role: "minter"
}]
>
添加其他节点(移除节点暂时不做)
- 第一步
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ mkdir new-node-2
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ bootnode --genkey=nodekey2
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ cp nodekey2 new-node-2/nodekey
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ bootnode --nodekey=new-node-2/nodekey --writeaddress
6f117ba6c467ce4164dcd02b74f07720b61b5cdef8ef061eeddcbffcb8e2a94fe881f0045dcd4b61ae0653663d81bfc7eadf92f61110c38c80e423820d594804
- 第二步
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ cp static-nodes.json new-node-2
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ vim new-node-2/static-nodes.json
[
"enode://5974b603488f3bfcf117b34dca2106100c1d6986f8859e08e72827ad075aa7791869c073dcbb01335b918e7938f12c05eb6455faa05be44f4aea324c99f8f165@127.0.0.1:21000?discport=0&raftport=50000",
"enode://6f117ba6c467ce4164dcd02b74f07720b61b5cdef8ef061eeddcbffcb8e2a94fe881f0045dcd4b61ae0653663d81bfc7eadf92f61110c38c80e423820d594804@127.0.0.1:21001?discport=0&raftport=50001"
]
- 第三步
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ geth --datadir new-node-2 init genesis.json
INFO [08-19|18:14:33.932] Maximum peer count ETH=50 LES=0 total=50
INFO [08-19|18:14:33.932] Smartcard socket not found, disabling err="stat /run/pcscd/pcscd.comm: no such file or directory"
INFO [08-19|18:14:33.933] Allocated cache and file handles database=/home/yanhao/quorum/fromscratch-again/new-node-2/geth/chaindata cache=16.00MiB handles=16
INFO [08-19|18:14:34.134] Writing custom genesis block
INFO [08-19|18:14:34.135] Persisted trie from memory database nodes=3 size=417.00B time=183.852µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [08-19|18:14:34.135] Successfully wrote genesis state database=chaindata hash=8fda1d…12de4d
INFO [08-19|18:14:34.136] Allocated cache and file handles database=/home/yanhao/quorum/fromscratch-again/new-node-2/geth/lightchaindata cache=16.00MiB handles=16
INFO [08-19|18:14:34.436] Writing custom genesis block
INFO [08-19|18:14:34.437] Persisted trie from memory database nodes=3 size=417.00B time=159.152µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [08-19|18:14:34.437] Successfully wrote genesis state database=lightchaindata hash=8fda1d…12de4d
- 第四步
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ geth attach new-node-1/geth.ipc
Welcome to the Geth JavaScript console!
instance: Geth/v1.9.7-stable-de45c9bb(quorum-v2.7.0)/linux-amd64/go1.12.6
coinbase: 0x03af8e050a5f40aec7a16eefefd9082aa89c038a
at block: 0 (Thu, 01 Jan 1970 08:00:00 CST)
datadir: /home/yanhao/quorum/fromscratch-again/new-node-1
modules: admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 raft:1.0 rpc:1.0 txpool:1.0 web3:1.0
> raft
{
cluster: [{
hostname: "127.0.0.1",
nodeActive: true,
nodeId: "5974b603488f3bfcf117b34dca2106100c1d6986f8859e08e72827ad075aa7791869c073dcbb01335b918e7938f12c05eb6455faa05be44f4aea324c99f8f165",
p2pPort: 21000,
raftId: 1,
raftPort: 50000,
role: "minter"
}],
leader: "5974b603488f3bfcf117b34dca2106100c1d6986f8859e08e72827ad075aa7791869c073dcbb01335b918e7938f12c05eb6455faa05be44f4aea324c99f8f165",
role: "minter",
addLearner: function(),
addPeer: function(),
getCluster: function(callback),
getLeader: function(callback),
getRole: function(callback),
promoteToPeer: function(),
removePeer: function()
}
> raft.addPeer('enode://6f117ba6c467ce4164dcd02b74f07720b61b5cdef8ef061eeddcbffcb8e2a94fe881f0045dcd4b61ae0653663d81bfc7eadf92f61110c38c80e423820d594804@127.0.0.1:21001?discport=0&raftport=50001')
2
> raft.cluster
[{
hostname: "127.0.0.1",
nodeActive: false,
nodeId: "6f117ba6c467ce4164dcd02b74f07720b61b5cdef8ef061eeddcbffcb8e2a94fe881f0045dcd4b61ae0653663d81bfc7eadf92f61110c38c80e423820d594804",
p2pPort: 21001,
raftId: 2,
raftPort: 50001,
role: "verifier"
}, {
hostname: "127.0.0.1",
nodeActive: true,
nodeId: "5974b603488f3bfcf117b34dca2106100c1d6986f8859e08e72827ad075aa7791869c073dcbb01335b918e7938f12c05eb6455faa05be44f4aea324c99f8f165",
p2pPort: 21000,
raftId: 1,
raftPort: 50000,
role: "minter"
}]
>
- 第五步
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ cp startnode1.sh startnode2.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ vim startnode2.sh
PRIVATE_CONFIG=ignore nohup geth --datadir new-node-2 --nodiscover --verbosity 5 --networkid 31337 --raft --raftport 50001 --raftjoinexisting 2 --rpc --rpcaddr 0.0.0.0 --rpcport 22001 --rpcapi admin,db,eth,debug,miner,net,shh,txpool,personal,web3,quorum,raft --emitcheckpoints --port 21001 2>>node2.log &
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ./startnode2.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ls
genesis.json new-node-1 new-node-2 node2.log nodekey nodekey2 node.log nohup.out startnode1.sh startnode2.sh static-nodes.json
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ cd new-node-2
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-2$ ls
geth geth.ipc keystore nodekey quorum-raft-state raft-snap raft-wal static-nodes.json
- 第六步
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ cp new-node-2/static-nodes.json new-node-1
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ geth attach new-node-2/geth.ipc
Welcome to the Geth JavaScript console!
instance: Geth/v1.9.7-stable-de45c9bb(quorum-v2.7.0)/linux-amd64/go1.12.6
at block: 0 (Thu, 01 Jan 1970 08:00:00 CST)
datadir: /home/yanhao/quorum/fromscratch-again/new-node-2
modules: admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 raft:1.0 rpc:1.0 txpool:1.0 web3:1.0
> raft
{
cluster: [{
hostname: "127.0.0.1",
nodeActive: true,
nodeId: "5974b603488f3bfcf117b34dca2106100c1d6986f8859e08e72827ad075aa7791869c073dcbb01335b918e7938f12c05eb6455faa05be44f4aea324c99f8f165",
p2pPort: 21000,
raftId: 1,
raftPort: 50000,
role: "minter"
}, {
hostname: "127.0.0.1",
nodeActive: true,
nodeId: "6f117ba6c467ce4164dcd02b74f07720b61b5cdef8ef061eeddcbffcb8e2a94fe881f0045dcd4b61ae0653663d81bfc7eadf92f61110c38c80e423820d594804",
p2pPort: 21001,
raftId: 2,
raftPort: 50001,
role: "verifier"
}],
leader: "5974b603488f3bfcf117b34dca2106100c1d6986f8859e08e72827ad075aa7791869c073dcbb01335b918e7938f12c05eb6455faa05be44f4aea324c99f8f165",
role: "verifier",
addLearner: function(),
addPeer: function(),
getCluster: function(callback),
getLeader: function(callback),
getRole: function(callback),
promoteToPeer: function(),
removePeer: function()
}
> exit
添加隐私交易管理器
第一步:下载并准备环境
yanhao@yanhao-ThinkPad-T480:~$ ls
examples.desktop quorum 模板 文档 桌面
go quorum-examples 视频 下载
go1.12.6.linux-amd64.tar.gz 公共的 图片 音乐
yanhao@yanhao-ThinkPad-T480:~$ cd quorum
yanhao@yanhao-ThinkPad-T480:~/quorum$ ls
accounts COPYING event Makefile raft
appveyor.yml COPYING.LESSER extension metrics README.md
AUTHORS core fromscratch miner rlp
build crypto fromscratch-again mkdocs.yml rpc
BUILDING.md dashboard fromscratch-new mobile SECURITY.md
circle.yml Dockerfile graphql node signer
cmd Dockerfile.alltools interfaces.go NOTES.md tests
common docs internal p2p trie
consensus eth les params vendor
console ethclient light permission whisper
containers ethdb log plugin
contracts ethstats logo.png private
yanhao@yanhao-ThinkPad-T480:~/quorum$ cd fromscratch-again/
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ls
genesis.json nodekey startnode1.sh tessera-app-0.10.6-app.jar
new-node-1 nodekey2 startnode2.sh
new-node-2 node.log static-nodes.json
node2.log nohup.out tessera-app-0.10.4-app.jar
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ mv tessera-app-0.10.4-app.jar tessera.jar
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ls
genesis.json node2.log node.log startnode2.sh tessera.jar
new-node-1 nodekey nohup.out static-nodes.json
new-node-2 nodekey2 startnode1.sh tessera-app-0.10.6-app.jar
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ mkdir new-node-1t
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ls
genesis.json node2.log nohup.out tessera-app-0.10.6-app.jar
new-node-1 nodekey startnode1.sh tessera.jar
new-node-1t nodekey2 startnode2.sh
new-node-2 node.log static-nodes.json
第二步:生成新密钥
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ cd new-node-1t
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-1t$ java -jar ../tessera.jar -keygen -filename new-node-1
Command 'java' not found, but can be installed with:
sudo apt install default-jre
sudo apt install openjdk-11-jre-headless
sudo apt install openjdk-8-jre-headless
缺少java环境,进行安装
一通操作之后,成功了
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-1t$ sudo apt install default-jre
[sudo] yanhao 的密码:
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
下列软件包是自动安装的并且现在不需要了:
linux-headers-5.0.0-37 linux-headers-5.0.0-37-generic
linux-image-5.0.0-37-generic linux-modules-5.0.0-37-generic
linux-modules-extra-5.0.0-37-generic
使用'sudo apt autoremove'来卸载它(它们)。
将会同时安装下列软件:
ca-certificates-java default-jre-headless fonts-dejavu-extra java-common
libatk-wrapper-java libatk-wrapper-java-jni libgif7 openjdk-11-jre
openjdk-11-jre-headless
建议安装:
fonts-ipafont-gothic fonts-ipafont-mincho fonts-wqy-microhei
| fonts-wqy-zenhei
下列【新】软件包将被安装:
ca-certificates-java default-jre default-jre-headless fonts-dejavu-extra
java-common libatk-wrapper-java libatk-wrapper-java-jni libgif7
openjdk-11-jre openjdk-11-jre-headless
升级了 0 个软件包,新安装了 10 个软件包,要卸载 0 个软件包,有 144 个软件包未被升级。
需要下载 39.7 MB 的归档。
解压缩后会消耗 179 MB 的额外空间。
您希望继续执行吗? [Y/n] y
获取:1 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 java-common all 0.68ubuntu1~18.04.1 [14.5 kB]
获取:2 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 openjdk-11-jre-headless amd64 11.0.8+10-0ubuntu1~18.04.1 [37.6 MB]
获取:3 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 default-jre-headless amd64 2:1.11-68ubuntu1~18.04.1 [10.9 kB]
获取:4 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 ca-certificates-java all 20180516ubuntu1~18.04.1 [12.2 kB]
获取:5 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libgif7 amd64 5.1.4-2ubuntu0.1 [30.9 kB]
获取:6 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 openjdk-11-jre amd64 11.0.8+10-0ubuntu1~18.04.1 [34.4 kB]
获取:7 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 default-jre amd64 2:1.11-68ubuntu1~18.04.1 [1,076 B]
获取:8 http://cn.archive.ubuntu.com/ubuntu bionic/main amd64 fonts-dejavu-extra all 2.37-1 [1,953 kB]
获取:9 http://cn.archive.ubuntu.com/ubuntu bionic/main amd64 libatk-wrapper-java all 0.33.3-20ubuntu0.1 [34.7 kB]
获取:10 http://cn.archive.ubuntu.com/ubuntu bionic/main amd64 libatk-wrapper-java-jni amd64 0.33.3-20ubuntu0.1 [28.3 kB]
已下载 39.7 MB,耗时 41分 22秒 (16.0 kB/s)
正在选中未选择的软件包 java-common。
(正在读取数据库 ... 系统当前共安装有 209992 个文件和目录。)
正准备解包 .../0-java-common_0.68ubuntu1~18.04.1_all.deb ...
正在解包 java-common (0.68ubuntu1~18.04.1) ...
正在选中未选择的软件包 openjdk-11-jre-headless:amd64。
正准备解包 .../1-openjdk-11-jre-headless_11.0.8+10-0ubuntu1~18.04.1_amd64.deb ...
正在解包 openjdk-11-jre-headless:amd64 (11.0.8+10-0ubuntu1~18.04.1) ...
正在选中未选择的软件包 default-jre-headless。
正准备解包 .../2-default-jre-headless_2%3a1.11-68ubuntu1~18.04.1_amd64.deb ...
正在解包 default-jre-headless (2:1.11-68ubuntu1~18.04.1) ...
正在选中未选择的软件包 ca-certificates-java。
正准备解包 .../3-ca-certificates-java_20180516ubuntu1~18.04.1_all.deb ...
正在解包 ca-certificates-java (20180516ubuntu1~18.04.1) ...
正在选中未选择的软件包 libgif7:amd64。
正准备解包 .../4-libgif7_5.1.4-2ubuntu0.1_amd64.deb ...
正在解包 libgif7:amd64 (5.1.4-2ubuntu0.1) ...
正在选中未选择的软件包 openjdk-11-jre:amd64。
正准备解包 .../5-openjdk-11-jre_11.0.8+10-0ubuntu1~18.04.1_amd64.deb ...
正在解包 openjdk-11-jre:amd64 (11.0.8+10-0ubuntu1~18.04.1) ...
正在选中未选择的软件包 default-jre。
正准备解包 .../6-default-jre_2%3a1.11-68ubuntu1~18.04.1_amd64.deb ...
正在解包 default-jre (2:1.11-68ubuntu1~18.04.1) ...
正在选中未选择的软件包 fonts-dejavu-extra。
正准备解包 .../7-fonts-dejavu-extra_2.37-1_all.deb ...
正在解包 fonts-dejavu-extra (2.37-1) ...
正在选中未选择的软件包 libatk-wrapper-java。
正准备解包 .../8-libatk-wrapper-java_0.33.3-20ubuntu0.1_all.deb ...
正在解包 libatk-wrapper-java (0.33.3-20ubuntu0.1) ...
正在选中未选择的软件包 libatk-wrapper-java-jni:amd64。
正准备解包 .../9-libatk-wrapper-java-jni_0.33.3-20ubuntu0.1_amd64.deb ...
正在解包 libatk-wrapper-java-jni:amd64 (0.33.3-20ubuntu0.1) ...
正在处理用于 mime-support (3.60ubuntu1) 的触发器 ...
正在处理用于 desktop-file-utils (0.23-1ubuntu3.18.04.2) 的触发器 ...
正在设置 java-common (0.68ubuntu1~18.04.1) ...
正在设置 libgif7:amd64 (5.1.4-2ubuntu0.1) ...
正在处理用于 libc-bin (2.27-3ubuntu1.2) 的触发器 ...
正在处理用于 man-db (2.8.3-2ubuntu0.1) 的触发器 ...
正在处理用于 gnome-menus (3.13.3-11ubuntu1.1) 的触发器 ...
正在设置 fonts-dejavu-extra (2.37-1) ...
正在处理用于 ca-certificates (20190110~18.04.1) 的触发器 ...
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
正在设置 libatk-wrapper-java (0.33.3-20ubuntu0.1) ...
正在处理用于 hicolor-icon-theme (0.17-2) 的触发器 ...
正在处理用于 fontconfig (2.12.6-0ubuntu2) 的触发器 ...
正在设置 libatk-wrapper-java-jni:amd64 (0.33.3-20ubuntu0.1) ...
正在设置 openjdk-11-jre-headless:amd64 (11.0.8+10-0ubuntu1~18.04.1) ...
update-alternatives: 使用 /usr/lib/jvm/java-11-openjdk-amd64/bin/rmid 来在自动模式中提供 /usr/bin/rmid (rmid)
update-alternatives: 使用 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 来在自动模式中提供 /usr/bin/java (java)
update-alternatives: 使用 /usr/lib/jvm/java-11-openjdk-amd64/bin/keytool 来在自动模式中提供 /usr/bin/keytool (keytool)
update-alternatives: 使用 /usr/lib/jvm/java-11-openjdk-amd64/bin/jjs 来在自动模式中提供 /usr/bin/jjs (jjs)
update-alternatives: 使用 /usr/lib/jvm/java-11-openjdk-amd64/bin/pack200 来在自动模式中提供 /usr/bin/pack200 (pack200)
update-alternatives: 使用 /usr/lib/jvm/java-11-openjdk-amd64/bin/rmiregistry 来在自动模式中提供 /usr/bin/rmiregistry (rmiregistry)
update-alternatives: 使用 /usr/lib/jvm/java-11-openjdk-amd64/bin/unpack200 来在自动模式中提供 /usr/bin/unpack200 (unpack200)
update-alternatives: 使用 /usr/lib/jvm/java-11-openjdk-amd64/bin/jfr 来在自动模式中提供 /usr/bin/jfr (jfr)
update-alternatives: 使用 /usr/lib/jvm/java-11-openjdk-amd64/lib/jexec 来在自动模式中提供 /usr/bin/jexec (jexec)
正在设置 default-jre-headless (2:1.11-68ubuntu1~18.04.1) ...
正在设置 openjdk-11-jre:amd64 (11.0.8+10-0ubuntu1~18.04.1) ...
正在设置 ca-certificates-java (20180516ubuntu1~18.04.1) ...
head: 无法打开'/etc/ssl/certs/java/cacerts' 读取数据: 没有那个文件或目录
Adding debian:T-TeleSec_GlobalRoot_Class_2.pem
Adding debian:Microsec_e-Szigno_Root_CA_2009.pem
Adding debian:IdenTrust_Commercial_Root_CA_1.pem
Adding debian:TWCA_Root_Certification_Authority.pem
Adding debian:VeriSign_Class_3_Public_Primary_Certification_Authority_-_G4.pem
Adding debian:Baltimore_CyberTrust_Root.pem
Adding debian:T-TeleSec_GlobalRoot_Class_3.pem
Adding debian:Deutsche_Telekom_Root_CA_2.pem
Adding debian:GeoTrust_Primary_Certification_Authority_-_G2.pem
Adding debian:ssl-cert-snakeoil.pem
Adding debian:OISTE_WISeKey_Global_Root_GA_CA.pem
Adding debian:Buypass_Class_2_Root_CA.pem
Adding debian:Atos_TrustedRoot_2011.pem
Adding debian:DigiCert_Global_Root_G3.pem
Adding debian:GlobalSign_Root_CA_-_R3.pem
Adding debian:SecureSign_RootCA11.pem
Adding debian:VeriSign_Universal_Root_Certification_Authority.pem
Adding debian:COMODO_Certification_Authority.pem
Adding debian:Sonera_Class_2_Root_CA.pem
Adding debian:GlobalSign_Root_CA.pem
Adding debian:Certum_Trusted_Network_CA_2.pem
Adding debian:SSL.com_EV_Root_Certification_Authority_RSA_R2.pem
Adding debian:QuoVadis_Root_CA_3.pem
Adding debian:GlobalSign_Root_CA_-_R2.pem
Adding debian:Entrust_Root_Certification_Authority_-_EC1.pem
Adding debian:TrustCor_RootCert_CA-2.pem
Adding debian:CFCA_EV_ROOT.pem
Adding debian:certSIGN_ROOT_CA.pem
Adding debian:Cybertrust_Global_Root.pem
Adding debian:GlobalSign_Root_CA_-_R6.pem
Adding debian:GlobalSign_ECC_Root_CA_-_R4.pem
Adding debian:Security_Communication_Root_CA.pem
Adding debian:GeoTrust_Primary_Certification_Authority_-_G3.pem
Adding debian:COMODO_RSA_Certification_Authority.pem
Adding debian:COMODO_ECC_Certification_Authority.pem
Adding debian:TUBITAK_Kamu_SM_SSL_Kok_Sertifikasi_-_Surum_1.pem
Adding debian:Izenpe.com.pem
Adding debian:Certplus_Class_2_Primary_CA.pem
Adding debian:ISRG_Root_X1.pem
Adding debian:QuoVadis_Root_CA_2_G3.pem
Adding debian:Security_Communication_RootCA2.pem
Adding debian:TrustCor_RootCert_CA-1.pem
Adding debian:CA_Disig_Root_R2.pem
Adding debian:Entrust.net_Premium_2048_Secure_Server_CA.pem
Adding debian:DigiCert_High_Assurance_EV_Root_CA.pem
Adding debian:EE_Certification_Centre_Root_CA.pem
Adding debian:Amazon_Root_CA_2.pem
Adding debian:Comodo_AAA_Services_root.pem
Adding debian:GDCA_TrustAUTH_R5_ROOT.pem
Adding debian:AffirmTrust_Networking.pem
Adding debian:SZAFIR_ROOT_CA2.pem
Adding debian:Autoridad_de_Certificacion_Firmaprofesional_CIF_A62634068.pem
Adding debian:OISTE_WISeKey_Global_Root_GB_CA.pem
Adding debian:Entrust_Root_Certification_Authority_-_G2.pem
Adding debian:SSL.com_Root_Certification_Authority_ECC.pem
Adding debian:DigiCert_Assured_ID_Root_G2.pem
Adding debian:DigiCert_Assured_ID_Root_CA.pem
Adding debian:AffirmTrust_Premium.pem
Adding debian:Certum_Trusted_Network_CA.pem
Adding debian:DigiCert_Global_Root_CA.pem
Adding debian:Entrust_Root_Certification_Authority.pem
Adding debian:Starfield_Root_Certificate_Authority_-_G2.pem
Adding debian:Starfield_Class_2_CA.pem
Adding debian:Amazon_Root_CA_1.pem
Adding debian:Secure_Global_CA.pem
Adding debian:EC-ACC.pem
Adding debian:Taiwan_GRCA.pem
Adding debian:OISTE_WISeKey_Global_Root_GC_CA.pem
Adding debian:Go_Daddy_Class_2_CA.pem
Adding debian:GeoTrust_Universal_CA_2.pem
Adding debian:AffirmTrust_Commercial.pem
Adding debian:SSL.com_EV_Root_Certification_Authority_ECC.pem
Adding debian:DigiCert_Trusted_Root_G4.pem
Adding debian:DigiCert_Global_Root_G2.pem
Adding debian:Trustis_FPS_Root_CA.pem
Adding debian:GeoTrust_Universal_CA.pem
Adding debian:Hellenic_Academic_and_Research_Institutions_RootCA_2015.pem
Adding debian:ACCVRAIZ1.pem
Adding debian:Verisign_Class_3_Public_Primary_Certification_Authority_-_G3.pem
Adding debian:SecureTrust_CA.pem
Adding debian:GlobalSign_ECC_Root_CA_-_R5.pem
Adding debian:Go_Daddy_Root_Certificate_Authority_-_G2.pem
Adding debian:VeriSign_Class_3_Public_Primary_Certification_Authority_-_G5.pem
Adding debian:D-TRUST_Root_Class_3_CA_2_EV_2009.pem
Adding debian:E-Tugra_Certification_Authority.pem
Adding debian:Hellenic_Academic_and_Research_Institutions_RootCA_2011.pem
Adding debian:IdenTrust_Public_Sector_Root_CA_1.pem
Adding debian:ePKI_Root_Certification_Authority.pem
Adding debian:LuxTrust_Global_Root_2.pem
Adding debian:Buypass_Class_3_Root_CA.pem
Adding debian:QuoVadis_Root_CA_3_G3.pem
Adding debian:Certigna.pem
Adding debian:Staat_der_Nederlanden_EV_Root_CA.pem
Adding debian:NetLock_Arany_=Class_Gold=_Főtanúsítvány.pem
Adding debian:Chambers_of_Commerce_Root_-_2008.pem
Adding debian:TWCA_Global_Root_CA.pem
Adding debian:Starfield_Services_Root_Certificate_Authority_-_G2.pem
Adding debian:TeliaSonera_Root_CA_v1.pem
Adding debian:thawte_Primary_Root_CA_-_G2.pem
Adding debian:Amazon_Root_CA_3.pem
Adding debian:SSL.com_Root_Certification_Authority_RSA.pem
Adding debian:DST_Root_CA_X3.pem
Adding debian:USERTrust_RSA_Certification_Authority.pem
Adding debian:thawte_Primary_Root_CA.pem
Adding debian:USERTrust_ECC_Certification_Authority.pem
Adding debian:Staat_der_Nederlanden_Root_CA_-_G3.pem
Adding debian:Certinomis_-_Root_CA.pem
Adding debian:GeoTrust_Global_CA.pem
Adding debian:AffirmTrust_Premium_ECC.pem
Adding debian:Network_Solutions_Certificate_Authority.pem
Adding debian:XRamp_Global_CA_Root.pem
Adding debian:Global_Chambersign_Root_-_2008.pem
Adding debian:SwissSign_Gold_CA_-_G2.pem
Adding debian:Hongkong_Post_Root_CA_1.pem
Adding debian:QuoVadis_Root_CA_1_G3.pem
Adding debian:Actalis_Authentication_Root_CA.pem
Adding debian:Hellenic_Academic_and_Research_Institutions_ECC_RootCA_2015.pem
Adding debian:DigiCert_Assured_ID_Root_G3.pem
Adding debian:QuoVadis_Root_CA_2.pem
Adding debian:GeoTrust_Primary_Certification_Authority.pem
Adding debian:Amazon_Root_CA_4.pem
Adding debian:QuoVadis_Root_CA.pem
Adding debian:Staat_der_Nederlanden_Root_CA_-_G2.pem
Adding debian:AC_RAIZ_FNMT-RCM.pem
Adding debian:TrustCor_ECA-1.pem
Adding debian:SwissSign_Silver_CA_-_G2.pem
Adding debian:thawte_Primary_Root_CA_-_G3.pem
Adding debian:D-TRUST_Root_Class_3_CA_2_2009.pem
done.
正在设置 default-jre (2:1.11-68ubuntu1~18.04.1) ...
正在处理用于 libc-bin (2.27-3ubuntu1.2) 的触发器 ...
正在处理用于 ca-certificates (20190110~18.04.1) 的触发器 ...
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
done.
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-1t$ java -jar ../tessera.jar -keygen -filename new-node-1
Error: Invalid or corrupt jarfile ../tessera.jar
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-1t$ ls
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-1t$ java -jar ./tessera.jar -keygen -filename new-node-1
Error: Unable to access jarfile ./tessera.jar
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-1t$ cd ..
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ls
genesis.json node2.log nohup.out tessera-app-0.10.6-app.jar
new-node-1 nodekey startnode1.sh tessera.jar
new-node-1t nodekey2 startnode2.sh
new-node-2 node.log static-nodes.json
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ^C
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ mv tessera-app-0.10.6-app.jar tessera.jar
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ls
genesis.json new-node-2 nodekey2 startnode1.sh tessera.jar
new-node-1 node2.log node.log startnode2.sh
new-node-1t nodekey nohup.out static-nodes.json
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ java -jar ../tessera.jar -keygen -filename new-node-1
Error: Unable to access jarfile ../tessera.jar
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ls
genesis.json new-node-2 nodekey2 startnode1.sh tessera.jar
new-node-1 node2.log node.log startnode2.sh
new-node-1t nodekey nohup.out static-nodes.json
不设置密码,为空直接回车
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ cd new-node-1t
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-1t$ java -jar ../tessera.jar -keygen -filename new-node-1
Enter a password if you want to lock the private key or leave blank
Please re-enter the password (or lack of) to confirm
2020-09-04 12:03:43.962 [main] INFO com.quorum.tessera.nacl.jnacl.Jnacl - Generating new keypair...
2020-09-04 12:03:44.007 [main] INFO com.quorum.tessera.nacl.jnacl.Jnacl - Generated new key pair with public key PublicKey[aVgqwifKUksF0QSdj60eTXWiQWB1YUKcRUytRs0lQwc=]
2020-09-04 12:03:44.425 [main] INFO c.q.t.k.generation.FileKeyGenerator - Saved public key to /home/yanhao/quorum/fromscratch-again/new-node-1t/new-node-1.pub
2020-09-04 12:03:44.425 [main] INFO c.q.t.k.generation.FileKeyGenerator - Saved private key to /home/yanhao/quorum/fromscratch-again/new-node-1t/new-node-1.key
引用新生成的密钥创建配置文件
vim config.json
{
"useWhiteList": false,
"jdbc": {
"username": "sa",
"password": "",
"url": "jdbc:h2:/home/yanhao/quorum/fromscratch-again/new-node-1t/db1;MODE=Oracle;TRACE_LEVEL_SYSTEM_OUT=0",
"autoCreateTables": true
},
"serverConfigs":[
{
"app":"ThirdParty",
"enabled": true,
"serverAddress": "http://localhost:9081",
"communicationType" : "REST"
},
{
"app":"Q2T",
"enabled": true,
"serverAddress":"unix:/home/yanhao/quorum/fromscratch-again/new-node-1t/tm.ipc",
"communicationType" : "REST"
},
{
"app":"P2P",
"enabled": true,
"serverAddress":"http://localhost:9001",
"sslConfig": {
"tls": "OFF"
},
"communicationType" : "REST"
}
],
"peer": [
{
"url": "http://localhost:9001"
},
{
"url": "http://localhost:9003"
}
],
"keys": {
"passwords": [],
"keyData": [
{
"privateKeyPath": "/home/yanhao/quorum/fromscratch-again/new-node-1t/new-node-1.key",
"publicKeyPath": "/home/yanhao/quorum/fromscratch-again/new-node-1t/new-node-1.pub"
}
]
},
"alwaysSendTo": []
}
创建第二个tessera节点
同样不设置密码,直接回车
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-1t$ cd ..
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ mkdir new-node-2t
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ cd new-node-2t
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-2t$ java -jar ../tessera.jar -keygen -filename new-node-2
Enter a password if you want to lock the private key or leave blank
Please re-enter the password (or lack of) to confirm
2020-09-08 19:50:21.578 [main] INFO com.quorum.tessera.nacl.jnacl.Jnacl - Generating new keypair...
2020-09-08 19:50:21.679 [main] INFO com.quorum.tessera.nacl.jnacl.Jnacl - Generated new key pair with public key PublicKey[26vwr5wxV0HMhVBkdCcQOMLH0KVYPla8R+FS3Np+/T8=]
2020-09-08 19:50:23.362 [main] INFO c.q.t.k.generation.FileKeyGenerator - Saved public key to /home/yanhao/quorum/fromscratch-again/new-node-2t/new-node-2.pub
2020-09-08 19:50:23.363 [main] INFO c.q.t.k.generation.FileKeyGenerator - Saved private key to /home/yanhao/quorum/fromscratch-again/new-node-2t/new-node-2.key
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-2t$ cp ../new-node-1t/config.json
cp: 在'../new-node-1t/config.json' 后缺少了要操作的目标文件
Try 'cp --help' for more information.
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-2t$ cp ../new-node-1t/config.json .
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-2t$ ls
config.json new-node-2.key new-node-2.pub
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-2t$ vim config.json
创建配置文件,类似与new-node-1t
{
"useWhiteList": false,
"jdbc": {
"username": "sa",
"password": "",
"url": "jdbc:h2:/home/yanhao/quorum/fromscratch-again/new-node-2t/db1;MODE=Oracle;TRACE_LEVEL_SYSTEM_OUT=0",
"autoCreateTables": true
},
"serverConfigs":[
{
"app":"ThirdParty",
"enabled": true,
"serverAddress": "http://localhost:9083",
"communicationType" : "REST"
},
{
"app":"Q2T",
"enabled": true,
"serverAddress":"unix:/home/yanhao/quorum/fromscratch-again/new-node-2t/tm.ipc",
"communicationType" : "REST"
},
{
"app":"P2P",
"enabled": true,
"serverAddress":"http://localhost:9003",
"sslConfig": {
"tls": "OFF"
},
"communicationType" : "REST"
}
],
"peer": [
{
"url": "http://localhost:9001"
},
{
"url": "http://localhost:9003"
}
],
"keys": {
"passwords": [],
"keyData": [
{
"privateKeyPath": "/home/yanhao/quorum/fromscratch-again/new-node-2t/new-node-2.key",
"publicKeyPath": "/home/yanhao/quorum/fromscratch-again/new-node-2t/new-node-2.pub"
}
]
},
"alwaysSendTo": []
}
第五步:启动Tessera节点,然后发送到后台
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-2t$ java -jar ../tessera.jar -configfile config.json >> tessera.log 2>&1 &
[1] 17165
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-2t$ cd ../new-node-1t
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-1t$ java -jar ../tessera.jar -configfile config.json >> tessera.log 2>&1 &
[2] 17941
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-1t$ ps
PID TTY TIME CMD
12185 pts/1 00:00:00 bash
17165 pts/1 00:00:17 java
17941 pts/1 00:00:16 java
18142 pts/1 00:00:00 ps
第六步:从上方启动连接到正在运行的Tessera节点的GoQuorum节点并将其发送到后台
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-1t$ cd ..
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ls
genesis.json new-node-1 new-node-1t new-node-2 new-node-2t node2.log nodekey nodekey2 node.log nohup.out startnode1.sh startnode2.sh static-nodes.json tessera.jar
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ vim startnode1.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ vim startnode1.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ vim startnode2.sh
startnode1.sh
PRIVATE_CONFIG=/home/yanhao/quorum/fromscratch-again/new-node-1t/tm.ipc nohup geth --datadir new-node-1 --nodiscover --verbosity 5 --networkid 31337 --raft --raftport 50000 --rpc --rpcaddr 0.0.0.0 --rpcport 22000 --rpcapi admin,db,eth,debug,miner,net,shh,txpool,personal,web3,quorum,raft --emitcheckpoints --port 21000 >> node.log 2>&1 &
startnode2.sh
PRIVATE_CONFIG=/home/yanhao/quorum/fromscratch-again/new-node-1t/tm.ipc nohup geth --datadir new-node-2 --nodiscover --verbosity 5 --networkid 31337 --raft --raftport 50001 --raftjoinexisting 2 --rpc --rpcaddr 0.0.0.0 --rpcport 22001 --rpcapi admin,db,eth,debug,miner,net,shh,txpool,personal,web3,quorum,raft --emitcheckpoints --port 21001 2>>node2.log &
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ./startnode1.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ./startnode2.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ps
PID TTY TIME CMD
12185 pts/1 00:00:00 bash
17165 pts/1 00:00:31 java
17941 pts/1 00:00:33 java
30059 pts/1 00:00:00 geth
30147 pts/1 00:00:00 geth
30241 pts/1 00:00:00 ps
节点现在可以运行(可操作),可以使用(geth attach new-node-1/geth.ipc)链接(attach)到该节点以发送私人交易
vim private-contract.js
//创建简单的私有合约,以从新节点1发送私有交易,以获取步骤四中创建的新节点2的tessera公钥
a = eth.accounts[0]
web3.eth.defaultAccount = a;
// abi and bytecode generated from simplestorage.sol:
// > solcjs --bin --abi simplestorage.sol
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"}],"payable":false,"type":"constructor"}];
var bytecode = "0x6060604052341561000f57600080fd5b604051602080610149833981016040528080519060200190919050505b806000819055505b505b610104806100456000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632a1afcd914605157806360fe47b11460775780636d4ce63c146097575b600080fd5b3415605b57600080fd5b606160bd565b6040518082815260200191505060405180910390f35b3415608157600080fd5b6095600480803590602001909190505060c3565b005b341560a157600080fd5b60a760ce565b6040518082815260200191505060405180910390f35b60005481565b806000819055505b50565b6000805490505b905600a165627a7a72305820d5851baab720bba574474de3d09dbeaabc674a15f4dd93b974908476542c23f00029";
var simpleContract = web3.eth.contract(abi);
var simple = simpleContract.new(42, {from:web3.eth.accounts[0], data: bytecode, gas: 0x47b760, privateFor: ["AeggpVlVsi+rxD6h9tcq/8qL/MsjyipUnkj1nvNPgTU="]}, function(e, contract) {
if (e) {
console.log("err creating contract", e);
} else {
if (!contract.address) {
console.log("Contract transaction send: TransactionHash: " + contract.transactionHash + " waiting to be mined...");
} else {
console.log("Contract mined! Address: " + contract.address);
console.log(contract);
}
}
});
unlockAccount一直Error: account unlock with HTTP access is forbidden,试了http://coder55.com/article/100458这里说的方法也没用
猜测是需要重新启动./startnode1.sh运行了但是没成功(线程冲突??)
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ geth attach new-node-1/geth.ipc
Welcome to the Geth JavaScript console!
instance: Geth/v1.9.7-stable-de45c9bb(quorum-v2.7.0)/linux-amd64/go1.12.6
coinbase: 0x03af8e050a5f40aec7a16eefefd9082aa89c038a
at block: 0 (Thu, 01 Jan 1970 08:00:00 CST)
datadir: /home/yanhao/quorum/fromscratch-again/new-node-1
modules: admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 quorumExtension:1.0 raft:1.0 rpc:1.0 txpool:1.0 web3:1.0
> eth.accounts
["0x03af8e050a5f40aec7a16eefefd9082aa89c038a", "0xe754b58a7147619d70b49dded8bddfb2b66366b4"]
> personal.unlockAccount("0x03af8e050a5f40aec7a16eefefd9082aa89c038a");
Unlock account 0x03af8e050a5f40aec7a16eefefd9082aa89c038a
Password:
Error: account unlock with HTTP access is forbidden
> personal.unlockAccount("0x03af8e050a5f40aec7a16eefefd9082aa89c038a");
Unlock account 0x03af8e050a5f40aec7a16eefefd9082aa89c038a
Password:
Error: account unlock with HTTP access is forbidden
> personal.unlockAccount("0x03af8e050a5f40aec7a16eefefd9082aa89c038a");
Unlock account 0x03af8e050a5f40aec7a16eefefd9082aa89c038a
Password:
Error: account unlock with HTTP access is forbidden
> ^C
> exit
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ vim startnode1.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ vim startnode2.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ./startnode1.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ./startnode2.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ps
PID TTY TIME CMD
12185 pts/1 00:00:00 bash
15511 pts/1 00:00:00 geth
15534 pts/1 00:00:00 ps
17165 pts/1 00:00:44 java
17941 pts/1 00:00:47 java
30059 pts/1 00:00:34 geth
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ geth attach new-node-1/geth.ipc
Welcome to the Geth JavaScript console!
instance: Geth/v1.9.7-stable-de45c9bb(quorum-v2.7.0)/linux-amd64/go1.12.6
coinbase: 0x03af8e050a5f40aec7a16eefefd9082aa89c038a
at block: 0 (Thu, 01 Jan 1970 08:00:00 CST)
datadir: /home/yanhao/quorum/fromscratch-again/new-node-1
modules: admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 quorumExtension:1.0 raft:1.0 rpc:1.0 txpool:1.0 web3:1.0
> eth.accounts
["0x03af8e050a5f40aec7a16eefefd9082aa89c038a", "0xe754b58a7147619d70b49dded8bddfb2b66366b4"]
> personal.unlockAccount("0x03af8e050a5f40aec7a16eefefd9082aa89c038a");
Unlock account 0x03af8e050a5f40aec7a16eefefd9082aa89c038a
Password:
Error: account unlock with HTTP access is forbidden
> exit
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ vim startnode1.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ vim startnode2.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ./startnode1.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ./startnode2.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ps
PID TTY TIME CMD
12185 pts/1 00:00:00 bash
17165 pts/1 00:00:46 java
17941 pts/1 00:00:49 java
18711 pts/1 00:00:00 geth
18848 pts/1 00:00:00 ps
30059 pts/1 00:00:40 geth
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ geth attach new-node-1/geth.ipc
Welcome to the Geth JavaScript console!
instance: Geth/v1.9.7-stable-de45c9bb(quorum-v2.7.0)/linux-amd64/go1.12.6
coinbase: 0x03af8e050a5f40aec7a16eefefd9082aa89c038a
at block: 0 (Thu, 01 Jan 1970 08:00:00 CST)
datadir: /home/yanhao/quorum/fromscratch-again/new-node-1
modules: admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 quorumExtension:1.0 raft:1.0 rpc:1.0 txpool:1.0 web3:1.0
> personal.unlockAccount("0x03af8e050a5f40aec7a16eefefd9082aa89c038a");
Unlock account 0x03af8e050a5f40aec7a16eefefd9082aa89c038a
Password:
Error: account unlock with HTTP access is forbidden
> personal.unlockAccount("0x03af8e050a5f40aec7a16eefefd9082aa89c038a");
Unlock account 0x03af8e050a5f40aec7a16eefefd9082aa89c038a
Password:
Error: account unlock with HTTP access is forbidden
> exit
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ vim startnode1.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ vim startnode2.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ vim startnode2.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ vim startnode1.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ./startnode1.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ./startnode2.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ps
PID TTY TIME CMD
12185 pts/1 00:00:00 bash
17165 pts/1 00:00:51 java
17941 pts/1 00:00:55 java
26032 pts/1 00:00:00 geth
26123 pts/1 00:00:00 ps
30059 pts/1 00:00:53 geth
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ geth attach new-node-1/geth.ipc
Welcome to the Geth JavaScript console!
instance: Geth/v1.9.7-stable-de45c9bb(quorum-v2.7.0)/linux-amd64/go1.12.6
coinbase: 0x03af8e050a5f40aec7a16eefefd9082aa89c038a
at block: 0 (Thu, 01 Jan 1970 08:00:00 CST)
datadir: /home/yanhao/quorum/fromscratch-again/new-node-1
modules: admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 quorumExtension:1.0 raft:1.0 rpc:1.0 txpool:1.0 web3:1.0
> personal.unlockAccount("0x03af8e050a5f40aec7a16eefefd9082aa89c038a");
Unlock account 0x03af8e050a5f40aec7a16eefefd9082aa89c038a
Password:
Error: account unlock with HTTP access is forbidden
> exit
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ geth attach new-node-1/geth.ipc personal.unlockAccount("0x03af8e050a5f40aec7a16eefefd9082aa89c038a");
bash: 未预期的符号 `(' 附近有语法错误
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ geth attach new-node-1/geth.ipc --allow-insecure-unlock
Incorrect Usage: flag provided but not defined: -allow-insecure-unlock
attach [command options] [arguments...]
The Geth console is an interactive shell for the JavaScript runtime environment
which exposes a node admin interface as well as the Ðapp JavaScript API.
See https://github.com/ethereum/go-ethereum/wiki/JavaScript-Console.
This command allows to open a console on a running geth node.
ETHEREUM OPTIONS:
--datadir value Data directory for the databases and keystore (default: "/home/yanhao/.ethereum")
API AND CONSOLE OPTIONS:
--jspath loadScript JavaScript root path for loadScript (default: ".")
--exec value Execute JavaScript statement
--preload value Comma separated list of JavaScript files to preload into the console
--rpcclitoken value RPC Client access token
--rpcclitls.cert value Server's TLS certificate PEM file on connection by client
--rpcclitls.cacert value CA certificate PEM file for provided server's TLS certificate on connection by client
--rpcclitls.ciphersuites value Customize supported cipher suites when using TLS connection. Value is a comma-separated cipher suite string
--rpcclitls.insecureskipverify Disable verification of server's TLS certificate on connection by client
flag provided but not defined: -allow-insecure-unlock
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ps
PID TTY TIME CMD
12185 pts/1 00:00:00 bash
17165 pts/1 00:00:55 java
17941 pts/1 00:00:59 java
30059 pts/1 00:01:04 geth
31660 pts/1 00:00:00 ps
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ./startnode2.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ps
PID TTY TIME CMD
12185 pts/1 00:00:00 bash
17165 pts/1 00:00:55 java
17941 pts/1 00:00:59 java
30059 pts/1 00:01:05 geth
31993 pts/1 00:00:00 geth
32028 pts/1 00:00:00 ps
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ geth attach new-node-1/geth.ipc
Welcome to the Geth JavaScript console!
instance: Geth/v1.9.7-stable-de45c9bb(quorum-v2.7.0)/linux-amd64/go1.12.6
coinbase: 0x03af8e050a5f40aec7a16eefefd9082aa89c038a
at block: 0 (Thu, 01 Jan 1970 08:00:00 CST)
datadir: /home/yanhao/quorum/fromscratch-again/new-node-1
modules: admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 quorumExtension:1.0 raft:1.0 rpc:1.0 txpool:1.0 web3:1.0
> eth.accounts
["0x03af8e050a5f40aec7a16eefefd9082aa89c038a", "0xe754b58a7147619d70b49dded8bddfb2b66366b4"]
> personal.unlockAccount("0x03af8e050a5f40aec7a16eefefd9082aa89c038a");
Unlock account 0x03af8e050a5f40aec7a16eefefd9082aa89c038a
Password:
Error: account unlock with HTTP access is forbidden
>
> exit
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ vim startnode1.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ vim startnode2.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ps
PID TTY TIME CMD
5057 pts/1 00:00:00 ps
12185 pts/1 00:00:00 bash
17165 pts/1 00:01:00 java
17941 pts/1 00:01:04 java
30059 pts/1 00:01:15 geth
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ./startnode1.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ps
PID TTY TIME CMD
5532 pts/1 00:00:00 ps
12185 pts/1 00:00:00 bash
17165 pts/1 00:01:00 java
17941 pts/1 00:01:04 java
30059 pts/1 00:01:16 geth
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ./startnode2.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ps
PID TTY TIME CMD
5604 pts/1 00:00:00 geth
5693 pts/1 00:00:00 ps
12185 pts/1 00:00:00 bash
17165 pts/1 00:01:00 java
17941 pts/1 00:01:04 java
30059 pts/1 00:01:17 geth
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ geth attach new-node-1/geth.ipc
Welcome to the Geth JavaScript console!
instance: Geth/v1.9.7-stable-de45c9bb(quorum-v2.7.0)/linux-amd64/go1.12.6
coinbase: 0x03af8e050a5f40aec7a16eefefd9082aa89c038a
at block: 0 (Thu, 01 Jan 1970 08:00:00 CST)
datadir: /home/yanhao/quorum/fromscratch-again/new-node-1
modules: admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 quorumExtension:1.0 raft:1.0 rpc:1.0 txpool:1.0 web3:1.0
> personal.unlockAccount(eth.accounts[0])
Unlock account 0x03af8e050a5f40aec7a16eefefd9082aa89c038a
Password:
Error: account unlock with HTTP access is forbidden
> exit
原因找到了,实际上上面的教程所说的需要添加–allow-insecure-unlock是对的,只不过我在重启节点./startnode1.sh的时候,并没有重启成功,通过geth.ipc未更新可以发现。于是我先su root进入root,通过netstat -nap|grep 22000和22001分别kill对应的进程,重新启动才成功。接下来,unlock就成功了。全过程如下:备注unlock密码是yanhao12
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ netstat -nap|grep 22001
(并非所有进程都能被检测到,所有非本用户的进程信息将不会显示,如果想看到所有信息,则必须切换到 root 用户)
tcp6 0 0 :::22001 :::* LISTEN -
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ root
Command 'root' not found, did you mean:
command 'roo' from snap roo (2.0.3)
command 'toot' from snap toot (0.27.0)
command 'rootv' from deb xawtv
command 'proot' from deb proot
command 'rott' from deb rott
See 'snap info <snapname>' for additional versions.
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ su root
密码:
root@yanhao-ThinkPad-T480:/home/yanhao/quorum/fromscratch-again# netstat -nap|grep 22001
tcp6 0 0 :::22001 :::* LISTEN 10661/docker-proxy
root@yanhao-ThinkPad-T480:/home/yanhao/quorum/fromscratch-again# kill 10661
root@yanhao-ThinkPad-T480:/home/yanhao/quorum/fromscratch-again# netstat -nap|grep 22001
root@yanhao-ThinkPad-T480:/home/yanhao/quorum/fromscratch-again# netstat -nap|grep 22000
tcp6 0 0 :::22000 :::* LISTEN 30059/geth
root@yanhao-ThinkPad-T480:/home/yanhao/quorum/fromscratch-again# exit
exit
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ./startnode2.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ./startnode1.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ps
PID TTY TIME CMD
12185 pts/1 00:00:00 bash
17165 pts/1 00:01:16 java
17941 pts/1 00:01:21 java
27987 pts/1 00:00:00 geth
28383 pts/1 00:00:00 ps
30059 pts/1 00:01:59 geth
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ su root
密码:
root@yanhao-ThinkPad-T480:/home/yanhao/quorum/fromscratch-again# netstat -nap|grep 22000
tcp6 0 0 :::22000 :::* LISTEN 30059/geth
root@yanhao-ThinkPad-T480:/home/yanhao/quorum/fromscratch-again# kill 30059
root@yanhao-ThinkPad-T480:/home/yanhao/quorum/fromscratch-again# exit
exit
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ./startnode1.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ./startnode2.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ geth attach new-node-1/geth.ipc
Welcome to the Geth JavaScript console!
instance: Geth/v1.9.7-stable-de45c9bb(quorum-v2.7.0)/linux-amd64/go1.12.6
coinbase: 0x03af8e050a5f40aec7a16eefefd9082aa89c038a
at block: 0 (Thu, 01 Jan 1970 08:00:00 CST)
datadir: /home/yanhao/quorum/fromscratch-again/new-node-1
modules: admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 quorumExtension:1.0 raft:1.0 rpc:1.0 txpool:1.0 web3:1.0
> eth.accounts
["0x03af8e050a5f40aec7a16eefefd9082aa89c038a", "0xe754b58a7147619d70b49dded8bddfb2b66366b4"]
> personal.unlockAccount(eth.accounts[0])
Unlock account 0x03af8e050a5f40aec7a16eefefd9082aa89c038a
Password:
true
>
继续,新的错误!
> loadScript("private-contract.js")
err creating contract Error: Non-200 status code: &{Status:404 Not Found StatusCode:404 Proto:HTTP/1.1 ProtoMajor:1 ProtoMinor:1 Header:map[Content-Length:[73] Content-Type:[text/plain] Date:[Tue, 08 Sep 2020 13:10:43 GMT] Server:[Jetty(9.4.25.v20191220)] Tesserasupportedapiversions:[0.10.6]] Body:0xc00a4eafc0 ContentLength:73 TransferEncoding:[] Close:false Uncompressed:false Trailer:map[] Request:0xc000273500 TLS:<nil>}
true
>
根据官网的提示:如果private-contract.js中的数组中没有有效的公共密钥,则在加载脚本时会看到以下错误。
节点2的公钥改一下就行,去new-node-2t目录下的.pub文件查看。
yanhao@yanhao-ThinkPad-T480:~$ cd quorum
yanhao@yanhao-ThinkPad-T480:~/quorum$ ls
accounts COPYING event Makefile raft
appveyor.yml COPYING.LESSER extension metrics README.md
AUTHORS core fromscratch miner rlp
build crypto fromscratch-again mkdocs.yml rpc
BUILDING.md dashboard fromscratch-new mobile SECURITY.md
circle.yml Dockerfile graphql node signer
cmd Dockerfile.alltools interfaces.go NOTES.md tests
common docs internal p2p trie
consensus eth les params vendor
console ethclient light permission whisper
containers ethdb log plugin
contracts ethstats logo.png private
yanhao@yanhao-ThinkPad-T480:~/quorum$ cd fromscratch-again/
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ps
PID TTY TIME CMD
24780 pts/0 00:00:00 bash
30242 pts/0 00:00:00 ps
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ cd new-node-1t
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-1t$ java -jar ../tessera.jar -configfile config.json >> tessera.log 2>&1 &
[1] 32472
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-1t$ cd ../new-node-2t
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-2t$ java -jar ../tessera.jar -configfile config.json >> tessera.log 2>&1 &
[2] 522
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-2t$ ps
PID TTY TIME CMD
522 pts/0 00:00:02 java
542 pts/0 00:00:00 ps
24780 pts/0 00:00:00 bash
32472 pts/0 00:00:04 java
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-2t$ cd ..
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ./startnode1.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ./startnode2.sh
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ps
PID TTY TIME CMD
522 pts/0 00:00:26 java
1699 pts/0 00:00:00 geth
1780 pts/0 00:00:00 geth
1864 pts/0 00:00:00 ps
24780 pts/0 00:00:00 bash
32472 pts/0 00:00:29 java
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ls
genesis.json new-node-2 nodekey nohup.out startnode2.sh
new-node-1 new-node-2t nodekey2 private-contract.js static-nodes.json
new-node-1t node2.log node.log startnode1.sh tessera.jar
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ cd new-node-2t
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-2t$ ls
config.json db1.trace.db new-node-2.pub tm.ipc
db1.mv.db new-node-2.key tessera.log
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-2t$ new-node-2.pub
new-node-2.pub:未找到命令
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-2t$ vim new-node-2.pub
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-2t$ vim private-contract.js
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-2t$ ls
config.json db1.trace.db new-node-2.pub tm.ipc
db1.mv.db new-node-2.key tessera.log
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again/new-node-2t$ cd ..
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ ls
genesis.json new-node-2 nodekey nohup.out startnode2.sh
new-node-1 new-node-2t nodekey2 private-contract.js static-nodes.json
new-node-1t node2.log node.log startnode1.sh tessera.jar
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ vim private-contract.js yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ geth attach new-node-1/geth.ipc
Welcome to the Geth JavaScript console!
instance: Geth/v1.9.7-stable-de45c9bb(quorum-v2.7.0)/linux-amd64/go1.12.6
coinbase: 0x03af8e050a5f40aec7a16eefefd9082aa89c038a
at block: 0 (Thu, 01 Jan 1970 08:00:00 CST)
datadir: /home/yanhao/quorum/fromscratch-again/new-node-1
modules: admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 quorumExtension:1.0 raft:1.0 rpc:1.0 txpool:1.0 web3:1.0
> eth.accounts
["0x03af8e050a5f40aec7a16eefefd9082aa89c038a", "0xe754b58a7147619d70b49dded8bddfb2b66366b4"]
> personal.unlock(eth.accounts[0])
TypeError: 'unlock' is not a function
at <anonymous>:1:1
> personal.unlockAccount(eth.accounts[0])
Unlock account 0x03af8e050a5f40aec7a16eefefd9082aa89c038a
Password:
Error: could not decrypt key with given password
> personal.unlockAccount(eth.accounts[0])
Unlock account 0x03af8e050a5f40aec7a16eefefd9082aa89c038a
Password:
Error: could not decrypt key with given password
> personal.unlockAccount(eth.accounts[0])
Unlock account 0x03af8e050a5f40aec7a16eefefd9082aa89c038a
Password:
Error: could not decrypt key with given password
> personal.unlockAccount(eth.accounts[0])
Unlock account 0x03af8e050a5f40aec7a16eefefd9082aa89c038a
Password:
true
> loadScript("private-contract.js")
Contract transaction send: TransactionHash: 0x5e070785d0530cd5d94e108afaedc65c9d2e9df4431b9009c9994c020d27ebc1 waiting to be mined...
true
> loadScript("private-contract.js")
Contract transaction send: TransactionHash: 0x630fac3873348923c41d549f6a4be193791029d0cdc7473c1a1e8b96fa900831 waiting to be mined...
true
>
正确的需要有Contract mined!提示并返回合约地址,此处为: 0x701118c5f2a39db8e05d32c5bfb269cb0bb787b9。
> loadScript('private-contract.js')
Contract transaction send: TransactionHash: 0x289cfde30f057b6d6cb24570d54a225227464d51cb5eb1f6d01c6daa36d63e6c waiting to be mined...
true
> Contract mined! Address: 0x701118c5f2a39db8e05d32c5bfb269cb0bb787b9
[object Object]
重开终端-连接节点2:
yanhao@yanhao-ThinkPad-T480:~/quorum/fromscratch-again$ geth attach new-node-2/geth.ipc
Welcome to the Geth JavaScript console!
instance: Geth/v1.9.7-stable-de45c9bb(quorum-v2.7.0)/linux-amd64/go1.12.6
at block: 2 (Fri, 18 Sep 2020 14:44:42 CST)
datadir: /home/yanhao/quorum/fromscratch-again/new-node-2
modules: admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 quorumExtension:1.0 raft:1.0 rpc:1.0 txpool:1.0 web3:1.0
> 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"}],"payable":false,"type":"constructor"}];
undefined
> var address="0x701118c5f2a39db8e05d32c5bfb269cb0bb787b9";
undefined
> var contract=eth.contract(abi).at(address);
undefined
> contract.get()
42
>
上述脚本(private-contract.js)在节点1上部署了一个简单的状态值为42的存储合约,交易是节点1和节点2之间私有的,这意味着其他节点将看不到这个状态值。
所以,进入节点2的geth终端,使用ABI和合约地址创建合约实例,然后尝试读取状态值,可以得到42(如上)。