Skip to content

Commit

Permalink
chg: address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
marcello33 committed Apr 17, 2024
1 parent 84d9b34 commit 0453e03
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 11 deletions.
3 changes: 1 addition & 2 deletions tests/e2e/gov/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,7 @@ func (s *E2ETestSuite) TestNewCmdWeightedVote() {
for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
// TODO HV2: changed from NewCmdWeightedVote to NewCmdVote. Fix tests accordingly.
cmd := cli.NewCmdVote()
cmd := cli.NewCmdWeightedVote()
clientCtx := val.ClientCtx
var txResp sdk.TxResponse

Expand Down
3 changes: 1 addition & 2 deletions x/feegrant/client/cli/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -694,8 +694,7 @@ func (s *CLITestSuite) msgVote(clientCtx client.Context, from, id, vote string,
}, commonArgs...)

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

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

Expand Down
2 changes: 2 additions & 0 deletions x/gov/keeper/deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ func (keeper Keeper) GetDeposits(ctx context.Context, proposalID uint64) (deposi

// DeleteAndBurnDeposits deletes and burns all the deposits on a specific proposal.
func (keeper Keeper) DeleteAndBurnDeposits(ctx context.Context, proposalID uint64) error {
// HV2: no support in heimdall for burn deposits
panic(errors.ErrPanic)
coinsToBurn := sdk.NewCoins()
err := keeper.IterateDeposits(ctx, proposalID, func(key collections.Pair[uint64, sdk.AccAddress], deposit v1.Deposit) (stop bool, err error) {
coinsToBurn = coinsToBurn.Add(deposit.Amount...)
Expand Down
8 changes: 4 additions & 4 deletions x/gov/keeper/tally.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,17 @@ func (keeper Keeper) Tally(ctx context.Context, proposal v1.Proposal) (passes, b
*/

// HV2: check on the length of the options.
// This should never fail as all votes must have only 1 option
// This should never fail as all votes must have only 1 option, hence we panic if something goes wrong
err := keeper.assertOptionsLength(val.Vote)
if err != nil {
return false, false, tallyResults, err
panic(err)
}

for _, option := range val.Vote {
// HV2: check on the weight of the option.
// This should never fail as the only option should have weight=1
// This should never fail as the only option should have weight=1, hence we panic if something goes wrong
if !v1.ValidWeightedVoteOption(*option) {
return false, false, tallyResults, err
panic(err)
}
weight, _ := math.LegacyNewDecFromStr(option.Weight)
subPower := votingPower.Mul(weight)
Expand Down
3 changes: 2 additions & 1 deletion x/gov/keeper/vote.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ func (keeper Keeper) AddVote(ctx context.Context, proposalID uint64, voterAddr s

// HV2: check on the length of the options. This should never fail as it is only used by `MsgServer.Vote`.
// There, `v1.NewNonSplitVoteOption` is used to enforce the constraints (only 1 option with weight=1)
// Hence, we panic if something goes wrong
err = keeper.assertOptionsLength(options)
if err != nil {
return err
panic(err)
}

// HV2: check on the weight of the option. This should never fail as it is only used by `MsgServer.Vote`.
Expand Down
7 changes: 5 additions & 2 deletions x/upgrade/types/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import (
)

const (
// TODO HV2: ProposalTypeSoftwareUpgrade was removed. What to do with it?
// ProposalTypeCancelSoftwareUpgrade was not even there in heimdall's gov/types/proposal.go. What to do with it?
/* TODO HV2: ProposalTypeSoftwareUpgrade was removed. What to do with it?
ProposalTypeCancelSoftwareUpgrade was not even there in heimdall's gov/types/proposal.go.
Also, ProposalTypeCancelSoftwareUpgrade depends on ProposalTypeSoftwareUpgrade semantically,
so whatever we do with one, we should do with the other.
*/

ProposalTypeSoftwareUpgrade string = "SoftwareUpgrade"
ProposalTypeCancelSoftwareUpgrade string = "CancelSoftwareUpgrade"
Expand Down

0 comments on commit 0453e03

Please sign in to comment.