Skip to content

Commit

Permalink
Merge main.
Browse files Browse the repository at this point in the history
  • Loading branch information
Taztingo committed May 21, 2024
2 parents e0ed1d9 + 946a83b commit aae3484
Show file tree
Hide file tree
Showing 15 changed files with 497 additions and 48 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
* Fix unit tests for ibcratelimit [#1977](https://github.com/provenance-io/provenance/pull/1977).
* 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.
* `ibcratelimit` add `UpdateParams` endpoint and deprecate `GovUpdateParams` [#1984](https://github.com/provenance-io/provenance/pull/1984).

### Client Breaking

Expand Down
4 changes: 2 additions & 2 deletions app/params/weights.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ const (
// Oracle
DefaultWeightUpdateOracle int = 25
DefaultWeightSendOracleQuery int = 75
// Rate Limiter
DefaultWeightGovUpdateParams int = 100
// Ibc Rate Limiter
DefaultWeightUpdateParams int = 100
)
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions client/docs/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105881,6 +105881,13 @@ definitions:
description: >-
MsgGovUpdateParamsResponse is a response message for the GovUpdateParams
endpoint.

Deprecated: Use MsgUpdateParamsResponse instead.
provenance.ibcratelimit.v1.MsgUpdateParamsResponse:
type: object
description: >-
MsgUpdateParamsResponse is a response message for the UpdateParams
endpoint.
provenance.marker.v1.Access:
type: string
enum:
Expand Down
2 changes: 2 additions & 0 deletions proto/provenance/attribute/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ service Msg {

// SetAccountData defines a method for setting/updating an account's accountdata attribute.
rpc SetAccountData(MsgSetAccountDataRequest) returns (MsgSetAccountDataResponse);

// TODO add update params
}

// MsgAddAttributeRequest defines an sdk.Msg type that is used to add a new attribute to an account.
Expand Down
31 changes: 28 additions & 3 deletions proto/provenance/ibcratelimit/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,44 @@ import "provenance/ibcratelimit/v1/params.proto";
// Msg is the service for ibcratelimit module's tx endpoints.
service Msg {
// GovUpdateParams is a governance proposal endpoint for updating the exchange module's params.
rpc GovUpdateParams(MsgGovUpdateParamsRequest) returns (MsgGovUpdateParamsResponse);
// Deprecated: Use UpdateParams instead.
rpc GovUpdateParams(MsgGovUpdateParamsRequest) returns (MsgGovUpdateParamsResponse) {
option deprecated = true;
}

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

// MsgGovUpdateParamsRequest is a request message for the GovUpdateParams endpoint.
// Deprecated: Use MsgUpdateParamsRequest instead.
message MsgGovUpdateParamsRequest {
option (cosmos.msg.v1.signer) = "authority";
option deprecated = true;

// 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 are the new param values to set.
Params params = 2 [(gogoproto.nullable) = false];
}

// MsgGovUpdateParamsResponse is a response message for the GovUpdateParams endpoint.
message MsgGovUpdateParamsResponse {}
// Deprecated: Use MsgUpdateParamsResponse instead.
message MsgGovUpdateParamsResponse {
option deprecated = true;
}

// 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 {}
2 changes: 2 additions & 0 deletions proto/provenance/marker/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ service Msg {
rpc WithdrawEscrowProposal(MsgWithdrawEscrowProposalRequest) returns (MsgWithdrawEscrowProposalResponse);
// SetDenomMetadataProposal is a governance proposal to set marker metadata
rpc SetDenomMetadataProposal(MsgSetDenomMetadataProposalRequest) returns (MsgSetDenomMetadataProposalResponse);

// TODO: UpdateParams
}

// MsgGrantAllowanceRequest validates permission to create a fee grant based on marker admin access. If
Expand Down
2 changes: 1 addition & 1 deletion x/ibcratelimit/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func GetCmdParamsUpdate() *cobra.Command {

flagSet := cmd.Flags()
authority := provcli.GetAuthority(flagSet)
msg := ibcratelimit.NewMsgGovUpdateParamsRequest(authority, args[0])
msg := ibcratelimit.NewMsgUpdateParamsRequest(authority, args[0])
return provcli.GenerateOrBroadcastTxCLIAsGovProp(clientCtx, flagSet, msg)
},
}
Expand Down
12 changes: 10 additions & 2 deletions x/ibcratelimit/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keeper

import (
"context"
"errors"

sdk "github.com/cosmos/cosmos-sdk/types"

Expand All @@ -22,7 +23,14 @@ func NewMsgServer(k Keeper) ibcratelimit.MsgServer {
var _ ibcratelimit.MsgServer = MsgServer{}

// GovUpdateParams is a governance proposal endpoint for updating the ibcratelimit module's params.
func (k MsgServer) GovUpdateParams(goCtx context.Context, msg *ibcratelimit.MsgGovUpdateParamsRequest) (*ibcratelimit.MsgGovUpdateParamsResponse, error) {
//
//lint:ignore SA1019 Suppress warning for deprecated MsgGovUpdateParamsRequest usage
func (k MsgServer) GovUpdateParams(_ context.Context, _ *ibcratelimit.MsgGovUpdateParamsRequest) (*ibcratelimit.MsgGovUpdateParamsResponse, error) {

Check failure on line 28 in x/ibcratelimit/keeper/msg_server.go

View workflow job for this annotation

GitHub Actions / golangci-lint

SA1019: ibcratelimit.MsgGovUpdateParamsRequest is deprecated: Do not use. (staticcheck)
return nil, errors.New("deprecated and unusable")
}

// UpdateParams is a governance proposal endpoint for updating the ibcratelimit module's params.
func (k MsgServer) UpdateParams(goCtx context.Context, msg *ibcratelimit.MsgUpdateParamsRequest) (*ibcratelimit.MsgUpdateParamsResponse, error) {
if err := k.ValidateAuthority(msg.Authority); err != nil {
return nil, err
}
Expand All @@ -31,5 +39,5 @@ func (k MsgServer) GovUpdateParams(goCtx context.Context, msg *ibcratelimit.MsgG
k.SetParams(ctx, msg.Params)
k.emitEvent(ctx, ibcratelimit.NewEventParamsUpdated())

return &ibcratelimit.MsgGovUpdateParamsResponse{}, nil
return &ibcratelimit.MsgUpdateParamsResponse{}, nil
}
14 changes: 7 additions & 7 deletions x/ibcratelimit/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ import (
"github.com/provenance-io/provenance/x/ibcratelimit"
)

func (s *TestSuite) TestGovUpdateParams() {
func (s *TestSuite) TestUpdateParams() {
authority := s.app.OracleKeeper.GetAuthority()

tests := []struct {
name string
req *ibcratelimit.MsgGovUpdateParamsRequest
res *ibcratelimit.MsgGovUpdateParamsResponse
req *ibcratelimit.MsgUpdateParamsRequest
res *ibcratelimit.MsgUpdateParamsResponse
event *sdk.Event
err string
}{
{
name: "failure - authority does not match module authority",
req: &ibcratelimit.MsgGovUpdateParamsRequest{
req: &ibcratelimit.MsgUpdateParamsRequest{
Params: ibcratelimit.NewParams("cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma"),
Authority: "cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma",
},
Expand All @@ -29,18 +29,18 @@ func (s *TestSuite) TestGovUpdateParams() {
},
{
name: "success - rate limiter is updated",
req: &ibcratelimit.MsgGovUpdateParamsRequest{
req: &ibcratelimit.MsgUpdateParamsRequest{
Params: ibcratelimit.NewParams("cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma"),
Authority: authority,
},
res: &ibcratelimit.MsgGovUpdateParamsResponse{},
res: &ibcratelimit.MsgUpdateParamsResponse{},
event: typedEventToEvent(ibcratelimit.NewEventParamsUpdated()),
},
}

for _, tc := range tests {
s.Run(tc.name, func() {
res, err := s.msgServer.GovUpdateParams(s.ctx, tc.req)
res, err := s.msgServer.UpdateParams(s.ctx, tc.req)
events := s.ctx.EventManager().Events()
numEvents := len(events)

Expand Down
16 changes: 11 additions & 5 deletions x/ibcratelimit/msgs.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ibcratelimit

import (
"errors"
fmt "fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -9,18 +10,23 @@ import (
// AllRequestMsgs defines all the Msg*Request messages.
var AllRequestMsgs = []sdk.Msg{
(*MsgGovUpdateParamsRequest)(nil),
(*MsgUpdateParamsRequest)(nil),
}

// NewMsgGovUpdateParamsRequest creates a new GovUpdateParams message.
func NewMsgGovUpdateParamsRequest(authority, ratelimiter string) *MsgGovUpdateParamsRequest {
return &MsgGovUpdateParamsRequest{
// ValidateBasic runs stateless validation checks on the message.
func (m MsgGovUpdateParamsRequest) ValidateBasic() error {
return errors.New("deprecated and unusable")
}

// NewMsgUpdateParamsRequest creates a new GovUpdateParams message.
func NewMsgUpdateParamsRequest(authority, ratelimiter string) *MsgUpdateParamsRequest {
return &MsgUpdateParamsRequest{
Authority: authority,
Params: NewParams(ratelimiter),
}
}

// ValidateBasic runs stateless validation checks on the message.
func (m MsgGovUpdateParamsRequest) ValidateBasic() error {
func (m MsgUpdateParamsRequest) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil {
return fmt.Errorf("invalid authority: %w", err)
}
Expand Down
9 changes: 5 additions & 4 deletions x/ibcratelimit/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,22 @@ import (
func TestAllMsgsGetSigners(t *testing.T) {
msgMakers := []testutil.MsgMaker{
func(signer string) sdk.Msg { return &MsgGovUpdateParamsRequest{Authority: signer} },
func(signer string) sdk.Msg { return &MsgUpdateParamsRequest{Authority: signer} },
}

testutil.RunGetSignersTests(t, AllRequestMsgs, msgMakers, nil)
}

func TestNewMsgGovUpdateParamsRequest(t *testing.T) {
expected := &MsgGovUpdateParamsRequest{
expected := &MsgUpdateParamsRequest{
Authority: "authority",
Params: NewParams("contract"),
}
event := NewMsgGovUpdateParamsRequest(expected.Authority, expected.Params.ContractAddress)
event := NewMsgUpdateParamsRequest(expected.Authority, expected.Params.ContractAddress)
assert.Equal(t, expected, event, "should create the correct with correct content")
}

func TestNewMsgGovUpdateParamsValidateBasic(t *testing.T) {
func TestNewMsgUpdateParamsValidateBasic(t *testing.T) {
tests := []struct {
name string
authority string
Expand Down Expand Up @@ -62,7 +63,7 @@ func TestNewMsgGovUpdateParamsValidateBasic(t *testing.T) {

for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
msg := NewMsgGovUpdateParamsRequest(tc.authority, tc.contract)
msg := NewMsgUpdateParamsRequest(tc.authority, tc.contract)
err := msg.ValidateBasic()

if len(tc.err) > 0 {
Expand Down
12 changes: 6 additions & 6 deletions x/ibcratelimit/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,28 @@ func WeightedOperations(
)

simState.AppParams.GetOrGenerate(OpWeightMsgUpdateParams, &wMsgUpdateParams, nil,
func(_ *rand.Rand) { wMsgUpdateParams = simappparams.DefaultWeightGovUpdateParams })
func(_ *rand.Rand) { wMsgUpdateParams = simappparams.DefaultWeightUpdateParams })

return simulation.WeightedOperations{
simulation.NewWeightedOperation(wMsgUpdateParams, SimulateMsgGovUpdateParams(simState, k, ak, bk)),
simulation.NewWeightedOperation(wMsgUpdateParams, SimulateMsgUpdateParams(simState, k, ak, bk)),
}
}

// SimulateMsgGovUpdateParams sends a MsgUpdateParams.
func SimulateMsgGovUpdateParams(simState module.SimulationState, _ keeper.Keeper, ak authkeeper.AccountKeeperI, bk bankkeeper.Keeper) simtypes.Operation {
// SimulateMsgUpdateParams sends a MsgUpdateParams.
func SimulateMsgUpdateParams(simState module.SimulationState, _ keeper.Keeper, ak authkeeper.AccountKeeperI, bk bankkeeper.Keeper) simtypes.Operation {
return func(
r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string,
) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {
raccs, err := RandomAccs(r, accs, uint64(len(accs)))
if err != nil {
return simtypes.NoOpMsg(ibcratelimit.ModuleName, sdk.MsgTypeURL(&ibcratelimit.MsgGovUpdateParamsRequest{}), err.Error()), nil, nil
return simtypes.NoOpMsg(ibcratelimit.ModuleName, sdk.MsgTypeURL(&ibcratelimit.MsgUpdateParamsRequest{}), err.Error()), nil, nil
}

// 50% chance to be from the module's authority
from := raccs[0]
to := raccs[1]

msg := ibcratelimit.NewMsgGovUpdateParamsRequest(from.Address.String(), to.Address.String())
msg := ibcratelimit.NewMsgUpdateParamsRequest(from.Address.String(), to.Address.String())

// TODO[1760]: Refactor this to submit it as a gov prop and return futures for votes.
return Dispatch(r, app, ctx, simState, from, chainID, msg, ak, bk, nil)
Expand Down
10 changes: 5 additions & 5 deletions x/ibcratelimit/simulation/operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (s *SimTestSuite) TestWeightedOperations() {
opMsgRoute string
opMsgName string
}{
{simappparams.DefaultWeightGovUpdateParams, ibcratelimit.ModuleName, sdk.MsgTypeURL(&ibcratelimit.MsgGovUpdateParamsRequest{})},
{simappparams.DefaultWeightUpdateParams, ibcratelimit.ModuleName, sdk.MsgTypeURL(&ibcratelimit.MsgUpdateParamsRequest{})},
}

expNames := make([]string, len(expected))
Expand Down Expand Up @@ -107,19 +107,19 @@ func (s *SimTestSuite) TestWeightedOperations() {
}
}

func (s *SimTestSuite) TestSimulateMsgGovUpdateParams() {
func (s *SimTestSuite) TestSimulateMsgUpdateParams() {
// setup 3 accounts
source := rand.NewSource(1)
r := rand.New(source)
accounts := s.getTestingAccounts(r, 3)

// execute operation
op := simulation.SimulateMsgGovUpdateParams(s.MakeTestSimState(), *s.app.RateLimitingKeeper, s.app.AccountKeeper, s.app.BankKeeper)
op := simulation.SimulateMsgUpdateParams(s.MakeTestSimState(), *s.app.RateLimitingKeeper, s.app.AccountKeeper, s.app.BankKeeper)
operationMsg, futureOperations, err := op(r, s.app.BaseApp, s.ctx, accounts, "")
s.Require().NoError(err, "SimulateMsgGovUpdateParams op(...) error")
s.Require().NoError(err, "SimulateMsgUpdateParams op(...) error")
s.LogOperationMsg(operationMsg, "good")

var msg ibcratelimit.MsgGovUpdateParamsRequest
var msg ibcratelimit.MsgUpdateParamsRequest
s.Require().NoError(s.app.AppCodec().Unmarshal(operationMsg.Msg, &msg), "UnmarshalJSON(operationMsg.Msg)")

s.Assert().True(operationMsg.OK, "operationMsg.OK")
Expand Down
Loading

0 comments on commit aae3484

Please sign in to comment.