Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decouple #155

Merged
merged 23 commits into from
Oct 15, 2024
Merged
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
4 changes: 2 additions & 2 deletions .github/images/builder.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# TODO: once we migrate to wasmvm 2.1.0, we can go back to using base golang image
FROM alpine:3.18

ENV PATH /usr/local/go/bin:$PATH
ENV PATH=/usr/local/go/bin:$PATH
COPY --from=golang:1.22 /usr/local/go /usr/local/go

ARG LEDGER_ENABLED
Expand All @@ -19,7 +19,7 @@ RUN set -eux; apk add --no-cache ca-certificates build-base;

RUN apk add git

ARG WASMVM_VERSION="v2.0.0"
ARG WASMVM_VERSION="v2.1.3"
ARG WASMVM_LIB="libwasmvm_muslc.x86_64.a"
ARG WASMVM_BASE_URL="https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION"
ARG WASMVM_URL="$WASMVM_BASE_URL/$WASMVM_LIB"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/nolus-core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ env:

# docker images
CONTAINER_REGISTRY: ghcr.io
BUILDER_IMAGE_TAG: "1.22.3"
BUILDER_IMAGE_TAG: "1.22.5"
BUILDER_IMAGE_NAME: "builder"
BUILDER_DOCKERFILE: ".github/images/builder.Dockerfile"
PROTOGEN_IMAGE_TAG: "0.2.0"
Expand Down Expand Up @@ -172,8 +172,8 @@ jobs:
needs: [test-unit-coverage, builder-image]
container:
# image name needs to be hardcoded: https://github.com/orgs/community/discussions/26324
image: "ghcr.io/nolus-protocol/nolus-core/builder:1.22.3"

image: "ghcr.io/nolus-protocol/nolus-core/builder:1.22.5"
steps:
- uses: actions/checkout@v4

Expand Down
1 change: 0 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,3 @@ issues:
# Set to 0 to disable.
# Default: 3
max-same-issues: 0

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ On a live network, a new DEX can be deployed using the following steps.
### Аutomated step

```sh
./scripts/add-new-dex.sh --dex-admin-key <dex_admin_key> --store-code-privileged-user-key <store_code_privileged_user_key> --wasm-artifacts-path <wasm_artifacts_dir_path> --dex-name <dex_name> --dex-chain-id <new_dex_chain_id> --dex-ip-addr-rpc-host <new_dex_ip_addr_rpc_host_part> --dex-ip-addr-grpc-host <new_dex_ip_addr_grpc_host_part> --dex-account-prefix <new_dex_account_prefix> --dex-price-denom <new_dex_price_denom> --dex-trusting-period-secs <new_dex_trusting_period_in_seconds> --dex-if-interchain-security <if_interchain_security_true/false> --protocol-currency <new_protocol_currency> --protocol-swap-tree <new_protocol_swap_tree>
./scripts/add-new-dex.sh --wasm-artifacts-path <wasm_artifacts_dir_path> --dex-name <dex_name> --dex-chain-id <new_dex_chain_id> --dex-ip-addr-rpc-host <new_dex_ip_addr_rpc_host_part> --dex-ip-addr-grpc-host <new_dex_ip_addr_grpc_host_part> --dex-account-prefix <new_dex_account_prefix> --dex-gas-price-denom <new_dex_price_denom> --dex-trusting-period-secs <new_dex_trusting_period_in_seconds> --dex-if-interchain-security <if_interchain_security_true/false> --protocol-currency <new_protocol_currency> --protocol-swap-tree <new_protocol_swap_tree> --dex-network <dex_network_name> --dex-type-and-params '<dex_specific_field>'
```

The script takes care of setting up Hermes to work with the new DEX and, for now, deploying DEX-specific contracts (More about deploying contracts on a live network can be found [here](https://github.com/nolus-protocol/nolus-money-market)).
Expand Down
43 changes: 41 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import (
"github.com/Nolus-Protocol/nolus-core/app/keepers"
appparams "github.com/Nolus-Protocol/nolus-core/app/params"
"github.com/Nolus-Protocol/nolus-core/app/upgrades"
v065 "github.com/Nolus-Protocol/nolus-core/app/upgrades/v065"
v066 "github.com/Nolus-Protocol/nolus-core/app/upgrades/v066"
"github.com/Nolus-Protocol/nolus-core/docs"

wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
Expand All @@ -67,7 +67,7 @@ const (
var (
DefaultNodeHome string

Upgrades = []upgrades.Upgrade{v065.Upgrade}
Upgrades = []upgrades.Upgrade{v066.Upgrade}
)

var (
Expand Down Expand Up @@ -486,3 +486,42 @@ func GetMaccPerms() map[string][]string {
func (app *App) RegisterNodeService(clientCtx client.Context, cfg config.Config) {
nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter(), cfg)
}

// TODO
// // GetTxConfig implements the TestingApp interface.
// func (app *App) GetTxConfig() client.TxConfig {
// return app.encodingConfig.TxConfig
// }

// // GetIBCKeeper implements the TestingApp interface.
// func (app *App) GetIBCKeeper() *ibckeeper.Keeper {
// return app.IBCKeeper
// }

// // GetScopedIBCKeeper implements the TestingApp interface.
// func (app *App) GetScopedIBCKeeper() capabilitykeeper.ScopedKeeper {
// return app.ScopedIBCKeeper
// }

// // GetStakingKeeper implements the TestingApp interface.
// func (app *App) GetStakingKeeper() ibctestingtypes.StakingKeeper {
// return app.StakingKeeper
// }

// // InitChainer application update at chain initialization.
// // ONLY FOR TESTING PURPOSES.
// func (app *App) TestInitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) {
// var genesisState GenesisState
// if err := tmjson.Unmarshal(req.AppStateBytes, &genesisState); err != nil {
// panic(err)
// }

// // manually set consensus params here, cause there is no way to set it using ibctesting stuff for now
// // TODO: app.ConsensusParamsKeeper.Set(ctx, sims.DefaultConsensusParams)

// err := app.UpgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap())
// if err != nil {
// return nil, fmt.Errorf("failed to set module version map: %w", err)
// }
// return app.mm.InitGenesis(ctx, app.appCodec, genesisState)
// }
5 changes: 2 additions & 3 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,7 @@ func (appKeepers *AppKeepers) NewAppKeepers(
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
appKeepers.ICAHostKeeper = &icaHostKeeper
// TODO: use this with ibc-go v8.3.0 https://github.com/cosmos/ibc-go/issues/6415
// appKeepers.ICAHostKeeper.WithQueryRouter(grpcQueryRouter)
appKeepers.ICAHostKeeper.WithQueryRouter(grpcQueryRouter)

appKeepers.IcaModule = ica.NewAppModule(appKeepers.ICAControllerKeeper, appKeepers.ICAHostKeeper)

Expand Down Expand Up @@ -424,7 +423,7 @@ func (appKeepers *AppKeepers) NewAppKeepers(
var wasmOpts []wasmkeeper.Option
// The last arguments can contain custom message handlers, and custom query handlers,
// if we want to allow any custom callbacks
supportedFeatures := []string{"iterator", "stargate", "staking", "neutron", "migrate", "upgrade", "cosmwasm_1_1", "cosmwasm_1_2", "cosmwasm_1_3", "cosmwasm_1_4", "cosmwasm_2_0"}
supportedFeatures := []string{"iterator", "stargate", "staking", "neutron", "migrate", "upgrade", "cosmwasm_1_1", "cosmwasm_1_2", "cosmwasm_1_3", "cosmwasm_1_4", "cosmwasm_2_0", "cosmwasm_2_1"}
wasmOpts = append(wasmbinding.RegisterCustomPlugins(
appKeepers.InterchainTxsKeeper,
appKeepers.InterchainQueriesKeeper,
Expand Down
4 changes: 2 additions & 2 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func appModules(
distribution.NewAppModule(appCodec, *app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)),
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)),
upgrade.NewAppModule(app.UpgradeKeeper, address.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix())),
wasm.NewAppModule(appCodec, &app.WasmKeeper, app.AccountKeeper, app.BankKeeper, app.MsgServiceRouter(), app.GetSubspace(wasmtypes.ModuleName)),
wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.MsgServiceRouter(), app.GetSubspace(wasmtypes.ModuleName)),
evidence.NewAppModule(*app.EvidenceKeeper),
ibc.NewAppModule(app.IBCKeeper),
sdkparams.NewAppModule(*app.ParamsKeeper),
Expand Down Expand Up @@ -188,7 +188,7 @@ func simulationModules(
slashing.NewAppModule(appCodec, *app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName), app.interfaceRegistry),
sdkparams.NewAppModule(*app.ParamsKeeper),
evidence.NewAppModule(*app.EvidenceKeeper),
wasm.NewAppModule(appCodec, &app.WasmKeeper, app.AccountKeeper, app.BankKeeper, app.MsgServiceRouter(), app.GetSubspace(wasmtypes.ModuleName)),
wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.MsgServiceRouter(), app.GetSubspace(wasmtypes.ModuleName)),
ibc.NewAppModule(app.IBCKeeper),
app.AppKeepers.TransferModule,
app.AppKeepers.InterchainQueriesModule,
Expand Down
19 changes: 19 additions & 0 deletions app/upgrades/v066/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package v066

import (
store "cosmossdk.io/store/types"
"github.com/Nolus-Protocol/nolus-core/app/upgrades"
)

const (
// UpgradeName defines the on-chain upgrades name.
UpgradeName = "v0.6.6"
)

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{
Added: []string{},
},
}
43 changes: 43 additions & 0 deletions app/upgrades/v066/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package v066

import (
"context"
"fmt"

"github.com/Nolus-Protocol/nolus-core/app/keepers"

upgradetypes "cosmossdk.io/x/upgrade/types"
tmtypes "github.com/cometbft/cometbft/types"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
)

func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
keepers *keepers.AppKeepers,
codec codec.Codec,
) upgradetypes.UpgradeHandler {
return func(c context.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
ctx := sdk.UnwrapSDKContext(c)

ctx.Logger().Info("Starting module migrations...")
vm, err := mm.RunMigrations(ctx, configurator, vm) //nolint:contextcheck
if err != nil {
return vm, err
}

ctx.Logger().Info(fmt.Sprintf("Migration {%s} applied", UpgradeName))

// Properly register consensus params. In the process, change block max bytes params:
defaultConsensusParams := tmtypes.DefaultConsensusParams().ToProto()
defaultConsensusParams.Block.MaxBytes = 4000000 // previously 22020096
defaultConsensusParams.Block.MaxGas = 100000000 // previously 100000000
err = keepers.ConsensusParamsKeeper.ParamsStore.Set(ctx, defaultConsensusParams)
if err != nil {
return nil, err
}
return vm, nil
}
}
29 changes: 0 additions & 29 deletions cmd/nolusd/genwasm.go

This file was deleted.

1 change: 0 additions & 1 deletion cmd/nolusd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ func initRootCmd(
),
genutilcli.ValidateGenesisCmd(app.ModuleBasics),
addGenesisAccountCmd(app.DefaultNodeHome),
addGenesisWasmMsgCmd(app.DefaultNodeHome),
tmcli.NewCompletionCmd(rootCmd, true),
debug.Cmd(),
confixcmd.ConfigCommand(),
Expand Down
Loading
Loading