Skip to content

Commit 3ed47c1

Browse files
committed
feat: add ICS1 fork to COSMOS SDK 0.50 upgrade PR
1 parent c0b5d97 commit 3ed47c1

File tree

6 files changed

+95
-21
lines changed

6 files changed

+95
-21
lines changed

app/keepers/gov_adapter.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package keepers
2+
3+
import (
4+
sdk "github.com/cosmos/cosmos-sdk/types"
5+
ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types"
6+
7+
atomonegovkeeper "github.com/atomone-hub/atomone/x/gov/keeper"
8+
)
9+
10+
// GovKeeperAdapter adapts AtomOne's gov keeper to match the interface expected by ICS
11+
type GovKeeperAdapter struct {
12+
keeper *atomonegovkeeper.Keeper
13+
}
14+
15+
// NewGovKeeperAdapter creates a new adapter for AtomOne's gov keeper
16+
func NewGovKeeperAdapter(k *atomonegovkeeper.Keeper) *GovKeeperAdapter {
17+
return &GovKeeperAdapter{keeper: k}
18+
}
19+
20+
// GetProposal retrieves a proposal and converts it to ICS's Proposal type
21+
func (a *GovKeeperAdapter) GetProposal(ctx sdk.Context, proposalID uint64) (ccvtypes.Proposal, bool) {
22+
prop, found := a.keeper.GetProposal(ctx, proposalID)
23+
if !found {
24+
return ccvtypes.Proposal{}, false
25+
}
26+
27+
// Convert AtomOne proposal to ICS proposal - only copy the Messages field
28+
return ccvtypes.Proposal{
29+
Messages: prop.Messages,
30+
}, true
31+
}

app/keepers/keepers.go

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import (
1414
ibcexported "github.com/cosmos/ibc-go/v10/modules/core/exported"
1515
ibckeeper "github.com/cosmos/ibc-go/v10/modules/core/keeper"
1616
ibctm "github.com/cosmos/ibc-go/v10/modules/light-clients/07-tendermint"
17+
icsprovider "github.com/cosmos/interchain-security/v5/x/ccv/provider"
18+
icsproviderkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper"
19+
providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types"
1720

1821
"cosmossdk.io/log"
1922
storetypes "cosmossdk.io/store/types"
@@ -87,11 +90,13 @@ type AppKeepers struct {
8790
ConsensusParamsKeeper consensusparamkeeper.Keeper
8891
PhotonKeeper *photonkeeper.Keeper
8992
DynamicfeeKeeper *dynamicfeekeeper.Keeper
93+
ProviderKeeper icsproviderkeeper.Keeper
9094

9195
// Modules
9296
ICAModule ica.AppModule
9397
TransferModule transfer.AppModule
9498
TMClientModule ibctm.AppModule
99+
ProviderModule icsprovider.AppModule
95100
}
96101

97102
func NewAppKeeper(
@@ -211,15 +216,6 @@ func NewAppKeeper(
211216
authorityStr,
212217
)
213218

214-
// register the staking hooks
215-
// NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
216-
appKeepers.StakingKeeper.SetHooks(
217-
stakingtypes.NewMultiStakingHooks(
218-
appKeepers.DistrKeeper.Hooks(),
219-
appKeepers.SlashingKeeper.Hooks(),
220-
),
221-
)
222-
223219
// UpgradeKeeper must be created before IBCKeeper
224220
appKeepers.UpgradeKeeper = upgradekeeper.NewKeeper(
225221
skipUpgradeHeights,
@@ -304,9 +300,41 @@ func NewAppKeeper(
304300
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
305301
)
306302

303+
// Initialize ProviderKeeper
304+
appKeepers.ProviderKeeper = icsproviderkeeper.NewKeeper(
305+
appCodec,
306+
appKeepers.keys[providertypes.StoreKey],
307+
appKeepers.GetSubspace(providertypes.ModuleName),
308+
appKeepers.IBCKeeper.ChannelKeeper,
309+
appKeepers.IBCKeeper.ConnectionKeeper,
310+
appKeepers.IBCKeeper.ClientKeeper,
311+
appKeepers.StakingKeeper,
312+
appKeepers.SlashingKeeper,
313+
appKeepers.AccountKeeper,
314+
appKeepers.DistrKeeper,
315+
appKeepers.BankKeeper,
316+
NewGovKeeperAdapter(appKeepers.GovKeeper), // inline the adapter creation
317+
authorityStr,
318+
addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()),
319+
addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()),
320+
authtypes.FeeCollectorName,
321+
)
322+
323+
// Register the staking hooks
324+
// NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
325+
// This includes hooks from distribution, slashing, and provider modules
326+
appKeepers.StakingKeeper.SetHooks(
327+
stakingtypes.NewMultiStakingHooks(
328+
appKeepers.DistrKeeper.Hooks(),
329+
appKeepers.SlashingKeeper.Hooks(),
330+
appKeepers.ProviderKeeper.Hooks(),
331+
),
332+
)
333+
307334
// Middleware Stacks
308335
appKeepers.ICAModule = ica.NewAppModule(nil, &appKeepers.ICAHostKeeper)
309336
appKeepers.TransferModule = transfer.NewAppModule(appKeepers.TransferKeeper)
337+
appKeepers.ProviderModule = icsprovider.NewAppModule(&appKeepers.ProviderKeeper, appKeepers.GetSubspace(providertypes.ModuleName))
310338

311339
// create IBC module from bottom to top of stack
312340
var (
@@ -366,6 +394,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
366394
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
367395
paramsKeeper.Subspace(ibcexported.ModuleName)
368396
paramsKeeper.Subspace(icahosttypes.SubModuleName)
397+
paramsKeeper.Subspace(providertypes.ModuleName)
369398

370399
return paramsKeeper
371400
}

app/keepers/keys.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
icahosttypes "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/host/types"
55
ibctransfertypes "github.com/cosmos/ibc-go/v10/modules/apps/transfer/types"
66
ibcexported "github.com/cosmos/ibc-go/v10/modules/core/exported"
7+
providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types"
78

89
storetypes "cosmossdk.io/store/types"
910
evidencetypes "cosmossdk.io/x/evidence/types"
@@ -47,6 +48,7 @@ func (appKeepers *AppKeepers) GenerateKeys() {
4748
consensusparamtypes.StoreKey,
4849
photontypes.StoreKey,
4950
dynamicfeetypes.StoreKey,
51+
providertypes.StoreKey,
5052
)
5153

5254
// Define transient store keys

app/modules.go

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
ibctransfertypes "github.com/cosmos/ibc-go/v10/modules/apps/transfer/types"
66
ibc "github.com/cosmos/ibc-go/v10/modules/core"
77
ibcexported "github.com/cosmos/ibc-go/v10/modules/core/exported"
8+
providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types"
89

910
"cosmossdk.io/x/evidence"
1011
evidencetypes "cosmossdk.io/x/evidence/types"
@@ -48,16 +49,18 @@ import (
4849
)
4950

5051
var maccPerms = map[string][]string{
51-
authtypes.FeeCollectorName: nil,
52-
distrtypes.ModuleName: nil,
53-
icatypes.ModuleName: nil,
54-
minttypes.ModuleName: {authtypes.Minter},
55-
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
56-
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
57-
govtypes.ModuleName: {authtypes.Burner},
58-
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
59-
photontypes.ModuleName: {authtypes.Minter, authtypes.Burner},
60-
dynamicfeetypes.ModuleName: nil,
52+
authtypes.FeeCollectorName: nil,
53+
distrtypes.ModuleName: nil,
54+
icatypes.ModuleName: nil,
55+
minttypes.ModuleName: {authtypes.Minter},
56+
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
57+
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
58+
govtypes.ModuleName: {authtypes.Burner},
59+
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
60+
photontypes.ModuleName: {authtypes.Minter, authtypes.Burner},
61+
dynamicfeetypes.ModuleName: nil,
62+
providertypes.ConsumerRewardsPool: nil,
63+
providertypes.ModuleName: nil,
6164
}
6265

6366
func appModules(
@@ -99,6 +102,7 @@ func appModules(
99102
app.TransferModule,
100103
app.ICAModule,
101104
app.TMClientModule,
105+
app.ProviderModule,
102106
}
103107
}
104108

@@ -127,6 +131,7 @@ func orderBeginBlockers() []string {
127131
banktypes.ModuleName,
128132
photontypes.ModuleName,
129133
govtypes.ModuleName,
134+
providertypes.ModuleName,
130135
ibcexported.ModuleName,
131136
ibctransfertypes.ModuleName,
132137
icatypes.ModuleName,
@@ -152,6 +157,7 @@ func orderEndBlockers() []string {
152157
dynamicfeetypes.ModuleName,
153158
govtypes.ModuleName,
154159
stakingtypes.ModuleName,
160+
providertypes.ModuleName, // provider.EndBlock must be after staking.EndBlock
155161
ibcexported.ModuleName,
156162
ibctransfertypes.ModuleName,
157163
icatypes.ModuleName,
@@ -193,6 +199,7 @@ func orderInitBlockers() []string {
193199
ibctransfertypes.ModuleName,
194200
ibcexported.ModuleName,
195201
icatypes.ModuleName,
202+
providertypes.ModuleName,
196203
evidencetypes.ModuleName,
197204
authz.ModuleName,
198205
feegrant.ModuleName,

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ replace (
77
cosmossdk.io/x/upgrade => github.com/atomone-hub/cosmos-sdk/x/upgrade v0.1.5-atomone.1
88
github.com/cosmos/cosmos-sdk => github.com/atomone-hub/cosmos-sdk v0.50.14-atomone.1
99
github.com/cosmos/ibc-go/v10 => github.com/cosmos/ibc-go/v10 v10.2.0
10+
github.com/cosmos/interchain-security/v5 => github.com/allinbits/interchain-security/v5 v5.2.1-0.20250818205642-6f8306deb72a
1011
)
1112

1213
require (
@@ -32,6 +33,7 @@ require (
3233
github.com/cosmos/go-bip39 v1.0.0
3334
github.com/cosmos/gogoproto v1.7.0
3435
github.com/cosmos/ibc-go/v10 v10.2.0
36+
github.com/cosmos/interchain-security/v5 v5.2.0
3537
github.com/golang/mock v1.6.0
3638
github.com/golang/protobuf v1.5.4
3739
github.com/google/gofuzz v1.2.0
@@ -211,6 +213,7 @@ require (
211213
github.com/tendermint/go-amino v0.16.0 // indirect
212214
github.com/tidwall/btree v1.7.0 // indirect
213215
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
216+
github.com/ugorji/go/codec v1.2.11 // indirect
214217
github.com/ulikunitz/xz v0.5.11 // indirect
215218
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
216219
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect

go.sum

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,8 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy
689689
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
690690
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
691691
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
692+
github.com/allinbits/interchain-security/v5 v5.2.1-0.20250818205642-6f8306deb72a h1:8gwMlZS0W8VxEEEMzZ7JlrtO6iMXrXA10SZxK17GlUE=
693+
github.com/allinbits/interchain-security/v5 v5.2.1-0.20250818205642-6f8306deb72a/go.mod h1:ouMe0waDG0lz6WqU8zW3IJX8+7oE9kNSW64pw3YSySg=
692694
github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
693695
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
694696
github.com/apache/arrow/go/v10 v10.0.1/go.mod h1:YvhnlEePVnBS4+0z3fhPfUy7W1Ikj0Ih0vcRo/gZ1M0=
@@ -1573,10 +1575,10 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1
15731575
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
15741576
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
15751577
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
1576-
github.com/ugorji/go v1.2.7 h1:qYhyWUUd6WbiM+C6JZAUkIJt/1WrjzNHY9+KCIjVqTo=
15771578
github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M=
1578-
github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0=
15791579
github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY=
1580+
github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU=
1581+
github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
15801582
github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
15811583
github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8=
15821584
github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=

0 commit comments

Comments
 (0)