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
Build Axon from source code
cd $your_workspace
git clone https://github.com/axonweb3/axon.git
cd axon
cargo build
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/axonOne of Axon's default configurations is
hardforks = []
, which defaults to enabling hardfork.reset.sh
changeshardforks = []
tohardforks = ["None"]
to disable hardfork. Later on, hardfork can be enabled using thehardfork -c
followed by specifying thehardfork-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 withaxon_getHardforkInfo
and receiving"result": {}
implies that hardfork is disabled.
Enable hardfork
hardfork.sh
enables the hardfork by default after 30 blocks.hardfork.sh
first kills all nodes. While the nodes are stopped, it executeshardfork -c
to specify thehardfork-start-number
. The nodes are then restarted. After startup, the status ofAndromeda
can be checked usingaxon_getHardforkInfo
, and the expected status value should bedetermined
.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
}
Wait and check hardfork info
You can use this following test case to verify if the status of
Andromeda
becomesenabled
when the nodes reach the specified height.npm install
npx hardhat test --grep "check hardfork info after hardfork"
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"
Increase
max_contract_limit
This test case increases the
max_contract_limit
by using the system contract0xffffffffffffffffffffffffffffffffffffff01
.npx hardhat test --grep "update max_contract_limit"
Test if new
max_contract_limit
is effectiveDeploy 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"