Skip to content

Commit acdcc38

Browse files
committed
chore: code cleanup
1 parent cc75eb9 commit acdcc38

File tree

3 files changed

+51
-49
lines changed

3 files changed

+51
-49
lines changed

app/common/version_modifier.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package common
2+
3+
import (
4+
"context"
5+
6+
"github.com/cosmos/cosmos-sdk/baseapp"
7+
)
8+
9+
// SimpleVersionModifier implements the baseapp.VersionModifier interface
10+
// required by AtomOne SDK v0.50.14 for ABCI queries to function properly.
11+
//
12+
// ICS1 E2E FIX: AtomOne SDK requires a VersionModifier for the baseapp to handle
13+
// ABCI info queries correctly. Without this, Hermes relayer fails with
14+
// "app.versionModifier is nil" error when creating IBC connections.
15+
//
16+
// This implementation returns protocol version 0, which is sufficient for testing
17+
// and basic operations. Production deployments may want to implement proper
18+
// version tracking if protocol upgrades are planned.
19+
type SimpleVersionModifier struct{}
20+
21+
// Ensure SimpleVersionModifier implements the baseapp.VersionModifier interface
22+
var _ baseapp.VersionModifier = (*SimpleVersionModifier)(nil)
23+
24+
// SetAppVersion sets the application protocol version.
25+
// This implementation is a no-op as we don't need to track version changes for testing.
26+
func (s SimpleVersionModifier) SetAppVersion(ctx context.Context, version uint64) error {
27+
// For testing purposes, we don't need to store the version
28+
return nil
29+
}
30+
31+
// AppVersion returns the current application protocol version.
32+
// Returns 0 as the default version, which is sufficient for testing.
33+
func (s SimpleVersionModifier) AppVersion(ctx context.Context) (uint64, error) {
34+
return 0, nil
35+
}

app/consumer/app.go

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import (
4848
"github.com/cosmos/cosmos-sdk/codec/types"
4949
"github.com/cosmos/cosmos-sdk/runtime"
5050
runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services"
51+
"github.com/cosmos/interchain-security/v5/app/common"
5152
"github.com/cosmos/cosmos-sdk/server"
5253
"github.com/cosmos/cosmos-sdk/server/api"
5354
"github.com/cosmos/cosmos-sdk/server/config"
@@ -155,21 +156,8 @@ var (
155156
_ ibctesting.TestingApp = (*App)(nil)
156157
)
157158

158-
// ICS1 E2E FIX: Simple implementation of VersionModifier interface
159-
// AtomOne SDK v0.50.14 requires a VersionModifier for ABCI queries to work.
160-
// This implementation returns protocol version 0, which is sufficient for testing.
161-
// Without this, Hermes fails with "app.versionModifier is nil" when querying ABCI info.
162-
type simpleVersionModifier struct{}
163-
164-
func (s simpleVersionModifier) SetAppVersion(ctx context.Context, version uint64) error {
165-
// For now, we don't need to store the version
166-
return nil
167-
}
168-
169-
func (s simpleVersionModifier) AppVersion(ctx context.Context) (uint64, error) {
170-
// Return protocol version 0 as default
171-
return 0, nil
172-
}
159+
// ICS1 E2E FIX: SimpleVersionModifier moved to app/common/version_modifier.go
160+
// to avoid code duplication between provider and consumer apps.
173161

174162
// App extends an ABCI application, but with most of its parameters exported.
175163
// They are exported for convenience in creating helper functions, as object
@@ -276,7 +264,7 @@ func New(
276264

277265
// ICS1 E2E FIX: Set a simple VersionModifier to fix "app.versionModifier is nil" error
278266
// This is needed for ABCI queries to work properly with AtomOne SDK
279-
bApp.SetVersionModifier(simpleVersionModifier{})
267+
bApp.SetVersionModifier(common.SimpleVersionModifier{})
280268

281269
// IBC v10: Capability keeper and scoped keepers removed
282270

@@ -365,13 +353,6 @@ func New(
365353
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
366354
)
367355

368-
// ICS1 E2E FIX: Register the tendermint light client module with IBC v10
369-
// This is required for the 07-tendermint light client to work properly
370-
// Based on AtomOne's implementation
371-
storeProvider := app.IBCKeeper.ClientKeeper.GetStoreProvider()
372-
tmLightClientModule := ibctm.NewLightClientModule(appCodec, storeProvider)
373-
app.IBCKeeper.ClientKeeper.AddRoute(ibctm.ModuleName, &tmLightClientModule)
374-
375356
// initialize the actual consumer keeper
376357
// IBC v10: Pass IBC keepers directly following ICS v7 pattern
377358
app.ConsumerKeeper = ibcconsumerkeeper.NewKeeper(
@@ -433,6 +414,11 @@ func New(
433414

434415
app.EvidenceKeeper = *evidenceKeeper
435416

417+
// IBC v10: Create light client module for tendermint
418+
// Reference: https://github.com/cosmos/interchain-security/blob/v7.0.1/app/consumer/app.go#L403-L404
419+
tmLightClientModule := ibctm.NewLightClientModule(appCodec, app.IBCKeeper.ClientKeeper.GetStoreProvider())
420+
app.IBCKeeper.ClientKeeper.AddRoute(ibctm.ModuleName, tmLightClientModule)
421+
436422
// NOTE: Any module instantiated in the module manager that is later modified
437423
// must be passed by reference here.
438424
app.MM = module.NewManager(

app/provider/app.go

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ import (
105105
tmos "github.com/cometbft/cometbft/libs/os"
106106
dbm "github.com/cosmos/cosmos-db"
107107

108+
"github.com/cosmos/interchain-security/v5/app/common"
108109
appencoding "github.com/cosmos/interchain-security/v5/app/encoding"
109110
testutil "github.com/cosmos/interchain-security/v5/testutil/integration"
110111
ibcprovider "github.com/cosmos/interchain-security/v5/x/ccv/provider"
@@ -236,22 +237,6 @@ var (
236237
_ ibctesting.TestingApp = (*App)(nil)
237238
)
238239

239-
// ICS1 E2E FIX: Simple implementation of VersionModifier interface
240-
// AtomOne SDK v0.50.14 requires a VersionModifier for ABCI queries to work.
241-
// This implementation returns protocol version 0, which is sufficient for testing.
242-
// Without this, Hermes fails with "app.versionModifier is nil" when querying ABCI info.
243-
type simpleVersionModifier struct{}
244-
245-
func (s simpleVersionModifier) SetAppVersion(ctx context.Context, version uint64) error {
246-
// For now, we don't need to store the version
247-
return nil
248-
}
249-
250-
func (s simpleVersionModifier) AppVersion(ctx context.Context) (uint64, error) {
251-
// Return protocol version 0 as default
252-
return 0, nil
253-
}
254-
255240
// App extends an ABCI application, but with most of its parameters exported.
256241
// They are exported for convenience in creating helper functions, as object
257242
// capabilities aren't needed for testing.
@@ -396,9 +381,9 @@ func New(
396381

397382
bApp.SetParamStore(&app.ConsensusParamsKeeper.ParamsStore)
398383

399-
// ICS1 E2E FIX: Set a simple VersionModifier to fix "app.versionModifier is nil" error
400-
// This is needed for ABCI queries to work properly with AtomOne SDK
401-
bApp.SetVersionModifier(simpleVersionModifier{})
384+
// ICS1 E2E FIX: Set VersionModifier to fix "app.versionModifier is nil" error
385+
// Uses shared implementation from app/common package
386+
bApp.SetVersionModifier(common.SimpleVersionModifier{})
402387

403388
// IBC v10: Capability keeper and scoped keepers removed
404389

@@ -500,13 +485,6 @@ func New(
500485
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
501486
)
502487

503-
// ICS1 E2E FIX: Register the tendermint light client module with IBC v10
504-
// This is required for the 07-tendermint light client to work properly
505-
// Based on AtomOne's implementation
506-
storeProvider := app.IBCKeeper.ClientKeeper.GetStoreProvider()
507-
tmLightClientModule := ibctm.NewLightClientModule(appCodec, storeProvider)
508-
app.IBCKeeper.ClientKeeper.AddRoute(ibctm.ModuleName, &tmLightClientModule)
509-
510488
// create evidence keeper with router
511489
app.EvidenceKeeper = *evidencekeeper.NewKeeper(
512490
appCodec,
@@ -594,6 +572,9 @@ func New(
594572
ibcRouter.AddRoute(providertypes.ModuleName, providerModule)
595573
app.IBCKeeper.SetRouter(ibcRouter)
596574

575+
// IBC v10: Create light client module for tendermint
576+
tmLightClientModule := ibctm.NewLightClientModule(appCodec, app.IBCKeeper.ClientKeeper.GetStoreProvider())
577+
app.IBCKeeper.ClientKeeper.AddRoute(ibctm.ModuleName, &tmLightClientModule)
597578

598579
// NOTE: Any module instantiated in the module manager that is later modified
599580
// must be passed by reference here.

0 commit comments

Comments
 (0)