Skip to content

Commit

Permalink
fix: auto-fill of gov address for provider 'draft-proposal' (#1444)
Browse files Browse the repository at this point in the history
Fix signer for gov proposal messages
  • Loading branch information
bermuell authored Nov 23, 2023
1 parent d3f3d9f commit 1819e73
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 126 deletions.
16 changes: 8 additions & 8 deletions proto/interchain_security/ccv/provider/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ service Msg {

// MsgUpdateParams is the Msg/UpdateParams request type
message MsgUpdateParams {
option (cosmos.msg.v1.signer) = "signer";
option (cosmos.msg.v1.signer) = "authority";

// signer is the address of the governance account.
string signer = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];

// params defines the x/provider parameters to update.
Params params = 2 [(gogoproto.nullable) = false];
Expand Down Expand Up @@ -77,7 +77,7 @@ message MsgAssignConsumerKeyResponse {}
//
// Note: this replaces ConsumerAdditionProposal which is deprecated and will be removed soon
message MsgConsumerAddition {
option (cosmos.msg.v1.signer) = "signer";
option (cosmos.msg.v1.signer) = "authority";

// the proposed chain-id of the new consumer chain, must be different from all
// other consumer chain ids of the executing provider chain.
Expand Down Expand Up @@ -132,7 +132,7 @@ message MsgConsumerAddition {
string distribution_transmission_channel = 12;

// signer address
string signer = 13 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string authority = 13 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// MsgConsumerAdditionResponse defines response type for MsgConsumerAddition messages
Expand All @@ -146,7 +146,7 @@ message MsgConsumerAdditionResponse {}
//
// Note: this replaces ConsumerRemovalProposal which is deprecated and will be removed soon
message MsgConsumerRemoval {
option (cosmos.msg.v1.signer) = "signer";
option (cosmos.msg.v1.signer) = "authority";

// the chain-id of the consumer chain to be stopped
string chain_id = 1;
Expand All @@ -156,7 +156,7 @@ message MsgConsumerRemoval {
[ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ];

// signer address
string signer = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string authority = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// MsgConsumerRemovalResponse defines response type for MsgConsumerRemoval messages
Expand All @@ -167,14 +167,14 @@ message MsgConsumerRemovalResponse {}
//
// Note: this replaces ChangeRewardDenomsProposal which is deprecated and will be removed soon
message MsgChangeRewardDenoms {
option (cosmos.msg.v1.signer) = "signer";
option (cosmos.msg.v1.signer) = "authority";

// the list of consumer reward denoms to add
repeated string denoms_to_add = 1;
// the list of consumer reward denoms to remove
repeated string denoms_to_remove = 2;
// signer address
string signer = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string authority = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];

}

Expand Down
16 changes: 8 additions & 8 deletions x/ccv/provider/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ var _ types.MsgServer = msgServer{}

// UpdateParams updates the params.
func (k msgServer) UpdateParams(goCtx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) {
if k.GetAuthority() != msg.Signer {
return nil, errorsmod.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Signer)
if k.GetAuthority() != msg.Authority {
return nil, errorsmod.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority)
}

ctx := sdk.UnwrapSDKContext(goCtx)
Expand Down Expand Up @@ -126,8 +126,8 @@ func (k msgServer) AssignConsumerKey(goCtx context.Context, msg *types.MsgAssign

// ConsumerAddition defines a rpc handler method for MsgConsumerAddition
func (k msgServer) ConsumerAddition(goCtx context.Context, msg *types.MsgConsumerAddition) (*types.MsgConsumerAdditionResponse, error) {
if k.GetAuthority() != msg.Signer {
return nil, errorsmod.Wrapf(types.ErrUnauthorized, "expected %s, got %s", k.GetAuthority(), msg.Signer)
if k.GetAuthority() != msg.Authority {
return nil, errorsmod.Wrapf(types.ErrUnauthorized, "expected %s, got %s", k.GetAuthority(), msg.Authority)
}

ctx := sdk.UnwrapSDKContext(goCtx)
Expand All @@ -142,8 +142,8 @@ func (k msgServer) ConsumerAddition(goCtx context.Context, msg *types.MsgConsume
func (k msgServer) ConsumerRemoval(
goCtx context.Context,
msg *types.MsgConsumerRemoval) (*types.MsgConsumerRemovalResponse, error) {
if k.GetAuthority() != msg.Signer {
return nil, errorsmod.Wrapf(types.ErrUnauthorized, "expected %s, got %s", k.GetAuthority(), msg.Signer)
if k.GetAuthority() != msg.Authority {
return nil, errorsmod.Wrapf(types.ErrUnauthorized, "expected %s, got %s", k.GetAuthority(), msg.Authority)
}

ctx := sdk.UnwrapSDKContext(goCtx)
Expand All @@ -157,8 +157,8 @@ func (k msgServer) ConsumerRemoval(

// ChangeRewardDenoms defines a rpc handler method for MsgChangeRewardDenoms
func (k msgServer) ChangeRewardDenoms(goCtx context.Context, msg *types.MsgChangeRewardDenoms) (*types.MsgChangeRewardDenomsResponse, error) {
if k.GetAuthority() != msg.Signer {
return nil, errorsmod.Wrapf(types.ErrUnauthorized, "expected %s, got %s", k.GetAuthority(), msg.Signer)
if k.GetAuthority() != msg.Authority {
return nil, errorsmod.Wrapf(types.ErrUnauthorized, "expected %s, got %s", k.GetAuthority(), msg.Authority)
}

sdkCtx := sdk.UnwrapSDKContext(goCtx)
Expand Down
2 changes: 1 addition & 1 deletion x/ccv/provider/types/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func ParseConsumerKeyFromJson(jsonStr string) (pkType, key string, err error) {
// If the validator address is not same as delegator's, then the validator must
// sign the msg as well.
func (msg *MsgConsumerAddition) GetSigners() []sdk.AccAddress {
valAddr, err := sdk.ValAddressFromBech32(msg.Signer)
valAddr, err := sdk.ValAddressFromBech32(msg.Authority)
if err != nil {
// same behavior as in cosmos-sdk
panic(err)
Expand Down
Loading

0 comments on commit 1819e73

Please sign in to comment.