Search
Duplicate
Try Notion
🧨
Upgrade the network without gov proposal
In case there is a security issue we must perform a fast upgrade. This upgrade can not be in voting period for 5 days (mainnet voting time), so we need to create an intermediate upgrade that will halt all the nodes of the network at the same height.
After that halt, validators can safety change their evmosd version without risking to run a different consensus version than the other validators. Running different consensus versions between validators will result in slashing for the minority of the voting power.
Create intermediate proposal
Git checkout to a new branch
cd cd evmos git checkout -b v9.1.2-branch
Bash
Schedule the fork upgrade
We need to set up the upgrade height in the file app/forks.go. There is a function called ScheduleForkUpgrade where we can set the upgrade name and info so the node will halt at the correct height and require the new binary on restart:
case 18_000: upgradePlan.Name = "v9.1.3" upgradePlan.Info = `'{"binaries":{"darwin/amd64":"https://github.com/hanchon/evmos/releases/download/v9.1.3/evmos_9.1.3_Darwin_arm64.tar.gz","darwin/x86_64":"https://github.com/hanchon/evmos/releases/download/v9.1.3/evmos_9.1.3_Darwin_x86_64.tar.gz","linux/arm64":"https://github.com/hanchon/evmos/releases/download/v9.1.3/evmos_9.1.3_Linux_arm64.tar.gz","linux/amd64":"https://github.com/hanchon/evmos/releases/download/v9.1.3/evmos_9.1.3_Linux_amd64.tar.gz","windows/x86_64":"https://github.com/hanchon/evmos/releases/download/v9.1.3/evmos_9.1.3_Windows_x86_64.zip"}}'`
Bash
NOTE: we also need to remove the mainnet check so the code is not exited on the first if statement:
// NOTE: there are no testnet forks for the existing versions if !types.IsMainnet(ctx.ChainID()) { return }
Go
Commit and create the correct tag
git add . git commit -m "feat: upgrade v9.1.2" git tag v9.1.2 git push origin HEAD --tags
Bash
Build the v9.1.2 in all of the validators
cd cd evmos rm -rf build git fetch --tags git checkout v9.1.2 make install cp $(which evmosd) ~/evmosd9.1.2
Bash
Run the new version on all the validators:
screen -r evmos # control + c to kill the process ~/evmosd9.1.2 start
Bash
Prepare the security patch (v9.1.3)
For the sake of changing something let’s revert the EVMHook status that we made in the last upgrade.
Git checkout to a new branch
cd cd evmos git checkout -b v9.1.3-branch
Bash
Create the upgrade logic
Create the file app/upgrades/v9_1_3/upgrade.go
package v913 import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" erc20 "github.com/evmos/evmos/v9/x/erc20/keeper" ) // CreateUpgradeHandler creates an SDK upgrade handler for v9 func CreateUpgradeHandler( mm *module.Manager, configurator module.Configurator, erc20k erc20.Keeper, ) upgradetypes.UpgradeHandler { return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { logger := ctx.Logger().With("upgrade", "v9.1.3") params := erc20k.GetParams(ctx) params.EnableEVMHook = false erc20k.SetParams(ctx, params) // Leave modules are as-is to avoid running InitGenesis. logger.Debug("running module migrations ...") return mm.RunMigrations(ctx, configurator, vm) } }
Go
Add the upgrade to the app.go file
In the file app/app.go modify the function setUpgradeHandlers to support our new version
// v913 "github.com/evmos/evmos/v9/app/upgrades/v9_1_3" // v9.1.3 upgrade handler app.UpgradeKeeper.SetUpgradeHandler( "v9.1.3", v911.CreateUpgradeHandler( app.mm, app.configurator, app.Erc20Keeper, ), )
Go
Commit and create the correct tag
git add . git commit -m "feat: upgrade v9.1.3" git tag v9.1.3 git push origin HEAD --tags
Bash
Build the v9.1.3 in all of the validators
cd cd evmos rm -rf build git fetch --tags git checkout v9.1.3 make install cp $(which evmosd) ~/evmosd9.1.3
Bash
Wait for the upgrade height
It will log the same error as the last upgrade
Kill the evmosd node with control + c
Run the new version (v9.1.3)
~/evmosd9.1.3 start
Bash
Check the erc20 module’s params
If the upgrade was applied correctly, the EVMHook should be off.
~/evmosd9.1.3 q erc20 params # params: # enable_erc20: true # enable_evm_hook: false
Bash