Skip to content

Commit 28fb048

Browse files
committed
feat: prepare v12.0.0-alpha.3
1 parent 341764c commit 28fb048

6 files changed

Lines changed: 242 additions & 7 deletions

File tree

app.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import (
4949
"github.com/noble-assets/noble/v12/jester"
5050
"github.com/noble-assets/noble/v12/upgrade"
5151
"github.com/noble-assets/noble/v12/upgrade/v12alpha2"
52+
"github.com/noble-assets/noble/v12/upgrade/v12alpha3"
5253
"github.com/spf13/cast"
5354

5455
_ "cosmossdk.io/x/evidence"
@@ -487,6 +488,19 @@ func (app *App) RegisterUpgradeHandler() error {
487488
app.FTFKeeper,
488489
),
489490
)
491+
app.UpgradeKeeper.SetUpgradeHandler(
492+
v12alpha3.UpgradeName,
493+
v12alpha3.CreateUpgradeHandler(
494+
app.ModuleManager,
495+
app.Configurator(),
496+
app.AccountKeeper.AddressCodec(),
497+
app.AuthorityKeeper,
498+
app.BankKeeper,
499+
app.HyperlaneKeeper,
500+
app.NovaKeeper,
501+
app.WarpKeeper,
502+
),
503+
)
490504

491505
upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
492506
if err != nil {

app.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ modules:
4040
- account: hyperlane
4141
- account: warp
4242
permissions: [ burner, minter ]
43+
- account: upgrade # TODO: Remove after v12.0.0-alpha.3 upgrade is completed!
44+
permissions: [ burner ]
4345
authority: authority # Utilize our custom x/authority module.
4446
- name: authz
4547
config:

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ require (
2626
github.com/cosmos/ibc-apps/modules/rate-limiting/v8 v8.0.0
2727
github.com/cosmos/ibc-go/modules/capability v1.0.1
2828
github.com/cosmos/ibc-go/v8 v8.7.0
29+
github.com/ethereum/go-ethereum v1.16.1
2930
github.com/golangci/golangci-lint v1.61.0
3031
github.com/gorilla/mux v1.8.1
3132
github.com/monerium/module-noble/v2 v2.0.0
3233
github.com/noble-assets/authority v1.0.4
3334
github.com/noble-assets/forwarding/v2 v2.0.2
3435
github.com/noble-assets/globalfee v1.0.1
3536
github.com/noble-assets/halo/v2 v2.0.1
36-
github.com/noble-assets/nova v1.0.0-alpha.1
37+
github.com/noble-assets/nova v1.0.0-alpha.1.0.20251010145505-aff9d9a3f96c
3738
github.com/noble-assets/wormhole v1.0.0
3839
github.com/ondoprotocol/usdy-noble/v2 v2.0.0
3940
github.com/spf13/cast v1.7.1
@@ -139,7 +140,6 @@ require (
139140
github.com/dvsekhvalnov/jose2go v1.6.0 // indirect
140141
github.com/emicklei/dot v1.6.2 // indirect
141142
github.com/ethereum/c-kzg-4844/v2 v2.1.0 // indirect
142-
github.com/ethereum/go-ethereum v1.16.1 // indirect
143143
github.com/ethereum/go-verkle v0.2.2 // indirect
144144
github.com/ettle/strcase v0.2.0 // indirect
145145
github.com/fatih/color v1.17.0 // indirect
@@ -379,7 +379,7 @@ require (
379379
)
380380

381381
// force hyperlane-cosmos update
382-
replace github.com/bcp-innovations/hyperlane-cosmos => github.com/bcp-innovations/hyperlane-cosmos v1.0.1-0.20250918085740-76b0807e8d60
382+
replace github.com/bcp-innovations/hyperlane-cosmos => github.com/noble-assets/hyperlane-cosmos v0.0.0-20251010144559-3086920bd41f
383383

384384
// use noble version of pfm
385385
replace github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8 => github.com/noble-assets/ibc-apps/middleware/packet-forward-middleware/v8 v8.2.0-noble

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,6 @@ github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX
317317
github.com/aws/aws-sdk-go v1.44.224 h1:09CiaaF35nRmxrzWZ2uRq5v6Ghg/d2RiPjZnSgtt+RQ=
318318
github.com/aws/aws-sdk-go v1.44.224/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
319319
github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
320-
github.com/bcp-innovations/hyperlane-cosmos v1.0.1-0.20250918085740-76b0807e8d60 h1:5bWxqZMEJcePHtxJ75LiRKufdlqcMnFjGZSLJVqoTBQ=
321-
github.com/bcp-innovations/hyperlane-cosmos v1.0.1-0.20250918085740-76b0807e8d60/go.mod h1:3yfa0io5Ii6GmhHWsWl2LEAOEHsqWuMgw2R02+LPogw=
322320
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
323321
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
324322
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
@@ -1155,10 +1153,12 @@ github.com/noble-assets/globalfee v1.0.1 h1:8OXkPe1nG3kAn+i/qH4oWr966uxgGGRjzrQ0
11551153
github.com/noble-assets/globalfee v1.0.1/go.mod h1:DmNoTJ2LqGP4KpJuz+IEKp/5uf/3hRu3GSNBGhNUZkA=
11561154
github.com/noble-assets/halo/v2 v2.0.1 h1:nHAhTnq5dPJGelcLnKzMviXtk9x0DfMnRPv+CPoEvyA=
11571155
github.com/noble-assets/halo/v2 v2.0.1/go.mod h1:DY4GCfZ/7S3IEjoJBCCh7HRTxirPBOLMVwkT0N6n3bA=
1156+
github.com/noble-assets/hyperlane-cosmos v0.0.0-20251010144559-3086920bd41f h1:Vm9tykEDHcpyn+u+V9PN7jgqZO8AYM0uVNQC4Tdgrd0=
1157+
github.com/noble-assets/hyperlane-cosmos v0.0.0-20251010144559-3086920bd41f/go.mod h1:3yfa0io5Ii6GmhHWsWl2LEAOEHsqWuMgw2R02+LPogw=
11581158
github.com/noble-assets/ibc-apps/middleware/packet-forward-middleware/v8 v8.2.0-noble h1:nxz3n15ChWqK/PvRYg0sGpfsrsIM1uqK4z/I/6CvSbc=
11591159
github.com/noble-assets/ibc-apps/middleware/packet-forward-middleware/v8 v8.2.0-noble/go.mod h1:O5H9Ic3Pe6cmJn1eqlj5N48sLb8WQ1VWmDP4/11g/4E=
1160-
github.com/noble-assets/nova v1.0.0-alpha.1 h1:HeydhZWJcAtOelp55DMwEAP9Fu4IBv1l7ceAP8DfSMk=
1161-
github.com/noble-assets/nova v1.0.0-alpha.1/go.mod h1:V2CEFyXqKtRqNmG58uP6QYBWrA7OLHdXvUZh4IFOtjQ=
1160+
github.com/noble-assets/nova v1.0.0-alpha.1.0.20251010145505-aff9d9a3f96c h1:pijWXWJbpwebz/7SSszF82jS/Wx1RR4tjYjB4g3hQpo=
1161+
github.com/noble-assets/nova v1.0.0-alpha.1.0.20251010145505-aff9d9a3f96c/go.mod h1:V2CEFyXqKtRqNmG58uP6QYBWrA7OLHdXvUZh4IFOtjQ=
11621162
github.com/noble-assets/wormhole v1.0.0 h1:c3otKgRv6Am4IoB/Vob2ziom02Ptpzv8R1/OtM2gxxI=
11631163
github.com/noble-assets/wormhole v1.0.0/go.mod h1:s7T9FC+bxHwlLED8pmXumdqwhr56CGJqTdhhcIj4A/Q=
11641164
github.com/nunnatsa/ginkgolinter v0.16.2 h1:8iLqHIZvN4fTLDC0Ke9tbSZVcyVHoBs0HIbnVSxfHJk=

upgrade/v12alpha3/constants.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
//
3+
// Copyright 2025 NASD Inc. All Rights Reserved.
4+
//
5+
// Licensed under the Apache License, Version 2.0 (the "License");
6+
// you may not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing, software
12+
// distributed under the License is distributed on an "AS IS" BASIS,
13+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
// See the License for the specific language governing permissions and
15+
// limitations under the License.
16+
17+
package v12alpha3
18+
19+
// UpgradeName is the name of this specific software upgrade used on-chain.
20+
const UpgradeName = "v12.0.0-alpha.3"
21+
22+
// DevnetChainID is the Chain ID of the Noble devnet.
23+
const DevnetChainID = "duke-1"

upgrade/v12alpha3/upgrade.go

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
//
3+
// Copyright 2025 NASD Inc. All Rights Reserved.
4+
//
5+
// Licensed under the Apache License, Version 2.0 (the "License");
6+
// you may not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing, software
12+
// distributed under the License is distributed on an "AS IS" BASIS,
13+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
// See the License for the specific language governing permissions and
15+
// limitations under the License.
16+
17+
package v12alpha3
18+
19+
import (
20+
"context"
21+
"fmt"
22+
23+
"cosmossdk.io/core/address"
24+
"cosmossdk.io/errors"
25+
"cosmossdk.io/math"
26+
upgradetypes "cosmossdk.io/x/upgrade/types"
27+
hyperlaneutil "github.com/bcp-innovations/hyperlane-cosmos/util"
28+
postdispatchtypes "github.com/bcp-innovations/hyperlane-cosmos/x/core/02_post_dispatch/types"
29+
hyperlanekeeper "github.com/bcp-innovations/hyperlane-cosmos/x/core/keeper"
30+
warpkeeper "github.com/bcp-innovations/hyperlane-cosmos/x/warp/keeper"
31+
warptypes "github.com/bcp-innovations/hyperlane-cosmos/x/warp/types"
32+
sdk "github.com/cosmos/cosmos-sdk/types"
33+
"github.com/cosmos/cosmos-sdk/types/module"
34+
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
35+
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
36+
"github.com/ethereum/go-ethereum/common"
37+
authoritykeeper "github.com/noble-assets/authority/keeper"
38+
authoritytypes "github.com/noble-assets/authority/types"
39+
novakeeper "github.com/noble-assets/nova/keeper"
40+
novatypes "github.com/noble-assets/nova/types"
41+
novaismtypes "github.com/noble-assets/nova/types/ism"
42+
)
43+
44+
func CreateUpgradeHandler(
45+
mm *module.Manager,
46+
cfg module.Configurator,
47+
addressCodec address.Codec,
48+
authorityKeeper *authoritykeeper.Keeper,
49+
bankKeeper bankkeeper.Keeper,
50+
hyperlaneKeeper *hyperlanekeeper.Keeper,
51+
novaKeeper *novakeeper.Keeper,
52+
warpKeeper warpkeeper.Keeper,
53+
) upgradetypes.UpgradeHandler {
54+
return func(ctx context.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
55+
chainID := sdk.UnwrapSDKContext(ctx).ChainID()
56+
if chainID != DevnetChainID {
57+
return vm, fmt.Errorf("%s upgrade not allowed to execute on %s chain", UpgradeName, chainID)
58+
}
59+
60+
vm, err := mm.RunMigrations(ctx, cfg, vm)
61+
if err != nil {
62+
return vm, err
63+
}
64+
65+
if err := clearHyperlaneState(ctx, hyperlaneKeeper); err != nil {
66+
return vm, fmt.Errorf("failed to clear hyperlane state: %w", err)
67+
}
68+
69+
if err := clearWarpState(ctx, warpKeeper); err != nil {
70+
return vm, fmt.Errorf("failed to clear warp state: %w", err)
71+
}
72+
73+
if err := clearNovaState(ctx, novaKeeper); err != nil {
74+
return vm, fmt.Errorf("failed to clear nova state: %w", err)
75+
}
76+
77+
authority, err := authorityKeeper.Owner.Get(ctx)
78+
if err != nil {
79+
return vm, fmt.Errorf("unable to get underlying authority address from state: %w", err)
80+
}
81+
authorityBz, err := addressCodec.StringToBytes(authority)
82+
if err != nil {
83+
return vm, fmt.Errorf("unable to decode underlying authority address: %w", err)
84+
}
85+
86+
// Send x/warp module balance back to authority.
87+
warpAddress := authtypes.NewModuleAddress(warptypes.ModuleName)
88+
warpBalance := bankKeeper.GetAllBalances(ctx, warpAddress)
89+
90+
err = bankKeeper.SendCoins(ctx, warpAddress, authorityBz, warpBalance)
91+
if err != nil {
92+
return vm, fmt.Errorf("failed to transfer coins from warp module to authority: %w", err)
93+
}
94+
95+
// Send $NOBLE balance to x/upgrade module, and then burn.
96+
users := []string{"noble158asjqdd8ashn9fedw475dwtg05e46kaccc9eg", "noble1hluft9p85fxl8rejst36wsmjq0w0ykzvsduttl"}
97+
98+
total := sdk.NewCoins()
99+
for _, user := range users {
100+
bz, err := addressCodec.StringToBytes(user)
101+
if err != nil {
102+
return vm, fmt.Errorf("unable to decode user address %s: %w", user, err)
103+
}
104+
105+
balance := bankKeeper.GetBalance(ctx, bz, "anoble")
106+
107+
err = bankKeeper.SendCoinsFromAccountToModule(ctx, bz, upgradetypes.ModuleName, sdk.NewCoins(balance))
108+
if err != nil {
109+
return vm, fmt.Errorf("failed to transfer coins from user %s to upgrade module: %w", user, err)
110+
}
111+
112+
total = total.Add(balance)
113+
}
114+
115+
err = bankKeeper.BurnCoins(ctx, upgradetypes.ModuleName, total)
116+
if err != nil {
117+
return vm, fmt.Errorf("failed to burn coins from upgrade module: %w", err)
118+
}
119+
120+
return vm, nil
121+
}
122+
}
123+
124+
// clearHyperlaneState helps clear the x/hyperlane module state.
125+
func clearHyperlaneState(ctx context.Context, keeper *hyperlanekeeper.Keeper) error {
126+
hookID, _ := hyperlaneutil.DecodeHexAddress("0x726f757465725f706f73745f6469737061746368000000030000000000000000")
127+
mailboxID, _ := hyperlaneutil.DecodeHexAddress("0x68797065726c616e650000000000000000000000000000000000000000000000")
128+
129+
err := keeper.PostDispatchKeeper.SetMerkleTreeHook(ctx, postdispatchtypes.MerkleTreeHook{
130+
Id: hookID,
131+
MailboxId: mailboxID,
132+
Owner: authoritytypes.ModuleAddress.String(),
133+
Tree: postdispatchtypes.ProtoFromTree(hyperlaneutil.NewTree(hyperlaneutil.ZeroHashes, 0)),
134+
})
135+
if err != nil {
136+
return errors.Wrap(err, "failed to set merkle tree hook")
137+
}
138+
139+
mailbox, err := keeper.Mailboxes.Get(ctx, mailboxID.GetInternalId())
140+
if err != nil {
141+
return errors.Wrap(err, "unable to get mailbox")
142+
}
143+
mailbox.MessageSent = 0
144+
mailbox.MessageReceived = 0
145+
if err := keeper.Mailboxes.Set(ctx, mailboxID.GetInternalId(), mailbox); err != nil {
146+
return errors.Wrap(err, "unable to set mailbox")
147+
}
148+
149+
if err := keeper.Messages.Clear(ctx, nil); err != nil {
150+
return errors.Wrap(err, "unable to clear messages")
151+
}
152+
153+
return nil
154+
}
155+
156+
// clearWarpState helps clear the x/warp module state.
157+
func clearWarpState(ctx context.Context, keeper warpkeeper.Keeper) error {
158+
tokenID, _ := hyperlaneutil.DecodeHexAddress("0x726f757465725f61707000000000000000000000000000010000000000000001")
159+
160+
usdc, err := keeper.HypTokens.Get(ctx, tokenID.GetInternalId())
161+
if err != nil {
162+
return errors.Wrap(err, "unable to get usdc token")
163+
}
164+
usdc.CollateralBalance = math.ZeroInt()
165+
if err := keeper.HypTokens.Set(ctx, tokenID.GetInternalId(), usdc); err != nil {
166+
return errors.Wrap(err, "unable to set usdc token")
167+
}
168+
169+
if err := keeper.EnrolledRouters.Clear(ctx, nil); err != nil {
170+
return errors.Wrap(err, "unable to clear enrolled routers")
171+
}
172+
173+
return nil
174+
}
175+
176+
// clearNovaState helps clear the x/nova module state.
177+
func clearNovaState(ctx context.Context, keeper *novakeeper.Keeper) error {
178+
genesis := novatypes.GenesisState{
179+
Ism: novaismtypes.GenesisState{
180+
Paused: false,
181+
},
182+
Config: novatypes.Config{
183+
EpochLength: 50,
184+
HookAddress: common.Address{}.String(),
185+
EnrolledValidators: []string{"noblevaloper1xynp8wn5r33c6dvhhg3zufn4xghgwz9hsyh3ey"},
186+
},
187+
PendingEpoch: nil,
188+
FinalizedEpochs: make(map[uint64]novatypes.Epoch),
189+
StateRoots: make(map[uint64]string),
190+
MailboxRoots: make(map[uint64]string),
191+
}
192+
193+
keeper.InitGenesis(ctx, genesis)
194+
195+
return nil
196+
}

0 commit comments

Comments
 (0)