Skip to content

Commit

Permalink
Merge branch 'main' into dwedul/1760-make-sims-pass
Browse files Browse the repository at this point in the history
  • Loading branch information
SpicyLemon committed May 31, 2024
2 parents 32ea53a + 5d3ed55 commit a035397
Show file tree
Hide file tree
Showing 28 changed files with 2,036 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/proto-registry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Buf setup action
uses: bufbuild/[email protected].1
uses: bufbuild/[email protected].2
- name: Buf push 'third_party/proto'
uses: bufbuild/buf-push-action@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/proto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
fi
echo "Setting output: base-branch=$branch"
echo "base-branch=$branch" >> "$GITHUB_OUTPUT"
- uses: bufbuild/[email protected].1
- uses: bufbuild/[email protected].2
- uses: bufbuild/[email protected]
if: always()
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Buf setup action
uses: bufbuild/[email protected].1
uses: bufbuild/[email protected].2
- name: Buf push 'proto/'
uses: bufbuild/buf-push-action@v1
with:
Expand Down
23 changes: 0 additions & 23 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,29 +117,6 @@ jobs:
name: "${{ needs.setup-tests.outputs.file-prefix }}-${{ matrix.part }}-coverage"
path: ./${{ matrix.part }}profile.out

build-tests:
# TODO[1760]: Delete this build-tests action once the tests reliably pass again.
needs: setup-tests
strategy:
fail-fast: false
matrix:
part: ["00", "01", "02", "03"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
if: needs.setup-tests.outputs.should-run
with:
go-version: ${{ needs.setup-tests.outputs.go-version }}
- uses: actions/download-artifact@v4
if: needs.setup-tests.outputs.should-run
with:
name: "${{ needs.setup-tests.outputs.file-prefix }}-pkgs.txt.part.${{ matrix.part }}"
- name: build tests
if: needs.setup-tests.outputs.should-run
run: |
cat pkgs.txt.part.${{ matrix.part }} | xargs go test -mod=readonly -timeout 30m -tags='norace ledger test_ledger_mock' -run='ZYX_NOPE_NOPE_XYZ'
# This action performs a code coverage assessment but filters out generated code from proto based types
# and grpc services
upload-coverage-report:
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* Fix unit tests for ibchooks [#1980](https://github.com/provenance-io/provenance/pull/1980).
* Replace deprecated wasm features [#1988](https://github.com/provenance-io/provenance/pull/1988).
* Add `UpdateParams` and `Params` query rpc endpoints to modules.
* `ibchooks` add `UpdateParams` endpoint and `Params` query endpoint [#2006](https://github.com/provenance-io/provenance/pull/2006).
* `ibcratelimit` add `UpdateParams` endpoint and deprecate `GovUpdateParams` [#1984](https://github.com/provenance-io/provenance/pull/1984).
* `attribute` add `UpdateParams` endpoint and cli [#1987](https://github.com/provenance-io/provenance/pull/1987).
* `marker` add `UpdateParams` endpoint and cli [#1991](https://github.com/provenance-io/provenance/pull/1991).
Expand Down Expand Up @@ -120,7 +121,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
- Bump `google.golang.org/grpc` from 1.62.1 to 1.64.0 ([#1903](https://github.com/provenance-io/provenance/pull/1903), [#1918](https://github.com/provenance-io/provenance/pull/1918), [#1972](https://github.com/provenance-io/provenance/pull/1972))
- Bump `bufbuild/buf-breaking-action` from 1.1.3 to 1.1.4 ([#1894](https://github.com/provenance-io/provenance/pull/1894))
- Bump `bufbuild/buf-lint-action` from 1.1.0 to 1.1.1 ([#1895](https://github.com/provenance-io/provenance/pull/1895))
- Bump `bufbuild/buf-setup-action` from 1.30.0 to 1.32.1 ([#1904](https://github.com/provenance-io/provenance/pull/1904), [#1949](https://github.com/provenance-io/provenance/pull/1949), [#1979](https://github.com/provenance-io/provenance/pull/1979), [#1990](https://github.com/provenance-io/provenance/pull/1990))
- Bump `bufbuild/buf-setup-action` from 1.30.0 to 1.32.2 ([#1904](https://github.com/provenance-io/provenance/pull/1904), [#1949](https://github.com/provenance-io/provenance/pull/1949), [#1979](https://github.com/provenance-io/provenance/pull/1979), [#1990](https://github.com/provenance-io/provenance/pull/1990), [#2011](https://github.com/provenance-io/provenance/pull/2011))
- Bump `github.com/cometbft/cometbft` from 0.38.5 to 0.38.7 ([#1912](https://github.com/provenance-io/provenance/pull/1912), [#1959](https://github.com/provenance-io/provenance/pull/1959))
- Bump `cosmossdk.io/x/upgrade` from 0.1.0 to 0.1.1 ([#1913](https://github.com/provenance-io/provenance/pull/1913))
- Bump `github.com/hashicorp/go-metrics` from 0.5.2 to 0.5.3 ([#1914](https://github.com/provenance-io/provenance/pull/1914))
Expand Down
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions client/docs/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105863,6 +105863,19 @@ definitions:
ibc_ack:
type: string
title: MsgEmitIBCAckResponse is the IBC Acknowledgement response
provenance.ibchooks.v1.MsgUpdateParamsResponse:
type: object
description: >-
MsgUpdateParamsResponse is a response message for the UpdateParams
endpoint.
provenance.ibchooks.v1.Params:
type: object
properties:
allowed_async_ack_contracts:
type: array
items:
type: string
title: Params defines the allowed async ack contracts
provenance.ibcratelimit.v1.Params:
type: object
properties:
Expand Down
12 changes: 12 additions & 0 deletions proto/provenance/ibchooks/v1/event.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
syntax = "proto3";
package provenance.ibchooks.v1;

option go_package = "github.com/provenance-io/provenance/x/ibchooks/types";

option java_package = "io.provenance.ibchooks.v1";
option java_multiple_files = true;

// EventIBCHooksParamsUpdated defines the event emitted after updating ibchooks parameters.
message EventIBCHooksParamsUpdated {
repeated string allowed_async_ack_contracts = 1;
}
28 changes: 28 additions & 0 deletions proto/provenance/ibchooks/v1/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
syntax = "proto3";
package provenance.ibchooks.v1;

option go_package = "github.com/provenance-io/provenance/x/ibchooks/types";

option java_package = "io.provenance.ibchooks.v1";
option java_multiple_files = true;

import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "provenance/ibchooks/v1/params.proto";

// Query defines the gRPC querier service for attribute module.
service Query {
// Params queries params of the ihchooks module.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/provenance/ibchooks/v1/params";
}
}

// QueryParamsRequest is the request type for the Query/Params RPC method.
message QueryParamsRequest {}

// QueryParamsResponse is the response type for the Query/Params RPC method.
message QueryParamsResponse {
// params defines the parameters of the module.
Params params = 1 [(gogoproto.nullable) = false];
}
24 changes: 22 additions & 2 deletions proto/provenance/ibchooks/v1/tx.proto
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
syntax = "proto3";
package provenance.ibchooks.v1;

import "cosmos/msg/v1/msg.proto";

option go_package = "github.com/provenance-io/provenance/x/ibchooks/types";

option java_package = "io.provenance.ibchooks.v1";
option java_multiple_files = true;

import "cosmos/msg/v1/msg.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "provenance/ibchooks/v1/params.proto";

// Msg defines the Msg service.
service Msg {
// EmitIBCAck checks the sender can emit the ack and writes the IBC
// acknowledgement
rpc EmitIBCAck(MsgEmitIBCAck) returns (MsgEmitIBCAckResponse);

// UpdateParams is a governance proposal endpoint for updating the ibchooks module's params.
rpc UpdateParams(MsgUpdateParamsRequest) returns (MsgUpdateParamsResponse);
}

// MsgEmitIBCAck is the IBC Acknowledgement
Expand All @@ -29,3 +35,17 @@ message MsgEmitIBCAckResponse {
string contract_result = 1;
string ibc_ack = 2;
}

// MsgUpdateParamsRequest is a request message for the UpdateParams endpoint.
message MsgUpdateParamsRequest {
option (cosmos.msg.v1.signer) = "authority";

// authority should be the governance module account address.
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];

// params are the new param values to set.
Params params = 2 [(gogoproto.nullable) = false];
}

// MsgUpdateParamsResponse is a response message for the UpdateParams endpoint.
message MsgUpdateParamsResponse {}
128 changes: 128 additions & 0 deletions x/ibchooks/client/cli/cli_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
package cli_test

import (
"fmt"
"testing"

"github.com/stretchr/testify/suite"

cmtcli "github.com/cometbft/cometbft/libs/cli"

sdkmath "cosmossdk.io/math"

"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
"github.com/cosmos/cosmos-sdk/testutil/network"
sdk "github.com/cosmos/cosmos-sdk/types"
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"

"github.com/provenance-io/provenance/internal/antewrapper"
"github.com/provenance-io/provenance/internal/pioconfig"
"github.com/provenance-io/provenance/testutil"
testcli "github.com/provenance-io/provenance/testutil/cli"
ibchookscli "github.com/provenance-io/provenance/x/ibchooks/client/cli"
"github.com/provenance-io/provenance/x/ibchooks/types"
)

type IntegrationTestSuite struct {
suite.Suite

cfg network.Config
testnet *network.Network
accountAddr sdk.AccAddress
accountKey *secp256k1.PrivKey
}

func TestIntegrationTestSuite(t *testing.T) {
suite.Run(t, new(IntegrationTestSuite))
}

func (s *IntegrationTestSuite) SetupSuite() {
s.T().Log("setting up integration test suite")
pioconfig.SetProvenanceConfig("", 0)
govv1.DefaultMinDepositRatio = sdkmath.LegacyZeroDec()
s.accountKey = secp256k1.GenPrivKeyFromSecret([]byte("acc2"))
addr, err := sdk.AccAddressFromHexUnsafe(s.accountKey.PubKey().Address().String())
s.Require().NoError(err)
s.accountAddr = addr

s.cfg = testutil.DefaultTestNetworkConfig()
genesisState := s.cfg.GenesisState

s.cfg.NumValidators = 1

testutil.MutateGenesisState(s.T(), &s.cfg, types.ModuleName, &types.GenesisState{}, func(ibchooks *types.GenesisState) *types.GenesisState {
ibchooksParams := types.DefaultParams()
ibchooksGenesis := &types.GenesisState{Params: ibchooksParams}
return ibchooksGenesis
})

s.cfg.GenesisState = genesisState

s.cfg.ChainID = antewrapper.SimAppChainID

s.testnet, err = network.New(s.T(), s.T().TempDir(), s.cfg)
s.Require().NoError(err, "network.New")

_, err = testutil.WaitForHeight(s.testnet, 6)
s.Require().NoError(err, "WaitForHeight")
}

func (s *IntegrationTestSuite) TearDownSuite() {
testutil.Cleanup(s.testnet, s.T())
}

func (s *IntegrationTestSuite) TestQueryParams() {
clientCtx := s.testnet.Validators[0].ClientCtx
cmd := ibchookscli.GetCmdQueryParams()

out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{fmt.Sprintf("--%s=json", cmtcli.OutputFlag)})
s.Require().NoError(err)

var response types.QueryParamsResponse
s.NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &response))
expectedParams := types.DefaultParams()
s.Equal(expectedParams, response.Params, "should have the default params")
}

func (s *IntegrationTestSuite) TestUpdateParamsCmd() {
testCases := []struct {
name string
args []string
expectErrMsg string
expectedCode uint32
}{
{
name: "success - update allowed async ack contracts",
args: []string{fmt.Sprintf("%v,%v", s.accountAddr.String(), sdk.AccAddress("input111111111111111").String())},
expectedCode: 0,
},
{
name: "failure - invalid args",
args: []string{"contract1"},
expectErrMsg: `invalid contract address: "contract1": decoding bech32 failed: invalid separator index 8`,
},
}

for _, tc := range testCases {
s.Run(tc.name, func() {
cmd := ibchookscli.NewUpdateParamsCmd()
tc.args = append(tc.args,
"--title", fmt.Sprintf("title: %v", tc.name),
"--summary", fmt.Sprintf("summary: %v", tc.name),
"--deposit=1000000stake",
fmt.Sprintf("--%s=%s", flags.FlagFrom, s.testnet.Validators[0].Address.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewInt64Coin(s.cfg.BondDenom, 10)).String()),
fmt.Sprintf("--%s=json", cmtcli.OutputFlag),
)

testcli.NewTxExecutor(cmd, tc.args).
WithExpErrMsg(tc.expectErrMsg).
WithExpCode(tc.expectedCode).
Execute(s.T(), s.testnet)
})
}
}
26 changes: 26 additions & 0 deletions x/ibchooks/client/cli/query.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package cli

import (
"context"
"fmt"
"strings"

"github.com/spf13/cobra"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version"
Expand Down Expand Up @@ -39,6 +41,7 @@ func GetQueryCmd() *cobra.Command {

cmd.AddCommand(
GetCmdWasmSender(),
GetCmdQueryParams(),
)
return cmd
}
Expand Down Expand Up @@ -75,3 +78,26 @@ $ %s query ibchooks wasm-hooks-sender channel-7 pb12smx2wdlyttvyzvzg54y2vnqwq2qj

return cmd
}

// GetCmdQueryParams returns a command to query the ibchooks module parameters.
func GetCmdQueryParams() *cobra.Command {
cmd := &cobra.Command{
Use: "params",
Short: "Query the current ibchooks module parameters",
RunE: func(cmd *cobra.Command, _ []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

queryClient := types.NewQueryClient(clientCtx)
res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{})
if err != nil {
return err
}

return clientCtx.PrintProto(res)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}
Loading

0 comments on commit a035397

Please sign in to comment.