Skip to content

Commit

Permalink
Porting: gov module (#7)
Browse files Browse the repository at this point in the history
* add: port gov module

* chg: implement WeightedVoteOptions with constraints

* chg: better TODOs descriptions

* chg: POS-2135: fix some tests

* chg: POS-2135: fix more tests

* chg: POS-2135: update an address format

* chg: fix few more tests

* chg: fix few more tests

* chg: fix some tests / temp revert some others to properly tune params later on

* chg: fix TestHooks

* chg: fix burn related methods / fix tests

* chg: fix query for WeightedVoteOptions / better comments

* chg: fix all tests in gov module

* chg: fix a staking integration test

* chg: POS-2142: edit gov readme

* chg: use AccAddressFromHex in tests instead of addressCodec

* chg: enable one test / provide better context for the only skipped test

* chg: use hex acc addresses in gov tests

* chg: return empty string on ProposalType normalization

* chg: remove TextProposals / add comment for Msgs auto-execution

* chg: re-enable textProposals / TBD with team

* chg: remove comment

* chg: better context for HV2 TODOs

* chg: filter out non valid proposals msgs types and content

* chg: fix typeUrls

* chg: filter out not supported messages at time of proposals submit / fix tests accordingly

* chg: go mod tidy

* chg: address PR comments: filtering dedicated file / test msg types / edit comments

* chg: register interfaces in gov test app

* chg: better context for comments

* chg: comment for future improvements

* chg: consistent example of gov tx for submit proposal

* chg: add msgServers in testApp to allow additional MsgUpdateParams types

* chg: fix tests after merge

* chg: update go deps for sdk and simapp

* chg: comment

* chg: comment in README for further actions

---------

Co-authored-by: Raneet Debnath <[email protected]>
  • Loading branch information
marcello33 and Raneet10 authored Apr 8, 2024
1 parent aceef00 commit 4e252ce
Show file tree
Hide file tree
Showing 61 changed files with 898 additions and 510 deletions.
3 changes: 1 addition & 2 deletions api/cosmos/gov/v1beta1/gov.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/cosmos/staking/v1beta1/staking.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/cosmos/staking/v1beta1/tx.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions proto/cosmos/gov/v1beta1/gov.proto
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ message WeightedVoteOption {
];
}

// TextProposal defines a standard text proposal whose changes need to be
// manually updated in case of approval.
// TODO HV2: TextProposals are disabled in heimdall. Remove it and re-implement all tests?

// TextProposal defines a standard text proposal whose changes need to be manually updated in case of approval.
message TextProposal {
option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content";
option (amino.name) = "cosmos-sdk/TextProposal";
Expand Down
4 changes: 3 additions & 1 deletion proto/cosmos/staking/v1beta1/staking.proto
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ message Description {
string details = 5;
}

// HV2: heimdall uses a different version of `Validator` in staking module, which will implement the ValidatorI

// Validator defines a validator, together with the total amount of the
// Validator's bond shares and their exchange rate to coins. Slashing results in
// a decrease in the exchange rate, allowing correct calculation of future
Expand All @@ -91,7 +93,7 @@ message Validator {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

// operator_address defines the address of the validator's operator; bech encoded in JSON.
// operator_address defines the address of the validator's operator; hex encoded in JSON.
string operator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// consensus_pubkey is the consensus public key of the validator, as a Protobuf Any.
google.protobuf.Any consensus_pubkey = 2 [(cosmos_proto.accepts_interface) = "cosmos.crypto.PubKey"];
Expand Down
2 changes: 1 addition & 1 deletion proto/cosmos/staking/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ message MsgCreateValidator {
];
// Deprecated: Use of Delegator Address in MsgCreateValidator is deprecated.
// The validator address bytes and delegator address bytes refer to the same account while creating validator (defer
// only in bech32 notation).
// only in hex notation).
string delegator_address = 4 [(cosmos_proto.scalar) = "cosmos.AddressString", deprecated = true];
string validator_address = 5 [(cosmos_proto.scalar) = "cosmos.ValidatorAddressString"];
google.protobuf.Any pubkey = 6 [(cosmos_proto.accepts_interface) = "cosmos.crypto.PubKey"];
Expand Down
4 changes: 4 additions & 0 deletions proto/cosmos/upgrade/v1beta1/upgrade.proto
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ message Plan {
google.protobuf.Any upgraded_client_state = 5 [deprecated = true];
}

// HV2: this was deleted from heimdall's gov/types/proposal.go.
// Did not remove it as it's only used in tests. Also it's marked as deprecated.
// Furthermore it's part of upgrade module heimdall won't use

// SoftwareUpgradeProposal is a gov Content type for initiating a software
// upgrade.
// Deprecated: This legacy proposal is deprecated in favor of Msg-based gov
Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/gov/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,8 @@ func (s *E2ETestSuite) TestNewCmdWeightedVote() {
for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
cmd := cli.NewCmdWeightedVote()
// TODO HV2: changed from NewCmdWeightedVote to NewCmdVote. Fix tests accordingly.
cmd := cli.NewCmdVote()
clientCtx := val.ClientCtx
var txResp sdk.TxResponse

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/staking/keeper/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func initFixture(t testing.TB) *fixture {

stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewKVStoreService(keys[types.StoreKey]), accountKeeper, bankKeeper, authority.String(), addresscodec.NewHexCodec(), addresscodec.NewHexCodec())
// TODO HV2: init processors with proper supply.AccountProcessor (supply module has been merged with bank module upstream)
authModule := auth.NewAppModule(cdc, accountKeeper, authsims.RandomGenesisAccounts, nil, []authtypes.AccountProcessor{})
authModule := auth.NewAppModule(cdc, accountKeeper, authsims.RandomGenesisAccounts, nil /*[]authtypes.AccountProcessor{}*/)
bankModule := bank.NewAppModule(cdc, bankKeeper, accountKeeper, nil)
stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper, nil)

Expand Down
2 changes: 1 addition & 1 deletion types/staking.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var (
DefaultBondDenom = "matic"

// DefaultPowerReduction is the default amount of staking tokens required for 1 unit of consensus-engine power
DefaultPowerReduction = sdkmath.NewIntFromUint64(1000000)
DefaultPowerReduction = sdkmath.NewIntFromUint64(1000000000000000000)
)

// TokensToConsensusPower - convert input tokens to potential consensus-engine power
Expand Down
3 changes: 2 additions & 1 deletion x/feegrant/client/cli/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,8 @@ func (s *CLITestSuite) msgVote(clientCtx client.Context, from, id, vote string,
}, commonArgs...)

args = append(args, extraArgs...)
cmd := govcli.NewCmdWeightedVote()
// TODO HV2: changed from NewCmdWeightedVote to NewCmdVote. Fix tests accordingly.
cmd := govcli.NewCmdVote()

out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, args)

Expand Down
Loading

0 comments on commit 4e252ce

Please sign in to comment.