Skip to content

HOW TO SETUP TTC SLAVE NETWORK

Liu Peng edited this page Aug 1, 2019 · 16 revisions

DISCLAIMER: TTC Foundation makes its contribution on a voluntary basis as a member of the TTC community and is not responsible for ensuring the overall performance of the software or any related applications. We make no representation, warranty, guarantee or undertaking in respect of the software or any related documentation, whether expressed or implied, including but not limited to the warranties or merchantability, fitness for a particular purpose and noninfringement. In no event shall we be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or documentation or the use or other dealings in the software or documentation. Any test results or performance figures are indicative and will not reflect performance under all conditions. Any reference to any third party or third-party product, service or other resource is not an endorsement or recommendation by TTC Foundation We are not responsible, and disclaim any and all responsibility and liability, for your use of or reliance on any of these resources. Third-party resources may be updated, changed or terminated at any time, so the information here may be out of date or inaccurate.

WARNING! All Address/Hash in this document is sample. Do NOT use them.

Step 0 : Preparation

Download and build gttc from branch sc-t1, which is the gttc version for this t1 Slave Network. You can find more information about how to build gttc on Building GTTC.

Notice:

  1. Make sure you are building sc-t1, not release/v0.2.0 (Mainnet still use relase/v0.2.0)
  2. After building gttc, to avoid further confusion, rename 'gttc' to 'gttc-t1', (gttc-t1 is used for deploy the slave network.)

Afterward, you need to create a new miner address for slave network. If you are operating more than one Representative node, please make sure to build one new address for each Representative node. You can create miner address using TTC connect or the following command:

./gttc-t1 --datadir your_slave_network_node_dir/ account new

Step 1 : Setup Coinbase for Slave Network

Each Representative should assign a miner address to delegate in order to mine on t1 slave network. This can be done through a customized transaction, signed by a Representative.

Sample Transaction (This need to be done by Representatives on Mainnet console)

> eth.sendTransaction({from:eth.accounts[0],to:"76378fc59f3c5a69ee5ba6c23d525ae9f8421992",value:web3.toWei(10),data:web3.toHex("ufo:1:sc:setcb:0x3210000000000000000000000000000000000000000000000000000000000000:")})

Notice: replace "76378fc59f3c5a69ee5ba6c23d525ae9f8421992" by your own slave network miner address, which created in step 0.

Data Description:

// representative address unlocked in console

from: eth.accounts[0]

// a slave network miner address, delegated by a representative. Replace this address with your own.

to: 76378fc59f3c5a69ee5ba6c23d525ae9f8421992

// initialize fee for setting up the slave network coinbase. Please keep this in the miner address. Do not whithdraw unless you change the slave network miner address.

value: web3.toWei(10)

// hash name of t1 slave network

data: web3.toHex("ufo:1:sc:setcb:0x3210000000000000000000000000000000000000000000000000000000000000:")

Notice:

  1. The balance of slave network miner address on t1 slave network will always be zero (0). Hence, do NOT use this address to operate any other transactions on slave network.
  2. The slave network miner address will also used to send confirmation of the slave network transactions. If you want to withdraw the miner rewards from the slave network miner address on main network, we recommend you to leave at least 10 TTC for the system custom transaction.

Step 2 : Start Running Slave Network

Sample Command

./gttc-t1 --datadir your_slave_network_node_dir/ --port 30312 --sca --sca.mainrpcaddr "10.0.142.0" --sca.mainrpcport 8503 -unlock '5320d9e372c2d51cf1f166384142ace1198e32a2' --password pass.txt --mine

RPC server

If you do not have local RPC server, please choose one to replace the ip and port in sample code .

  • IP:35.190.239.155 Port:80/8501/8502/8503/8504
  • IP:34.77.28.121 Port:80/8501/8502
  • IP:34.74.182.148 Port:80/8501/8502
  • IP:34.85.14.244 Port:80/8501/8502/8503/8504

If you prefer to use local RPC server(recommend), please make sure alien,eth,net,web3 is contained in --rpcapi

Slave Network enode list (NOT Mainnet)

admin.addPeer("enode://61f22feba7bd39147630431a0001e4348d86c6cf78814901695d00f37601e66ab4e0c01d3eee21dc5b3619639d84a117d59bf6231bd8632cda7d3ee0e3452beb@35.200.80.194:30311")
admin.addPeer("enode://98fd1836015ac436fe29c39ccc14caf09fb174246398c4625c1fa2b83b27f25c7dcd0febc901b2f9139d39482ed0f97eecf8245111d230337d25cf93a0b1c302@35.200.80.194:30312")
admin.addPeer("enode://59cc31fc86023972df14c0238b3a70f89127c6c47051440ed926bb22d380a888246fda6a961bc03af5127d875ccf1351f03ac888c7df3f702f543feae55477aa@35.200.80.194:30313")
admin.addPeer("enode://3ffc7514f9528a313345836ea94b19a4c54d2e034139adcf3372379cd29bef793528cb9c1b6b23133322a01b8b21cc745a5cd6d994fe6115ae6b4cd8f0b94031@35.200.80.194:30314")

admin.addPeer("enode://3072c9ac8a0890119958ba6a1cc1825f65470e1f1dea17252bdb412e93e48cdb8f849d01d80af0df2fb8909c000980758211f9e49fddb2979dff9f74313f3336@35.205.95.24:30311")
admin.addPeer("enode://221c425050509da7e30dab69c78c30a32490677cd7389e80ae8c24251a9402a8b4d06703469c6227369d4500a506f6df62bdb42606c22384444d2a05e06388fc@35.205.95.24:30312")
admin.addPeer("enode://e0f6d91578989531d86b7e7c44a387e770b3987ba441fe06c396dbc29dbcde46c1c93d8ea28061765dbd050291fcbf1d5587d0d74d08c30b469cae8bc1aa80de@35.205.95.24:30313")
admin.addPeer("enode://1586bebc2524d92669f0bd93a2e509812d66cc53d397fbdc36b7986cff910b7b2401407462f5558fcfc7b68f36a8fcece5575a9d628aa7a0bf20238f331dea12@35.205.95.24:30314")

admin.addPeer("enode://ca535274576024a01a27d95c5adf708c93c741cefbde5acbceb382186e4dcb840129a66d358df95806d412ffb24aae55b223ff5ee5e42b034530d4f20132bc67@35.243.161.121:30311")
admin.addPeer("enode://e43bbd2461e0f899602e49a2cfc82d3601271d5b04050befc8586edf6fbd89b78deb214e0955caf82b684f5124bc7b695006876768352459b14b769b7f482016@35.243.161.121:30312")
admin.addPeer("enode://6e021bd4c8a720529096c943e603ec8cde3d8ab2852e4b4157f2214bff2ee69bfbe5efb797340f44278c3b1f622bc2a3d1e0a4f8bbb23ee8a317617e6fbb9e03@35.243.161.121:30313")
admin.addPeer("enode://adaa6a12dfa1360d178fbff577a13e20299a7f1a1a54419c030ad9136221094d4ac3ecb6ea44fb8f05d40e8b24d88632f8b5f6a58e20fd96c0a82238e96919f9@35.243.161.121:30314")

Arguments Description

--datadir // the directory of your node
--port // listen port of your node
--sca // this node belongs to slave network
--unlock // slave network miner address
--password // password for this keystore
--mine // mine
--sca.mainrpcaddr // Address of main network rpc node
--sca.mainrpcport // Port of main network rpc node

If your slave network node is running properly, you will see the log information as below:

INFO [07-22|09:24:05] Maximum peer count ETH=25 LES=0 total=25
INFO [07-22|09:24:05] Starting peer-to-peer node instance=gttc/v0.2.0-sidechain-stable/linux-amd64/go1.11.5
INFO [07-22|09:24:05] Allocated cache and file handles database=/home/peng/scnet/node1/gttc/chaindata cache=768 handles=512
INFO [07-22|09:24:05] Writing default main-net genesis block
INFO [07-22|09:24:05] Persisted trie from memory database nodes=0 size=0.00B time=3.422µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [07-22|09:24:05] Initialised chain configuration config="{ChainID: 8123 Homestead: 1 EIP150: 2 EIP155: 3 EIP158: 3 Byzantium: 4 Constantinople: <nil> Engine: alien}"
INFO [07-22|09:24:05] Initialised alien configuration config="{Period:1 Epoch:201600 MaxSignerCount:21 MinVoterBalance:+100000000000000000000 GenesisTimestamp:1554004800 SelfVoteSigners:[] SideChain:false MCRPCClient:<nil> PBFTEnable:false TrantorBlock:+5 TerminusBlock:<nil> LightConfig:<nil>}"
INFO [07-22|09:24:05] Maximum peer count ETH=25 LES=0 total=25
INFO [07-22|09:24:05] Starting peer-to-peer node instance=gttc/v0.2.0-sidechain-stable/linux-amd64/go1.11.5
INFO [07-22|09:24:05] Allocated cache and file handles database=/home/peng/scnet/node1/gttc/chaindata cache=768 handles=512
INFO [07-22|09:24:05] Writing default main-net genesis block
INFO [07-22|09:24:05] Persisted trie from memory database nodes=0 size=0.00B time=3.422µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [07-22|09:24:05] Initialised chain configuration config="{ChainID: 8123 Homestead: 1 EIP150: 2 EIP155: 3 EIP158: 3 Byzantium: 4 Constantinople: <nil> Engine: alien}"
INFO [07-22|09:24:05] Initialised alien configuration config="{Period:1 Epoch:201600 MaxSignerCount:21 MinVoterBalance:+100000000000000000000 GenesisTimestamp:1554004800 SelfVoteSigners:[] SideChain:false MCRPCClient:<nil> PBFTEnable:false TrantorBlock:+5 TerminusBlock:<nil> LightConfig:<nil>}"
INFO [07-22|09:24:05] Initialising TTC protocol versions="[63 62]" network=8123
INFO [07-22|09:24:05] Loaded most recent local header number=0 hash=aed8dd…a45a9d td=1
INFO [07-22|09:24:05] Loaded most recent local full block number=0 hash=aed8dd…a45a9d td=1
INFO [07-22|09:24:05] Loaded most recent local fast block number=0 hash=aed8dd…a45a9d td=1
INFO [07-22|09:24:05] Regenerated local transaction journal transactions=0 accounts=0
INFO [07-22|09:24:05] Starting P2P networking
INFO [07-22|09:24:07] UDP listener up self=enode://61f22feba7bd39147630431a0001e4348d86c6cf78814901695d00f37601e66ab4e0c01d3eee21dc5b3619639d84a117d59bf6231bd8632cda7d3ee0e3452beb@[::]:30311
INFO [07-22|09:24:07] RLPx listener up self=enode://61f22feba7bd39147630431a0001e4348d86c6cf78814901695d00f37601e66ab4e0c01d3eee21dc5b3619639d84a117d59bf6231bd8632cda7d3ee0e3452beb@[::]:30311
INFO [07-22|09:24:07] IPC endpoint opened url=/home/peng/scnet/node1/gttc.ipc
INFO [07-22|09:24:07] HTTP endpoint opened url=http://localhost:8501 cors= vhosts=localhost
INFO [07-22|09:24:09] Unlocked account address=t1e52eA7b1841D3B98775599e8eA28b3Af2C4b72CD
INFO [07-22|09:24:09] Transaction pool price threshold updated price=500000000000
INFO [07-22|09:24:09] Etherbase automatically configured address=t1e52eA7b1841D3B98775599e8eA28b3Af2C4b72CD
INFO [07-22|09:24:09] Starting mining operation
INFO [07-22|09:24:09] Commit new mining work number=1 txs=0 uncles=0 elapsed=185.995µs
INFO [07-22|09:24:09] Commit new mining work number=1 txs=0 uncles=0 elapsed=215.742µs
WARN [07-22|09:24:09] Block sealing failed err=unauthorized
INFO [07-22|09:24:10] Commit new mining work number=1 txs=0 uncles=0 elapsed=186.401µs

Notice

  1. Till now, the slave network will start to seal block. When the Representative of main network have the right to seal one block, the slave network miner, which delegate that main network Representative also have right to seal blocks.
  2. The block height shown here is the block height of this slave network, not of the main network.
  3. Regarding the main network RPC node address, we recommend you to use your own RPC node address. (If you wish not to use your own, you can use the RPC node address provided by us.)

Step 3 : Add Slave Network to Main Network

This step includes a proposal and a declaration process to add a slave network to the main network.

Proposal

A Representative can propose to add slave network by making a proposal transaction AND sending the proposal deposit. See an example below.

Sample Proposal Transaction (This Not need to be done by Representatives)

eth.sendTransaction({from:eth.accounts[0],to:eth.accounts[0],value:0,data:web3.toHex("ufo:1:event:proposal:proposal_type:4:sccount:3:screward:10:schash:0x3210000000000000000000000000000000000000000000000000000000000000:vlcnt:10")})

Data Description:

proposal_type:4 // 4 means this is a proposal to add a slave network
sccount:3 // the # of blocks a miner should seal in each main network period
screward:10 // 10 means the miner rewards for this slave network is 10/1000 of main network
schash:0x3210000000000000000000000000000000000000000000000000000000000000 // hash name of slave network
vlcnt:10 // the loop length of this proposal before conclusion. this number will be large in real main network.

Declaration

All the Representatives will declare their position on the proposal by making a declaration transaction containing the transaction hash of the proposal transaction.

The proposal passes only if

more than two thirds (2/3) of the

the confirm declare on this proposal more than 2/3, this proposal will be success.

2/3 is the # of votes delegated to Representatives, not the headcount of Representatives

Sample Declaration Transaction (This need to be done by Representatives on Mainnet console)

eth.sendTransaction({from:eth.accounts[0],to:eth.accounts[0],value:0,data:web3.toHex("ufo:1:event:declare:hash:t0dde2f9ae9d23611bd4bc9b1f999e4acb600fe6f200266e82682e7d8c0b2214d3:decision:yes")})

Data Description:

// hash value of the proposal transaction
hash:t019936d32dd513ecfca27d616aac04e3ed5dff48d5f4118eb57c63d8ff8ccb3b0
// the declaration about the proposal. If a Representative fails to declare, it is considered as 'no' automatically.
decision:yes

Notice:

  • Do NOT use any hash shown above, as they are dummy hashes generated for the sample.

Step 4 : Charge tgas for Slave Network

This step includes a proposal and a declaration process to charge tgas to a newly added slave network. tgas is a TST-20 token used to pay for the usage of slave networks on TTC blockchain.

Proposal

At the launching, the slave network does not hold any tgas, which is required for the slave network to run. Hence if a developer wants to utilize the slave network, he/she must request Representatives to first charge tgas on slave network.

Sample Proposal Transaction (Not need do)

eth.sendTransaction({from:eth.accounts[0],to:eth.accounts[0],value:0,data:web3.toHex("ufo:1:event:proposal:proposal_type:8:scrt:0x74883A82Eb05c1EFfF9C40F6101b7D8E7DE52504:scrf:15000:scrr:100:scrl:1000000:schash:0x4210000000000000000000000000000000000000000000000000000000000000:vlcnt:10")})

Data Description:

proposal_type:8 // Revised: 8 mean that this is a proposal to charge tgas to a slave network
scrt:0x74883A82Eb05c1EFfF9C40F6101b7D8E7DE52504 // target address on t1 slave network
scrf:15000 //  amount of TTC to charge
scrr:100 // tgas/TTC rate. 100 means when you charge 1 TTC, you will get 100 tgas on t1 slave network
scrl:1000000 // the # of rounds, which the slave network could operate with the charged tgas
schash:0x4210000000000000000000000000000000000000000000000000000000000000 // hash name of side chain
vlcnt:10 // the loop length of this proposal before conclusion

Declaration

The step for the declaration is same as Step 3 : Add Slave Network to Main Network

Sample Declaration

eth.sendTransaction({from:eth.accounts[0],to:eth.accounts[0],value:0,data:web3.toHex("ufo:1:event:declare:hash:t019936d32dd513ecfca27d616aac04e3ed5dff48d5f4118eb57c63d8ff8ccb3b0:decision:yes")})
Clone this wiki locally