-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(upgrade): network upgrade v0.32.0
Signed-off-by: Artur Troian <[email protected]>
- Loading branch information
Showing
14 changed files
with
248 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"migrations": { | ||
"market": { | ||
"from": "4", | ||
"to": "5" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
//go:build e2e.upgrade | ||
|
||
// Package v0_32_0 | ||
// nolint revive | ||
package v0_32_0 | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
types "github.com/akash-network/akash-api/go/node/types/v1beta3" | ||
sdkclient "github.com/cosmos/cosmos-sdk/client" | ||
"github.com/cosmos/cosmos-sdk/client/flags" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" | ||
"github.com/stretchr/testify/require" | ||
|
||
cltypes "github.com/akash-network/akash-api/go/node/client/types" | ||
ptypes "github.com/akash-network/akash-api/go/node/provider/v1beta3" | ||
|
||
"github.com/akash-network/node/app" | ||
"github.com/akash-network/node/client" | ||
uttypes "github.com/akash-network/node/tests/upgrade/types" | ||
) | ||
|
||
func init() { | ||
uttypes.RegisterPostUpgradeWorker("v0.32.0", &postUpgrade{}) | ||
} | ||
|
||
type postUpgrade struct{} | ||
|
||
var _ uttypes.TestWorker = (*postUpgrade)(nil) | ||
|
||
func (pu *postUpgrade) Run(ctx context.Context, t *testing.T, params uttypes.TestParams) { | ||
encodingConfig := app.MakeEncodingConfig() | ||
|
||
rpcClient, err := sdkclient.NewClientFromNode(params.Node) | ||
require.NoError(t, err) | ||
|
||
cctx := sdkclient.Context{}. | ||
WithCodec(encodingConfig.Marshaler). | ||
WithInterfaceRegistry(encodingConfig.InterfaceRegistry). | ||
WithTxConfig(encodingConfig.TxConfig). | ||
WithLegacyAmino(encodingConfig.Amino). | ||
WithAccountRetriever(authtypes.AccountRetriever{}). | ||
WithBroadcastMode(flags.BroadcastBlock). | ||
WithHomeDir(params.Home). | ||
WithChainID(params.ChainID). | ||
WithNodeURI(params.Node). | ||
WithClient(rpcClient). | ||
WithSkipConfirmation(true). | ||
WithFrom(params.From). | ||
WithKeyringDir(params.Home) | ||
|
||
kr, err := sdkclient.NewKeyringFromBackend(cctx, params.KeyringBackend) | ||
require.NoError(t, err) | ||
|
||
info, err := kr.Key(params.From) | ||
require.NoError(t, err) | ||
|
||
cctx = cctx.WithFromName(info.GetName()). | ||
WithFromAddress(info.GetAddress()). | ||
WithKeyring(kr) | ||
|
||
cl, err := client.DiscoverClient(ctx, cctx, cltypes.WithGasPrices("0.0025uakt"), cltypes.WithGas(flags.GasSetting{Simulate: false, Gas: 100000})) | ||
require.NoError(t, err) | ||
require.NotNil(t, cl) | ||
|
||
cmsg := &ptypes.MsgCreateProvider{ | ||
Owner: cctx.GetFromAddress().String(), | ||
HostURI: "https://example.com:443", | ||
Info: ptypes.ProviderInfo{}, | ||
Attributes: types.Attributes{ | ||
{ | ||
Key: "test1", | ||
Value: "test1", | ||
}, | ||
}, | ||
} | ||
|
||
err = cmsg.ValidateBasic() | ||
require.NoError(t, err) | ||
|
||
resp, err := cl.Tx().Broadcast(ctx, []sdk.Msg{cmsg}) | ||
require.NoError(t, err) | ||
require.NotNil(t, resp) | ||
require.IsType(t, &sdk.TxResponse{}, resp) | ||
|
||
txResp := resp.(*sdk.TxResponse) | ||
|
||
require.Equal(t, uint32(0), txResp.Code) | ||
|
||
pmsg := &ptypes.MsgUpdateProvider{ | ||
Owner: cctx.GetFromAddress().String(), | ||
HostURI: "https://example.com:443", | ||
Info: ptypes.ProviderInfo{}, | ||
Attributes: types.Attributes{ | ||
{ | ||
Key: "test1", | ||
Value: "test1", | ||
}, | ||
}, | ||
} | ||
|
||
err = cmsg.ValidateBasic() | ||
require.NoError(t, err) | ||
|
||
resp, err = cl.Tx().Broadcast(ctx, []sdk.Msg{pmsg}) | ||
require.NoError(t, err) | ||
require.NotNil(t, resp) | ||
require.IsType(t, &sdk.TxResponse{}, resp) | ||
|
||
txResp = resp.(*sdk.TxResponse) | ||
|
||
require.Equal(t, uint32(0), txResp.Code) | ||
require.LessOrEqual(t, txResp.GasUsed, int64(100000)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Package v0_32_0 | ||
// nolint revive | ||
package v0_32_0 | ||
|
||
import ( | ||
mv1beta4 "github.com/akash-network/akash-api/go/node/market/v1beta4" | ||
|
||
utypes "github.com/akash-network/node/upgrades/types" | ||
) | ||
|
||
func init() { | ||
utypes.RegisterUpgrade(UpgradeName, initUpgrade) | ||
utypes.RegisterMigration(mv1beta4.ModuleName, 4, newMarketMigration) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Package v0_32_0 | ||
// nolint revive | ||
package v0_32_0 | ||
|
||
import ( | ||
types "github.com/akash-network/akash-api/go/node/market/v1beta4" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
sdkmodule "github.com/cosmos/cosmos-sdk/types/module" | ||
|
||
utypes "github.com/akash-network/node/upgrades/types" | ||
"github.com/akash-network/node/x/market/keeper/keys/v1beta4" | ||
) | ||
|
||
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 3 to 4. | ||
func (m marketMigrations) handler(ctx sdk.Context) error { | ||
store := ctx.KVStore(m.StoreKey()) | ||
iter := sdk.KVStorePrefixIterator(store, types.LeasePrefix()) | ||
defer iter.Close() | ||
for ; iter.Valid(); iter.Next() { | ||
var val types.Lease | ||
m.Codec().MustUnmarshal(iter.Value(), &val) | ||
|
||
store.Delete(v1beta4.SecondaryLeaseKeyByProvider(val.LeaseID)) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Package v0_32_0 | ||
// nolint revive | ||
package v0_32_0 | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/tendermint/tendermint/libs/log" | ||
|
||
storetypes "github.com/cosmos/cosmos-sdk/store/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" | ||
|
||
apptypes "github.com/akash-network/node/app/types" | ||
utypes "github.com/akash-network/node/upgrades/types" | ||
) | ||
|
||
const ( | ||
UpgradeName = "v0.32.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 sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { | ||
return up.MM.RunMigrations(ctx, up.Configurator, fromVM) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.