Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: update x/foundation params #704

Merged
merged 29 commits into from
Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
145649d
Update params proto
0Tech Sep 27, 2022
7bfedab
Update params related logics
0Tech Sep 27, 2022
6f51609
Remove unused logics
0Tech Sep 27, 2022
d005570
Add OutsourcingDecisionPolicy into proto
0Tech Sep 27, 2022
5b663c0
Implement OutsourcingDecisionPolicy
0Tech Sep 28, 2022
ef93429
Use more specific method of require
0Tech Sep 28, 2022
195b23e
Increase coverage
0Tech Sep 28, 2022
f2d3bf5
Revisit genesis proto
0Tech Sep 28, 2022
1cef861
Revisit genesis logic
0Tech Sep 28, 2022
2b66e6c
Use MustAccAddressFromBech32()
0Tech Sep 29, 2022
3c3bdac
Lint
0Tech Oct 11, 2022
59185af
Update CHANGELOG.md
0Tech Oct 11, 2022
30d0d04
Make sure operator is a module account
0Tech Oct 12, 2022
74b2475
Stop providing generated members
0Tech Oct 12, 2022
1d24053
Stop providing CreateValidatorAuthorizations
0Tech Oct 12, 2022
4ce362f
Add more validations on proposals in x/foundation genesis
0Tech Oct 5, 2022
5a28fdd
Merge branch 'main' into foundation_params
0Tech Oct 13, 2022
226d392
Revisit validation of FoundationInfo
0Tech Oct 13, 2022
d177a6a
Increase coverage
0Tech Oct 13, 2022
ded8679
Apply suggestions from code review
0Tech Oct 14, 2022
f1bfa5d
Revert "Apply suggestions from code review"
0Tech Oct 14, 2022
317c8c2
Update unit test on UpdateFoundationParamsProposal
0Tech Oct 14, 2022
f313d35
Merge branch 'main' into foundation_params
0Tech Oct 17, 2022
11a60c0
Apply feedback
0Tech Oct 17, 2022
8fedb10
Merge branch 'main' into foundation_params
0Tech Oct 17, 2022
2c25348
Increase coverage
0Tech Oct 17, 2022
3854c36
Merge branch 'main' into foundation_params
0Tech Oct 18, 2022
405d3c6
Merge branch 'main' into foundation_params
0Tech Oct 18, 2022
d06ef0d
Use snake_case
0Tech Oct 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (x/auth,bank,foundation,wasm) [\#691](https://github.com/line/lbm-sdk/pull/691) change AccAddressFromBech32 to MustAccAddressFromBech32
* (x/wasm) [\#690](https://github.com/line/lbm-sdk/pull/690) fix to prevent accepting file name
* (cli) [\#708](https://github.com/line/lbm-sdk/pull/708) In CLI, allow 1 SIGN_MODE_DIRECT signer in transactions with multiple signers.
* (x/foundation) [\#704](https://github.com/line/lbm-sdk/pull/704) update x/foundation params

0Tech marked this conversation as resolved.
Show resolved Hide resolved
### Bug Fixes
* (x/wasm) [\#453](https://github.com/line/lbm-sdk/pull/453) modify wasm grpc query api path
Expand Down
2 changes: 1 addition & 1 deletion baseapp/block_gas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func TestBaseApp_BlockGas(t *testing.T) {
txBuilder.SetFeeAmount(feeAmount)
txBuilder.SetGasLimit(txtypes.MaxGasWanted) // tx validation checks that gasLimit can't be bigger than this

privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{8}, []uint64{0}
privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{7}, []uint64{0}
_, txBytes, err := createTestTx(encCfg.TxConfig, txBuilder, privs, accNums, accSeqs, ctx.ChainID())
require.NoError(t, err)

Expand Down
9 changes: 5 additions & 4 deletions client/docs/statik/statik.go

Large diffs are not rendered by default.

21 changes: 12 additions & 9 deletions client/docs/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34882,11 +34882,12 @@ paths:
params:
type: object
properties:
enabled:
type: boolean
format: boolean
foundation_tax:
type: string
censored_msg_type_urls:
type: array
items:
type: string
description: Params defines the parameters for the foundation module.
description: >-
QueryParamsResponse is the response type for the Query/Params RPC
Expand Down Expand Up @@ -68588,11 +68589,12 @@ definitions:
lbm.foundation.v1.Params:
type: object
properties:
enabled:
type: boolean
format: boolean
foundation_tax:
type: string
censored_msg_type_urls:
type: array
items:
type: string
description: Params defines the parameters for the foundation module.
lbm.foundation.v1.Proposal:
type: object
Expand Down Expand Up @@ -69248,11 +69250,12 @@ definitions:
params:
type: object
properties:
enabled:
type: boolean
format: boolean
foundation_tax:
type: string
censored_msg_type_urls:
type: array
items:
type: string
description: Params defines the parameters for the foundation module.
description: QueryParamsResponse is the response type for the Query/Params RPC method.
lbm.foundation.v1.QueryProposalResponse:
Expand Down
23 changes: 21 additions & 2 deletions docs/core/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,7 @@
- [FoundationInfo](#lbm.foundation.v1.FoundationInfo)
- [Member](#lbm.foundation.v1.Member)
- [MemberRequest](#lbm.foundation.v1.MemberRequest)
- [OutsourcingDecisionPolicy](#lbm.foundation.v1.OutsourcingDecisionPolicy)
- [Params](#lbm.foundation.v1.Params)
- [PercentageDecisionPolicy](#lbm.foundation.v1.PercentageDecisionPolicy)
- [Pool](#lbm.foundation.v1.Pool)
Expand Down Expand Up @@ -16846,6 +16847,22 @@ since this field cannot be set as part of requests.



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

### OutsourcingDecisionPolicy
OutsourcingDecisionPolicy is a dummy decision policy which is set after
the operator has been updated into x/group's group policy.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `description` | [string](#string) | | |






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

### Params
Expand All @@ -16854,8 +16871,8 @@ Params defines the parameters for the foundation module.

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `enabled` | [bool](#bool) | | |
| `foundation_tax` | [string](#string) | | |
| `censored_msg_type_urls` | [string](#string) | repeated | |



Expand Down Expand Up @@ -16974,7 +16991,9 @@ UpdateFoundationParamsProposal details a proposal to update params of foundation
| ----- | ---- | ----- | ----------- |
| `title` | [string](#string) | | |
| `description` | [string](#string) | | |
| `params` | [Params](#lbm.foundation.v1.Params) | | |
| `params` | [Params](#lbm.foundation.v1.Params) | | params defines the x/foundation parameters to update.

Note: All parameters must be supplied. |



Expand Down
2 changes: 1 addition & 1 deletion proto/lbm/foundation/v1/event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import "lbm/foundation/v1/foundation.proto";

// EventUpdateFoundationParams is emitted after updating foundation parameters.
message EventUpdateFoundationParams {
Params params = 1;
Params params = 1 [(gogoproto.nullable) = false];
}

// EventFundTreasury is an event emitted when one funds the treasury.
Expand Down
18 changes: 15 additions & 3 deletions proto/lbm/foundation/v1/foundation.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import "cosmos_proto/cosmos.proto";

// Params defines the parameters for the foundation module.
message Params {
bool enabled = 1;
string foundation_tax = 2
string foundation_tax = 1
[(gogoproto.customtype) = "github.com/line/lbm-sdk/types.Dec", (gogoproto.nullable) = false];
repeated string censored_msg_type_urls = 2;
}

// UpdateFoundationParamsProposal details a proposal to update params of foundation module.
Expand All @@ -26,7 +26,11 @@ message UpdateFoundationParamsProposal {

string title = 1;
string description = 2;
Params params = 3;

// params defines the x/foundation parameters to update.
//
// Note: All parameters must be supplied.
Params params = 3 [(gogoproto.nullable) = false];
}

// Member represents a foundation member with an account address and metadata.
Expand Down Expand Up @@ -107,6 +111,14 @@ message DecisionPolicyWindows {
google.protobuf.Duration min_execution_period = 2 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false];
}

// OutsourcingDecisionPolicy is a dummy decision policy which is set after
// the operator has been updated into x/group's group policy.
dudong2 marked this conversation as resolved.
Show resolved Hide resolved
message OutsourcingDecisionPolicy {
option (cosmos_proto.implements_interface) = "DecisionPolicy";

string description = 1;
}

// VoteOption enumerates the valid vote options for a given proposal.
enum VoteOption {
option (gogoproto.goproto_enum_prefix) = false;
Expand Down
4 changes: 2 additions & 2 deletions proto/lbm/foundation/v1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ message GenesisState {
option (gogoproto.goproto_getters) = false;

// params defines the module parameters at genesis.
Params params = 1;
Params params = 1 [(gogoproto.nullable) = false];

// foundation is the foundation info.
FoundationInfo foundation = 2;
FoundationInfo foundation = 2 [(gogoproto.nullable) = false];

// members is the list of the foundation members.
repeated Member members = 3 [(gogoproto.nullable) = false];
Expand Down
2 changes: 1 addition & 1 deletion proto/lbm/foundation/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ message QueryParamsRequest {}

// QueryParamsResponse is the response type for the Query/Params RPC method.
message QueryParamsResponse {
Params params = 1;
Params params = 1 [(gogoproto.nullable) = false];
}

// QueryTreasuryRequest is the request type for the
Expand Down
6 changes: 3 additions & 3 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ var (
authtypes.FeeCollectorName: nil,
distrtypes.ModuleName: nil,
foundation.TreasuryName: nil,
foundation.AdministratorName: nil,
foundation.DefaultOperatorName: nil,
minttypes.ModuleName: {authtypes.Minter},
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
Expand Down Expand Up @@ -377,7 +377,7 @@ func NewSimApp(
app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp)

foundationConfig := foundation.DefaultConfig()
app.FoundationKeeper = foundationkeeper.NewKeeper(appCodec, keys[foundation.StoreKey], app.BaseApp.MsgServiceRouter(), app.AccountKeeper, app.BankKeeper, stakingKeeper, authtypes.FeeCollectorName, foundationConfig)
app.FoundationKeeper = foundationkeeper.NewKeeper(appCodec, keys[foundation.StoreKey], app.BaseApp.MsgServiceRouter(), app.AccountKeeper, app.BankKeeper, authtypes.FeeCollectorName, foundationConfig)

classKeeper := classkeeper.NewKeeper(appCodec, keys[class.StoreKey])
app.TokenKeeper = tokenkeeper.NewKeeper(appCodec, keys[token.StoreKey], app.AccountKeeper, classKeeper)
Expand Down Expand Up @@ -520,7 +520,7 @@ func NewSimApp(
capability.NewAppModule(appCodec, *app.CapabilityKeeper),
crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants),
feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
foundationmodule.NewAppModule(appCodec, app.FoundationKeeper, app.StakingKeeper),
foundationmodule.NewAppModule(appCodec, app.FoundationKeeper),
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper),
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
Expand Down
2 changes: 1 addition & 1 deletion x/auth/ante/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ func (suite *AnteTestSuite) TestAnteHandlerFees() {
{
"signer as enough funds, should pass",
func() {
accNums = []uint64{8}
accNums = []uint64{7}
modAcc := suite.app.AccountKeeper.GetModuleAccount(suite.ctx, types.FeeCollectorName)

suite.Require().True(suite.app.BankKeeper.GetAllBalances(suite.ctx, modAcc.GetAddress()).Empty())
Expand Down
44 changes: 26 additions & 18 deletions x/foundation/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"strconv"
"strings"

"github.com/spf13/cobra"

Expand All @@ -13,21 +12,26 @@ import (
"github.com/line/lbm-sdk/client/tx"
"github.com/line/lbm-sdk/codec"
sdk "github.com/line/lbm-sdk/types"
"github.com/line/lbm-sdk/version"
"github.com/line/lbm-sdk/x/foundation"
"github.com/line/lbm-sdk/x/gov/client/cli"
govtypes "github.com/line/lbm-sdk/x/gov/types"
)

// Proposal flags
const (
FlagAllowedValidatorAdd = "add"
FlagAllowedValidatorDelete = "delete"

FlagExec = "exec"
ExecTry = "try"
)

func parseParams(codec codec.Codec, paramsJSON string) (*foundation.Params, error) {
var params foundation.Params
if err := codec.UnmarshalJSON([]byte(paramsJSON), &params); err != nil {
return nil, err
}

return &params, nil
}

func parseMemberRequests(codec codec.Codec, membersJSON string) ([]foundation.MemberRequest, error) {
var cliMembers []json.RawMessage
if err := json.Unmarshal([]byte(membersJSON), &cliMembers); err != nil {
Expand Down Expand Up @@ -145,19 +149,21 @@ func NewTxCmd() *cobra.Command {
// NewProposalCmdUpdateFoundationParams implements the command to submit an update-foundation-params proposal
func NewProposalCmdUpdateFoundationParams() *cobra.Command {
cmd := &cobra.Command{
Use: "update-foundation-params",
Args: cobra.NoArgs,
Use: "update-foundation-params [params-json]",
Args: cobra.ExactArgs(1),
Short: "Submit an update foundation params proposal",
Long: strings.TrimSpace(
fmt.Sprintf(`Submit an update foundation params proposal.
For now, you have no other options, so we make the corresponding params json file for you.
Long: `Submit an update foundation params proposal.

Example:
$ %s tx gov submit-proposal update-foundation-params [flags]
Example of the content of params-json:

{
"foundation_tax": "0.1",
"censored_msg_type_urls": [
"/cosmos.staking.v1beta1.MsgCreateValidator",
"/lbm.foundation.v1.MsgWithdrawFromTreasury"
]
}
`,
version.AppName,
),
),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
Expand Down Expand Up @@ -185,10 +191,12 @@ $ %s tx gov submit-proposal update-foundation-params [flags]
return err
}

params := &foundation.Params{
Enabled: false,
params, err := parseParams(clientCtx.Codec, args[0])
if err != nil {
return err
}
content := foundation.NewUpdateFoundationParamsProposal(title, description, params)

content := foundation.NewUpdateFoundationParamsProposal(title, description, *params)
msg, err := govtypes.NewMsgSubmitProposal(content, deposit, from)
if err != nil {
return err
Expand Down
8 changes: 6 additions & 2 deletions x/foundation/client/testutil/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

sdk "github.com/line/lbm-sdk/types"
"github.com/line/lbm-sdk/x/foundation"
stakingtypes "github.com/line/lbm-sdk/x/staking/types"
)

func (s *IntegrationTestSuite) TestGRPCParams() {
Expand All @@ -27,9 +28,12 @@ func (s *IntegrationTestSuite) TestGRPCParams() {
false,
&foundation.QueryParamsResponse{},
&foundation.QueryParamsResponse{
Params: &foundation.Params{
Enabled: true,
Params: foundation.Params{
FoundationTax: sdk.MustNewDecFromStr("0.2"),
CensoredMsgTypeUrls: []string{
sdk.MsgTypeURL((*stakingtypes.MsgCreateValidator)(nil)),
sdk.MsgTypeURL((*foundation.MsgWithdrawFromTreasury)(nil)),
},
},
},
},
Expand Down
Loading