Unverified Commit efe28536 authored by Ethan Frey's avatar Ethan Frey Committed by GitHub
Browse files

Add wasmd module (#769)

* Add some initial wasmd in app

* Wire up wasm gov,ibc, begin/endblock, genesis

* Properly register params spaces

* Arm64 not supported by wasmd, windows currently not but soon

* Default genesis uses permissioned wasm settings

* Pass EnabledProposals as an argument to the app constructor to allow for more configurable tests

* Add comment, let CI run

* Add wasm support to osmosisd command

* Allow setting wasmopts in binary, for eg. telemetry

* Add wasmd 0.22.0 to go.sum

* Update go.mod

* Setting up wasmtest environment

* Got minimal store proposal test working

* Ensure cannot upload code with message (only proposal)

* Add instantiation test

* Update app setup from PR comments

* Cleanup go.mod
parent 0b5eadd8
Showing with 474 additions and 38 deletions
+474 -38
......@@ -15,11 +15,11 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
arch: [amd64, arm64]
arch: [amd64]
targetos: [darwin, linux]
include:
- targetos: windows
arch: amd64
# include:
# - targetos: windows
# arch: amd64
name: osmosis ${{ matrix.arch }} for ${{ matrix.targetos }}
steps:
- uses: actions/checkout@v2
......
......@@ -185,6 +185,9 @@ import (
txfeeskeeper "github.com/osmosis-labs/osmosis/x/txfees/keeper"
txfeestypes "github.com/osmosis-labs/osmosis/x/txfees/types"
"github.com/CosmWasm/wasmd/x/wasm"
wasmclient "github.com/CosmWasm/wasmd/x/wasm/client"
// Modules related to bech32-ibc, which allows new ibc funcationality based on the bech32 prefix of addresses
"github.com/osmosis-labs/bech32-ibc/x/bech32ibc"
bech32ibckeeper "github.com/osmosis-labs/bech32-ibc/x/bech32ibc/keeper"
......@@ -195,6 +198,36 @@ import (
const appName = "OsmosisApp"
var (
// If EnableSpecificWasmProposals is "", and this is "true", then enable all x/wasm proposals.
// If EnableSpecificWasmProposals is "", and this is not "true", then disable all x/wasm proposals.
WasmProposalsEnabled = "true"
// If set to non-empty string it must be comma-separated list of values that are all a subset
// of "EnableAllProposals" (takes precedence over WasmProposalsEnabled)
// https://github.com/CosmWasm/wasmd/blob/02a54d33ff2c064f3539ae12d75d027d9c665f05/x/wasm/internal/types/proposal.go#L28-L34
EnableSpecificWasmProposals = ""
// use this for clarity in argument list
EmptyWasmOpts []wasm.Option
)
// GetWasmEnabledProposals parses the WasmProposalsEnabled / EnableSpecificWasmProposals values to
// produce a list of enabled proposals to pass into wasmd app.
func GetWasmEnabledProposals() []wasm.ProposalType {
if EnableSpecificWasmProposals == "" {
if WasmProposalsEnabled == "true" {
return wasm.EnableAllProposals
}
return wasm.DisableAllProposals
}
chunks := strings.Split(EnableSpecificWasmProposals, ",")
proposals, err := wasm.ConvertToProposals(chunks)
if err != nil {
panic(err)
}
return proposals
}
var (
// DefaultNodeHome default home directories for the application daemon
DefaultNodeHome string
......@@ -211,9 +244,11 @@ var (
mint.AppModuleBasic{},
distr.AppModuleBasic{},
gov.NewAppModuleBasic(
paramsclient.ProposalHandler, distrclient.ProposalHandler, upgradeclient.ProposalHandler, upgradeclient.CancelProposalHandler,
poolincentivesclient.UpdatePoolIncentivesHandler,
ibcclientclient.UpdateClientProposalHandler, ibcclientclient.UpgradeProposalHandler,
append(
wasmclient.ProposalHandlers,
paramsclient.ProposalHandler, distrclient.ProposalHandler, upgradeclient.ProposalHandler, upgradeclient.CancelProposalHandler,
poolincentivesclient.UpdatePoolIncentivesHandler,
ibcclientclient.UpdateClientProposalHandler, ibcclientclient.UpgradeProposalHandler)...,
),
params.AppModuleBasic{},
crisis.AppModuleBasic{},
......@@ -233,6 +268,7 @@ var (
claim.AppModuleBasic{},
superfluid.AppModuleBasic{},
bech32ibc.AppModuleBasic{},
wasm.AppModuleBasic{},
)
// module account permissions
......@@ -252,6 +288,7 @@ var (
poolincentivestypes.ModuleName: nil,
superfluidtypes.ModuleName: nil,
txfeestypes.ModuleName: nil,
wasm.ModuleName: {authtypes.Burner},
}
// module accounts that are allowed to receive tokens
......@@ -288,6 +325,7 @@ type OsmosisApp struct {
// make scoped keepers public for test purposes
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
ScopedWasmKeeper capabilitykeeper.ScopedKeeper
// "Normal" keepers
AccountKeeper *authkeeper.AccountKeeper
......@@ -311,6 +349,7 @@ type OsmosisApp struct {
TxFeesKeeper *txfeeskeeper.Keeper
SuperfluidKeeper superfluidkeeper.Keeper
GovKeeper *govkeeper.Keeper
WasmKeeper *wasm.Keeper
transferModule transfer.AppModule
// the module manager
......@@ -335,7 +374,9 @@ func init() {
// NewOsmosis returns a reference to an initialized Osmosis.
func NewOsmosisApp(
logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool, skipUpgradeHeights map[int64]bool,
homePath string, invCheckPeriod uint, encodingConfig appparams.EncodingConfig, appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp),
homePath string, invCheckPeriod uint, encodingConfig appparams.EncodingConfig, appOpts servertypes.AppOptions,
wasmEnabledProposals []wasm.ProposalType, wasmOpts []wasm.Option,
baseAppOptions ...func(*baseapp.BaseApp),
) *OsmosisApp {
appCodec := encodingConfig.Marshaler
......@@ -373,6 +414,7 @@ func NewOsmosisApp(
txfeestypes.StoreKey,
superfluidtypes.StoreKey,
bech32ibctypes.StoreKey,
wasm.StoreKey,
)
// Define transient store keys
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
......@@ -393,7 +435,7 @@ func NewOsmosisApp(
app.InitSpecialKeepers(skipUpgradeHeights, homePath, invCheckPeriod)
app.setupUpgradeStoreLoaders()
app.InitNormalKeepers()
app.InitNormalKeepers(homePath, appOpts, wasmEnabledProposals, wasmOpts)
app.SetupHooks()
app.setupUpgradeHandlers()
......@@ -428,6 +470,7 @@ func NewOsmosisApp(
distr.NewAppModule(appCodec, *app.DistrKeeper, app.AccountKeeper, app.BankKeeper, *app.StakingKeeper),
staking.NewAppModule(appCodec, *app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
upgrade.NewAppModule(*app.UpgradeKeeper),
wasm.NewAppModule(appCodec, app.WasmKeeper, app.StakingKeeper),
evidence.NewAppModule(*app.EvidenceKeeper),
authzmodule.NewAppModule(appCodec, *app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
ibc.NewAppModule(app.IBCKeeper),
......@@ -474,6 +517,7 @@ func NewOsmosisApp(
paramstypes.ModuleName, vestingtypes.ModuleName,
gammtypes.ModuleName, incentivestypes.ModuleName, lockuptypes.ModuleName, claimtypes.ModuleName,
poolincentivestypes.ModuleName, superfluidtypes.ModuleName, bech32ibctypes.ModuleName, txfeestypes.ModuleName,
wasm.ModuleName,
)
// Tell the app's module manager how to set the order of EndBlockers, which are run at the end of every block.
......@@ -489,6 +533,7 @@ func NewOsmosisApp(
poolincentivestypes.ModuleName, superfluidtypes.ModuleName, bech32ibctypes.ModuleName, txfeestypes.ModuleName,
// Note: epochs' endblock should be "real" end of epochs, we keep epochs endblock at the end
epochstypes.ModuleName,
wasm.ModuleName,
)
// NOTE: The genutils moodule must occur after staking so that pools are
......@@ -523,6 +568,8 @@ func NewOsmosisApp(
epochstypes.ModuleName,
lockuptypes.ModuleName,
authz.ModuleName,
// wasm after ibc transfer
wasm.ModuleName,
)
app.mm.RegisterInvariants(app.CrisisKeeper)
......@@ -548,6 +595,7 @@ func NewOsmosisApp(
staking.NewAppModule(appCodec, *app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
params.NewAppModule(*app.ParamsKeeper),
evidence.NewAppModule(*app.EvidenceKeeper),
wasm.NewAppModule(appCodec, app.WasmKeeper, app.StakingKeeper),
ibc.NewAppModule(app.IBCKeeper),
incentives.NewAppModule(appCodec, *app.IncentivesKeeper, app.AccountKeeper, app.BankKeeper, app.EpochsKeeper),
lockup.NewAppModule(appCodec, *app.LockupKeeper, app.AccountKeeper, app.BankKeeper),
......@@ -842,6 +890,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(poolincentivestypes.ModuleName)
paramsKeeper.Subspace(superfluidtypes.ModuleName)
paramsKeeper.Subspace(gammtypes.ModuleName)
paramsKeeper.Subspace(wasm.ModuleName)
return paramsKeeper
}
......@@ -52,6 +52,8 @@ func NewAppConstructor(encodingCfg params.EncodingConfig) network.AppConstructor
val.Ctx.Logger, dbm.NewMemDB(), nil, true, make(map[int64]bool), val.Ctx.Config.RootDir, 0,
encodingCfg,
simapp.EmptyAppOptions{},
GetWasmEnabledProposals(),
EmptyWasmOpts,
baseapp.SetMinGasPrices(val.AppConfig.MinGasPrices),
)
}
......
......@@ -2,6 +2,8 @@ package app
import (
"encoding/json"
"github.com/CosmWasm/wasmd/x/wasm"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
)
// The genesis state of the blockchain is represented here as a map of raw json
......@@ -13,8 +15,25 @@ import (
// object provided to it during init.
type GenesisState map[string]json.RawMessage
const (
// DefaultMaxWasmCodeSize limit max bytes read to prevent gzip bombs
// 600 KB is copied from x/wasm, but you can customize here as desired
DefaultMaxWasmCodeSize = 600 * 1024 * 2
)
// NewDefaultGenesisState generates the default state for the application.
func NewDefaultGenesisState() GenesisState {
encCfg := MakeEncodingConfig()
return ModuleBasics.DefaultGenesis(encCfg.Marshaler)
gen := ModuleBasics.DefaultGenesis(encCfg.Marshaler)
// here we override wasm config to make it permissioned by default
wasmGen := wasm.GenesisState{
Params: wasmtypes.Params{
CodeUploadAccess: wasmtypes.AllowNobody,
InstantiateDefaultPermission: wasmtypes.AccessTypeEverybody,
MaxWasmCodeSize: DefaultMaxWasmCodeSize,
},
}
gen[wasm.ModuleName] = encCfg.Marshaler.MustMarshalJSON(&wasmGen)
return gen
}
package app
import (
"fmt"
"path/filepath"
"github.com/CosmWasm/wasmd/x/wasm"
"github.com/cosmos/cosmos-sdk/baseapp"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
......@@ -85,6 +90,7 @@ func (app *OsmosisApp) InitSpecialKeepers(
app.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey])
app.ScopedIBCKeeper = app.CapabilityKeeper.ScopeToModule(ibchost.ModuleName)
app.ScopedTransferKeeper = app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
app.ScopedWasmKeeper = app.CapabilityKeeper.ScopeToModule(wasm.ModuleName)
app.CapabilityKeeper.Seal()
// TODO: Make a SetInvCheckPeriod fn on CrisisKeeper.
......@@ -104,7 +110,13 @@ func (app *OsmosisApp) InitSpecialKeepers(
app.UpgradeKeeper = &upgradeKeeper
}
func (app *OsmosisApp) InitNormalKeepers() {
// Note: I put x/wasm here as I need to write it up to these other ones
func (app *OsmosisApp) InitNormalKeepers(
homePath string,
appOpts servertypes.AppOptions,
wasmEnabledProposals []wasm.ProposalType,
wasmOpts []wasm.Option,
) {
appCodec := app.appCodec
bApp := app.BaseApp
keys := app.keys
......@@ -176,7 +188,7 @@ func (app *OsmosisApp) InitNormalKeepers() {
// Create static IBC router, add transfer route, then set and seal it
ibcRouter := porttypes.NewRouter()
ibcRouter.AddRoute(ibctransfertypes.ModuleName, app.transferModule)
app.IBCKeeper.SetRouter(ibcRouter)
// Note: the sealing is done after creating wasmd and wiring that up
app.Bech32IBCKeeper = bech32ibckeeper.NewKeeper(
app.IBCKeeper.ChannelKeeper, appCodec, keys[bech32ibctypes.StoreKey],
......@@ -257,6 +269,40 @@ func (app *OsmosisApp) InitNormalKeepers() {
)
app.TxFeesKeeper = &txFeesKeeper
wasmDir := filepath.Join(homePath, "wasm")
wasmConfig, err := wasm.ReadWasmConfig(appOpts)
if err != nil {
panic(fmt.Sprintf("error while reading wasm config: %s", err))
}
// The last arguments can contain custom message handlers, and custom query handlers,
// if we want to allow any custom callbacks
supportedFeatures := "iterator,staking,stargate"
wasmKeeper := wasm.NewKeeper(
appCodec,
keys[wasm.StoreKey],
app.GetSubspace(wasm.ModuleName),
app.AccountKeeper,
app.BankKeeper,
app.StakingKeeper,
app.DistrKeeper,
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper,
app.ScopedWasmKeeper,
app.TransferKeeper,
app.MsgServiceRouter(),
app.GRPCQueryRouter(),
wasmDir,
wasmConfig,
supportedFeatures,
wasmOpts...,
)
app.WasmKeeper = &wasmKeeper
// wire up x/wasm to IBC
ibcRouter.AddRoute(wasm.ModuleName, wasm.NewIBCHandler(app.WasmKeeper, app.IBCKeeper.ChannelKeeper))
app.IBCKeeper.SetRouter(ibcRouter)
// register the proposal types
// TODO: This appears to be missing tx fees proposal type
govRouter := govtypes.NewRouter()
......@@ -270,6 +316,11 @@ func (app *OsmosisApp) InitNormalKeepers() {
AddRoute(bech32ibctypes.RouterKey, bech32ibc.NewBech32IBCProposalHandler(*app.Bech32IBCKeeper)).
AddRoute(txfeestypes.RouterKey, txfees.NewUpdateFeeTokenProposalHandler(*app.TxFeesKeeper))
// The gov proposal types can be individually enabled
if len(wasmEnabledProposals) != 0 {
govRouter.AddRoute(wasm.RouterKey, wasm.NewWasmProposalHandler(app.WasmKeeper, wasmEnabledProposals))
}
govKeeper := govkeeper.NewKeeper(
appCodec, keys[govtypes.StoreKey],
app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper,
......
......@@ -14,7 +14,7 @@ import (
// Setup initializes a new OsmosisApp
func Setup(isCheckTx bool) *OsmosisApp {
db := dbm.NewMemDB()
app := NewOsmosisApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, DefaultNodeHome, 5, MakeEncodingConfig(), simapp.EmptyAppOptions{})
app := NewOsmosisApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, DefaultNodeHome, 5, MakeEncodingConfig(), simapp.EmptyAppOptions{}, GetWasmEnabledProposals(), EmptyWasmOpts)
if !isCheckTx {
genesisState := NewDefaultGenesisState()
stateBytes, err := json.MarshalIndent(genesisState, "", " ")
......@@ -42,7 +42,7 @@ func SetupTestingAppWithLevelDb(isCheckTx bool) (app *OsmosisApp, cleanupFn func
if err != nil {
panic(err)
}
app = NewOsmosisApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, DefaultNodeHome, 5, MakeEncodingConfig(), simapp.EmptyAppOptions{})
app = NewOsmosisApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, DefaultNodeHome, 5, MakeEncodingConfig(), simapp.EmptyAppOptions{}, GetWasmEnabledProposals(), EmptyWasmOpts)
if !isCheckTx {
genesisState := NewDefaultGenesisState()
stateBytes, err := json.MarshalIndent(genesisState, "", " ")
......
# Wasm Tests
This contains a few high level test that `x/wasm` is properly integrated.
Since the code tested is not in this repo, and we are just testing the application
integration (app.go), I figured this is the most suitable location for it
\ No newline at end of file
package wasmtest
import (
"github.com/stretchr/testify/require"
"testing"
"time"
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
"github.com/osmosis-labs/osmosis/app"
)
func CreateTestInput() (*app.OsmosisApp, sdk.Context) {
osmosis := app.Setup(false)
ctx := osmosis.BaseApp.NewContext(false, tmproto.Header{Height: 1, ChainID: "osmosis-1", Time: time.Now().UTC()})
return osmosis, ctx
}
func FundAccount(t *testing.T, ctx sdk.Context, osmosis *app.OsmosisApp, acct sdk.AccAddress) {
err := simapp.FundAccount(osmosis.BankKeeper, ctx, acct, sdk.NewCoins(
sdk.NewCoin("uosmo", sdk.NewInt(10000000000)),
))
require.NoError(t, err)
}
// we need to make this deterministic (same every test run), as content might affect gas costs
func keyPubAddr() (crypto.PrivKey, crypto.PubKey, sdk.AccAddress) {
key := ed25519.GenPrivKey()
pub := key.PubKey()
addr := sdk.AccAddress(pub.Address())
return key, pub, addr
}
func RandomAccountAddress() sdk.AccAddress {
_, _, addr := keyPubAddr()
return addr
}
func RandomBech32AccountAddress() string {
return RandomAccountAddress().String()
}
package wasmtest
import (
"encoding/json"
"io/ioutil"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/CosmWasm/wasmd/x/wasm/keeper"
"github.com/CosmWasm/wasmd/x/wasm/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/osmosis-labs/osmosis/app"
)
func TestNoStorageWithoutProposal(t *testing.T) {
// we use default config
osmosis, ctx := CreateTestInput()
wasmKeeper := osmosis.WasmKeeper
// this wraps wasmKeeper, providing interfaces exposed to external messages
contractKeeper := keeper.NewDefaultPermissionKeeper(wasmKeeper)
_, _, creator := keyPubAddr()
// upload reflect code
wasmCode, err := ioutil.ReadFile("./testdata/hackatom.wasm")
require.NoError(t, err)
_, err = contractKeeper.Create(ctx, creator, wasmCode, nil)
require.Error(t, err)
}
func storeCodeViaProposal(t *testing.T, ctx sdk.Context, osmosis *app.OsmosisApp, addr sdk.AccAddress) {
govKeeper := osmosis.GovKeeper
wasmCode, err := ioutil.ReadFile("./testdata/hackatom.wasm")
require.NoError(t, err)
src := types.StoreCodeProposalFixture(func(p *types.StoreCodeProposal) {
p.RunAs = addr.String()
p.WASMByteCode = wasmCode
})
// when stored
storedProposal, err := govKeeper.SubmitProposal(ctx, src)
require.NoError(t, err)
// and proposal execute
handler := govKeeper.Router().GetRoute(storedProposal.ProposalRoute())
err = handler(ctx, storedProposal.GetContent())
require.NoError(t, err)
}
func TestStoreCodeProposal(t *testing.T) {
osmosis, ctx := CreateTestInput()
myActorAddress := RandomAccountAddress()
wasmKeeper := osmosis.WasmKeeper
storeCodeViaProposal(t, ctx, osmosis, myActorAddress)
// then
cInfo := wasmKeeper.GetCodeInfo(ctx, 1)
require.NotNil(t, cInfo)
assert.Equal(t, myActorAddress.String(), cInfo.Creator)
assert.True(t, wasmKeeper.IsPinnedCode(ctx, 1))
storedCode, err := wasmKeeper.GetByteCode(ctx, 1)
require.NoError(t, err)
wasmCode, err := ioutil.ReadFile("./testdata/hackatom.wasm")
require.NoError(t, err)
assert.Equal(t, wasmCode, storedCode)
}
type HackatomExampleInitMsg struct {
Verifier sdk.AccAddress `json:"verifier"`
Beneficiary sdk.AccAddress `json:"beneficiary"`
}
func TestInstantiateContract(t *testing.T) {
osmosis, ctx := CreateTestInput()
funder := RandomAccountAddress()
benefit, arb := RandomAccountAddress(), RandomAccountAddress()
FundAccount(t, ctx, osmosis, funder)
storeCodeViaProposal(t, ctx, osmosis, funder)
contractKeeper := keeper.NewDefaultPermissionKeeper(osmosis.WasmKeeper)
codeID := uint64(1)
initMsg := HackatomExampleInitMsg{
Verifier: arb,
Beneficiary: benefit,
}
initMsgBz, err := json.Marshal(initMsg)
require.NoError(t, err)
funds := sdk.NewInt64Coin("uosmo", 123456)
_, _, err = contractKeeper.Instantiate(ctx, codeID, funder, funder, initMsgBz, "demo contract", sdk.Coins{funds})
require.NoError(t, err)
}
#!/bin/bash
set -o errexit -o nounset -o pipefail
command -v shellcheck > /dev/null && shellcheck "$0"
if [ $# -ne 1 ]; then
echo "Usage: ./download_releases.sh RELEASE_TAG"
exit 1
fi
tag="$1"
for contract in hackatom reflect; do
url="https://github.com/CosmWasm/cosmwasm/releases/download/$tag/${contract}.wasm"
echo "Downloading $url ..."
wget -O "${contract}.wasm" "$url"
done
rm -f version.txt
echo "$tag" >version.txt
\ No newline at end of file
File added
File added
v1.0.0-beta4
package cmd
import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/spf13/cobra"
wasmcli "github.com/CosmWasm/wasmd/x/wasm/client/cli"
)
func AddGenesisWasmMsgCmd(defaultNodeHome string) *cobra.Command {
txCmd := &cobra.Command{
Use: "add-wasm-genesis-message",
Short: "Wasm genesis subcommands",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}
genesisIO := wasmcli.NewDefaultGenesisIO()
txCmd.AddCommand(
wasmcli.GenesisStoreCodeCmd(defaultNodeHome, genesisIO),
wasmcli.GenesisInstantiateContractCmd(defaultNodeHome, genesisIO),
wasmcli.GenesisExecuteContractCmd(defaultNodeHome, genesisIO),
wasmcli.GenesisListContractsCmd(defaultNodeHome, genesisIO),
wasmcli.GenesisListCodesCmd(defaultNodeHome, genesisIO),
)
return txCmd
}
package cmd
import (
"github.com/prometheus/client_golang/prometheus"
"io"
"os"
"path/filepath"
"github.com/cosmos/cosmos-sdk/x/crisis"
"github.com/osmosis-labs/osmosis/app/params"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/config"
......@@ -25,6 +23,7 @@ import (
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
"github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/cosmos-sdk/x/crisis"
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
"github.com/spf13/cast"
"github.com/spf13/cobra"
......@@ -33,7 +32,11 @@ import (
"github.com/tendermint/tendermint/libs/log"
dbm "github.com/tendermint/tm-db"
"github.com/CosmWasm/wasmd/x/wasm"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
osmosis "github.com/osmosis-labs/osmosis/app"
"github.com/osmosis-labs/osmosis/app/params"
)
// NewRootCmd creates a new root command for simd. It is called once in the
......@@ -140,6 +143,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) {
genutilcli.CollectGenTxsCmd(banktypes.GenesisBalancesIterator{}, osmosis.DefaultNodeHome),
genutilcli.MigrateGenesisCmd(),
AddGenesisAccountCmd(osmosis.DefaultNodeHome),
AddGenesisWasmMsgCmd(osmosis.DefaultNodeHome),
genutilcli.GenTxCmd(osmosis.ModuleBasics, encodingConfig.TxConfig, banktypes.GenesisBalancesIterator{}, osmosis.DefaultNodeHome),
genutilcli.ValidateGenesisCmd(osmosis.ModuleBasics),
ExportDeriveBalancesCmd(),
......@@ -166,6 +170,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) {
func addModuleInitFlags(startCmd *cobra.Command) {
crisis.AddModuleInitFlags(startCmd)
wasm.AddModuleInitFlags(startCmd)
}
func queryCommand() *cobra.Command {
......@@ -245,12 +250,19 @@ func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts serverty
panic(err)
}
var wasmOpts []wasm.Option
if cast.ToBool(appOpts.Get("telemetry.enabled")) {
wasmOpts = append(wasmOpts, wasmkeeper.WithVMCacheMetrics(prometheus.DefaultRegisterer))
}
return osmosis.NewOsmosisApp(
logger, db, traceStore, true, skipUpgradeHeights,
cast.ToString(appOpts.Get(flags.FlagHome)),
cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)),
osmosis.MakeEncodingConfig(), // Ideally, we would reuse the one created by NewRootCmd.
appOpts,
osmosis.GetWasmEnabledProposals(),
wasmOpts,
baseapp.SetPruning(pruningOpts),
baseapp.SetMinGasPrices(cast.ToString(appOpts.Get(server.FlagMinGasPrices))),
baseapp.SetMinRetainBlocks(cast.ToUint64(appOpts.Get(server.FlagMinRetainBlocks))),
......@@ -274,13 +286,13 @@ func createOsmosisAppAndExport(
encCfg.Marshaler = codec.NewProtoCodec(encCfg.InterfaceRegistry)
var app *osmosis.OsmosisApp
if height != -1 {
app = osmosis.NewOsmosisApp(logger, db, traceStore, false, map[int64]bool{}, "", uint(1), encCfg, appOpts)
app = osmosis.NewOsmosisApp(logger, db, traceStore, false, map[int64]bool{}, "", uint(1), encCfg, appOpts, osmosis.GetWasmEnabledProposals(), osmosis.EmptyWasmOpts)
if err := app.LoadHeight(height); err != nil {
return servertypes.ExportedApp{}, err
}
} else {
app = osmosis.NewOsmosisApp(logger, db, traceStore, true, map[int64]bool{}, "", uint(1), encCfg, appOpts)
app = osmosis.NewOsmosisApp(logger, db, traceStore, true, map[int64]bool{}, "", uint(1), encCfg, appOpts, osmosis.GetWasmEnabledProposals(), osmosis.EmptyWasmOpts)
}
return app.ExportAppStateAndValidators(forZeroHeight, jailWhiteList)
......
......@@ -3,10 +3,11 @@ module github.com/osmosis-labs/osmosis
go 1.17
require (
github.com/CosmWasm/wasmd v0.22.0
github.com/cosmos/cosmos-sdk v0.45.0
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/iavl v0.17.3
github.com/cosmos/ibc-go/v2 v2.0.0
github.com/cosmos/ibc-go/v2 v2.0.2
github.com/gogo/protobuf v1.3.3
github.com/golang/protobuf v1.5.2
github.com/gorilla/mux v1.8.0
......@@ -22,7 +23,7 @@ require (
github.com/tendermint/tendermint v0.34.15
github.com/tendermint/tm-db v0.6.6
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa
google.golang.org/grpc v1.42.0
google.golang.org/grpc v1.43.0
google.golang.org/protobuf v1.27.1
gopkg.in/yaml.v2 v2.4.0
)
......@@ -31,6 +32,7 @@ require (
filippo.io/edwards25519 v1.0.0-beta.2 // indirect
github.com/99designs/keyring v1.1.6 // indirect
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect
github.com/CosmWasm/wasmvm v1.0.0-beta5 // indirect
github.com/DataDog/zstd v1.4.5 // indirect
github.com/Workiva/go-datastructures v1.0.53 // indirect
github.com/armon/go-metrics v0.3.10 // indirect
......@@ -47,13 +49,13 @@ require (
github.com/danieljoos/wincred v1.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
github.com/dgraph-io/badger/v2 v2.2007.3 // indirect
github.com/dgraph-io/ristretto v0.0.3 // indirect
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b // indirect
github.com/felixge/httpsnoop v1.0.1 // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/gin-gonic/gin v1.7.0 // indirect
github.com/go-kit/kit v0.12.0 // indirect
github.com/go-kit/log v0.2.0 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
......@@ -61,6 +63,7 @@ require (
github.com/gogo/gateway v1.1.0 // indirect
github.com/golang/snappy v0.0.3 // indirect
github.com/google/btree v1.0.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/orderedcode v0.0.1 // indirect
github.com/gorilla/handlers v1.5.1 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
......@@ -90,17 +93,17 @@ require (
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.11.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.30.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect
github.com/rs/cors v1.8.0 // indirect
github.com/rs/zerolog v1.23.0 // indirect
github.com/rs/zerolog v1.26.0 // indirect
github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa // indirect
github.com/spf13/afero v1.6.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/viper v1.10.0 // indirect
github.com/spf13/viper v1.10.1 // indirect
github.com/stretchr/objx v0.3.0 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca // indirect
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect
......@@ -111,12 +114,15 @@ require (
go.etcd.io/bbolt v1.3.6 // indirect
golang.org/x/crypto v0.0.0-20210915214749-c084706c2272 // indirect
golang.org/x/net v0.0.0-20211005001312-d4b1ae081e3b // indirect
golang.org/x/sys v0.0.0-20211205182925-97ca703d548d // indirect
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect
golang.org/x/text v0.3.7 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/ini.v1 v1.66.2 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
nhooyr.io/websocket v1.8.6 // indirect
github.com/dgraph-io/badger/v2 v2.2007.3 // indirect
github.com/prometheus/client_golang v1.12.0
)
replace (
......
This diff is collapsed.
......@@ -78,6 +78,8 @@ func fullAppSimulation(tb testing.TB, is_testing bool) {
sdkSimapp.FlagPeriodValue,
app.MakeEncodingConfig(),
sdkSimapp.EmptyAppOptions{},
app.GetWasmEnabledProposals(),
app.EmptyWasmOpts,
interBlockCacheOpt(),
fauxMerkleModeOpt)
......@@ -154,6 +156,8 @@ func TestAppStateDeterminism(t *testing.T) {
sdkSimapp.FlagPeriodValue,
app.MakeEncodingConfig(),
sdkSimapp.EmptyAppOptions{},
app.GetWasmEnabledProposals(),
app.EmptyWasmOpts,
interBlockCacheOpt())
fmt.Printf(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment