Process of Sidechain Construction

Build Elastos node

1. Check Go Version
Check the golang version. Make sure they're the following version number or above:
1
$ go version
2
go version go1.17
Copied!
If you cannot see the version number, an error must have occurred when installing.
2. Clone Source Code
Make sure you're in the following folder:
1
$ git clone https://github.com/elastos/Elastos.ELA.git
Copied!
If clone works successfully, you should see the folder structure appear similar to Elastos.ELA/Makefile.
3. Make
Build the node:
1
$ cd Elastos.ELA
2
$ make
Copied!
If you don't see an error message, then congratulations! You've made the ELA full node.
4. Configuration
If you would like to connect to regnet, do the following:
1
{
2
"Configuration": {
3
"DisableDNS": true, // DisableDNS. Disable the DNS seeding function.
4
"PrintLevel": 0, // Log level. Level 0 is the highest, 5 is the lowest
5
"EnableRPC": true, // Enable the RPC service
6
"DPoSConfiguration": {
7
"SignTolerance": 5, // The time interval of consensus in seconds
8
"OriginArbiters": [ // The publickey list of arbiters before CRCOnlyDPOSHeight
9
"038eba1db314e7569aafc62a3c0fd1de9fe6359f88962521768a37786fce62dd37",
10
"02fb5528297b3c43e015d7e20a62b2fc70592cb0b08dfdec7ff95bcd11ff5a5fe6",
11
"03a9d3bbed3db04a4a6c167514b6a4e187b3eaeb3b8d4edd9a618d27b9fe4a0179",
12
"03022428a02e52ef0dd6adc1c7d95ea9cd93854057e9dd6a48486dc536ece71603",
13
"0251fc966a08f0e097711f54fa22ef69c90510ea8e8cf4431e8167c221cf3c7b86"
14
],
15
"PublicKey": "0342eeb0d664e2507d732382c66d0eedbd0a0f989179fd33d71679aa607d5d3b57",
16
"CandidatesCount": 36, // The count of candidates
17
"MaxInactiveRounds": 180, // Max Inactive Rounds
18
"MaxLogsSize": 0, // Max total logs size in MB
19
"CRCArbiters": [
20
"0342eeb0d664e2507d732382c66d0eedbd0a0f989179fd33d71679aa607d5d3b57",
21
"02cf7e80d1a1a76ab6259e0abdf2848c618655393f1fa3328901f80949ebed1476",
22
"02514cab9af25ee95e102b5c3a7c862b16f24b2de88d0110176e66ea379dfbc7a9",
23
"0322766f133141d2c9d82fb7e331ea6ec7c52e14de2c76bea0f59e479a1408fee3",
24
"02280ff02ec55bda6c40eae18d7f8c8830be950b26959cae976025da2252c85434",
25
"02fc7e75278b3cda28245c0cb567081c6ba08ab560a9c783ca3032014fe8d3b1e2"
26
],
27
"MaxPerLogSize": 0, // Max per log file size in MB
28
"EnableArbiter": true, // EnableArbiter enables the arbiter service.
29
"InactivePenalty":1000000000, // InactivePenalty defines the penalty amount the producer takes.
30
"IllegalPenalty":2000000000,
31
"NormalArbitratorsCount": 12, // The count of voted arbiters
32
"PreConnectOffset": 5, // PreConnectOffset defines the offset blocks to pre-connect to the block producers.
33
"DPoSPort": 10119,
34
"IPAddress": "127.0.0.1",
35
"Magic": 2019000, // Magic Number:Segregation for different subnet. No matter the port number, as long as the magic number not matching, nodes cannot talk to each others
36
"EmergencyInactivePenalty": 0, // EmergencyInactivePenalty defines the penalty amount the emergency producer takes.
37
"RandomCandidatePeriod": 108,
38
"MaxInactiveRoundsOfRandomNode": 108, // MaxInactiveRounds defines the maximum inactive rounds before producer takes penalty.
39
"DPOSNodeCrossChainHeight": 3050, //Dpos node cross-chain support start height
40
"NoCRCDPOSNodeHeight": 3050,
41
"DposV2StartHeight": 800, // Dpos version 2 start height
42
"RevertToPOWNoBlockTime": 60480003600, //Revert to POW no block time
43
"StopConfirmBlockTime": 60480000000, // Stop confirm block time
44
"RevertToPOWStartHeight": 3050 // Revert to POW start height
45
},
46
"MaxLogsSize": 0,
47
"HttpJsonPort": 10116, // RPC port number
48
"MaxPerLogSize": 0,
49
"HttpRestStart": true, // Whether to enable the REST service
50
"CRConfiguration": {
51
"DutyPeriod": 1500, // CRDutyPeriod defines the duration of a normal duty period which measured by block height
52
"MemberCount": 6, // The count of CR committee members
53
"VotingPeriod": 360, // CRVotingStartHeight defines the height of CR voting started
54
"DepositLockupBlocks": 30, // Deposit lockup blocks
55
"CRCAppropriatePercentage": 5, // CRC appropriate percentage
56
"MaxCommitteeProposalCount": 13, // Max committee proposal count
57
"MaxProposalTrackingCount": 20, // Max Proposal rracking count
58
"ProposalCRVotingPeriod":24, // Proposal CR voting period
59
"ProposalPublicVotingPeriod": 30, // Proposal Public voting period
60
"CRAgreementCount": 4, // CR agreement count
61
"VoterRejectPercentage": 1, // Voter reject percentage
62
"RegisterCRByDIDHeight": 750, // Register CR by DID height
63
"SecretaryGeneral": "029364873c85eaf04de2f65276d8a2cd68f84145da91c318bf191283af88154bed", // Secretary general public key
64
"MaxCRAssetsAddressUTXOCount":1440, // Max CR assets address UTXO count
65
"MinCRAssetsAddressUTXOCount":60, // Min CR assets address UTXO count
66
"CRAssetsRectifyTransactionHeight":1450, // CR assets rectify transaction height
67
"CRCProposalWithdrawPayloadV1Height":1470, // CRC proposal withdraw payload version 1.0 height
68
"RectifyTxFee":10000, // Rectify txfee
69
"RealWithdrawSingleFee":10000, // Real withdraw single fee
70
"CRVotingStartHeight": 700, // CRVotingStartHeight defines the height of CR voting started
71
"CRCommitteeStartHeight": 1303, // CRCommitteeStartHeight defines the height of CR Committee started
72
"CRClaimDPOSNodeStartHeight":1900, // CR claim DPOS node start height
73
"CRClaimDPOSNodePeriod":200, // CR claim DPOS Node period
74
"NewP2PProtocolVersionHeight":1430, // New P2P protocol version height
75
"CRCProposalV1Height":1406, // CRC proposal version 1.0 height
76
"ChangeCommitteeNewCRHeight":3050, // Change committee New CR height
77
"CRCProposalDraftDataStartHeight":1300 // CRC Proposal DraftData start height
78
},
79
"HttpWsPort": 10115, // Websocket port number
80
"HttpRestPort": 10114, // Restful port number
81
"PowConfiguration": {
82
"MinerInfo": "ELA", // No need to change
83
"MinTxFee": 100, // Minimal mining fee
84
"InstantBlock": true, // false: high difficulty to mine block true: low difficulty to mine block
85
"AutoMining": false, // Start mining automatically? true or false
86
"PayToAddr": "ELFguDWvxPgcUxWKueTSGpc1eeGEnqLCK1" // Pay bonus to this address. Cannot be empty if AutoMining set to "true"
87
},
88
"PermanentPeers": [ // PermanentPeers. Other nodes will look up this seed list to connect to any of those seed in order to get all nodes addresses, if lost connection will try to connect again
89
"127.0.0.1:10018",
90
"127.0.0.1:10118",
91
"127.0.0.1:10218",
92
],
93
"MinCrossChainTxFee": 10000, // Minimal cross-chain transaction fee
94
"CRCOnlyDPOSHeight": 300, // The height start DPOS by CRC producers
95
"CheckRewardHeight": 100, // Check reward height
96
"RpcConfiguration": {
97
"User": "", // Check the username when use rpc interface, null will not check
98
"Pass": "", // Check the password when use rpc interface, null will not check
99
"WhiteIPList": [ // Check if ip in list when use rpc interface, "0.0.0.0" will not check
100
"0.0.0.0"
101
]
102
},
103
"FoundationAddress": "EgLe9ZAQyLmjxFZLp5em9VfqsYKvdhpGys",
104
"ActiveNet": "regnet", // Network type. Choices: mainnet testnet and regnet
105
"HttpWsStart": true, // Whether to enable the WebSocket service
106
"CheckAddressHeight": 101, //Before the height will not check that if address is ela address
107
"NodePort": 10118, // P2P port number
108
"HttpInfoPort": 10113, // Local web portal port number. User can go to http://127.0.0.1:10333/info to access the web UI
109
"SeedList": [
110
"127.0.0.1:10018",
111
"127.0.0.1:10118",
112
"127.0.0.1:10218",
113
],
114
"VoteStartHeight": 100, //Starting height of statistical voting
115
"HttpInfoStart": true, // Whether to enable the HTTPInfo service
116
"PublicDPOSHeight": 500, //The height start DPOS by CRCProducers and voted producers
117
"EnableUtxoDB": true, //Whether the db is enabled to store the UTXO
118
"Magic": 2018201,
119
"MaxNodePerHost": 200, // Max node per Host
120
"NodeProfileStrategy": "MemoryFirst",
121
"EnableActivateIllegalHeight": 2320, //The start height to enable activate illegal producer though activate tx
122
"CustomIDProposalStartHeight": 3050, //CustomID proposal start height
123
"MaxReservedCustomIDLength": 50, // Max Reserved CustomID Length
124
"NewELAIssuanceHeight": 8000, // NewELA issuance height
125
"HalvingRewardHeight": 8200, // Halving reward height
126
"HalvingRewardInterval": 365,// Halving reward interval
127
"NewCrossChainStartHeight": 600, // New version cross-chain transaction height
128
"SmallCrossTransferThreshold":20000, // Small cross transfer threshold
129
"ReturnDepositCoinFee": 10000 //Return deposit coin fee
130
}
131
}
Copied!
5. Run the Node
Run the node as follows:
1
$ ./ela
Copied!

Build Arbiter Node

1. Check Go version
Check the golang version. Make sure they're the following version number or above:
1
$ go version
2
go version go1.17
Copied!
If you cannot see the version number, an error must have occurred during installation.
2. Clone Source Code
Make sure you're in the following folder:
1
$ git clone https://github.com/elastos/Elastos.ELA.Arbiter.git
Copied!
If clone works successfully, you should see folder structure appear as Elastos.ELA.Arbiter/Makefile.
3. Make
Build the node as follows:
1
$ cd Elastos.ELA.Arbiter
2
$ make
Copied!
If you don't see an error message, then congratulations! You've made the arbiter full node.
4. Configuration
If you would like to connect to regnet, do the following:
1
{
2
"Configuration": {
3
"PrintLevel": 0, // Log level. Level 0 is the highest, 5 is the lowest
4
"SchnorrStartHeight": 1000,
5
"DPoSNetAddress": "127.0.0.1:10119", // The address used for arbiter to connect with the main ela node
6
"RpcConfiguration": { // Arbiter RPC Configuration
7
"Pass": "",
8
"WhiteIPList": [
9
"0.0.0.0"
10
],
11
"User": ""
12
},
13
"MaxLogsSize": 0,
14
"DepositAmount": 10000000, // The Amount of money to deposit when minthreshold reaches
15
"MaxPerLogSize": 0,
16
"HttpJsonPort": 10126, // RPC port number
17
"ClearTransactionInterval": 60000, // Clear handled transaction interval
18
"MaxTxsPerWithdrawTx": 1000, // Sidechain withdraw transaction process limit per block
19
"MainNode": {
20
"SpvSeedList": [ // SpvSeedList. spv module use the seed list to discover mainnet peers
21
"127.0.0.1:10118"
22
],
23
"FoundationAddress": "EgLe9ZAQyLmjxFZLp5em9VfqsYKvdhpGys", // Main ELA Node FoundationAddress
24
"MaxConnections": 3,
25
"DefaultPort": 10118, // DefaultPort for spv to connect the main ela node
26
"Magic": 2018201, // Main ELA Node Magic Number
27
"MinOutbound": 1,
28
"Rpc": {
29
"User": "", // The username when use rpc interface
30
"Pass": "", // The password when use rpc interface,
31
"WhiteIPList": [
32
"0.0.0.0"
33
],
34
"HttpJsonPort": 10116, // RPC port number
35
"IpAddress": "127.0.0.1" // Main ELA Node Ip Address
36
}
37
},
38
"SpvPrintLevel": 0, // SPV Log level. Level 0 is the highest, 5 is the lowest
39
"CRCOnlyDPOSHeight": 300, // The height start DPOS by CRC producers
40
"OriginCrossChainArbiters": [ // The publickey list of arbiters before CRCOnlyDPOSHeight
41
"038eba1db314e7569aafc62a3c0fd1de9fe6359f88962521768a37786fce62dd37",
42
"02fb5528297b3c43e015d7e20a62b2fc70592cb0b08dfdec7ff95bcd11ff5a5fe6",
43
"03a9d3bbed3db04a4a6c167514b6a4e187b3eaeb3b8d4edd9a618d27b9fe4a0179",
44
"03022428a02e52ef0dd6adc1c7d95ea9cd93854057e9dd6a48486dc536ece71603",
45
"0251fc966a08f0e097711f54fa22ef69c90510ea8e8cf4431e8167c221cf3c7b86"
46
],
47
"MinOutbound": 3,
48
"ActiveNet": "regnet",
49
"SideAuxPowFee": 50000, // Sidechain pow transaction fee
50
"SideChainMonitorScanInterval": 1000, // Arbiter syncing with sidechain interval
51
"NodePort": 10128, // P2P port number
52
"MaxConnections": 8,
53
"SyncInterval": 1000, // Arbiter syncing with mainchain interval
54
"MinThreshold": 10000000, // The minimum value for warning the mining address don't have enough coin
55
"Magic": 2018203, // Magic Number:Segregation for different subnet. No matter the port number, as long as the magic number not matching, nodes cannot talk to each others
56
"SideNodeList": [
57
{
58
"GenesisBlock": "d2e3decbcd1dbbf3028db57e04e85014d5a81253faafc59121568ee9f0d2fc67", // SideChain genesis block hash
59
"ExchangeRate": 1.0, // Sidechain token exchange rate with ELA
60
"SyncStartHeight": 2230, // The height at which synchronization begins.
61
"MiningAddr": "EHgqDuPig7CwPruu6QCHB6sG2kXpdi7dy2", // Sending sideChain pow transaction address
62
"PowChain": false, // Indicate if this is a pow sidechain
63
"PayToAddr": "Eg4FRyiMa2xvjv2Kzd7V4jxRxWm1bv4JGY", // SideChain mining address
64
"Rpc": {
65
"User": "",
66
"Pass": "",
67
"HttpJsonPort": 20632, // RPC port number
68
"IpAddress": "127.0.0.1"
69
}
70
}
71
],
72
"CRCCrossChainArbiters": [ // The crc arbiters after CRCOnlyDPOSHeight
73
"0342eeb0d664e2507d732382c66d0eedbd0a0f989179fd33d71679aa607d5d3b57",
74
"02cf7e80d1a1a76ab6259e0abdf2848c618655393f1fa3328901f80949ebed1476",
75
"02514cab9af25ee95e102b5c3a7c862b16f24b2de88d0110176e66ea379dfbc7a9",
76
"0322766f133141d2c9d82fb7e331ea6ec7c52e14de2c76bea0f59e479a1408fee3",
77
"02280ff02ec55bda6c40eae18d7f8c8830be950b26959cae976025da2252c85434",
78
"02fc7e75278b3cda28245c0cb567081c6ba08ab560a9c783ca3032014fe8d3b1e2"
79
],
80
"Version": 0,
81
"CRClaimDPOSNodeStartHeight": 1900, // CR node claim height
82
"NewP2PProtocolVersionHeight":1430, // New P2P protocol version height
83
"DPOSNodeCrossChainHeight": 300, // DPOS Node cross chain height
84
"NewCrossChainTransactionHeight": 6000,
85
"ReturnDepositTransactionFee": 20000
86
}
87
}
Copied!
5. Run the Node
Run the node as follows:
1
$ ./arbiter -p password
Copied!

Register the Sidechain Node

There are many ways for developers to participate in the Elastos ecology - the most direct way is to register new sidechains to join the mainchain consensus network.
Use the crc_register_sidechain_proposal_tx.lua script to register the sidechain proposal transaction:
1
./ela-cli script -f transaction/crc_register_sidechain_proposal_tx.lua --sidechainname eth --magicnumber 202000 --dnsseeds "one.elastos.cn:20821,two.elastos.cn:20822" --nodeport 20632 --genesishash 5cfc2f5257c44acff37b9fbd426bae95e2541b007fb99b844a0e2745c74c667a --genesistimestamp 1569381871 --genesisblockdifficulty 1 --drafthash 7e29f26924d4ab5a270d672059323e09fdb5652b37b680214c2e68cabd0e27fd --upgradeproposaltype 546 --rpcport 10116 --wallet ./cr/cr3.dat
Copied!
The above example of registering sidechain instructions shows:
Params
Description
sidechainname
Name of side name
magicnumber
Sidechain code
dnsseeds
Domain name of sidechain cluster
nodeport
Sidechain service port
genesishash
Genesis hash
genesistimestamp
Genesis time stamp
genesisblockdifficulty
Genesis difficulty
drafthash
Draft hash
upgradeproposaltype
Upgrade the type of proposal
rpcport
Mainchain RPC port
wallet
Wallet file
When the proposal is successfully sent to the mainchain, the chain reviews it and initiates a vote. After the vote is passed, the arbiter automatically senses the registration transaction of the sidechain, registers the transaction in the arbiter’s database, and prepares to receive the final configuration information of the sidechain.
1
curl -H "Content-Type: application/json" -X POST -d '{"method": "setregistersidechainrpcinfo","params":{"genesisblockhash": "7a664cc745270e4a849bb97f001b54e295ae6b42bd9f7bf3cf4ac457522ffc5c","httpjsonport": 20821, "ipaddr": "172.16.0.29", "user": "", "pass": ""}}' http://localhost:20632
Copied!
When the chain test cluster is ready and runs normally, the sidechain needs to send the final configuration to the setregistersidechainrpcinfo interface of arbiter for final confirmation. When arbiter receives the information that the sidechain matches the proposal of the mainchain, it can start a sidechain monitoring bridge, and construction of the main sidechain can be completed.
Params
Description
genesisblockhash
Genesis hash
httpjsonport
Sidechain cluster
ipaddr
IP address of side chain cluster
user
User’s RPC name
pass
User’s RPC password