Skip to content

Commit bf140aa

Browse files
dimiandrecatconcat
andauthored
upgrade handler for v23 (#1032)
* basic upgrade handler for v23 * remove icq from store upgrades * migrate icq params in upgrade handler * builder module account conversion * port back tf patch from mainnet with a better implementation * lint * refuse in tf update * core1 vesting migration * lint * lint 2 * remove uneccessary consensus params migration * ci: allow flaky interchaintest to rerun. (#1034) * ci * test * test2 * test3 --------- Co-authored-by: Tuan Tran <[email protected]>
1 parent 386f90b commit bf140aa

File tree

12 files changed

+493
-39
lines changed

12 files changed

+493
-39
lines changed

.github/workflows/interchaintest-E2E.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,19 @@ jobs:
9999
docker image ls -a
100100
101101
- name: Run Test
102+
id: run_test
103+
continue-on-error: true
102104
run: make ${{ matrix.test }}
105+
106+
- name: Retry Failed Test
107+
if: steps.run_test.outcome == 'failure'
108+
run: |
109+
for i in 1 2; do
110+
echo "Retry attempt $i"
111+
if make ${{ matrix.test }}; then
112+
echo "Test passed on retry"
113+
exit 0
114+
fi
115+
done
116+
echo "Test failed after retries"
117+
exit 1

app/app.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ import (
7373
testnetV19alpha3 "github.com/CosmosContracts/juno/v23/app/upgrades/testnet/v19.0.0-alpha.3"
7474
testnetV21alpha1 "github.com/CosmosContracts/juno/v23/app/upgrades/testnet/v21.0.0-alpha.1"
7575
testnetV22alpha1 "github.com/CosmosContracts/juno/v23/app/upgrades/testnet/v22.0.0-alpha.1"
76+
testnetV23alpha1 "github.com/CosmosContracts/juno/v23/app/upgrades/testnet/v23.0.0-alpha.1"
7677
v10 "github.com/CosmosContracts/juno/v23/app/upgrades/v10"
7778
v11 "github.com/CosmosContracts/juno/v23/app/upgrades/v11"
7879
v12 "github.com/CosmosContracts/juno/v23/app/upgrades/v12"
@@ -85,6 +86,7 @@ import (
8586
v19 "github.com/CosmosContracts/juno/v23/app/upgrades/v19"
8687
v21 "github.com/CosmosContracts/juno/v23/app/upgrades/v21"
8788
v22 "github.com/CosmosContracts/juno/v23/app/upgrades/v22"
89+
v23 "github.com/CosmosContracts/juno/v23/app/upgrades/v23"
8890
"github.com/CosmosContracts/juno/v23/docs"
8991
)
9092

@@ -114,6 +116,7 @@ var (
114116
testnetV19alpha3.Upgrade,
115117
testnetV21alpha1.Upgrade,
116118
testnetV22alpha1.Upgrade,
119+
testnetV23alpha1.Upgrade,
117120

118121
v10.Upgrade,
119122
v11.Upgrade,
@@ -127,6 +130,7 @@ var (
127130
v19.Upgrade,
128131
v21.Upgrade,
129132
v22.Upgrade,
133+
v23.Upgrade,
130134
}
131135
)
132136

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package v23
2+
3+
import (
4+
"fmt"
5+
6+
icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v7/types"
7+
8+
store "github.com/cosmos/cosmos-sdk/store/types"
9+
sdk "github.com/cosmos/cosmos-sdk/types"
10+
"github.com/cosmos/cosmos-sdk/types/module"
11+
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
12+
13+
"github.com/CosmosContracts/juno/v23/app/keepers"
14+
"github.com/CosmosContracts/juno/v23/app/upgrades"
15+
)
16+
17+
// UpgradeName defines the on-chain upgrade name for the upgrade.
18+
const UpgradeName = "v2300alpha1"
19+
20+
var Upgrade = upgrades.Upgrade{
21+
UpgradeName: UpgradeName,
22+
CreateUpgradeHandler: v2300Alpha1UpgradeHandler,
23+
StoreUpgrades: store.StoreUpgrades{
24+
Added: []string{
25+
// updated modules
26+
icqtypes.ModuleName,
27+
},
28+
},
29+
}
30+
31+
func v2300Alpha1UpgradeHandler(
32+
mm *module.Manager,
33+
cfg module.Configurator,
34+
_ *keepers.AppKeepers,
35+
) upgradetypes.UpgradeHandler {
36+
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
37+
logger := ctx.Logger().With("upgrade", UpgradeName)
38+
39+
nativeDenom := upgrades.GetChainsDenomToken(ctx.ChainID())
40+
logger.Info(fmt.Sprintf("With native denom %s", nativeDenom))
41+
42+
// Run migrations
43+
logger.Info(fmt.Sprintf("pre migrate version map: %v", vm))
44+
versionMap, err := mm.RunMigrations(ctx, cfg, vm)
45+
if err != nil {
46+
return nil, err
47+
}
48+
logger.Info(fmt.Sprintf("post migrate version map: %v", versionMap))
49+
50+
return versionMap, err
51+
}
52+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package v23_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/suite"
7+
8+
"github.com/CosmosContracts/juno/v23/app/apptesting"
9+
v23alpha1 "github.com/CosmosContracts/juno/v23/app/upgrades/testnet/v22.0.0-alpha.1"
10+
)
11+
12+
type UpgradeTestSuite struct {
13+
apptesting.KeeperTestHelper
14+
}
15+
16+
func (s *UpgradeTestSuite) SetupTest() {
17+
s.Setup()
18+
}
19+
20+
func TestKeeperTestSuite(t *testing.T) {
21+
suite.Run(t, new(UpgradeTestSuite))
22+
}
23+
24+
// Ensures the test does not error out.
25+
func (s *UpgradeTestSuite) TestUpgrade() {
26+
s.Setup()
27+
28+
preUpgradeChecks(s)
29+
30+
upgradeHeight := int64(5)
31+
s.ConfirmUpgradeSucceeded(v23alpha1.UpgradeName, upgradeHeight)
32+
33+
postUpgradeChecks(s)
34+
}
35+
36+
func preUpgradeChecks(_ *UpgradeTestSuite) {
37+
}
38+
39+
func postUpgradeChecks(_ *UpgradeTestSuite) {
40+
}

app/upgrades/v23/constants.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package v23
2+
3+
import (
4+
store "github.com/cosmos/cosmos-sdk/store/types"
5+
6+
"github.com/CosmosContracts/juno/v23/app/upgrades"
7+
)
8+
9+
// UpgradeName defines the on-chain upgrade name for the upgrade.
10+
const UpgradeName = "v23"
11+
12+
var Upgrade = upgrades.Upgrade{
13+
UpgradeName: UpgradeName,
14+
CreateUpgradeHandler: CreateV23UpgradeHandler,
15+
StoreUpgrades: store.StoreUpgrades{},
16+
}

app/upgrades/v23/upgrade_test.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package v23_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/suite"
7+
8+
"github.com/CosmosContracts/juno/v23/app/apptesting"
9+
v23 "github.com/CosmosContracts/juno/v23/app/upgrades/v23"
10+
)
11+
12+
type UpgradeTestSuite struct {
13+
apptesting.KeeperTestHelper
14+
}
15+
16+
func (s *UpgradeTestSuite) SetupTest() {
17+
s.Setup()
18+
}
19+
20+
func TestKeeperTestSuite(t *testing.T) {
21+
suite.Run(t, new(UpgradeTestSuite))
22+
}
23+
24+
// Ensures the test does not error out.
25+
func (s *UpgradeTestSuite) TestUpgrade() {
26+
s.Setup()
27+
preUpgradeChecks(s)
28+
29+
upgradeHeight := int64(5)
30+
s.ConfirmUpgradeSucceeded(v23.UpgradeName, upgradeHeight)
31+
32+
postUpgradeChecks(s)
33+
}
34+
35+
func preUpgradeChecks(_ *UpgradeTestSuite) {
36+
}
37+
38+
func postUpgradeChecks(_ *UpgradeTestSuite) {
39+
}

app/upgrades/v23/upgrades.go

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
package v23
2+
3+
import (
4+
"fmt"
5+
6+
icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v7/types"
7+
8+
sdk "github.com/cosmos/cosmos-sdk/types"
9+
"github.com/cosmos/cosmos-sdk/types/module"
10+
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
11+
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
12+
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
13+
14+
"github.com/CosmosContracts/juno/v23/app/keepers"
15+
"github.com/CosmosContracts/juno/v23/app/upgrades"
16+
)
17+
18+
type IndividualAccount struct {
19+
Owner string
20+
Address string
21+
}
22+
23+
// Core1VestingAccounts https://daodao.zone/dao/juno1j6glql3xmrcnga0gytecsucq3kd88jexxamxg3yn2xnqhunyvflqr7lxx3/members
24+
// we are including only lobo, dimi and jake because the other ones do not agree on giving up their vesting
25+
var Core1VestingAccounts = []IndividualAccount{
26+
{
27+
Owner: "dimi",
28+
Address: "juno1s33zct2zhhaf60x4a90cpe9yquw99jj0zen8pt",
29+
},
30+
{
31+
Owner: "jake",
32+
Address: "juno18qw9ydpewh405w4lvmuhlg9gtaep79vy2gmtr2",
33+
},
34+
{
35+
Owner: "wolf",
36+
Address: "juno1a8u47ggy964tv9trjxfjcldutau5ls705djqyu",
37+
},
38+
}
39+
40+
func CreateV23UpgradeHandler(
41+
mm *module.Manager,
42+
cfg module.Configurator,
43+
keepers *keepers.AppKeepers,
44+
) upgradetypes.UpgradeHandler {
45+
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
46+
logger := ctx.Logger().With("upgrade", UpgradeName)
47+
48+
nativeDenom := upgrades.GetChainsDenomToken(ctx.ChainID())
49+
logger.Info(fmt.Sprintf("With native denom %s", nativeDenom))
50+
51+
// migrate ICQ params
52+
for _, subspace := range keepers.ParamsKeeper.GetSubspaces() {
53+
subspace := subspace
54+
55+
var keyTable paramstypes.KeyTable
56+
if subspace.Name() == icqtypes.ModuleName {
57+
keyTable = icqtypes.ParamKeyTable()
58+
} else {
59+
continue
60+
}
61+
62+
if !subspace.HasKeyTable() {
63+
subspace.WithKeyTable(keyTable)
64+
}
65+
}
66+
67+
// Run migrations
68+
logger.Info(fmt.Sprintf("pre migrate version map: %v", vm))
69+
versionMap, err := mm.RunMigrations(ctx, cfg, vm)
70+
if err != nil {
71+
return nil, err
72+
}
73+
74+
logger.Info(fmt.Sprintf("post migrate version map: %v", versionMap))
75+
76+
// convert pob builder account to an actual module account
77+
// during upgrade from v15 to v16 it wasn't correctly created, and since it received tokens on mainnet is now a base account
78+
// it's like this on both mainnet and uni
79+
if ctx.ChainID() == "juno-1" || ctx.ChainID() == "uni-6" {
80+
logger.Info("converting x/pob builder module account")
81+
82+
address := sdk.MustAccAddressFromBech32("juno1ma4sw9m2nvtucny6lsjhh4qywvh86zdh5dlkd4")
83+
84+
acc := keepers.AccountKeeper.NewAccount(
85+
ctx,
86+
authtypes.NewModuleAccount(
87+
authtypes.NewBaseAccountWithAddress(address),
88+
"builder",
89+
),
90+
)
91+
keepers.AccountKeeper.SetAccount(ctx, acc)
92+
93+
logger.Info("x/pob builder module address is now a module account")
94+
}
95+
96+
// only on mainnet and uni, migrate core1 vesting accounts
97+
if ctx.ChainID() == "juno-1" || ctx.ChainID() == "uni-6" {
98+
if err := migrateCore1VestingAccounts(ctx, keepers, nativeDenom); err != nil {
99+
return nil, err
100+
}
101+
}
102+
103+
return versionMap, err
104+
}
105+
}
106+
107+
// Migrate balances from the Core-1 vesting accounts to the Council SubDAO.
108+
func migrateCore1VestingAccounts(ctx sdk.Context, keepers *keepers.AppKeepers, bondDenom string) error {
109+
for _, account := range Core1VestingAccounts {
110+
if err := MoveVestingCoinFromVestingAccount(ctx,
111+
keepers,
112+
bondDenom,
113+
account.Owner,
114+
sdk.MustAccAddressFromBech32(account.Address),
115+
); err != nil {
116+
return err
117+
}
118+
}
119+
return nil
120+
}

0 commit comments

Comments
 (0)