🏗️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:

$ go version
go version go1.17

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:

$ git clone https://github.com/elastos/Elastos.ELA.git

If clone works successfully, you should see the folder structure appear similar to Elastos.ELA/Makefile.

3. Make

Build the node:

$ cd Elastos.ELA
$ make

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:

{
    "Configuration": {
        "DisableDNS": true, // DisableDNS. Disable the DNS seeding function.
        "PrintLevel": 0,   // Log level. Level 0 is the highest, 5 is the lowest
        "EnableRPC": true, // Enable the RPC service
        "DPoSConfiguration": {
            "SignTolerance": 5, // The time interval of consensus in seconds
            "OriginArbiters": [ // The publickey list of arbiters before CRCOnlyDPOSHeight
                "038eba1db314e7569aafc62a3c0fd1de9fe6359f88962521768a37786fce62dd37",
                "02fb5528297b3c43e015d7e20a62b2fc70592cb0b08dfdec7ff95bcd11ff5a5fe6",
                "03a9d3bbed3db04a4a6c167514b6a4e187b3eaeb3b8d4edd9a618d27b9fe4a0179",
                "03022428a02e52ef0dd6adc1c7d95ea9cd93854057e9dd6a48486dc536ece71603",
                "0251fc966a08f0e097711f54fa22ef69c90510ea8e8cf4431e8167c221cf3c7b86"
            ],
            "PublicKey": "0342eeb0d664e2507d732382c66d0eedbd0a0f989179fd33d71679aa607d5d3b57",
            "CandidatesCount": 36, // The count of candidates
            "MaxInactiveRounds": 180, // Max Inactive Rounds
            "MaxLogsSize": 0, // Max total logs size in MB
            "CRCArbiters": [
                "0342eeb0d664e2507d732382c66d0eedbd0a0f989179fd33d71679aa607d5d3b57",
                "02cf7e80d1a1a76ab6259e0abdf2848c618655393f1fa3328901f80949ebed1476",
                "02514cab9af25ee95e102b5c3a7c862b16f24b2de88d0110176e66ea379dfbc7a9",
                "0322766f133141d2c9d82fb7e331ea6ec7c52e14de2c76bea0f59e479a1408fee3",
                "02280ff02ec55bda6c40eae18d7f8c8830be950b26959cae976025da2252c85434",
                "02fc7e75278b3cda28245c0cb567081c6ba08ab560a9c783ca3032014fe8d3b1e2"
            ],
            "MaxPerLogSize": 0, // Max per log file size in MB
            "EnableArbiter": true, // EnableArbiter enables the arbiter service.
            "InactivePenalty":1000000000, // InactivePenalty defines the penalty amount the producer takes.
	    "IllegalPenalty":2000000000,
            "NormalArbitratorsCount": 12, // The count of voted arbiters
            "PreConnectOffset": 5, // PreConnectOffset defines the offset blocks to pre-connect to the block producers.
            "DPoSPort": 10119,
            "IPAddress": "127.0.0.1",
            "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
            "EmergencyInactivePenalty": 0, // EmergencyInactivePenalty defines the penalty amount the emergency producer takes.
	    "RandomCandidatePeriod": 108,
	    "MaxInactiveRoundsOfRandomNode": 108, // MaxInactiveRounds defines the maximum inactive rounds before producer takes penalty.
	    "DPOSNodeCrossChainHeight": 3050, //Dpos node cross-chain support start height
	    "NoCRCDPOSNodeHeight": 3050,
	    "DposV2StartHeight": 800, // Dpos version 2 start height
	    "RevertToPOWNoBlockTime": 60480003600, //Revert to POW no block time
	    "StopConfirmBlockTime": 60480000000, // Stop confirm block time
	    "RevertToPOWStartHeight": 3050 // Revert to POW start height
        },
        "MaxLogsSize": 0,
        "HttpJsonPort": 10116, // RPC port number
        "MaxPerLogSize": 0,
        "HttpRestStart": true, // Whether to enable the REST service
        "CRConfiguration": {
            "DutyPeriod": 1500, // CRDutyPeriod defines the duration of a normal duty period which measured by block height
            "MemberCount": 6, // The count of CR committee members
            "VotingPeriod": 360, // CRVotingStartHeight defines the height of CR voting started
	    "DepositLockupBlocks": 30, // Deposit lockup blocks
	    "CRCAppropriatePercentage": 5, // CRC appropriate percentage
	    "MaxCommitteeProposalCount": 13, // Max committee proposal count
      "MaxProposalTrackingCount": 20, // Max Proposal rracking count
	    "ProposalCRVotingPeriod":24, // Proposal CR voting period
	    "ProposalPublicVotingPeriod": 30, // Proposal Public voting period
	    "CRAgreementCount": 4, // CR agreement count
	    "VoterRejectPercentage": 1, // Voter reject percentage
      "RegisterCRByDIDHeight": 750, // Register CR by DID height
      "SecretaryGeneral": "029364873c85eaf04de2f65276d8a2cd68f84145da91c318bf191283af88154bed", // Secretary general public key
	    "MaxCRAssetsAddressUTXOCount":1440, // Max CR assets address UTXO count
 	    "MinCRAssetsAddressUTXOCount":60, // Min CR assets address UTXO count
  	  "CRAssetsRectifyTransactionHeight":1450, // CR assets rectify transaction height
  	  "CRCProposalWithdrawPayloadV1Height":1470, // CRC proposal withdraw payload version 1.0 height
  	  "RectifyTxFee":10000, // Rectify txfee
  	  "RealWithdrawSingleFee":10000, // Real withdraw single fee
	    "CRVotingStartHeight": 700, // CRVotingStartHeight defines the height of CR voting started
	    "CRCommitteeStartHeight": 1303, // CRCommitteeStartHeight defines the height of CR Committee started
	    "CRClaimDPOSNodeStartHeight":1900, // CR claim DPOS node start height
	    "CRClaimDPOSNodePeriod":200, // CR claim DPOS Node period
	    "NewP2PProtocolVersionHeight":1430, // New P2P protocol version height
	    "CRCProposalV1Height":1406, // CRC proposal version 1.0 height
	    "ChangeCommitteeNewCRHeight":3050, // Change committee New CR height
	    "CRCProposalDraftDataStartHeight":1300 // CRC Proposal DraftData start height
        },
        "HttpWsPort": 10115, // Websocket port number
        "HttpRestPort": 10114,  // Restful port number
        "PowConfiguration": {
            "MinerInfo": "ELA", // No need to change
            "MinTxFee": 100, // Minimal mining fee
            "InstantBlock": true, // false: high difficulty to mine block  true: low difficulty to mine block
            "AutoMining": false, // Start mining automatically? true or false
            "PayToAddr": "ELFguDWvxPgcUxWKueTSGpc1eeGEnqLCK1" // Pay bonus to this address. Cannot be empty if AutoMining set to "true"
        },
        "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
            "127.0.0.1:10018",
            "127.0.0.1:10118",
            "127.0.0.1:10218",
        ],
        "MinCrossChainTxFee": 10000, // Minimal cross-chain transaction fee
        "CRCOnlyDPOSHeight": 300, // The height start DPOS by CRC producers
        "CheckRewardHeight": 100, // Check reward height
        "RpcConfiguration": {
	    "User": "", // Check the username when use rpc interface, null will not check
            "Pass": "", // Check the password when use rpc interface, null will not check
            "WhiteIPList": [    // Check if ip in list when use rpc interface, "0.0.0.0" will not check
                "0.0.0.0"
            ]
        },
        "FoundationAddress": "EgLe9ZAQyLmjxFZLp5em9VfqsYKvdhpGys",
        "ActiveNet": "regnet", // Network type. Choices: mainnet testnet and regnet
        "HttpWsStart": true,  // Whether to enable the WebSocket service
        "CheckAddressHeight": 101, //Before the height will not check that if address is ela address
        "NodePort": 10118, // P2P port number
        "HttpInfoPort": 10113, // Local web portal port number. User can go to http://127.0.0.1:10333/info to access the web UI
        "SeedList": [
            "127.0.0.1:10018",
            "127.0.0.1:10118",
            "127.0.0.1:10218",
        ],
        "VoteStartHeight": 100, //Starting height of statistical voting
        "HttpInfoStart": true, // Whether to enable the HTTPInfo service
        "PublicDPOSHeight": 500, //The height start DPOS by CRCProducers and voted producers
        "EnableUtxoDB": true, //Whether the db is enabled to store the UTXO
        "Magic": 2018201,
	      "MaxNodePerHost": 200, // Max node per Host
        "NodeProfileStrategy": "MemoryFirst",
				"EnableActivateIllegalHeight": 2320, //The start height to enable activate illegal producer though activate tx
				"CustomIDProposalStartHeight": 3050, //CustomID proposal start height
				"MaxReservedCustomIDLength": 50, // Max Reserved CustomID Length
				"NewELAIssuanceHeight": 8000, // NewELA issuance height
				"HalvingRewardHeight": 8200, // Halving reward height
				"HalvingRewardInterval": 365,// Halving reward interval
				"NewCrossChainStartHeight": 600, // New version cross-chain transaction height
				"SmallCrossTransferThreshold":20000, // Small cross transfer threshold
				"ReturnDepositCoinFee": 10000 //Return deposit coin fee 
    }
}

5. Run the Node

Run the node as follows:

$ ./ela

Build Arbiter Node

1. Check Go version

Check the golang version. Make sure they're the following version number or above:

$ go version
go version go1.17

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:

$ git clone https://github.com/elastos/Elastos.ELA.Arbiter.git

If clone works successfully, you should see folder structure appear as Elastos.ELA.Arbiter/Makefile.

3. Make

Build the node as follows:

$ cd Elastos.ELA.Arbiter
$ make

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:

{
    "Configuration": {
        "PrintLevel": 0, // Log level. Level 0 is the highest, 5 is the lowest
	"SchnorrStartHeight": 1000,
        "DPoSNetAddress": "127.0.0.1:10119", // The address used for arbiter to connect with the main ela node
        "RpcConfiguration": { // Arbiter RPC Configuration 
            "Pass": "",
            "WhiteIPList": [
                "0.0.0.0"
            ],
            "User": ""
        },
        "MaxLogsSize": 0,
        "DepositAmount": 10000000, // The Amount of money to deposit when minthreshold reaches
        "MaxPerLogSize": 0,
        "HttpJsonPort": 10126, // RPC port number
        "ClearTransactionInterval": 60000, // Clear handled transaction interval
        "MaxTxsPerWithdrawTx": 1000, // Sidechain withdraw transaction process limit per block
        "MainNode": {
            "SpvSeedList": [ // SpvSeedList. spv module use the seed list to discover mainnet peers
                "127.0.0.1:10118" 
            ],
            "FoundationAddress": "EgLe9ZAQyLmjxFZLp5em9VfqsYKvdhpGys", // Main ELA Node FoundationAddress
            "MaxConnections": 3,
            "DefaultPort": 10118, // DefaultPort for spv to connect the main ela node 
            "Magic": 2018201, // Main ELA Node Magic Number
            "MinOutbound": 1,
            "Rpc": {
                "User": "", // The username when use rpc interface
                "Pass": "", // The password when use rpc interface,
                "WhiteIPList": [
                    "0.0.0.0"
                ],
                "HttpJsonPort": 10116, // RPC port number
                "IpAddress": "127.0.0.1" // Main ELA Node Ip Address
            }
        },
        "SpvPrintLevel": 0, // SPV Log level. Level 0 is the highest, 5 is the lowest
        "CRCOnlyDPOSHeight": 300, // The height start DPOS by CRC producers
        "OriginCrossChainArbiters": [ // The publickey list of arbiters before CRCOnlyDPOSHeight
            "038eba1db314e7569aafc62a3c0fd1de9fe6359f88962521768a37786fce62dd37",
            "02fb5528297b3c43e015d7e20a62b2fc70592cb0b08dfdec7ff95bcd11ff5a5fe6",
            "03a9d3bbed3db04a4a6c167514b6a4e187b3eaeb3b8d4edd9a618d27b9fe4a0179",
            "03022428a02e52ef0dd6adc1c7d95ea9cd93854057e9dd6a48486dc536ece71603",
            "0251fc966a08f0e097711f54fa22ef69c90510ea8e8cf4431e8167c221cf3c7b86"
        ],
        "MinOutbound": 3,
        "ActiveNet": "regnet",
        "SideAuxPowFee": 50000, // Sidechain pow transaction fee
        "SideChainMonitorScanInterval": 1000, // Arbiter syncing with sidechain interval
        "NodePort": 10128, // P2P port number
        "MaxConnections": 8,
        "SyncInterval": 1000,  // Arbiter syncing with mainchain interval
        "MinThreshold": 10000000, // The minimum value for warning the mining address don't have enough coin
        "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
        "SideNodeList": [
            {
                "GenesisBlock": "d2e3decbcd1dbbf3028db57e04e85014d5a81253faafc59121568ee9f0d2fc67", // SideChain genesis block hash
                "ExchangeRate": 1.0, // Sidechain token exchange rate with ELA
	"SyncStartHeight": 2230, // The height at which synchronization begins.
                "MiningAddr": "EHgqDuPig7CwPruu6QCHB6sG2kXpdi7dy2", // Sending sideChain pow transaction address
                "PowChain": false, // Indicate if this is a pow sidechain 
                "PayToAddr": "Eg4FRyiMa2xvjv2Kzd7V4jxRxWm1bv4JGY", // SideChain mining address
                "Rpc": {
                    "User": "",
                    "Pass": "",
                    "HttpJsonPort": 20632, // RPC port number
                    "IpAddress": "127.0.0.1"
                }
            }
        ],
        "CRCCrossChainArbiters": [ // The crc arbiters after CRCOnlyDPOSHeight 
            "0342eeb0d664e2507d732382c66d0eedbd0a0f989179fd33d71679aa607d5d3b57",
            "02cf7e80d1a1a76ab6259e0abdf2848c618655393f1fa3328901f80949ebed1476",
            "02514cab9af25ee95e102b5c3a7c862b16f24b2de88d0110176e66ea379dfbc7a9",
            "0322766f133141d2c9d82fb7e331ea6ec7c52e14de2c76bea0f59e479a1408fee3",
            "02280ff02ec55bda6c40eae18d7f8c8830be950b26959cae976025da2252c85434",
            "02fc7e75278b3cda28245c0cb567081c6ba08ab560a9c783ca3032014fe8d3b1e2"
        ],
  			"Version": 0,
				"CRClaimDPOSNodeStartHeight": 1900, // CR node claim height
  			"NewP2PProtocolVersionHeight":1430, // New P2P protocol version height
				"DPOSNodeCrossChainHeight": 300, // DPOS Node cross chain height
				"NewCrossChainTransactionHeight": 6000,
				"ReturnDepositTransactionFee": 20000
    }
}

5. Run the Node

Run the node as follows:

$ ./arbiter -p password

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:

 ./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

The above example of registering sidechain instructions shows:

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.

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

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.

Last updated