Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions app/types/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,10 +482,10 @@
ibctable := ibcclienttypes.ParamKeyTable()
ibctable.RegisterParamSet(&ibcconnectiontypes.Params{})

paramsKeeper.Subspace(authtypes.ModuleName).WithKeyTable(authtypes.ParamKeyTable()) // nolint: staticcheck
paramsKeeper.Subspace(banktypes.ModuleName).WithKeyTable(banktypes.ParamKeyTable()) // nolint: staticcheck // SA1019
paramsKeeper.Subspace(stakingtypes.ModuleName).WithKeyTable(stakingtypes.ParamKeyTable()) // nolint: staticcheck // SA1019
paramsKeeper.Subspace(minttypes.ModuleName).WithKeyTable(minttypes.ParamKeyTable()) // nolint: staticcheck // SA1019
paramsKeeper.Subspace(authtypes.ModuleName).WithKeyTable(authtypes.ParamKeyTable()) // nolint: staticcheck
paramsKeeper.Subspace(banktypes.ModuleName).WithKeyTable(banktypes.ParamKeyTable()) // nolint: staticcheck // SA1019
paramsKeeper.Subspace(stakingtypes.ModuleName).WithKeyTable(stakingtypes.ParamKeyTable()) // nolint: staticcheck // SA1019
//paramsKeeper.Subspace(minttypes.ModuleName).WithKeyTable(minttypes.ParamKeyTable()) // nolint: staticcheck // SA1019

Check failure on line 488 in app/types/app.go

View workflow job for this annotation

GitHub Actions / lint-go

commentFormatting: put a space between `//` and comment text (gocritic)
paramsKeeper.Subspace(distrtypes.ModuleName).WithKeyTable(distrtypes.ParamKeyTable()) // nolint: staticcheck // SA1019
paramsKeeper.Subspace(slashingtypes.ModuleName).WithKeyTable(slashingtypes.ParamKeyTable()) // nolint: staticcheck // SA1019
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable()) // nolint: staticcheck // SA1019
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module pkg.akt.dev/node

go 1.25.4
go 1.25.5

require (
cosmossdk.io/api v0.9.2
Expand Down Expand Up @@ -54,7 +54,7 @@ replace (
// use cosmos fork of keyring
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0

github.com/bytedance/sonic => github.com/bytedance/sonic v1.14.1
github.com/bytedance/sonic => github.com/bytedance/sonic v1.14.2

// use akash fork of cometbft
github.com/cometbft/cometbft => github.com/akash-network/cometbft v0.38.21-akash.1
Expand Down Expand Up @@ -113,7 +113,7 @@ require (
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/bytedance/gopkg v0.1.3 // indirect
github.com/bytedance/sonic v1.13.2 // indirect
github.com/bytedance/sonic/loader v0.3.0 // indirect
github.com/bytedance/sonic/loader v0.4.0 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/chzyer/readline v1.5.1 // indirect
Expand Down
9 changes: 5 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1340,10 +1340,10 @@ github.com/bufbuild/protocompile v0.14.1 h1:iA73zAf/fyljNjQKwYzUHD6AD4R8KMasmwa/
github.com/bufbuild/protocompile v0.14.1/go.mod h1:ppVdAIhbr2H8asPk6k4pY7t9zB1OU5DoEw9xY/FUi1c=
github.com/bytedance/gopkg v0.1.3 h1:TPBSwH8RsouGCBcMBktLt1AymVo2TVsBVCY4b6TnZ/M=
github.com/bytedance/gopkg v0.1.3/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM=
github.com/bytedance/sonic v1.14.1 h1:FBMC0zVz5XUmE4z9wF4Jey0An5FueFvOsTKKKtwIl7w=
github.com/bytedance/sonic v1.14.1/go.mod h1:gi6uhQLMbTdeP0muCnrjHLeCUPyb70ujhnNlhOylAFc=
github.com/bytedance/sonic/loader v0.3.0 h1:dskwH8edlzNMctoruo8FPTJDF3vLtDT0sXZwvZJyqeA=
github.com/bytedance/sonic/loader v0.3.0/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
github.com/bytedance/sonic v1.14.2 h1:k1twIoe97C1DtYUo+fZQy865IuHia4PR5RPiuGPPIIE=
github.com/bytedance/sonic v1.14.2/go.mod h1:T80iDELeHiHKSc0C9tubFygiuXoGzrkjKzX2quAx980=
github.com/bytedance/sonic/loader v0.4.0 h1:olZ7lEqcxtZygCK9EKYKADnpQoYkRQxaeY2NYzevs+o=
github.com/bytedance/sonic/loader v0.4.0/go.mod h1:AR4NYCk5DdzZizZ5djGqQ92eEhCCcdf5x77udYiSJRo=
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4=
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
Expand Down Expand Up @@ -2183,6 +2183,7 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
Expand Down
5 changes: 1 addition & 4 deletions make/test-upgrade.mk
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,14 @@ UPGRADE_FROM := $(shell cat $(ROOT_DIR)/meta.json | jq -r --arg name
GENESIS_BINARY_VERSION := $(shell cat $(ROOT_DIR)/meta.json | jq -r --arg name $(UPGRADE_TO) '.upgrades[$$name].from_binary' | tr -d '\n')
UPGRADE_BINARY_VERSION ?= local

SNAPSHOT_SOURCE ?= sandbox-2
SNAPSHOT_SOURCE ?= sandbox

ifeq ($(SNAPSHOT_SOURCE),mainnet)
SNAPSHOT_NETWORK := akashnet-2
CHAIN_METADATA_URL := https://raw.githubusercontent.com/akash-network/net/master/mainnet/meta.json
else ifeq ($(SNAPSHOT_SOURCE),sandbox)
SNAPSHOT_NETWORK := sandbox-2
CHAIN_METADATA_URL := https://raw.githubusercontent.com/akash-network/net/master/sandbox-2/meta.json
else ifeq ($(SNAPSHOT_SOURCE),sandbox1)
SNAPSHOT_NETWORK := sandbox-01
CHAIN_METADATA_URL := https://raw.githubusercontent.com/akash-network/net/master/sandbox/meta.json
else
$(error "invalid snapshot source $(SNAPSHOT_SOURCE)")
endif
Expand Down
5 changes: 5 additions & 0 deletions meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
"skipped": false,
"from_binary": "v1.0.4",
"from_version": "v1.0.0"
},
"v1.2.0": {
"skipped": false,
"from_binary": "v1.1.1",
"from_version": "v1.1.0"
}
}
}
12 changes: 12 additions & 0 deletions tests/upgrade/test-cases.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
{
"v1.2.0": {
"modules": {
},
"migrations": {
"market": [
{
"from": "7",
"to": "8"
}
]
}
},
"v1.1.0": {
"modules": {
},
Expand Down
53 changes: 0 additions & 53 deletions upgrades/software/v1.0.0/market.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,41 +35,6 @@ func (m marketMigrations) handler(ctx sdk.Context) error {

cdc := m.Codec()

// order prefix does not change in this upgrade
oiter := storetypes.KVStorePrefixIterator(store, mkeys.OrderPrefix)
defer func() {
_ = oiter.Close()
}()

var ordersTotal uint64
var ordersOpen uint64
var ordersActive uint64
var ordersClosed uint64

for ; oiter.Valid(); oiter.Next() {
nVal := migrate.OrderFromV1beta4(cdc, oiter.Value())

switch nVal.State {
case mv1beta.OrderOpen:
ordersOpen++
case mv1beta.OrderActive:
ordersActive++
case mv1beta.OrderClosed:
ordersClosed++
default:
return fmt.Errorf("unknown order state %d", nVal.State)
}

ordersTotal++

bz := cdc.MustMarshal(&nVal)

store.Delete(oiter.Key())

key := mkeys.MustOrderKey(mkeys.OrderStateToPrefix(nVal.State), nVal.ID)
store.Set(key, bz)
}

// bid prefixes do not change in this upgrade
store.Delete(mkeys.BidPrefixReverse)
biter := storetypes.KVStorePrefixIterator(store, mkeys.BidPrefix)
Expand Down Expand Up @@ -175,24 +140,6 @@ func (m marketMigrations) handler(ctx sdk.Context) error {
store.Set(revKey, data)
}
}
ctx.Logger().Info(fmt.Sprintf("[upgrade %s]: updated x/market store keys:"+
"\n\torders total: %d"+
"\n\torders open: %d"+
"\n\torders active: %d"+
"\n\torders closed: %d"+
"\n\tbids total: %d"+
"\n\tbids open: %d"+
"\n\tbids active: %d"+
"\n\tbids lost: %d"+
"\n\tbids closed: %d"+
"\n\tleases total: %d"+
"\n\tleases active: %d"+
"\n\tleases insufficient funds: %d"+
"\n\tleases closed: %d",
UpgradeName,
ordersTotal, ordersOpen, ordersActive, ordersClosed,
bidsTotal, bidsOpen, bidsActive, bidsLost, bidsClosed,
leasesTotal, leasesActive, leasesInsufficientFunds, leasesClosed))

return nil
}
15 changes: 15 additions & 0 deletions upgrades/software/v1.2.0/init.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Package v1_2_0
// nolint revive
package v1_2_0

import (
mv1 "pkg.akt.dev/go/node/market/v1"

utypes "pkg.akt.dev/node/upgrades/types"
)

func init() {
utypes.RegisterUpgrade(UpgradeName, initUpgrade)

utypes.RegisterMigration(mv1.ModuleName, 7, newMarketMigration)
}
148 changes: 148 additions & 0 deletions upgrades/software/v1.2.0/market.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
// Package v1_2_0
// nolint revive
package v1_2_0

import (
"fmt"

"cosmossdk.io/collections"
storetypes "cosmossdk.io/store/types"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/runtime"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkmodule "github.com/cosmos/cosmos-sdk/types/module"

mv1 "pkg.akt.dev/go/node/market/v1"
mtypes "pkg.akt.dev/go/node/market/v1beta5"

utypes "pkg.akt.dev/node/upgrades/types"
mkeeper "pkg.akt.dev/node/x/market/keeper"
mkeys "pkg.akt.dev/node/x/market/keeper/keys"
)

type marketMigrations struct {
utypes.Migrator
}

func newMarketMigration(m utypes.Migrator) utypes.Migration {
return marketMigrations{Migrator: m}
}

func (m marketMigrations) GetHandler() sdkmodule.MigrationHandler {
return m.handler
}

// handler migrates market from version 7 to 8.
// Moves orders, bids, and leases from manual KVStore keys to collections.IndexedMap.
func (m marketMigrations) handler(ctx sdk.Context) error {
skey := m.StoreKey()
cdc := m.Codec()
store := ctx.KVStore(skey)

// Build IndexedMaps locally (same construction as NewKeeper)
ssvc := runtime.NewKVStoreService(skey.(*storetypes.KVStoreKey))
sb := collections.NewSchemaBuilder(ssvc)

orderIndexes := mkeeper.NewOrderIndexes(sb)
orders := collections.NewIndexedMap(sb, collections.NewPrefix(mkeys.OrderPrefixNew), "orders", mkeys.OrderPrimaryKeyCodec, codec.CollValue[mtypes.Order](cdc), orderIndexes)

bidIndexes := mkeeper.NewBidIndexes(sb)
bids := collections.NewIndexedMap(sb, collections.NewPrefix(mkeys.BidPrefixNew), "bids", mkeys.BidPrimaryKeyCodec, codec.CollValue[mtypes.Bid](cdc), bidIndexes)

leaseIndexes := mkeeper.NewLeaseIndexes(sb)
leases := collections.NewIndexedMap(sb, collections.NewPrefix(mkeys.LeasePrefixNew), "leases", mkeys.LeasePrimaryKeyCodec, codec.CollValue[mv1.Lease](cdc), leaseIndexes)

if _, err := sb.Build(); err != nil {
return err
}

// === Orders ===
oiter := storetypes.KVStorePrefixIterator(store, mkeys.OrderPrefix)
defer func() {
_ = oiter.Close()
}()

var orderCount int64
var bidCount int64
var leaseCount int64

for ; oiter.Valid(); oiter.Next() {
var order mtypes.Order
cdc.MustUnmarshal(oiter.Value(), &order)

pk := mkeys.OrderIDToKey(order.ID)
if err := orders.Set(ctx, pk, order); err != nil {
return fmt.Errorf("failed to migrate order %s: %w", order.ID, err)
}

store.Delete(oiter.Key())

orderCount++
}

// === Bids ===
biter := storetypes.KVStorePrefixIterator(store, mkeys.BidPrefix)
defer func() {
_ = biter.Close()
}()

for ; biter.Valid(); biter.Next() {
var bid mtypes.Bid
cdc.MustUnmarshal(biter.Value(), &bid)

pk := mkeys.BidIDToKey(bid.ID)
if err := bids.Set(ctx, pk, bid); err != nil {
return fmt.Errorf("failed to migrate bid %s: %w", bid.ID, err)
}

store.Delete(biter.Key())
bidCount++
}

// Delete old bid reverse keys
brevIter := storetypes.KVStorePrefixIterator(store, mkeys.BidPrefixReverse)
defer func() {
_ = brevIter.Close()
}()

for ; brevIter.Valid(); brevIter.Next() {
store.Delete(brevIter.Key())
}

// === Leases ===
liter := storetypes.KVStorePrefixIterator(store, mkeys.LeasePrefix)
defer func() {
_ = liter.Close()
}()

for ; liter.Valid(); liter.Next() {
var lease mv1.Lease
cdc.MustUnmarshal(liter.Value(), &lease)

pk := mkeys.LeaseIDToKey(lease.ID)
if err := leases.Set(ctx, pk, lease); err != nil {
return fmt.Errorf("failed to migrate lease %s: %w", lease.ID, err)
}

store.Delete(liter.Key())
leaseCount++
}

// Delete old lease reverse keys
lrevIter := storetypes.KVStorePrefixIterator(store, mkeys.LeasePrefixReverse)
defer func() {
_ = lrevIter.Close()
}()

for ; lrevIter.Valid(); lrevIter.Next() {
store.Delete(lrevIter.Key())
}

ctx.Logger().Info("market store migration complete",
"orders_migrated", orderCount,
"bids_migrated", bidCount,
"leases_migrated", leaseCount,
)

return nil
}
53 changes: 53 additions & 0 deletions upgrades/software/v1.2.0/upgrade.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Package v1_2_0
// nolint revive
package v1_2_0

import (
"context"
"fmt"

"cosmossdk.io/log"
storetypes "cosmossdk.io/store/types"
upgradetypes "cosmossdk.io/x/upgrade/types"
"github.com/cosmos/cosmos-sdk/types/module"

apptypes "pkg.akt.dev/node/app/types"
utypes "pkg.akt.dev/node/upgrades/types"
)

const (
UpgradeName = "v1.2.0"
)

type upgrade struct {
*apptypes.App
log log.Logger
}

var _ utypes.IUpgrade = (*upgrade)(nil)

func initUpgrade(log log.Logger, app *apptypes.App) (utypes.IUpgrade, error) {
up := &upgrade{
App: app,
log: log.With("module", fmt.Sprintf("upgrade/%s", UpgradeName)),
}

return up, nil
}

func (up *upgrade) StoreLoader() *storetypes.StoreUpgrades {
return &storetypes.StoreUpgrades{}
}

func (up *upgrade) UpgradeHandler() upgradetypes.UpgradeHandler {
return func(ctx context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
toVM, err := up.MM.RunMigrations(ctx, up.Configurator, fromVM)
if err != nil {
return nil, err
}

up.log.Info(fmt.Sprintf("all migrations have been completed"))

return toVM, err
}
}
Loading
Loading