logo

Run a Side Chain

This tutorial explains how to run a side chain node after it has been approved by the producers and released by the creator. After creating the side chain, producers need to run a side chain node.

Prerequisites#

  • You already have a main-chain node running.
  • The creation of the side chain has been approved and released.
  • Important Note#

    The key-pair (account) used for mining on the side chain must be the same as the one used on the main-chain node. Both production nodes need to be launched with the same key-pair.

    For more information about side chain creation, refer to the document in the request-side-chain section.

    Side Chain Configuration#

    Configuration Files#

    Two configuration files must be placed in the configuration folder of the side chain, from which you will launch the node:

  • appsettings.json
  • appsettings.SideChain.MainNet.json
  • Chain ID and Settings#

    After the release of the side chain creation request, the ChainId of the new side chain will be accessible in the SideChainCreatedEvent logged by the transaction that released it.

    In this example, we will set up the side chain node with ChainId tDVV (1866392 converted to base58), connecting to Redis db2, and using web API port 1235. Don’t forget to change the account, password, and initial miner.

    appsettings.json

    1
    {
    2
    "ChainId": "tDVV",
    3
    "ChainType": "SideChain",
    4
    "NetType": "MainNet",
    5
    "ConnectionStrings": {
    6
    "BlockchainDb": "redis://localhost:6379?db=2",
    7
    "StateDb": "redis://localhost:6379?db=2"
    8
    },
    9
    "Account": {
    10
    "NodeAccount": "YOUR PRODUCER ACCOUNT",
    11
    "NodeAccountPassword": "YOUR PRODUCER PASSWORD"
    12
    },
    13
    "Kestrel": {
    14
    "EndPoints": {
    15
    "Http": {
    16
    "Url": "http://*:1235/"
    17
    }
    18
    }
    19
    },
    20
    "Consensus": {
    21
    "MiningInterval": 4000,
    22
    "StartTimestamp": 0
    23
    }
    24
    }

    appsettings.SideChain.MainNet.json

    1
    {
    2
    "CrossChain": {
    3
    "Grpc": {
    4
    "ParentChainServerPort": 5010,
    5
    "ListeningPort": 5000,
    6
    "ParentChainServerIp": "127.0.0.1"
    7
    },
    8
    "ParentChainId": "AELF"
    9
    }
    10
    }

    Change ParentChainServerIp and ParentChainServerPort depending on the listening address of your mainchain node.

    Launching the Side Chain Node#

    Open a terminal and navigate to the folder where you created the side chain configuration:

    Terminal

    1
    dotnet ../AElf.Launcher.dll

    You can try out a few commands from another terminal to check if everything is fine, for example:

    Terminal

    1
    aelf-command get-blk-height -e http://127.0.0.1:1235

    Edited on: 18 July 2024 04:44:21 GMT+0