Skip to content

Commit

Permalink
refactor: remove x/foundation UpdateValidatorAuthsProposal (#685)
Browse files Browse the repository at this point in the history
* Remove `UpdateValidatorAuthsProposal` from proto

* Remove the logic relevant to the proposal

* Remove granter from authorization releated messages

* Remove the logic relevant to granter

* Update CHANGELOG.md
  • Loading branch information
0Tech authored Sep 28, 2022
1 parent fcaf1c5 commit 47eeccc
Show file tree
Hide file tree
Showing 32 changed files with 181 additions and 1,248 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (x/token) [\#637](https://github.com/line/lbm-sdk/pull/637) rename x/token events
* (x/collection) [\#639](https://github.com/line/lbm-sdk/pull/639) rename x/collection events
* (x/wasm) [\#661](https://github.com/line/lbm-sdk/pull/661) x/wasm refactoring - detaching the custom wasm proto part of lbm-sdk. (apply changes of [\#625](https://github.com/line/lbm-sdk/pull/625) and [\#655](https://github.com/line/lbm-sdk/pull/655))
* (refactor) [\#685](https://github.com/line/lbm-sdk/pull/685) remove x/foundation UpdateValidatorAuthsProposal

### Bug Fixes
* (x/wasm) [\#453](https://github.com/line/lbm-sdk/pull/453) modify wasm grpc query api path
Expand Down
7 changes: 4 additions & 3 deletions client/docs/statik/statik.go

Large diffs are not rendered by default.

36 changes: 0 additions & 36 deletions docs/core/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1112,8 +1112,6 @@
- [TallyResult](#lbm.foundation.v1.TallyResult)
- [ThresholdDecisionPolicy](#lbm.foundation.v1.ThresholdDecisionPolicy)
- [UpdateFoundationParamsProposal](#lbm.foundation.v1.UpdateFoundationParamsProposal)
- [UpdateValidatorAuthsProposal](#lbm.foundation.v1.UpdateValidatorAuthsProposal)
- [ValidatorAuth](#lbm.foundation.v1.ValidatorAuth)
- [Vote](#lbm.foundation.v1.Vote)

- [ProposalExecutorResult](#lbm.foundation.v1.ProposalExecutorResult)
Expand Down Expand Up @@ -16940,39 +16938,6 @@ UpdateFoundationParamsProposal details a proposal to update params of foundation



<a name="lbm.foundation.v1.UpdateValidatorAuthsProposal"></a>

### UpdateValidatorAuthsProposal
UpdateValidatorAuthsProposal details a proposal to update validator auths on foundation.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `title` | [string](#string) | | |
| `description` | [string](#string) | | |
| `auths` | [ValidatorAuth](#lbm.foundation.v1.ValidatorAuth) | repeated | |






<a name="lbm.foundation.v1.ValidatorAuth"></a>

### ValidatorAuth
ValidatorAuth defines authorization info of a validator.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `operator_address` | [string](#string) | | |
| `creation_allowed` | [bool](#bool) | | |






<a name="lbm.foundation.v1.Vote"></a>

### Vote
Expand Down Expand Up @@ -17298,7 +17263,6 @@ GrantAuthorization defines authorization grant to grantee via route.

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `granter` | [string](#string) | | |
| `grantee` | [string](#string) | | |
| `authorization` | [google.protobuf.Any](#google.protobuf.Any) | | |

Expand Down
17 changes: 0 additions & 17 deletions proto/lbm/foundation/v1/foundation.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ message Params {
[(gogoproto.customtype) = "github.com/line/lbm-sdk/types.Dec", (gogoproto.nullable) = false];
}

// ValidatorAuth defines authorization info of a validator.
message ValidatorAuth {
string operator_address = 1;
bool creation_allowed = 2;
}

// UpdateFoundationParamsProposal details a proposal to update params of foundation module.
message UpdateFoundationParamsProposal {
option (gogoproto.equal) = false;
Expand All @@ -34,17 +28,6 @@ message UpdateFoundationParamsProposal {
Params params = 3;
}

// UpdateValidatorAuthsProposal details a proposal to update validator auths on foundation.
message UpdateValidatorAuthsProposal {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;

string title = 1;
string description = 2;
repeated ValidatorAuth auths = 3 [(gogoproto.nullable) = false];
}

// Member represents a foundation member with an account address and metadata.
message Member {
// address is the member's account address.
Expand Down
5 changes: 2 additions & 3 deletions proto/lbm/foundation/v1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ message GenesisState {
message GrantAuthorization {
option (gogoproto.goproto_getters) = false;

string granter = 1;
string grantee = 2;
string grantee = 1;

google.protobuf.Any authorization = 3
google.protobuf.Any authorization = 2
[(cosmos_proto.accepts_interface) = "github.com/line/lbm-sdk/x/foundation.Authorization"];
}
1 change: 0 additions & 1 deletion simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ var (
append(
wasmclient.ProposalHandlers,
foundationclient.UpdateFoundationParamsProposalHandler,
foundationclient.UpdateValidatorAuthsProposalHandler,
paramsclient.ProposalHandler,
distrclient.ProposalHandler,
upgradeclient.ProposalHandler,
Expand Down
106 changes: 0 additions & 106 deletions x/foundation/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,112 +209,6 @@ $ %s tx gov submit-proposal update-foundation-params [flags]
return cmd
}

// NewProposalCmdUpdateValidatorAuths implements the command to submit an update-validator-auths proposal
func NewProposalCmdUpdateValidatorAuths() *cobra.Command {
cmd := &cobra.Command{
Use: "update-validator-auths",
Args: cobra.NoArgs,
Short: "Submit an update validator auths proposal",
Long: strings.TrimSpace(
fmt.Sprintf(`Submit an update validator auths proposal.
Example:
$ %s tx gov submit-proposal update-validator-auths [flags]
`,
version.AppName,
),
),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}
from := clientCtx.GetFromAddress()

depositStr, err := cmd.Flags().GetString(cli.FlagDeposit)
if err != nil {
return err
}

deposit, err := sdk.ParseCoinsNormalized(depositStr)
if err != nil {
return err
}

title, err := cmd.Flags().GetString(cli.FlagTitle)
if err != nil {
return err
}

description, err := cmd.Flags().GetString(cli.FlagDescription)
if err != nil {
return err
}

parseCommaSeparated := func(concat string) []string {
if concat == "" {
return []string{}
}
return strings.Split(concat, ",")
}

addingValidatorsStr, err := cmd.Flags().GetString(FlagAllowedValidatorAdd)
if err != nil {
return err
}
addingValidators := parseCommaSeparated(addingValidatorsStr)

deletingValidatorsStr, err := cmd.Flags().GetString(FlagAllowedValidatorDelete)
if err != nil {
return err
}
deletingValidators := parseCommaSeparated(deletingValidatorsStr)

createAuths := func(addings, deletings []string) []foundation.ValidatorAuth {
var auths []foundation.ValidatorAuth
for _, addr := range addings {
auth := foundation.ValidatorAuth{
OperatorAddress: addr,
CreationAllowed: true,
}
auths = append(auths, auth)
}
for _, addr := range deletings {
auth := foundation.ValidatorAuth{
OperatorAddress: addr,
CreationAllowed: false,
}
auths = append(auths, auth)
}

return auths
}

auths := createAuths(addingValidators, deletingValidators)
content := foundation.NewUpdateValidatorAuthsProposal(title, description, auths)
msg, err := govtypes.NewMsgSubmitProposal(content, deposit, from)
if err != nil {
return err
}

if err := msg.ValidateBasic(); err != nil {
return err
}

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}

cmd.Flags().String(cli.FlagTitle, "", "title of proposal")
cmd.Flags().String(cli.FlagDescription, "", "description of proposal")
cmd.Flags().String(cli.FlagDeposit, "", "deposit of proposal")

cmd.Flags().String(FlagAllowedValidatorAdd, "", "validator addresses to add")
cmd.Flags().String(FlagAllowedValidatorDelete, "", "validator addresses to delete")

return cmd
}

func NewTxCmdFundTreasury() *cobra.Command {
cmd := &cobra.Command{
Use: "fund-treasury [from] [amount]",
Expand Down
1 change: 0 additions & 1 deletion x/foundation/client/proposal_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ import (
)

var UpdateFoundationParamsProposalHandler = govclient.NewProposalHandler(cli.NewProposalCmdUpdateFoundationParams, rest.DummyRESTHandler)
var UpdateValidatorAuthsProposalHandler = govclient.NewProposalHandler(cli.NewProposalCmdUpdateValidatorAuths, rest.DummyRESTHandler)
1 change: 0 additions & 1 deletion x/foundation/client/testutil/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ func (s *IntegrationTestSuite) SetupSuite() {
foundationData.Authorizations = make([]foundation.GrantAuthorization, len(grantees))
for i, grantee := range grantees {
ga := foundation.GrantAuthorization{
Granter: foundation.ModuleName,
Grantee: grantee.String(),
}.WithAuthorization(&foundation.ReceiveFromTreasuryAuthorization{})
s.Require().NotNil(ga)
Expand Down
87 changes: 0 additions & 87 deletions x/foundation/client/testutil/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,93 +65,6 @@ func (s *IntegrationTestSuite) TestNewProposalCmdUpdateFoundationParams() {
}
}

func (s *IntegrationTestSuite) TestNewProposalCmdUpdateValidatorAuths() {
val := s.network.Validators[0]

commonFlags := []string{
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)))),
}

testCases := []struct {
name string
args []string
expectErr bool
expectedCode uint32
respType proto.Message
}{
{
"with no args",
commonFlags,
true, 0, nil,
},
{
"with an invalid address",
append([]string{
fmt.Sprintf("--%s=%s",
cli.FlagAllowedValidatorAdd,
"this-is-an-invalid-address",
),
}, commonFlags...),
true, 0, nil,
},
{
"with duplicated validators in add",
append([]string{
fmt.Sprintf("--%s=%s,%s",
cli.FlagAllowedValidatorAdd,
val.ValAddress.String(),
val.ValAddress.String(),
),
}, commonFlags...),
true, 0, nil,
},
{
"with same validators in both add and delete",
append([]string{
fmt.Sprintf("--%s=%s",
cli.FlagAllowedValidatorAdd,
val.ValAddress.String()),
fmt.Sprintf("--%s=%s",
cli.FlagAllowedValidatorDelete,
val.ValAddress.String()),
}, commonFlags...),
true, 0, nil,
},
{
"valid transaction",
append([]string{
fmt.Sprintf("--%s=%s",
cli.FlagAllowedValidatorDelete,
val.ValAddress.String()),
}, commonFlags...),
false, 0, &sdk.TxResponse{},
},
}

for _, tc := range testCases {
tc := tc

s.Run(tc.name, func() {
cmd := cli.NewProposalCmdUpdateValidatorAuths()
flags.AddTxFlagsToCmd(cmd)

out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, tc.args)
if tc.expectErr {
s.Require().Error(err)
} else {
s.Require().NoError(err)
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out)

txResp := tc.respType.(*sdk.TxResponse)
s.Require().Equal(tc.expectedCode, txResp.Code)
}
})
}
}

func (s *IntegrationTestSuite) TestNewTxCmdFundTreasury() {
val := s.network.Validators[0]
commonArgs := []string{
Expand Down
1 change: 0 additions & 1 deletion x/foundation/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
func RegisterInterfaces(registry types.InterfaceRegistry) {
registry.RegisterImplementations((*govtypes.Content)(nil),
&UpdateFoundationParamsProposal{},
&UpdateValidatorAuthsProposal{},
)

registry.RegisterImplementations((*sdk.Msg)(nil),
Expand Down
Loading

0 comments on commit 47eeccc

Please sign in to comment.