Skip to content

Commit 68b8d56

Browse files
committed
refactor: cleanup and migrate akash-api to chain-sdk
Signed-off-by: Artur Troian <[email protected]>
1 parent 8556302 commit 68b8d56

File tree

24 files changed

+414
-259
lines changed

24 files changed

+414
-259
lines changed

app/app.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ import (
4949
"github.com/cosmos/cosmos-sdk/x/authz"
5050
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
5151
"github.com/cosmos/cosmos-sdk/x/crisis"
52-
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
5352
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
5453
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
5554
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
@@ -298,7 +297,7 @@ func orderBeginBlockers(_ []string) []string {
298297
audittypes.ModuleName,
299298
genutiltypes.ModuleName,
300299
vestingtypes.ModuleName,
301-
crisistypes.ModuleName,
300+
//crisistypes.ModuleName,
302301
authtypes.ModuleName,
303302
authz.ModuleName,
304303
taketypes.ModuleName,
@@ -308,7 +307,7 @@ func orderBeginBlockers(_ []string) []string {
308307
slashingtypes.ModuleName,
309308
evidencetypes.ModuleName,
310309
stakingtypes.ModuleName,
311-
astaking.ModuleName,
310+
//astaking.ModuleName,
312311
transfertypes.ModuleName,
313312
ibchost.ModuleName,
314313
feegrant.ModuleName,
@@ -318,7 +317,7 @@ func orderBeginBlockers(_ []string) []string {
318317
// OrderEndBlockers returns EndBlockers (crisis, govtypes, staking) with no relative order.
319318
func OrderEndBlockers(_ []string) []string {
320319
return []string{
321-
crisistypes.ModuleName,
320+
//crisistypes.ModuleName,
322321
govtypes.ModuleName,
323322
stakingtypes.ModuleName,
324323
astaking.ModuleName,

app/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
1010
authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module"
1111
"github.com/cosmos/cosmos-sdk/x/bank"
12+
"github.com/cosmos/cosmos-sdk/x/consensus"
1213
"github.com/cosmos/cosmos-sdk/x/crisis"
1314
distr "github.com/cosmos/cosmos-sdk/x/distribution"
1415
"github.com/cosmos/cosmos-sdk/x/genutil"
@@ -56,6 +57,7 @@ var mbasics = module.NewBasicManager(
5657
),
5758
// chain parameters
5859
params.AppModuleBasic{},
60+
consensus.AppModuleBasic{},
5961
crisis.AppModuleBasic{},
6062
slashing.AppModuleBasic{},
6163
ibclightclient.AppModuleBasic{},

app/modules.go

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module"
1111
"github.com/cosmos/cosmos-sdk/x/bank"
1212
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
13+
"github.com/cosmos/cosmos-sdk/x/consensus"
1314
"github.com/cosmos/ibc-go/modules/capability"
1415
"pkg.akt.dev/go/sdkutil"
1516

@@ -144,11 +145,10 @@ func appModules(
144145
params.NewAppModule(
145146
app.Keepers.Cosmos.Params,
146147
),
147-
//crisis.NewAppModule(
148-
// app.Keepers.Cosmos.Crisis,
149-
// skipGenesisInvariants,
150-
// app.GetSubspace(crisistypes.ModuleName),
151-
//),
148+
consensus.NewAppModule(
149+
cdc,
150+
*app.Keepers.Cosmos.ConsensusParams,
151+
),
152152
// akash modules
153153
take.NewAppModule(
154154
app.cdc,
@@ -192,10 +192,6 @@ func appModules(
192192
app.cdc,
193193
app.Keepers.Akash.Cert,
194194
),
195-
//auction.NewAppModule(
196-
// app.cdc,
197-
// *app.Keepers.External.Auction,
198-
//),
199195
}
200196
}
201197

@@ -283,6 +279,10 @@ func appSimModules(
283279
params.NewAppModule(
284280
app.Keepers.Cosmos.Params,
285281
),
282+
//consensus.NewAppModule(
283+
// app.cdc,
284+
// *app.Keepers.Cosmos.ConsensusParams,
285+
//),
286286
evidence.NewAppModule(
287287
*app.Keepers.Cosmos.Evidence,
288288
),
@@ -292,11 +292,6 @@ func appSimModules(
292292
transfer.NewAppModule(
293293
app.Keepers.Cosmos.Transfer,
294294
),
295-
// auction.NewAppModule(
296-
// app.cdc,
297-
// *app.Keepers.External.Auction,
298-
// ),
299-
300295
// akash sim modules
301296
take.NewAppModule(
302297
app.cdc,

app/sim_test.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
1616
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
1717
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
18-
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
1918
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
2019
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
2120
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
@@ -326,12 +325,6 @@ func TestAppImportExport(t *testing.T) {
326325
appB,
327326
[][]byte{},
328327
},
329-
{
330-
crisistypes.StoreKey,
331-
appA,
332-
appB,
333-
[][]byte{},
334-
},
335328
{
336329
atypes.StoreKey,
337330
appA,
@@ -469,8 +462,7 @@ func TestAppStateDeterminism(t *testing.T) {
469462
}
470463

471464
encodingConfig := sdkutil.MakeEncodingConfig()
472-
473-
`akash.ModuleBasics().RegisterInterfaces(encodingConfig.InterfaceRegistry)`
465+
akash.ModuleBasics().RegisterInterfaces(encodingConfig.InterfaceRegistry)
474466

475467
config := sim.NewConfigFromFlags()
476468
config.InitialBlockHeight = 1

app/types/app.go

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,14 @@ import (
5858
porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types"
5959
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
6060
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"
61-
etypes "pkg.akt.dev/go/node/escrow/v1"
6261

6362
atypes "pkg.akt.dev/go/node/audit/v1"
6463
ctypes "pkg.akt.dev/go/node/cert/v1"
6564
dtypes "pkg.akt.dev/go/node/deployment/v1"
65+
dv1beta "pkg.akt.dev/go/node/deployment/v1beta3"
66+
etypes "pkg.akt.dev/go/node/escrow/v1"
6667
agovtypes "pkg.akt.dev/go/node/gov/v1beta3"
67-
mtypes "pkg.akt.dev/go/node/market/v1beta5"
68+
mtypes "pkg.akt.dev/go/node/market/v1beta4"
6869
ptypes "pkg.akt.dev/go/node/provider/v1beta4"
6970
astakingtypes "pkg.akt.dev/go/node/staking/v1beta3"
7071
ttypes "pkg.akt.dev/go/node/take/v1"
@@ -426,21 +427,6 @@ func (app *App) InitNormalKeepers(
426427

427428
app.Keepers.Cosmos.IBC.SetRouter(ibcRouter)
428429

429-
// initialize the auction keeper
430-
//{
431-
//
432-
// auctionKeeper := auctionkeeper.NewKeeper(
433-
// cdc,
434-
// app.keys[auctiontypes.StoreKey],
435-
// app.Keepers.Cosmos.Acct,
436-
// app.Keepers.Cosmos.Bank,
437-
// app.Keepers.Cosmos.Distr,
438-
// app.Keepers.Cosmos.Staking,
439-
// authtypes.NewModuleAddress(govtypes.ModuleName).String(),
440-
// )
441-
// app.Keepers.External.Auction = &auctionKeeper
442-
//}
443-
444430
app.Keepers.Akash.Take = tkeeper.NewKeeper(
445431
cdc,
446432
app.keys[ttypes.StoreKey],
@@ -531,8 +517,8 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
531517
paramsKeeper.Subspace(icahosttypes.SubModuleName)
532518

533519
// akash params subspaces
534-
paramsKeeper.Subspace(dtypes.ModuleName)
535-
paramsKeeper.Subspace(mtypes.ModuleName)
520+
paramsKeeper.Subspace(dtypes.ModuleName).WithKeyTable(dv1beta.ParamKeyTable())
521+
paramsKeeper.Subspace(mtypes.ModuleName).WithKeyTable(mtypes.ParamKeyTable())
536522
paramsKeeper.Subspace(astakingtypes.ModuleName).WithKeyTable(astakingtypes.ParamKeyTable()) // nolint: staticcheck // SA1019
537523
paramsKeeper.Subspace(agovtypes.ModuleName).WithKeyTable(agovtypes.ParamKeyTable()) // nolint: staticcheck // SA1019
538524
paramsKeeper.Subspace(ttypes.ModuleName).WithKeyTable(ttypes.ParamKeyTable()) // nolint: staticcheck // SA1019

cmd/akash/cmd/genesis.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"github.com/cosmos/cosmos-sdk/x/genutil"
2020

2121
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
22-
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
2322
distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
2423
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
2524
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
@@ -156,15 +155,15 @@ func PrepareGenesis(clientCtx client.Context, appState map[string]json.RawMessag
156155
appState[govtypes.ModuleName] = govGenStateBz
157156

158157
// crisis module genesis
159-
crisisGenState := crisistypes.DefaultGenesisState()
160-
crisisGenState.ConstantFee = genesisParams.CrisisConstantFee
161-
// TODO Set initial community pool
162-
// distributionGenState.FeePool.CommunityPool = sdk.NewDecCoins()
163-
crisisGenStateBz, err := cdc.MarshalJSON(crisisGenState)
164-
if err != nil {
165-
return nil, nil, fmt.Errorf("failed to marshal crisis genesis state: %w", err)
166-
}
167-
appState[crisistypes.ModuleName] = crisisGenStateBz
158+
//crisisGenState := crisistypes.DefaultGenesisState()
159+
//crisisGenState.ConstantFee = genesisParams.CrisisConstantFee
160+
//// TODO Set initial community pool
161+
//// distributionGenState.FeePool.CommunityPool = sdk.NewDecCoins()
162+
//crisisGenStateBz, err := cdc.MarshalJSON(crisisGenState)
163+
//if err != nil {
164+
// return nil, nil, fmt.Errorf("failed to marshal crisis genesis state: %w", err)
165+
//}
166+
//appState[crisistypes.ModuleName] = crisisGenStateBz
168167

169168
// slashing module genesis
170169
slashingGenState := slashingtypes.DefaultGenesisState()

cmd/akash/cmd/root.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,24 @@ import (
44
"context"
55
"os"
66

7-
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
87
"github.com/rs/zerolog"
98
"github.com/spf13/cobra"
109
"pkg.akt.dev/go/cli"
1110

1211
cmtcfg "github.com/cometbft/cometbft/config"
1312
cmtcli "github.com/cometbft/cometbft/libs/cli"
1413

15-
"github.com/cosmos/cosmos-sdk/client/pruning"
16-
"github.com/cosmos/cosmos-sdk/client/snapshot"
17-
14+
_ "github.com/coinbase/rosetta-sdk-go/types"
1815
sdkclient "github.com/cosmos/cosmos-sdk/client"
1916
"github.com/cosmos/cosmos-sdk/client/debug"
2017
"github.com/cosmos/cosmos-sdk/client/keys"
18+
"github.com/cosmos/cosmos-sdk/client/pruning"
19+
"github.com/cosmos/cosmos-sdk/client/snapshot"
2120
sdkserver "github.com/cosmos/cosmos-sdk/server"
2221
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
22+
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
2323
"github.com/cosmos/cosmos-sdk/x/crisis"
24+
rosettaCmd "github.com/cosmos/rosetta/cmd"
2425

2526
cflags "pkg.akt.dev/go/cli/flags"
2627
"pkg.akt.dev/go/sdkutil"
@@ -131,7 +132,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig sdkutil.EncodingConfig)
131132
genesisCommand(encodingConfig),
132133
cmtcli.NewCompletionCmd(rootCmd, true),
133134
debugCmd,
134-
//rosettaCmd.RosettaCommand(encodingConfig.InterfaceRegistry, encodingConfig.Codec),
135+
rosettaCmd.RosettaCommand(encodingConfig.InterfaceRegistry, encodingConfig.Codec),
135136
pruning.Cmd(ac.newApp, home),
136137
snapshot.Cmd(ac.newApp),
137138
testnetCmd(app.ModuleBasics(), banktypes.GenesisBalancesIterator{}),

cmd/akash/cmd/testnetify/testnetify.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package testnetify
22

33
import (
44
"bufio"
5+
"context"
56
"encoding/json"
67
"fmt"
78
"io"
@@ -26,6 +27,7 @@ import (
2627
serverconfig "github.com/cosmos/cosmos-sdk/server/config"
2728
"github.com/cosmos/cosmos-sdk/telemetry"
2829
"github.com/spf13/cobra"
30+
"golang.org/x/sync/errgroup"
2931

3032
dbm "github.com/cosmos/cosmos-db"
3133
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
@@ -165,6 +167,15 @@ you want to test the upgrade handler itself.
165167
return err
166168
}
167169

170+
ctx, cancelFn := context.WithCancel(cmd.Context())
171+
172+
getCtx := func(svrCtx *server.Context, block bool) (*errgroup.Group, context.Context) {
173+
g, ctx := errgroup.WithContext(ctx)
174+
// listen for quit signals so the calling parent process can gracefully exit
175+
server.ListenForQuitSignals(g, block, cancelFn, svrCtx.Logger)
176+
return g, ctx
177+
}
178+
168179
defer func() {
169180
traceCleanupFn()
170181
if localErr := app.Close(); localErr != nil {
@@ -174,11 +185,8 @@ you want to test the upgrade handler itself.
174185

175186
go func() {
176187
defer func() {
177-
if proc, err := os.FindProcess(os.Getpid()); err == nil {
178-
_ = proc.Signal(os.Interrupt)
179-
}
188+
cancelFn()
180189
}()
181-
ctx := cmd.Context()
182190

183191
cctx, err := client.GetClientQueryContext(cmd)
184192
if err != nil {
@@ -225,7 +233,9 @@ you want to test the upgrade handler itself.
225233
}
226234
}()
227235

228-
err = sdksrv.StartInProcess(sctx, srvCfg, cctx, app, metrics, sdksrv.StartCmdOptions{})
236+
err = sdksrv.StartInProcess(sctx, srvCfg, cctx, app, metrics, sdksrv.StartCmdOptions{
237+
GetCtx: getCtx,
238+
})
229239
if err != nil && !strings.Contains(err.Error(), "130") {
230240
sctx.Logger.Error("testnetify finished with error", "err", err.Error())
231241
return err

0 commit comments

Comments
 (0)