diff --git a/demo/app/app.go b/demo/app/app.go index 0b166693..c491985f 100644 --- a/demo/app/app.go +++ b/demo/app/app.go @@ -269,7 +269,7 @@ type MeshApp struct { TransferKeeper ibctransferkeeper.Keeper WasmKeeper wasmkeeper.Keeper MeshSecKeeper *meshseckeeper.Keeper - MeshSecProvKeeper meshsecprovkeeper.Keeper + MeshSecProvKeeper *meshsecprovkeeper.Keeper ScopedIBCKeeper capabilitykeeper.ScopedKeeper ScopedICAHostKeeper capabilitykeeper.ScopedKeeper @@ -425,7 +425,7 @@ func NewMeshApp( authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) - app.MeshSecProvKeeper = *meshsecprovkeeper.NewKeeper( + app.MeshSecProvKeeper = meshsecprovkeeper.NewKeeper( appCodec, keys[meshsecprovtypes.StoreKey], authtypes.NewModuleAddress(govtypes.ModuleName).String(), diff --git a/tests/e2e/e2e.go b/tests/e2e/e2e.go index f3499dad..cab70123 100644 --- a/tests/e2e/e2e.go +++ b/tests/e2e/e2e.go @@ -1,7 +1,6 @@ package e2e import ( - "fmt" "path/filepath" "testing" @@ -76,7 +75,6 @@ func voteAndPassGovProposal(t *testing.T, chain *ibctesting.TestChain, proposalI } func InstantiateContract(t *testing.T, chain *ibctesting.TestChain, codeID uint64, initMsg []byte, funds ...sdk.Coin) sdk.AccAddress { - fmt.Println(codeID, string(initMsg)) instantiateMsg := &wasmtypes.MsgInstantiateContract{ Sender: chain.SenderAccount.GetAddress().String(), Admin: chain.SenderAccount.GetAddress().String(), @@ -101,6 +99,7 @@ type example struct { ConsumerChain *ibctesting.TestChain ProviderChain *ibctesting.TestChain ConsumerApp *app.MeshApp + ProviderApp *app.MeshApp IbcPath *ibctesting.Path ProviderDenom string ConsumerDenom string @@ -116,6 +115,7 @@ func setupExampleChains(t *testing.T) example { ConsumerChain: consChain, ProviderChain: provChain, ConsumerApp: consChain.App.(*app.MeshApp), + ProviderApp: provChain.App.(*app.MeshApp), IbcPath: ibctesting.NewPath(consChain, provChain), ProviderDenom: sdk.DefaultBondDenom, ConsumerDenom: sdk.DefaultBondDenom, @@ -134,7 +134,7 @@ func setupMeshSecurity(t *testing.T, x example) (*TestConsumerClient, ConsumerCo x.ConsumerChain.DefaultMsgFees = sdk.NewCoins(sdk.NewCoin(x.ConsumerDenom, math.NewInt(1_000_000))) providerCli := NewProviderClient(t, x.ProviderChain) - providerContracts := providerCli.BootstrapContracts(x.IbcPath.EndpointA.ConnectionID, converterPortID) + providerContracts := providerCli.BootstrapContracts(x.ProviderApp, x.IbcPath.EndpointA.ConnectionID, converterPortID) // setup ibc control path: consumer -> provider (direction matters) x.IbcPath.EndpointB.ChannelConfig = &ibctesting2.ChannelConfig{ diff --git a/tests/e2e/mvp_test.go b/tests/e2e/mvp_test.go index 6c59438c..06981fe3 100644 --- a/tests/e2e/mvp_test.go +++ b/tests/e2e/mvp_test.go @@ -59,7 +59,7 @@ func TestMVP(t *testing.T) { // provider chain // ============== // Deposit - A user deposits the vault denom to provide some collateral to their account - execMsg := fmt.Sprintf(`{"bond":{"amount":{"denom":"%s", "amount":"100000000"}}}`, x.ProviderDenom) + execMsg := fmt.Sprintf(`{"bond":{"amount":{"denom":"%s", "amount":"100000000"}}}`, x.ProviderDenom) providerCli.MustExecVault(execMsg) // then query contract state diff --git a/tests/e2e/slashing_test.go b/tests/e2e/slashing_test.go index d068a0ea..f9abdbab 100644 --- a/tests/e2e/slashing_test.go +++ b/tests/e2e/slashing_test.go @@ -21,8 +21,8 @@ func TestSlashingScenario1(t *testing.T) { // Provider chain // ============== // Deposit - A user deposits the vault denom to provide some collateral to their account - execMsg := `{"bond":{}}` - providerCli.MustExecVault(execMsg, sdk.NewInt64Coin(x.ProviderDenom, 200_000_000)) + execMsg := fmt.Sprintf(`{"bond":{"amount":{"denom":"%s", "amount":"200000000"}}}`, x.ProviderDenom) + providerCli.MustExecVault(execMsg) // Stake Locally - A user triggers a local staking action to a chosen validator. myLocalValidatorAddr := sdk.ValAddress(x.ProviderChain.Vals.Validators[0].Address).String() @@ -121,8 +121,8 @@ func TestSlashingScenario2(t *testing.T) { // Provider chain // ============== // Deposit - A user deposits the vault denom to provide some collateral to their account - execMsg := `{"bond":{}}` - providerCli.MustExecVault(execMsg, sdk.NewInt64Coin(x.ProviderDenom, 200_000_000)) + execMsg := fmt.Sprintf(`{"bond":{"amount":{"denom":"%s", "amount":"200000000"}}}`, x.ProviderDenom) + providerCli.MustExecVault(execMsg) // Stake Locally - A user triggers a local staking action to a chosen validator. myLocalValidatorAddr := sdk.ValAddress(x.ProviderChain.Vals.Validators[0].Address).String() @@ -208,8 +208,8 @@ func TestSlashingScenario3(t *testing.T) { // Provider chain // ============== // Deposit - A user deposits the vault denom to provide some collateral to their account - execMsg := `{"bond":{}}` - providerCli.MustExecVault(execMsg, sdk.NewInt64Coin(x.ProviderDenom, 200_000_000)) + execMsg := fmt.Sprintf(`{"bond":{"amount":{"denom":"%s", "amount":"200000000"}}}`, x.ProviderDenom) + providerCli.MustExecVault(execMsg) // Stake Locally - A user triggers a local staking action to a chosen validator. myLocalValidatorAddr := sdk.ValAddress(x.ProviderChain.Vals.Validators[0].Address).String() diff --git a/tests/e2e/test_client.go b/tests/e2e/test_client.go index 392f3077..0b10bb3f 100644 --- a/tests/e2e/test_client.go +++ b/tests/e2e/test_client.go @@ -78,7 +78,7 @@ type ProviderContracts struct { externalStaking sdk.AccAddress } -func (p *TestProviderClient) BootstrapContracts(connId, portID string) ProviderContracts { +func (p *TestProviderClient) BootstrapContracts(provApp *app.MeshApp, connId, portID string) ProviderContracts { var ( unbondingPeriod = 21 * 24 * 60 * 60 // 21 days - make configurable? localSlashRatioDoubleSign = "0.20" @@ -88,6 +88,7 @@ func (p *TestProviderClient) BootstrapContracts(connId, portID string) ProviderC rewardTokenDenom = sdk.DefaultBondDenom localTokenDenom = sdk.DefaultBondDenom ) + vaultCodeID := p.chain.StoreCodeFile(buildPathToWasm("mesh_vault.wasm")).CodeID proxyCodeID := p.chain.StoreCodeFile(buildPathToWasm("mesh_native_staking_proxy.wasm")).CodeID nativeStakingCodeID := p.chain.StoreCodeFile(buildPathToWasm("mesh_native_staking.wasm")).CodeID @@ -96,6 +97,10 @@ func (p *TestProviderClient) BootstrapContracts(connId, portID string) ProviderC initMsg := []byte(fmt.Sprintf(`{"denom": %q, "local_staking": {"code_id": %d, "msg": %q}}`, localTokenDenom, nativeStakingCodeID, base64.StdEncoding.EncodeToString(nativeInitMsg))) vaultContract := InstantiateContract(p.t, p.chain, vaultCodeID, initMsg) + ctx := p.chain.GetContext() + params := provApp.MeshSecProvKeeper.GetParams(ctx) + params.VaultAddress = vaultContract.String() + provApp.MeshSecProvKeeper.SetParams(ctx, params) // external staking extStakingCodeID := p.chain.StoreCodeFile(buildPathToWasm("mesh_external_staking.wasm")).CodeID initMsg = []byte(fmt.Sprintf( diff --git a/tests/starship/go.mod b/tests/starship/go.mod index f67c84d0..cfcddbcb 100644 --- a/tests/starship/go.mod +++ b/tests/starship/go.mod @@ -37,7 +37,7 @@ require ( github.com/cosmology-tech/starship/registry v0.0.0-20231216113645-d0facbadb180 github.com/cosmos/go-bip39 v1.0.0 github.com/osmosis-labs/mesh-security-sdk/demo v0.0.0-00010101000000-000000000000 - github.com/osmosis-labs/mesh-security-sdk/x v0.0.0-00010101000000-000000000000 + github.com/osmosis-labs/mesh-security-sdk/x v0.0.0-20231230023625-3cdce6e349eb github.com/strangelove-ventures/lens v0.0.0-00010101000000-000000000000 go.uber.org/zap v1.26.0 gopkg.in/yaml.v3 v3.0.1 @@ -147,6 +147,7 @@ require ( github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mtibben/percent v0.2.1 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect + github.com/osmosis-labs/mesh-security-sdk/wasmbinding v0.0.0-00010101000000-000000000000 // indirect github.com/pelletier/go-toml/v2 v2.0.8 // indirect github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect @@ -201,6 +202,7 @@ replace ( // local work dirs github.com/osmosis-labs/mesh-security-sdk/demo => ../../demo + github.com/osmosis-labs/mesh-security-sdk/wasmbinding => ../../wasmbinding github.com/osmosis-labs/mesh-security-sdk/x => ../../x github.com/strangelove-ventures/lens => github.com/Anmol1696/lens v0.1.1-0.20230705212610-c00628a886a0 diff --git a/tests/starship/mvp_test.go b/tests/starship/mvp_test.go index 524a797e..0fcf789f 100644 --- a/tests/starship/mvp_test.go +++ b/tests/starship/mvp_test.go @@ -10,7 +10,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/osmosis-labs/mesh-security-sdk/tests/starship/setup" @@ -52,8 +51,8 @@ func Test2WayContract(t *testing.T) { // ============== // Deposit - A user deposits the vault denom to provide some collateral to their account fmt.Println("provider chain: deposit vault denom to provide some collateral to account") - execMsg := `{"bond":{}}` - vault, err := providerClient1.MustExecVault(execMsg, sdk.NewInt64Coin(providerClient1.Chain.Denom, 100_000_000)) + execMsg := fmt.Sprintf(`{"bond":{"amount":{"denom":"%s", "amount":"100000000"}}}`, providerClient1.Chain.Denom) + vault, err := providerClient1.MustExecVault(execMsg) require.NoError(t, err) require.NotEmpty(t, vault) @@ -130,8 +129,8 @@ func Test2WayContract(t *testing.T) { // ============== // Deposit - A user deposits the vault denom to provide some collateral to their account fmt.Println("provider chain: deposit vault denom to provide some collateral to account") - execMsg = `{"bond":{}}` - vault, err = providerClient2.MustExecVault(execMsg, sdk.NewInt64Coin(providerClient2.Chain.Denom, 100_000_000)) + execMsg = fmt.Sprintf(`{"bond":{"amount":{"denom":"%s", "amount":"100000000"}}}`, providerClient2.Chain.Denom) + vault, err = providerClient2.MustExecVault(execMsg) require.NoError(t, err) require.NotEmpty(t, vault) diff --git a/wasmbinding/bindings/msg.go b/wasmbinding/bindings/msg.go index 4b0936c7..4b30515e 100644 --- a/wasmbinding/bindings/msg.go +++ b/wasmbinding/bindings/msg.go @@ -31,7 +31,7 @@ type ( type ( SudoMsg struct { HandleEpoch *struct{} `json:"handle_epoch,omitempty"` - ValsetUpdate *ValsetUpdate `json:"valset_update,omitempty"` + ValsetUpdate *ValsetUpdate `json:"handle_valset_update,omitempty"` } // Validator alias to wasmVM type diff --git a/x/meshsecurity/abci_test.go b/x/meshsecurity/abci_test.go index 677686bd..675d17d5 100644 --- a/x/meshsecurity/abci_test.go +++ b/x/meshsecurity/abci_test.go @@ -79,7 +79,7 @@ func TestEndBlocker(t *testing.T) { assert: func(t *testing.T, ctx sdk.Context) { require.Len(t, capturedCalls, 2) assert.Equal(t, myContractAddr, capturedCalls[0].contractAddress) - exp := fmt.Sprintf(`{"valset_update":{"additions":[{"address":"%s","commission":"0.000000000000000000","max_commission":"0.000000000000000000","max_change_rate":"0.000000000000000000"}],"removals":[],"updated":[],"jailed":[],"unjailed":[],"slashed":[],"tombstoned":[]}}`, val1.GetOperator()) + exp := fmt.Sprintf(`{"handle_valset_update":{"additions":[{"address":"%s","commission":"0.000000000000000000","max_commission":"0.000000000000000000","max_change_rate":"0.000000000000000000"}],"removals":[],"updated":[],"jailed":[],"unjailed":[],"slashed":[],"tombstoned":[]}}`, val1.GetOperator()) assert.JSONEq(t, exp, string(capturedCalls[0].msg)) assert.Equal(t, myOtherContractAddr, capturedCalls[1].contractAddress) diff --git a/x/meshsecurityprovider/module.go b/x/meshsecurityprovider/module.go index a62bd7b3..ae573e35 100644 --- a/x/meshsecurityprovider/module.go +++ b/x/meshsecurityprovider/module.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" + abci "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -12,7 +13,6 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" - abci "github.com/cometbft/cometbft/abci/types" "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurityprovider/client/cli" "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurityprovider/keeper" @@ -69,7 +69,7 @@ func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) type AppModule struct { AppModuleBasic - k keeper.Keeper + k *keeper.Keeper } func (am AppModule) RegisterServices(cfg module.Configurator) { @@ -77,8 +77,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { // queryproto.RegisterQueryServer(cfg.QueryServer(), grpc.Querier{Q: module.NewQuerier(am.k)}) } - -func NewAppModule(moduleKeeper keeper.Keeper) AppModule { +func NewAppModule(moduleKeeper *keeper.Keeper) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{}, k: moduleKeeper,