Skip to content

Commit

Permalink
chore(upgrade): Prepare v15.0.0 upgrade (#1972)
Browse files Browse the repository at this point in the history
* add v15 upgrade logic

* replace v15rc2 upgrade handler with v15 handler in app.go

* remove v15rc2 upgrade logic

* adjust changelog for v15.0.0

* remove unnecessary stuff from test suite

* add logic to remove crisis module from store

* revert to using SDK v0.47.5 (without distribution authorization)

* update gomod2nix.toml

* fix(test): seq error on e2e test (#1909)

* fix(test): seq error

* refactor

* refactor

* refactor

* chore: update precompiles file name (#1737)

* chore: update precompiles file name to match the interface naming convention

* add changelog entry

* remove duplicated entry

---------

Co-authored-by: Tom <54514587+GAtom22@users.noreply.github.com>
Co-authored-by: tom <tomasguerraalda@hotmail.com>
  • Loading branch information
3 people committed Oct 31, 2023
1 parent 28feae6 commit ba5b8a3
Show file tree
Hide file tree
Showing 22 changed files with 218 additions and 212 deletions.
15 changes: 2 additions & 13 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

# Changelog

## Unreleased

### Bug Fixes

- (ibc) [#1918](https://github.com/evmos/evmos/pull/1918) Upgrade ibc-go to `v7.3.1`, which (among other things) fixes the `DenomTraces` REST endpoint.

## [v15.0.0-rc2] - 2023-10-30

### State Machine Breaking

- (authz) [#1957](https://github.com/evmos/evmos/pull/1957) Remove outdated distribution authorizations from testnet.

## [v15.0.0-rc1] - 2023-10-18
## [v15.0.0] - 2023-10-31

### API Breaking

Expand Down Expand Up @@ -87,6 +75,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
- (rpc) [#1829](https://github.com/evmos/evmos/pull/1829) Bump IAVL to v0.20.1 to fix concurrency issue
- (testnet) [#1857](https://github.com/evmos/evmos/pull/1857) Remove the crisis module causing an error when using the `evmosd testnet init-files` command.
- (rpc) [#1863](https://github.com/evmos/evmos/pull/1863) Handle error gracefully on RPC calls when node is not persisting ABCI responses.
- (ibc) [#1918](https://github.com/evmos/evmos/pull/1918) Upgrade ibc-go to `v7.3.1`, which (among other things) fixes the `DenomTraces` REST endpoint.

## [v14.1.0] - 2023-09-25

Expand Down
19 changes: 12 additions & 7 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ import (
v12 "github.com/evmos/evmos/v15/app/upgrades/v12"
v13 "github.com/evmos/evmos/v15/app/upgrades/v13"
v14 "github.com/evmos/evmos/v15/app/upgrades/v14"
"github.com/evmos/evmos/v15/app/upgrades/v15rc2"
v15 "github.com/evmos/evmos/v15/app/upgrades/v15"
v8 "github.com/evmos/evmos/v15/app/upgrades/v8"
v81 "github.com/evmos/evmos/v15/app/upgrades/v8_1"
v82 "github.com/evmos/evmos/v15/app/upgrades/v8_2"
Expand Down Expand Up @@ -1309,12 +1309,14 @@ func (app *Evmos) setupUpgradeHandlers() {
),
)

// v15rc2 upgrade handler
// v15 upgrade handler
app.UpgradeKeeper.SetUpgradeHandler(
v15rc2.UpgradeName,
v15rc2.CreateUpgradeHandler(
v15.UpgradeName,
v15.CreateUpgradeHandler(
app.mm, app.configurator,
app.AuthzKeeper,
app.BankKeeper,
app.EvmKeeper,
app.StakingKeeper,
),
)

Expand Down Expand Up @@ -1372,8 +1374,11 @@ func (app *Evmos) setupUpgradeHandlers() {
crisistypes.ModuleName,
},
}
case v15rc2.UpgradeName:
// no store upgrades in v15.0.0-rc2
case v15.UpgradeName:
// crisis module is deprecated in v15
storeUpgrades = &storetypes.StoreUpgrades{
Deleted: []string{crisistypes.ModuleName},
}
}

if storeUpgrades != nil {
Expand Down
11 changes: 11 additions & 0 deletions app/upgrades/v15/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright Tharsis Labs Ltd.(Evmos)
// SPDX-License-Identifier:ENCL-1.0(https://github.com/evmos/evmos/blob/main/LICENSE)

package v15

const (
// UpgradeName is the shared upgrade plan name for mainnet
UpgradeName = "v15.0.0"
// UpgradeInfo defines the binaries that will be used for the upgrade
UpgradeInfo = `'{"binaries":{"darwin/arm64":"https://github.com/evmos/evmos/releases/download/v15.0.0/evmos_15.0.0_Darwin_arm64.tar.gz","darwin/amd64":"https://github.com/evmos/evmos/releases/download/v15.0.0/evmos_15.0.0_Darwin_amd64.tar.gz","linux/arm64":"https://github.com/evmos/evmos/releases/download/v15.0.0/evmos_15.0.0_Linux_arm64.tar.gz","linux/amd64":"https://github.com/evmos/evmos/releases/download/v15.0.0/evmos_15.0.0_Linux_amd64.tar.gz","windows/x86_64":"https://github.com/evmos/evmos/releases/download/v15.0.0/evmos_15.0.0_Windows_x86_64.zip"}}'`
)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright Tharsis Labs Ltd.(Evmos)
// SPDX-License-Identifier:ENCL-1.0(https://github.com/evmos/evmos/blob/main/LICENSE)

package v15rc2_test
package v15_test

import (
"testing"
Expand Down
67 changes: 67 additions & 0 deletions app/upgrades/v15/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Copyright Tharsis Labs Ltd.(Evmos)
// SPDX-License-Identifier:ENCL-1.0(https://github.com/evmos/evmos/blob/main/LICENSE)

package v15

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
v14 "github.com/evmos/evmos/v15/app/upgrades/v14"
"github.com/evmos/evmos/v15/utils"
evmkeeper "github.com/evmos/evmos/v15/x/evm/keeper"
)

// CreateUpgradeHandler creates an SDK upgrade handler for v15.0.0
func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
bk bankkeeper.Keeper,
ek *evmkeeper.Keeper,
sk stakingkeeper.Keeper,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
logger := ctx.Logger().With("upgrade", UpgradeName)

if utils.IsMainnet(ctx.ChainID()) {
logger.Info("migrating strategic reserves")
if err := v14.MigrateNativeMultisigs(
ctx, bk, sk, v14.NewTeamStrategicReserveAcc, v14.OldStrategicReserves...,
); err != nil {
// NOTE: log error instead of aborting the upgrade
logger.Error("error while migrating native multisigs", "error", err)
}

// Add EIP contained in Shanghai hard fork to the extra EIPs
// in the EVM parameters. This enables using the PUSH0 opcode and
// thus supports Solidity v0.8.20.
//
// NOTE: this was already enabled on testnet
logger.Info("adding EIP 3855 to EVM parameters")
err := EnableEIPs(ctx, ek, 3855)
if err != nil {
logger.Error("error while enabling EIPs", "error", err)
}

// we are deprecating the crisis module since it is not being used
//
// NOTE: this was already removed on testnet
logger.Debug("deleting crisis module from version map...")
delete(vm, "crisis")
}

// Leave modules are as-is to avoid running InitGenesis.
logger.Debug("running module migrations ...")
return mm.RunMigrations(ctx, configurator, vm)
}
}

// EnableEIPs enables the given EIPs in the EVM parameters.
func EnableEIPs(ctx sdk.Context, ek *evmkeeper.Keeper, eips ...int64) error {
evmParams := ek.GetParams(ctx)
evmParams.ExtraEIPs = append(evmParams.ExtraEIPs, eips...)

return ek.SetParams(ctx, evmParams)
}
84 changes: 84 additions & 0 deletions app/upgrades/v15/upgrades_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// Copyright Tharsis Labs Ltd.(Evmos)
// SPDX-License-Identifier:ENCL-1.0(https://github.com/evmos/evmos/blob/main/LICENSE)

package v15_test

import (
sdk "github.com/cosmos/cosmos-sdk/types"
v15 "github.com/evmos/evmos/v15/app/upgrades/v15"
evmkeeper "github.com/evmos/evmos/v15/x/evm/keeper"
evmtypes "github.com/evmos/evmos/v15/x/evm/types"
)

func (s *UpgradesTestSuite) TestEnableEIPs() {
testcases := []struct {
name string
extraEIPs []int64
malleate func(sdk.Context, *evmkeeper.Keeper)
expEIPs []int64
expPass bool
errContains string
}{
{
name: "success - empty EIPs",
extraEIPs: []int64{},
expPass: true,
},
{
name: "success - single EIP",
extraEIPs: []int64{3855},
expEIPs: []int64{3855},
expPass: true,
},
{
name: "success - multiple EIPs",
extraEIPs: []int64{3855, 2200, 1884, 1344},
expEIPs: []int64{3855, 2200, 1884, 1344},
expPass: true,
},
{
name: "fail - duplicate EIP",
extraEIPs: []int64{3855, 1344, 2200},
malleate: func(ctx sdk.Context, ek *evmkeeper.Keeper) {
params := evmtypes.DefaultParams()
params.ExtraEIPs = []int64{2200}
err := ek.SetParams(ctx, params)
s.Require().NoError(err, "expected no error setting params")
},
expEIPs: []int64{2200}, // NOTE: since the function is failing, we expect the EIPs to remain the same
expPass: false,
errContains: "found duplicate EIP: 2200",
},
{
name: "fail - invalid EIP",
extraEIPs: []int64{3860},
expEIPs: []int64{},
expPass: false,
errContains: "is not activateable, valid EIPS are",
},
}

for _, tc := range testcases {
tc := tc

s.Run(tc.name, func() {
s.SetupTest()

if tc.malleate != nil {
tc.malleate(s.ctx, s.app.EvmKeeper)
}

err := v15.EnableEIPs(s.ctx, s.app.EvmKeeper, tc.extraEIPs...)

if tc.expPass {
s.Require().NoError(err, "expected no error enabling EIPs")
} else {
s.Require().Error(err, "expected error enabling EIPs")
s.Require().ErrorContains(err, tc.errContains, "expected different error")
}

evmParams := s.app.EvmKeeper.GetParams(s.ctx)
s.Require().ElementsMatch(tc.expEIPs, evmParams.ExtraEIPs, "expected different EIPs after test")
})
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright Tharsis Labs Ltd.(Evmos)
// SPDX-License-Identifier:ENCL-1.0(https://github.com/evmos/evmos/blob/main/LICENSE)

package v15rc2_test
package v15_test

import (
"encoding/json"
Expand Down Expand Up @@ -151,6 +151,7 @@ func (s *UpgradesTestSuite) DoSetupTest() {

// generate genesis account
_, priv := testutiltx.NewAddrKey()

baseAcc := authtypes.NewBaseAccount(priv.PubKey().Address().Bytes(), priv.PubKey(), 0, 0)

acc := &evmostypes.EthAccount{
Expand Down
11 changes: 0 additions & 11 deletions app/upgrades/v15rc2/constants.go

This file was deleted.

63 changes: 0 additions & 63 deletions app/upgrades/v15rc2/upgrades.go

This file was deleted.

Loading

0 comments on commit ba5b8a3

Please sign in to comment.