Skip to content
This repository was archived by the owner on Dec 1, 2025. It is now read-only.

Commit 43d9fec

Browse files
authored
Merge pull request #1017 from persistenceOne/puneet/add-gaia-liquid
refactor: replace sdk-lsm to use gaia/liquid
2 parents ee7bbf8 + fd1afe9 commit 43d9fec

10 files changed

Lines changed: 152 additions & 89 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ Ref: https://keepachangelog.com/en/1.0.0/
3636

3737
## [Unreleased]
3838

39+
### Refactoring
40+
41+
- replace sdk-lsm to use gaia/liquid ([#1017](https://github.com/persistenceOne/pstake-native/pull/1017))
42+
3943
## [v4.0.0]
4044

4145
### Features

app/app.go

Lines changed: 56 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010

1111
autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
1212
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
13+
"cosmossdk.io/client/v2/autocli"
14+
"cosmossdk.io/core/appmodule"
1315
"cosmossdk.io/log"
1416
store "cosmossdk.io/store/types"
1517
"cosmossdk.io/x/evidence"
@@ -87,9 +89,12 @@ import (
8789
"github.com/cosmos/cosmos-sdk/x/staking"
8890
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
8991
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
90-
"github.com/persistenceOne/persistence-sdk/v4/x/epochs"
91-
epochskeeper "github.com/persistenceOne/persistence-sdk/v4/x/epochs/keeper"
92-
epochstypes "github.com/persistenceOne/persistence-sdk/v4/x/epochs/types"
92+
"github.com/cosmos/gaia/v24/x/liquid"
93+
liquidkeeper "github.com/cosmos/gaia/v24/x/liquid/keeper"
94+
liquidtypes "github.com/cosmos/gaia/v24/x/liquid/types"
95+
"github.com/persistenceOne/persistence-sdk/v5/x/epochs"
96+
epochskeeper "github.com/persistenceOne/persistence-sdk/v5/x/epochs/keeper"
97+
epochstypes "github.com/persistenceOne/persistence-sdk/v5/x/epochs/types"
9398
"github.com/spf13/cast"
9499

95100
pstakeante "github.com/persistenceOne/pstake-native/v5/ante"
@@ -125,6 +130,7 @@ var (
125130
evidence.AppModuleBasic{},
126131
vesting.AppModuleBasic{},
127132
epochs.AppModuleBasic{},
133+
liquid.AppModuleBasic{},
128134
liquidstake.AppModuleBasic{},
129135
consensus.AppModuleBasic{},
130136
wasm.AppModuleBasic{},
@@ -180,10 +186,12 @@ type PstakeApp struct {
180186
ParamsKeeper paramskeeper.Keeper
181187
ConsensusParamsKeeper consensusparamkeeper.Keeper
182188

183-
EvidenceKeeper evidencekeeper.Keeper
184-
FeeGrantKeeper feegrantkeeper.Keeper
185-
AuthzKeeper authzkeeper.Keeper
186-
EpochsKeeper *epochskeeper.Keeper
189+
EvidenceKeeper evidencekeeper.Keeper
190+
FeeGrantKeeper feegrantkeeper.Keeper
191+
AuthzKeeper authzkeeper.Keeper
192+
EpochsKeeper *epochskeeper.Keeper
193+
194+
LiquidKeeper liquidkeeper.Keeper
187195
LiquidStakeKeeper liquidstakekeeper.Keeper
188196

189197
// the module manager
@@ -231,7 +239,7 @@ func NewpStakeApp(
231239
govtypes.StoreKey, paramstypes.StoreKey, upgradetypes.StoreKey,
232240
evidencetypes.StoreKey,
233241
feegrant.StoreKey, authzkeeper.StoreKey,
234-
epochstypes.StoreKey, liquidstaketypes.StoreKey, consensusparamtypes.StoreKey,
242+
epochstypes.StoreKey, liquidtypes.StoreKey, liquidstaketypes.StoreKey, consensusparamtypes.StoreKey,
235243
)
236244
tkeys := store.NewTransientStoreKeys(paramstypes.TStoreKey)
237245

@@ -337,10 +345,19 @@ func NewpStakeApp(
337345
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
338346
)
339347

348+
app.LiquidKeeper = *liquidkeeper.NewKeeper(appCodec,
349+
runtime.NewKVStoreService(keys[liquidtypes.StoreKey]),
350+
app.AccountKeeper,
351+
app.BankKeeper,
352+
app.StakingKeeper,
353+
app.DistrKeeper,
354+
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
355+
)
356+
340357
// register the staking hooks
341358
// NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
342359
app.StakingKeeper.SetHooks(
343-
stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks()),
360+
stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks(), app.LiquidKeeper.Hooks()),
344361
)
345362

346363
app.LiquidStakeKeeper = liquidstakekeeper.NewKeeper(
@@ -352,6 +369,7 @@ func NewpStakeApp(
352369
app.MintKeeper,
353370
app.DistrKeeper,
354371
app.SlashingKeeper,
372+
app.LiquidKeeper,
355373
app.MsgServiceRouter(),
356374
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
357375
)
@@ -427,6 +445,7 @@ func NewpStakeApp(
427445
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
428446
params.NewAppModule(app.ParamsKeeper),
429447
epochs.NewAppModule(*app.EpochsKeeper),
448+
liquid.NewAppModule(appCodec, &app.LiquidKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
430449
liquidstake.NewAppModule(app.LiquidStakeKeeper),
431450
consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper),
432451
)
@@ -454,6 +473,7 @@ func NewpStakeApp(
454473
feegrant.ModuleName,
455474
paramstypes.ModuleName,
456475
vestingtypes.ModuleName,
476+
liquidtypes.ModuleName,
457477
liquidstaketypes.ModuleName,
458478
consensusparamtypes.ModuleName,
459479
)
@@ -474,6 +494,7 @@ func NewpStakeApp(
474494
paramstypes.ModuleName,
475495
upgradetypes.ModuleName,
476496
vestingtypes.ModuleName,
497+
liquidtypes.ModuleName,
477498
liquidstaketypes.ModuleName,
478499
consensusparamtypes.ModuleName,
479500
)
@@ -501,13 +522,17 @@ func NewpStakeApp(
501522
paramstypes.ModuleName,
502523
upgradetypes.ModuleName,
503524
vestingtypes.ModuleName,
525+
liquidtypes.ModuleName,
504526
liquidstaketypes.ModuleName,
505527
consensusparamtypes.ModuleName,
506528
)
507529

508530
app.mm.RegisterInvariants(app.CrisisKeeper)
509531
app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
510-
app.mm.RegisterServices(app.configurator)
532+
err := app.mm.RegisterServices(app.configurator)
533+
if err != nil {
534+
panic(err)
535+
}
511536

512537
autocliv1.RegisterQueryServer(app.GRPCQueryRouter(), runtimeservices.NewAutoCLIQueryService(app.mm.Modules))
513538

@@ -773,3 +798,24 @@ func (app *PstakeApp) RegisterUpgradeHandler() {
773798
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
774799
}
775800
}
801+
802+
// AutoCliOpts returns the autocli options for the app.
803+
func (app *PstakeApp) AutoCliOpts() autocli.AppOptions {
804+
modules := make(map[string]appmodule.AppModule, 0)
805+
for _, m := range app.mm.Modules {
806+
if moduleWithName, ok := m.(module.HasName); ok {
807+
moduleName := moduleWithName.Name()
808+
if appModule, ok := moduleWithName.(appmodule.AppModule); ok {
809+
modules[moduleName] = appModule
810+
}
811+
}
812+
}
813+
814+
return autocli.AppOptions{
815+
Modules: modules,
816+
ModuleOptions: runtimeservices.ExtractAutoCLIOptions(app.mm.Modules),
817+
AddressCodec: addresscodec.NewBech32Codec(Bech32PrefixAccAddr),
818+
ValidatorAddressCodec: addresscodec.NewBech32Codec(Bech32PrefixValAddr),
819+
ConsensusAddressCodec: addresscodec.NewBech32Codec(Bech32PrefixConsAddr),
820+
}
821+
}

cmd/pstaked/cmd/root.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,14 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
7878
return server.InterceptConfigsPreRunHandler(cmd, customTemplate, custompStakeConfig, customTMConfig)
7979
},
8080
}
81+
autoCliOpts := tempApp.AutoCliOpts()
82+
initClientCtx, _ = config.ReadFromClientConfig(initClientCtx)
83+
autoCliOpts.ClientCtx = initClientCtx
8184

8285
initRootCmd(rootCmd, encodingConfig, *tempApp)
86+
if err := autoCliOpts.EnhanceRootCommand(rootCmd); err != nil {
87+
panic(err)
88+
}
8389

8490
return rootCmd, encodingConfig
8591
}

cmd/pstaked/cmd/testnet.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ func InitTestnet(
228228
sdk.NewCoin(sdk.DefaultBondDenom, valTokens),
229229
stakingtypes.NewDescription(nodeDirName, "", "", "", ""),
230230
stakingtypes.NewCommissionRates(math.LegacyOneDec(), math.LegacyOneDec(), math.LegacyOneDec()),
231+
math.OneInt(),
231232
)
232233
if err != nil {
233234
return err

go.mod

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ toolchain go1.24.6
66

77
require (
88
cosmossdk.io/api v0.9.2
9+
cosmossdk.io/client/v2 v2.0.0-beta.7
910
cosmossdk.io/core v0.11.3
1011
cosmossdk.io/errors v1.0.2
1112
cosmossdk.io/log v1.5.1
@@ -21,11 +22,12 @@ require (
2122
github.com/cosmos/cosmos-db v1.1.3
2223
github.com/cosmos/cosmos-proto v1.0.0-beta.5
2324
github.com/cosmos/cosmos-sdk v0.50.14
25+
github.com/cosmos/gaia/v24 v24.0.0
2426
github.com/cosmos/gogoproto v1.7.0
2527
github.com/golang/protobuf v1.5.4
2628
github.com/gorilla/mux v1.8.1
2729
github.com/grpc-ecosystem/grpc-gateway v1.16.0
28-
github.com/persistenceOne/persistence-sdk/v4 v4.0.1
30+
github.com/persistenceOne/persistence-sdk/v5 v5.0.0-rc1
2931
github.com/spf13/cast v1.8.0
3032
github.com/spf13/cobra v1.9.1
3133
github.com/spf13/pflag v1.0.7
@@ -71,27 +73,27 @@ require (
7173
github.com/cncf/xds/go v0.0.0-20250121191232-2f005788dc42 // indirect
7274
github.com/cockroachdb/apd/v2 v2.0.2 // indirect
7375
github.com/cockroachdb/errors v1.11.3 // indirect
74-
github.com/cockroachdb/fifo v0.0.0-20240616162244-4768e80dfb9a // indirect
75-
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
76+
github.com/cockroachdb/fifo v0.0.0-20240816210425-c5d0cb0b6fc0 // indirect
77+
github.com/cockroachdb/logtags v0.0.0-20241215232642-bb51bb14a506 // indirect
7678
github.com/cockroachdb/pebble v1.1.5 // indirect
7779
github.com/cockroachdb/redact v1.1.6 // indirect
7880
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
79-
github.com/cometbft/cometbft-db v0.14.1 // indirect
81+
github.com/cometbft/cometbft-db v1.0.4 // indirect
8082
github.com/cosmos/btcutil v1.0.5 // indirect
8183
github.com/cosmos/go-bip39 v1.0.0 // indirect
8284
github.com/cosmos/gogogateway v1.2.0 // indirect
8385
github.com/cosmos/iavl v1.2.4 // indirect
8486
github.com/cosmos/ibc-go/v10 v10.1.1 // indirect
8587
github.com/cosmos/ics23/go v0.11.0 // indirect
8688
github.com/cosmos/ledger-cosmos-go v0.14.0 // indirect
87-
github.com/creachadair/atomicfile v0.3.1 // indirect
88-
github.com/creachadair/tomledit v0.0.24 // indirect
89+
github.com/creachadair/atomicfile v0.3.3 // indirect
90+
github.com/creachadair/tomledit v0.0.26 // indirect
8991
github.com/danieljoos/wincred v1.2.1 // indirect
9092
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
9193
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect
9294
github.com/desertbit/timer v1.0.1 // indirect
93-
github.com/dgraph-io/badger/v4 v4.2.0 // indirect
94-
github.com/dgraph-io/ristretto v0.1.1 // indirect
95+
github.com/dgraph-io/badger/v4 v4.5.1 // indirect
96+
github.com/dgraph-io/ristretto/v2 v2.1.0 // indirect
9597
github.com/distribution/reference v0.5.0 // indirect
9698
github.com/dustin/go-humanize v1.0.1 // indirect
9799
github.com/dvsekhvalnov/jose2go v1.7.0 // indirect
@@ -102,7 +104,7 @@ require (
102104
github.com/fatih/color v1.17.0 // indirect
103105
github.com/felixge/httpsnoop v1.0.4 // indirect
104106
github.com/fsnotify/fsnotify v1.9.0 // indirect
105-
github.com/getsentry/sentry-go v0.28.1 // indirect
107+
github.com/getsentry/sentry-go v0.31.1 // indirect
106108
github.com/go-jose/go-jose/v4 v4.0.5 // indirect
107109
github.com/go-kit/kit v0.13.0 // indirect
108110
github.com/go-kit/log v0.2.1 // indirect
@@ -113,12 +115,11 @@ require (
113115
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
114116
github.com/gogo/googleapis v1.4.1 // indirect
115117
github.com/gogo/protobuf v1.3.2 // indirect
116-
github.com/golang/glog v1.2.4 // indirect
117-
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
118+
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
118119
github.com/golang/mock v1.6.0 // indirect
119-
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
120+
github.com/golang/snappy v0.0.5-0.20231225225746-43d5d4cd4e0e // indirect
120121
github.com/google/btree v1.1.3 // indirect
121-
github.com/google/flatbuffers v24.3.25+incompatible // indirect
122+
github.com/google/flatbuffers v25.1.24+incompatible // indirect
122123
github.com/google/go-cmp v0.7.0 // indirect
123124
github.com/google/gofuzz v1.2.0 // indirect
124125
github.com/google/orderedcode v0.0.1 // indirect
@@ -137,7 +138,7 @@ require (
137138
github.com/hashicorp/go-metrics v0.5.4 // indirect
138139
github.com/hashicorp/go-plugin v1.6.3 // indirect
139140
github.com/hashicorp/go-safetemp v1.0.0 // indirect
140-
github.com/hashicorp/go-version v1.6.0 // indirect
141+
github.com/hashicorp/go-version v1.7.0 // indirect
141142
github.com/hashicorp/golang-lru v1.0.2 // indirect
142143
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
143144
github.com/hashicorp/yamux v0.1.1 // indirect
@@ -154,7 +155,7 @@ require (
154155
github.com/kr/pretty v0.3.1 // indirect
155156
github.com/kr/text v0.2.0 // indirect
156157
github.com/lib/pq v1.10.9 // indirect
157-
github.com/linxGnu/grocksdb v1.9.3 // indirect
158+
github.com/linxGnu/grocksdb v1.9.8 // indirect
158159
github.com/manifoldco/promptui v0.9.0 // indirect
159160
github.com/mattn/go-colorable v0.1.14 // indirect
160161
github.com/mattn/go-isatty v0.0.20 // indirect
@@ -195,7 +196,7 @@ require (
195196
github.com/zeebo/errs v1.4.0 // indirect
196197
github.com/zondax/hid v0.9.2 // indirect
197198
github.com/zondax/ledger-go v0.14.3 // indirect
198-
go.etcd.io/bbolt v1.4.0-alpha.1 // indirect
199+
go.etcd.io/bbolt v1.4.0 // indirect
199200
go.opencensus.io v0.24.0 // indirect
200201
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
201202
go.opentelemetry.io/contrib/detectors/gcp v1.34.0 // indirect
@@ -229,11 +230,12 @@ require (
229230
)
230231

231232
replace (
233+
cosmossdk.io/api => github.com/informalsystems/cosmos-sdk/api v0.7.5-lsm
232234
// use cosmos fork of keyring
233235
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0
234236
// Downgraded to avoid bugs in following commits which caused simulations to fail.
235237
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
236238
)
237239

238240
// use persistence's forks with LSM implemented
239-
replace github.com/cosmos/cosmos-sdk => github.com/persistenceOne/cosmos-sdk v0.50.14-lsm
241+
replace github.com/cosmos/cosmos-sdk => github.com/persistenceOne/cosmos-sdk v0.50.14-lsm-disabled

0 commit comments

Comments
 (0)