Skip to main content

Hardfork

introduction

Currently, Axon has only one hardfork named Andromeda. The name of the hardfork is derived from one of the 88 constellations, and in the future, names will continue to be chosen based on the order of the constellations. After enabling Andromeda, validators are allowed to modify the max_contract_limit through the system contract 0xffffffffffffffffffffffffffffffffffffff01. If the hardfork is not activated, only the max_contract_limit is immutable, while other configs remain adjustable. Axon already has hardfork test CI and a test project available for your reference.

Usage steps

  1. Build Axon from source code

    cd $your_workspace
    git clone https://github.com/axonweb3/axon.git
    cd axon
    cargo build
  1. Start multiple Axon nodes

    reset.sh is used to clear data and start axon nodes. You can also use it for the first-time startup.

    git clone https://github.com/axonweb3/axon-hardfork-test.git
    cd axon-hardfork-test
    bash reset.sh $your_workspace/axon

    One of Axon's default configurations is hardforks = [], which defaults to enabling hardfork. reset.sh changes hardforks = [] to hardforks = ["None"] to disable hardfork. Later on, hardfork can be enabled using the hardfork -c followed by specifying the hardfork-start-number.

    You should see an output similar to this following:

    No process found listening on port 8001
    No process found listening on port 8002
    No process found listening on port 8003
    No process found listening on port 8004
    hardforks = ["None"]
    node_1 height: 6
    node_2 height: 6
    node_3 height: 6
    node_4 height: 6
    {
    "jsonrpc": "2.0",
    "result": {},
    "id": 1
    }
    {
    "jsonrpc": "2.0",
    "result": {},
    "id": 2
    }
    {
    "jsonrpc": "2.0",
    "result": {},
    "id": 3
    }
    {
    "jsonrpc": "2.0",
    "result": {},
    "id": 4
    }

    height: 6 indicates that the nodes are producing blocks normally. Querying with axon_getHardforkInfo and receiving "result": {} implies that hardfork is disabled.

  1. Enable hardfork

    hardfork.sh enables the hardfork by default after 30 blocks.

    hardfork.sh first kills all nodes. While the nodes are stopped, it executes hardfork -c to specify the hardfork-start-number. The nodes are then restarted. After startup, the status of Andromeda can be checked using axon_getHardforkInfo, and the expected status value should be determined.

    bash hardfork.sh $your_workspace/axon   

    You should see an output similar to this following:

    axon_path: /Users/sunchengzhu/tmp/axon
    hardfork-start-number: 694
    Killing processes on port 8001: 9285
    Killing processes on port 8002: 9286
    Killing processes on port 8003: 9287
    Killing processes on port 8004: 9288
    node_1 height: 670
    node_2 height: 670
    node_3 height: 670
    node_4 height: 670
    {
    "jsonrpc": "2.0",
    "result": {
    "Andromeda": "determined"
    },
    "id": 1
    }
    {
    "jsonrpc": "2.0",
    "result": {
    "Andromeda": "determined"
    },
    "id": 2
    }
    {
    "jsonrpc": "2.0",
    "result": {
    "Andromeda": "determined"
    },
    "id": 3
    }
    {
    "jsonrpc": "2.0",
    "result": {
    "Andromeda": "determined"
    },
    "id": 4
    }
  1. Wait and check hardfork info

    You can use this following test case to verify if the status of Andromeda becomes enabled when the nodes reach the specified height.

    npm install
    npx hardhat test --grep "check hardfork info after hardfork"
  1. Deploy a contract larger than default max_contract_limit

    The expected outcome of this test case is that the deployment transaction returns an error message containing CreateContractLimit.

    npx hardhat test --grep "deploy a big contract larger than max_contract_limit"
  1. Increase max_contract_limit

    This test case increases the max_contract_limit by using the system contract 0xffffffffffffffffffffffffffffffffffffff01.

    npx hardhat test --grep "update max_contract_limit"
  1. Test if new max_contract_limit is effective

    Deploy the previous contract again, with the expectation that it will deploy successfully.

    npx hardhat test --grep "deploy a big contract smaller than max_contract_limit"