tron-搭建私有超级节点和FullNode节点

准备工作

  1. 具备至少两个钱包账户的私钥与地址;
  2. 至少部署一个SuperNode用于出块;
  3. 部署任意数量的FullNode节点用于同步区块、广播交易;
  4. SuperNode与FullNode组成了私有网络,可以进行网络发现、区块同步、广播交易;

部署超级节点

  1. 下载 private_net_config.conf

https://raw.githubusercontent.com/tronprotocol/tron-deployment/master/private_net_config.conf

  1. 在localwitness中添加自己的私钥
    localwitness
  2. 设置genesis.block.witnesses为私钥对应的地址
    witnesses
  3. 设置p2p.version为除了11111之外的任意正整数
    version
  4. 第1个SR设置needSyncCheck为false,其他可以设置为true
    needSyncCheck
  5. 设置node.discovery.enable为true
    node.discovery.enable
  6. 运行部署脚本
nohup java -Xmx6g -XX:+HeapDumpOnOutOfMemoryError -jar FullNode.jar  --witness  -c private_net_config.conf &>/dev/null &
命令行参数说明:
--witness: 启动witness功能,i.e.: --witness
--log-config: 指定日志配置文件路径,i.e.: --log-config logback.xml
-c: 指定配置文件路径,i.e.: -c config.conf

部署FullNode节点

  1. 下载private_net_config.conf

https://raw.githubusercontent.com/tronprotocol/tron-deployment/master/private_net_config.conf

  1. 设置seed.node ip.list 为SR的ip地址和端口
    seed.node ip.list
  2. 设置p2p.version与超级节点的p2p.version一致
    p2p.version
  3. 设置genesis.block 与SR中的genesis.block配置一致
    genesis.block
  4. 设置needSyncCheck为true
    needSyncCheck
  5. 设置node.discovery.enable 为true
    node.discovery.enable
  6. 如果FullNode和SR部署在同一台机器上,则需要修改listen.port、http端口、rpc 端口运行部署脚本
    listen.port
    http端口、rpc 端口

supernode.conf

net {
  type = mainnet
  # type = testnet
}

storage {
  # Directory for storing persistent data

  db.version = 2,
  db.engine = "LEVELDB",
  db.directory = "database",
  index.directory = "index",

  # You can custom these 14 databases' configs:

  # account, account-index, asset-issue, block, block-index,
  # block_KDB, peers, properties, recent-block, trans,
  # utxo, votes, witness, witness_schedule.

  # Otherwise, db configs will remain defualt and data will be stored in
  # the path of "output-directory" or which is set by "-d" ("--output-directory").

  # Attention: name is a required field that must be set !!!
  properties = [
    //    {
    //      name = "account",
    //      path = "storage_directory_test",
    //      createIfMissing = true,
    //      paranoidChecks = true,
    //      verifyChecksums = true,
    //      compressionType = 1,        // compressed with snappy
    //      blockSize = 4096,           // 4  KB =         4 * 1024 B
    //      writeBufferSize = 10485760, // 10 MB = 10 * 1024 * 1024 B
    //      cacheSize = 10485760,       // 10 MB = 10 * 1024 * 1024 B
    //      maxOpenFiles = 100
    //    },
    //    {
    //      name = "account-index",
    //      path = "storage_directory_test",
    //      createIfMissing = true,
    //      paranoidChecks = true,
    //      verifyChecksums = true,
    //      compressionType = 1,        // compressed with snappy
    //      blockSize = 4096,           // 4  KB =         4 * 1024 B
    //      writeBufferSize = 10485760, // 10 MB = 10 * 1024 * 1024 B
    //      cacheSize = 10485760,       // 10 MB = 10 * 1024 * 1024 B
    //      maxOpenFiles = 100
    //    },
  ]

}

# this part of config is used to node discovery.
node.discovery = {
  enable = true  # you should set this entry value with ture if you want your node can be discovered by other node.
  persist = true  # this entry is used to determined to whether storing the peers in the database or not.
  bind.ip = ""
  external.ip = 127.0.0.1
}

# this part of config is used to set backup node for witness service.
node.backup {
  port = 10001
  priority = 8
  members = [
  ]
}

node {
  # trust node for solidity node
  # trustNode = "ip:port"
  trustNode = "127.0.0.1:50051"

  # expose extension api to public or not
  walletExtensionApi = true

  listen.port = 16666

  connection.timeout = 2

  tcpNettyWorkThreadNum = 0

  udpNettyWorkThreadNum = 1

  # Number of validate sign thread, default availableProcessors / 2
  # validateSignThreadNum = 16

  maxActiveNodes = 30

  maxActiveNodesWithSameIp = 2

  minParticipationRate = 0

  # check the peer data transfer ,disconnect factor
  disconnectNumberFactor = 0.4
  maxConnectNumberFactor = 0.8
  receiveTcpMinDataLength = 2048
  isOpenFullTcpDisconnect = true

  p2p {
    version = 98766789 # 11111: mainnet; 20180622: testnet; you can set other number when you deploy one private net, but the node must have the same number in some private net. 
  }

  active = [
    # Active establish connection in any case
    # Sample entries:
    # "ip:port",
    # "ip:port"
  ]

  passive = [
    # Passive accept connection in any case
    # Sample entries:
    # "ip:port",
    # "ip:port"
  ]

  http {
    fullNodePort = 26667
    solidityPort = 26668
  }

  rpc {
    port = 16669

    # Number of gRPC thread, default availableProcessors / 2
    # thread = 16

    # The maximum number of concurrent calls permitted for each incoming connection
    # maxConcurrentCallsPerConnection =

    # The HTTP/2 flow control window, default 1MB
    # flowControlWindow =

    # Connection being idle for longer than which will be gracefully terminated
    maxConnectionIdleInMillis = 60000

    # Connection lasting longer than which will be gracefully terminated
    # maxConnectionAgeInMillis =

    # The maximum message size allowed to be received on the server, default 4MB
    # maxMessageSize =

    # The maximum size of header list allowed to be received, default 8192
    # maxHeaderListSize =

    # Transactions can only be broadcast if the number of effective connections is reached.
    minEffectiveConnection = 0
  }

}



seed.node = {
  # List of the seed nodes. This is used to enable the node can connect when join one net at first.
  # If you deploy one private net, you must add some "ip:port" here for other node connecting.
  # Seed nodes are stable full nodes, and the first SuperNode must be inclued in.
  # example:
  # ip.list = [
  #   "ip:port",
  #   "ip:port"
  # ]
  ip.list = [
  ]
}

genesis.block = {
  # Reserve balance
  assets = [
    {
      accountName = "Zion"
      accountType = "AssetIssue"
      address = "TWVQLxQHLDrtSnuggVNNrJbvGzPVoNde5j"
      balance = "95000000000000000"
    }
  ]

  witnesses = [
    {
      address: TKFgZSa5Qc3aegpGN6uAN8Yhs328yFSq5X,
      url = "http://tronstudio.com",
      voteCount = 10000
    }
  ]

  timestamp = "0" #2017-8-26 12:00:00

  parentHash = "957dc2d350daecc7bb6a38f3938ebde0a0c1cedafe15f0edae4256a2907449f6"
}

localwitness = [
  1e588f360499a2f09219e93ae65f0d2ef4aaa8d343f481d3e7eee13a6b47a0b2  # you must enable this value and the witness address are match.
]

#localwitnesskeystore = [
#  "src/main/resources/localwitnesskeystore.json"  # if you do not set the localwitness above, you must set this value.Otherwise,your SuperNode can not produce the block. 
#]

block = {
  needSyncCheck = false # first node : false, other : true
  maintenanceTimeInterval = 300000 // 1 day: 86400000(ms), 6 hours: 21600000(ms)
  proposalExpireTime = 600000
}


vm = {
  supportConstant = true
  minTimeRatio = 0.0
  maxTimeRatio = 5.0
}

committee = {
  allowCreationOfContracts = 1  //mainnet:0 (reset by committee),test:1
  #allowAdaptiveEnergy = 1  //mainnet:0 (reset by committee),test:1
  allowUpdateAccountName = 1
  allowSameTokenName = 1
  allowDelegateResource = 1
  allowTvmTransferTrc10 = 1
  allowTvmConstantinople = 1
  multiSignFee = 1
  allowMultiSign = 1
  updateAccountPermissionFee = 1
}

event.subscribe = {
  native = {
    useNativeQueue = true // if true, use native message queue, else use event plugin.
    bindport = 5555 // bind port
    sendqueuelength = 1000 //max length of send queue
  }

  path = "" // absolute path of plugin
  server = "" // target server address to receive event triggers
  dbconfig = "" // dbname|username|password
  contractParse = true,
  topics = [
    {
      triggerName = "block" // block trigger, the value can't be modified
      enable = false
      topic = "block" // plugin topic, the value could be modified
    },
    {
      triggerName = "transaction"
      enable = false
      topic = "transaction"
    },
    {
      triggerName = "contractevent"
      enable = false
      topic = "contractevent"
    },
    {
      triggerName = "contractlog"
      enable = false
      topic = "contractlog"
    },
    {
      triggerName = "solidity" // solidity block event trigger, the value can't be modified
      enable = true            // the default value is true
      topic = "solidity"
    }
  ]

  filter = {
    fromblock = "" // the value could be "", "earliest" or a specified block number as the beginning of the queried range
    toblock = "" // the value could be "", "latest" or a specified block number as end of the queried range
    contractAddress = [
      "" // contract address you want to subscribe, if it's set to "", you will receive contract logs/events with any contract address.
    ]

    contractTopic = [
      "" // contract topic you want to subscribe, if it's set to "", you will receive contract logs/events with any contract topic.
    ]
  }
}

fullnode.conf

net {
  type = mainnet
  # type = testnet
}

storage {
  # Directory for storing persistent data

  db.version = 2,
  db.engine = "LEVELDB",
  db.directory = "database",
  index.directory = "index",

  # You can custom these 14 databases' configs:

  # account, account-index, asset-issue, block, block-index,
  # block_KDB, peers, properties, recent-block, trans,
  # utxo, votes, witness, witness_schedule.

  # Otherwise, db configs will remain defualt and data will be stored in
  # the path of "output-directory" or which is set by "-d" ("--output-directory").

  # Attention: name is a required field that must be set !!!
  properties = [
    //    {
    //      name = "account",
    //      path = "storage_directory_test",
    //      createIfMissing = true,
    //      paranoidChecks = true,
    //      verifyChecksums = true,
    //      compressionType = 1,        // compressed with snappy
    //      blockSize = 4096,           // 4  KB =         4 * 1024 B
    //      writeBufferSize = 10485760, // 10 MB = 10 * 1024 * 1024 B
    //      cacheSize = 10485760,       // 10 MB = 10 * 1024 * 1024 B
    //      maxOpenFiles = 100
    //    },
    //    {
    //      name = "account-index",
    //      path = "storage_directory_test",
    //      createIfMissing = true,
    //      paranoidChecks = true,
    //      verifyChecksums = true,
    //      compressionType = 1,        // compressed with snappy
    //      blockSize = 4096,           // 4  KB =         4 * 1024 B
    //      writeBufferSize = 10485760, // 10 MB = 10 * 1024 * 1024 B
    //      cacheSize = 10485760,       // 10 MB = 10 * 1024 * 1024 B
    //      maxOpenFiles = 100
    //    },
  ]

}

# this part of config is used to node discovery.
node.discovery = {
  enable = true  # you should set this entry value with ture if you want your node can be discovered by other node.
  persist = true  # this entry is used to determined to whether storing the peers in the database or not.
  bind.ip = ""
  external.ip = null
}

# this part of config is used to set backup node for witness service.
node.backup {
  port = 10001
  priority = 8
  members = [
  ]
}

node {
  # trust node for solidity node
  # trustNode = "ip:port"
  trustNode = "127.0.0.1:50051"

  # expose extension api to public or not
  walletExtensionApi = true

  listen.port = 26666

  connection.timeout = 2

  tcpNettyWorkThreadNum = 0

  udpNettyWorkThreadNum = 1

  # Number of validate sign thread, default availableProcessors / 2
  # validateSignThreadNum = 16

  maxActiveNodes = 30

  maxActiveNodesWithSameIp = 2

  minParticipationRate = 0

  # check the peer data transfer ,disconnect factor
  disconnectNumberFactor = 0.4
  maxConnectNumberFactor = 0.8
  receiveTcpMinDataLength = 2048
  isOpenFullTcpDisconnect = true

  p2p {
    version = 98766789 # 11111: mainnet; 20180622: testnet; you can set other number when you deploy one private net, but the node must have the same number in some private net. 
  }

  active = [
    # Active establish connection in any case
    # Sample entries:
    # "ip:port",
    # "ip:port"
  ]

  passive = [
    # Passive accept connection in any case
    # Sample entries:
    # "ip:port",
    # "ip:port"
  ]

  http {
    fullNodePort = 8090
    solidityPort = 26668
  }

  rpc {
    port = 26669

    # Number of gRPC thread, default availableProcessors / 2
    # thread = 16

    # The maximum number of concurrent calls permitted for each incoming connection
    # maxConcurrentCallsPerConnection =

    # The HTTP/2 flow control window, default 1MB
    # flowControlWindow =

    # Connection being idle for longer than which will be gracefully terminated
    maxConnectionIdleInMillis = 60000

    # Connection lasting longer than which will be gracefully terminated
    # maxConnectionAgeInMillis =

    # The maximum message size allowed to be received on the server, default 4MB
    # maxMessageSize =

    # The maximum size of header list allowed to be received, default 8192
    # maxHeaderListSize =

    # Transactions can only be broadcast if the number of effective connections is reached.
    minEffectiveConnection = 0
  }

}



seed.node = {
  # List of the seed nodes. This is used to enable the node can connect when join one net at first.
  # If you deploy one private net, you must add some "ip:port" here for other node connecting.
  # Seed nodes are stable full nodes, and the first SuperNode must be inclued in.
  # example:
  # ip.list = [
  #   "ip:port",
  #   "ip:port"
  # ]
  ip.list = [
    "127.0.0.1:16666"
  ]
}

genesis.block = {
  # Reserve balance
  assets = [
    {
      accountName = "Zion"
      accountType = "AssetIssue"
      address = "TWVQLxQHLDrtSnuggVNNrJbvGzPVoNde5j"
      balance = "95000000000000000"
    }
  ]

  witnesses = [
    {
      address: TKFgZSa5Qc3aegpGN6uAN8Yhs328yFSq5X,
      url = "http://tronstudio.com",
      voteCount = 10000
    }
  ]

  timestamp = "0" #2017-8-26 12:00:00

  parentHash = "957dc2d350daecc7bb6a38f3938ebde0a0c1cedafe15f0edae4256a2907449f6"
}

localwitness = [
  9b9b8bd8ee343d43c5889ec06b3c4e7fe723211a73be18119c7729107b4fcdc8  # you must enable this value and the witness address are match.
]

#localwitnesskeystore = [
#  "src/main/resources/localwitnesskeystore.json"  # if you do not set the localwitness above, you must set this value.Otherwise,your SuperNode can not produce the block. 
#]

block = {
  needSyncCheck = true # first node : false, other : true
  maintenanceTimeInterval = 300000 // 1 day: 86400000(ms), 6 hours: 21600000(ms)
  proposalExpireTime = 600000
}


vm = {
  supportConstant = true
  minTimeRatio = 0.0
  maxTimeRatio = 5.0
}

committee = {
  allowCreationOfContracts = 1  //mainnet:0 (reset by committee),test:1
  #allowAdaptiveEnergy = 1  //mainnet:0 (reset by committee),test:1
  allowUpdateAccountName = 1
  allowSameTokenName = 1
  allowDelegateResource = 1
  allowTvmTransferTrc10 = 1
  allowTvmConstantinople = 1
  multiSignFee = 1
  allowMultiSign = 1
  updateAccountPermissionFee = 1
}

event.subscribe = {
  native = {
    useNativeQueue = true // if true, use native message queue, else use event plugin.
    bindport = 6555 // bind port
    sendqueuelength = 1000 //max length of send queue
  }

  path = "" // absolute path of plugin
  server = "" // target server address to receive event triggers
  dbconfig = "" // dbname|username|password
  contractParse = true,
  topics = [
    {
      triggerName = "block" // block trigger, the value can't be modified
      enable = false
      topic = "block" // plugin topic, the value could be modified
    },
    {
      triggerName = "transaction"
      enable = false
      topic = "transaction"
    },
    {
      triggerName = "contractevent"
      enable = false
      topic = "contractevent"
    },
    {
      triggerName = "contractlog"
      enable = false
      topic = "contractlog"
    },
    {
      triggerName = "solidity" // solidity block event trigger, the value can't be modified
      enable = true            // the default value is true
      topic = "solidity"
    }
  ]

  filter = {
    fromblock = "" // the value could be "", "earliest" or a specified block number as the beginning of the queried range
    toblock = "" // the value could be "", "latest" or a specified block number as end of the queried range
    contractAddress = [
      "" // contract address you want to subscribe, if it's set to "", you will receive contract logs/events with any contract address.
    ]

    contractTopic = [
      "" // contract topic you want to subscribe, if it's set to "", you will receive contract logs/events with any contract topic.
    ]
  }
}

参考文档
https://tronprotocol.github.io/documentation-zh/architecture/network/#tron 官方教程
https://github.com/tronprotocol/tron-deployment 官方配置文件

猜你喜欢

转载自blog.csdn.net/u012387141/article/details/108658091