节点入网

注意事项

节点入网时,请确保首先注册创世节点

创世节点入网

FISCO BCOS提供register_node.sh工具用于节点入网,创世节点入网过程如下:

  1. # 进入脚本所在目录(设FISCO-BCOS位于~/mydata目录)
  2. $ cd ~/mydata/FISCO-BCOS/tools/scripts
  3.  
  4. # -d: 创世节点所在目录
  5. # -g: 创世节点类型是国密版FISCO-BCOS
  6. $ bash ./register_node.sh -d ~/mydata/node0 -g
  7. RUN: babel-node tool.js NodeAction register ~/mydata/node0/data/gmnode.json
  8. { HttpProvider: 'http://127.0.0.1:8546',
  9. Ouputpath: './output/',
  10. EncryptType: 1,
  11. privKey: 'bcec428d5205abe0f0cc8a734083908d9eb8563e31f943d760786edf42ad67dd',
  12. account: '0x64fa644d2a694681bd6addd6c5e36cccd8dcdde3' }
  13. Soc File :NodeAction
  14. Func :register
  15. SystemProxy address 0xee80d7c98cb9a840b9c4df742f61336770951875
  16. node.json=~/mydata/node0/data/gmnode.json
  17. NodeAction address 0x22af893607e84456eb5aea0b277e4dffe260fdcd
  18. send transaction success: 0xbfc83175af76dd7e466b75ecd76cd6fd328a4b700233943a81187ea72b0c6bf7
  19. SUCCESS execution of command: babel-node tool.js NodeAction register ~/mydata/node0/data/gmnode.json
  20. ~/mydata/FISCO-BCOS/tools/scripts
  21. Register Node Success!
  22.  
  23. # 创世节点配置~/mydata/node0/data/gmnode.json如下:
  24. $ cat ~/mydata/node0/data/gmnode.json
  25. {
  26. "id":"730195b08dda7b027c9ba5bec8ec19420aa996c7ce72fa0954711d46c1c66ae8c2eeaa5f84d1f7766f21ba3dc822bc6d764fbee14034b19a0cf1c69c7f75e537",
  27. "name":"",
  28. "agency":"",
  29. "caHash":"AF33DEB4033C0D47"
  30. }

普通节点入网

普通节点入网过程如下:

  1. # 进入脚本所在目录(设FISCO-BCOS位于~/mydata目录)
  2. $ cd ~/mydata/FISCO-BCOS/tools/scripts
  3.  
  4. # -d: 普通节点目录,这里是~/mydata/node1
  5. # -g:普通节点类型是国密版FISCO-BCOS,必须设置
  6. $ bash ./register_node.sh -d ~/mydata/node1 -g
  7. RUN: babel-node tool.js NodeAction register /mydata/node1/data/gmnode.json
  8. { HttpProvider: 'http://127.0.0.1:8545',
  9. Ouputpath: './output/',
  10. EncryptType: 1,
  11. privKey: 'bcec428d5205abe0f0cc8a734083908d9eb8563e31f943d760786edf42ad67dd',
  12. account: '0x64fa644d2a694681bd6addd6c5e36cccd8dcdde3' }
  13. Soc File :NodeAction
  14. Func :register
  15. SystemProxy address 0xee80d7c98cb9a840b9c4df742f61336770951875
  16. node.json=~/mydata/node1/data/gmnode.json
  17. NodeAction address 0x22af893607e84456eb5aea0b277e4dffe260fdcd
  18. send transaction success: 0xc67d4e08a03a7094244e3de100979e1f0e50b7f9d83be5691d3833e3ddfcb97b
  19. SUCCESS execution of command: babel-node tool.js NodeAction register ~/mydata/node1/data/gmnode.json { HttpProvider: 'http://127.0.0.1:8545',
  20. Ouputpath: './output/',
  21. EncryptType: 1,
  22. privKey: 'bcec428d5205abe0f0cc8a734083908d9eb8563e31f943d760786edf42ad67dd',
  23. account: '0x64fa644d2a694681bd6addd6c5e36cccd8dcdde3' }
  24. Soc File :NodeAction
  25. Func :register
  26. SystemProxy address 0xee80d7c98cb9a840b9c4df742f61336770951875
  27. node.json=~/mydata/node1/data/gmnode.json
  28.  
  29. ~/mydata/FISCO-BCOS/tools/scriptsNodeAction address 0x22af893607e84456eb5aea0b277e4dffe260fdcd
  30. # 查看记账节点信息
  31. RUN: babel-node tool.js NodeAction all
  32. { HttpProvider: 'http://127.0.0.1:8545',
  33. Ouputpath: './output/',
  34. EncryptType: 1,
  35. privKey: 'bcec428d5205abe0f0cc8a734083908d9eb8563e31f943d760786edf42ad67dd',
  36. account: '0x64fa644d2a694681bd6addd6c5e36cccd8dcdde3' }
  37. send transaction success: 0x1f923378d2640acad78378ee2f21002213cb9f81dfcb7b0f2e42ea5a960a08e6
  38. SUCCESS execution of command: babel-node tool.js NodeAction register ~/mydata/node1/data/gmnode.json
  39. ~/mydata/FISCO-BCOS/tools/scripts
  40. RUN: babel-node tool.js NodeAction all
  41.  
  42. Soc File :NodeAction
  43. Func :all
  44. SystemProxy address 0xee80d7c98cb9a840b9c4df742f61336770951875
  45. NodeAction address 0x22af893607e84456eb5aea0b277e4dffe260fdcd
  46. NodeIdsLength= 2
  47. ----------node 0---------
  48. id=3d4fe4c876cac411d4c7180b5794198fb3b4f3e0814156410ae4184e0a51097a01bf63e431293f30af0c01a57f24477ad1704d8f676bc7e345526ba1735db6a7
  49. name=
  50. agency=
  51. caHash=D14983471F0AC975
  52. Idx=0
  53. blocknumber=30
  54. ----------node 1---------
  55. id=9af16c4543919589982932b57bb97b162f8eba522037a95e7b013780911c2b0ffdef775b5387b2a4f4867b1271a06357d15055cde76a0b49e4714b691fdd368a
  56. name=
  57. agency=
  58. caHash=95F1A5C35D8CFFA7
  59. Idx=1
  60. blocknumber=31
  61. SUCCESS execution of command: babel-node tool.js NodeAction all{ HttpProvider: 'http://127.0.0.1:8545',
  62. Ouputpath: './output/',
  63. EncryptType: 1,
  64. privKey: 'bcec428d5205abe0f0cc8a734083908d9eb8563e31f943d760786edf42ad67dd',
  65. account: '0x64fa644d2a694681bd6addd6c5e36cccd8dcdde3' }
  66. Soc File :NodeAction
  67. Func :all

查看节点入网情况

FISCO-BCOS提供了node_all.sh命令查看记账节点信息:

  1. $ bash ./node_all.sh
  2. RUN: babel-node tool.js NodeAction all
  3. { HttpProvider: 'http://127.0.0.1:8545',
  4. Ouputpath: './output/',
  5. EncryptType: 1,
  6. privKey: 'bcec428d5205abe0f0cc8a734083908d9eb8563e31f943d760786edf42ad67dd',
  7. account: '0x64fa644d2a694681bd6addd6c5e36cccd8dcdde3' }
  8. Soc File :NodeAction
  9. Func :all
  10. SystemProxy address 0xee80d7c98cb9a840b9c4df742f61336770951875
  11. NodeAction address 0x22af893607e84456eb5aea0b277e4dffe260fdcd
  12. NodeIdsLength= 2
  13. ----------node 0---------
  14. id=3d4fe4c876cac411d4c7180b5794198fb3b4f3e0814156410ae4184e0a51097a01bf63e431293f30af0c01a57f24477ad1704d8f676bc7e345526ba1735db6a7
  15. name=
  16. agency=
  17. caHash=D14983471F0AC975
  18. Idx=0
  19. blocknumber=30
  20. ----------node 1---------
  21. id=9af16c4543919589982932b57bb97b162f8eba522037a95e7b013780911c2b0ffdef775b5387b2a4f4867b1271a06357d15055cde76a0b49e4714b691fdd368a
  22. name=
  23. agency=
  24. caHash=95F1A5C35D8CFFA7
  25. Idx=1
  26. blocknumber=31
  27. SUCCESS execution of command: babel-node tool.js NodeAction all

从输出信息可看出,创世节点和普通节点均成功入网。

check节点入网情况

使用如下命令检查创世节点入网情况,若输出+++等打包信息,表明创世节点入网成功:

  1. $ tail -f ~/mydata/node0/log/log_2018081220.log | grep +++
  2. INFO|2018-08-12 20:33:13:431|+++++++++++++++++++++++++++ Generating seal on31e1a94c1feb79a4145272a9c5175636d7c24cf4ed90b0b2f5471e4323e5e89e#34tx:0,maxtx:0,tq.num=0time:1534077193431
  3. INFO|2018-08-12 20:33:15:457|+++++++++++++++++++++++++++ Generating seal ondbfa0c0cac0e39f0d22c0c6fa3c21e77e15a3c31d8c81dac580dfbf95b2f96cb#34tx:0,maxtx:0,tq.num=0time:1534077195457

同样地,使用如下命令检查普通节点入网情况,若输出+++等打包信息,表明普通节点入网成功:

  1. $ tail -f ~/mydata/node1/log/log_2018081220.log | grep +++
  2. INFO|2018-08-12 20:33:36:696|+++++++++++++++++++++++++++ Generating seal on17d28b77047be017be9ec7ebd048b3b9b711cf75dcbdc1eabfe9cd57d8d6e7f7#34tx:0,maxtx:0,tq.num=0time:1534077216696
  3. INFO|2018-08-12 20:33:38:718|+++++++++++++++++++++++++++ Generating seal onf082c29bcadab361a1bd88853964f8daac643265e4b1a786d669d58a99ce3833#34tx:0,maxtx:0,tq.num=0time:1534077218718

congratulations :)

补充说明

FISCO-BCOS提供了remove_node.sh命令将指定节点从记账节点列表中移除:

  1. #进入执行脚本目录
  2. $ cd ~/mydata/FISCO-BCOS/tools/scripts
  3. #执行remove_node.sh命令将位于~/mydata/node0目录的node0节点退网
  4. $ bash remove_node.sh -d ~/mydata/node0 -g
  5.  
  6. # remove_node.sh使用方法:
  7. $ bash remove_node.sh -h
  8.  
  9. Usage:
  10. -d <node dir> Node dir to be removed # 被从记账列表中移除的节点所在目录
  11. Optional:
  12. -w <web3lib dir> Directory of web3lib # web3lib所在目录,使用默认配置,不填
  13. -s <systemcontract dir> Directory of systemcontract # 系统合约所在目录,使用默认配置,不填
  14. -g remove guomi node # 移除国密版FISCO-BCOS记账节点
  15. -h This help
  16. Example: # 移除非国密版FISCO-BCOS记账节点示例
  17. bash remove_node.sh -d /mydata/node0
  18. bash remove_node.sh -d /mydata/node0 -w ../web3lib/ -s ../systemcontract/
  19. Guomi Example: # 移除国密版FISCO-BCOS记账节点示例
  20. bash remove_node.sh -d ~/mydata/node0 -g
  21. bash remove_node.sh -d ~/mydata/node0 -w ../web3lib/ -s ../systemcontract/ -g