快速启动本地测试链

关于共识类型,若使用 Caravel,需启动多个节点组网;本地测试可使用 单节点共识。

  1. 根据源码编译或下载节点程序到本地。

  2. 新建目录(如:node)并将节点程序放到该目录中。

  3. 在node目录中新建data目录,用于存的节点数据以及钱包数据。

  4. 在node目录中参考如下内容新建文件genesis.json并调整相关信息,用于创世区块的生成:

{
  "networkId": 6,
  "timestamp": "0x0",
  "gasLimit": "0xffffffff",
  "extraData": "0x",
  "consensus": "0xf84e8001a05d93025288dddb431e3f43e07c63d1a96a28bf033457c74ee3f4d8eed88d3cf601a0010000000000000000000000000000000000000000000000000000000000000001801a8207d0820fa0",
  "mixHash": "0x87c71741b903194ab0eb0bd581d5c522f0328e979f3c1bf29f6068bd2797fdf8",
  "coinbase": "0x59677fD68ec54e43aD4319D915f81748B5a6Ff8B",
  "alloc": {
    "0000000000000000000000000000001111111111": {
      "balance": "0x1cf389cd46047d030000000"
    },
    "15f04a855a332ac34b3fdf06502e801786fefad8": {
      "balance": "0xa044288bc398d899c000000"
    },
    "59677fd68ec54e43ad4319d915f81748b5a6ff8b": {
      "balance": "0xa044288bc398d899c000000"
    },
    "8a6d78c7e0078430f6347863421055b8d2979e1c": {
      "balance": "0xa044288bc398d899c000000"
    }
  },
  "validators": {
    "0x8e036959e057f0df5ffa0211a2548194c6cb08ff": {
      "name": "",
      "operatorAddress": "0x8E036959E057F0df5FFa0211A2548194C6Cb08FF",
      "coinbase": "0x8E036959E057F0df5FFa0211A2548194C6Cb08FF",
      "mainPubKey": "0x035464e3a63958f0dc9cd16443328f558500a56e0e1a2b7c37d9420d8babeb0f26",
      "blsPubKey": "0x9714e0e24b93941eca0e383bf3145a0f6bf6102ccb8b343361156743999f35f5f39c25e694a7556e8d2582bfd6e57a0e14cbe82a925c98b416616ea6305016c9f8aa7a1e735c045d3e14ab341bdb0225a9f8de938e85b9974922cc86263a93aa",
      "token": "0x112704cffb9b70a00000",
      "role": 1,
      "status": 1
    },
    "0x93e8ccbf6383ce4186d8f1f25a9429ce6aecc954": {
      "name": "",
      "operatorAddress": "0x93e8cCBF6383Ce4186d8f1F25a9429Ce6Aecc954",
      "coinbase": "0x93e8cCBF6383Ce4186d8f1F25a9429Ce6Aecc954",
      "mainPubKey": "0x03f04b9efabc1d73b2be8e9b15f4a8c31712f663bc26f0aec698b5308e1af31122",
      "blsPubKey": "0x8a2aca87d746e5ebe38dfc2631dec33d63463ae7a92b19c276b99cffeb4b47446807fb66bd2db3e8fa18171b3a4506f30f4adcfd3a6b3754dfdd95a78fe25bba63d75ad9485b86f74b0fe664e293826abe086b32d79af690755005fab7e695df",
      "token": "0xbbd45dc918965c600000",
      "role": 1,
      "status": 1
    },
    "0xa716bbbde530e58c4b400ce63320970714aaa89a": {
      "name": "",
      "operatorAddress": "0xa716bBBDE530E58C4b400cE63320970714aaa89a",
      "coinbase": "0xa716bBBDE530E58C4b400cE63320970714aaa89a",
      "mainPubKey": "0x0394831c73142b89c6dd7b3eb43649994742bef08145f27d520e92354a3990920e",
      "blsPubKey": "0xa079279906f09d9deedfaaa5ccef4a5de2ab2e04b073d1b7a51cdcbd5cc28a2dc5a63acdae0a0771eeba59b5e2c483fa031688f3f85e9669f0a9355f33fd797b2814fcf937a304ba06b05eb2226fda87207282ac83103c0571f45974b9b905b1",
      "token": "0x1fc3842bd1f071c00000",
      "role": 3,
      "status": 1
    },
    "0xbe635e5a8d2552160c26221adc1c8a58730e388b": {
      "name": "",
      "operatorAddress": "0xbe635E5a8D2552160c26221ADC1c8A58730E388B",
      "coinbase": "0xbe635E5a8D2552160c26221ADC1c8A58730E388B",
      "mainPubKey": "0x024646f2ec9575438d961e945aaab6af5fd284b60d004671e9ccc434cbfa94b5b6",
      "blsPubKey": "0x882027d7f466cd0ce33c67d569ae9cb3258fdb8ab6db2ca0c52732d47123ecda641b36473c04e4214966b21d2ca28ff6071544ee32b7ec3e38c9e8505791d950397ad336c045593b4cc88c8ba0e051804c8eb1b06c0e94469945ff517c0860e2",
      "token": "0xc7e657b0c9a4ee00000",
      "role": 2,
      "status": 1
    },
    "0xccc6936e6fcbedf2db1becf46399e0e153dd189c": {
      "name": "",
      "operatorAddress": "0xCCc6936E6FcbEdF2Db1bECf46399E0E153dd189c",
      "coinbase": "0xCCc6936E6FcbEdF2Db1bECf46399E0E153dd189c",
      "mainPubKey": "0x02277c7a972777a090970cd7637989ae7c158fe371d98119114b705c04c6429172",
      "blsPubKey": "0xa31bdad808cec395781db027af17dc853184dd35c53cd18aaef3911b023b4946ba5a928a81c257f06b5f8e132aafa9570bceeba4af1ee0510bc71d5058b02d87430a6dbaa72838f5c72fd16aa9d9262f7860272b62d32db00dc9174d4a422e04",
      "token": "0x59ff4bd17d7e97a00000",
      "role": 3,
      "status": 1
    },
    "0xe4926b924960eeef6801c3c9de7470e7de7ab49f": {
      "name": "",
      "operatorAddress": "0xE4926b924960eEEF6801C3C9dE7470e7dE7ab49F",
      "coinbase": "0xE4926b924960eEEF6801C3C9dE7470e7dE7ab49F",
      "mainPubKey": "0x03827a57e8afe1215464730e74d5ae2c2305f773dde5e412ede46761b562aebb66",
      "blsPubKey": "0x98cd979838545cc061dcbcde123ccda824473429830113a5452dabf04db7c4966c03c805ae0b966b31a584b12efe02741937799c740058b22eacf7a52b724164d1ab25875934b636e54440e123ef59128a4ee2bb55900ebcaec45a44570eee12",
      "token": "0x112704cffb9b70a00000",
      "role": 2,
      "status": 1
    },
    "0xfc417779c6805a80fe8e788335ffd9f326aa5893": {
      "name": "",
      "operatorAddress": "0xFc417779C6805A80Fe8e788335ffD9F326AA5893",
      "coinbase": "0xFc417779C6805A80Fe8e788335ffD9F326AA5893",
      "mainPubKey": "0x02caaee86e678fe50e4dcbfb5c44c34068c98d4beb5e48ec48873b66735d963686",
      "blsPubKey": "0xaf1f6e9853a8b5ed698d0b4769b023f5a6e417809c9ca981f063d94ab81d1b9028ad675fd6a0e2614cd62b719861ff09127500f97b7277dfc83a5f4b3711736c9a188631f2f1e8216be744c6af64aaa3751dc3c24728dd595ef9605b466e065d",
      "token": "0xb35bf645f1ab93600000",
      "role": 2,
      "status": 1
    }
  },
  "version": 1,
  "number": "0x0",
  "gasUsed": "0x0",
  "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
  1. 执行启动命令
  2. windows系统(需要编写bat):
    1 在node目录新建bat文件,如node.bat
    2 使用文档编辑器打开node.bat并写入如下内容
         @echo off
         set DIRNAME=%~dp0
         %DIRNAME%/go-youchain-windows-4.0-amd64.exe  -genesis %DIRNAME%/genesis.json -datadir %DIRNAME%/data -rpc.port 8283 -p2p.port 8284 -pprof.port 3209 -constype 1 -mine
         pause
    
    3 直接打开node.bat,启动节点
  3. Linux
          ./go-youchain-linux-amd64 -genesis ./genesis.json -datadir ./data -rpc.port 8283 -p2p.port 8284 -pprof.port 3209 -constype 1 -mine
    
  4. Mac系统
          ./you-Darwin  -genesis ./genesis.json -datadir ./data -rpc.port 8283 -p2p.port 8284 -pprof.port 3209 -constype 1 -mine
    

启动参数简介

参数 说明
genesis 创世区块原始数据
datadir 数据存放目录
rpc.port JSON-RPC接口的端口
p2p.port p2p端口
pprof.port pprof的端口
constype 共识方式 可选值【0:Caravel 1:单节点共识】
mine 是否开启挖矿,提供即代表true