Skip to content

Commit 629f873

Browse files
yihuangalpealjo242
authored
Merge commit from fork (#1386)
* Merge commit from fork * Fix ABS061 (cherry picked from commit f6f5639) * Update changelog * Review feedback (cherry picked from commit c892055e7fa86db8382fb2af17bb66342d7e2eeb) * Review feedback * Remove unecessary code comments * Set release date * Make format + removed todos * fix changelog --------- Co-authored-by: aljo242 <alex@interchainlabs.io> * remove new test * revert test --------- Co-authored-by: Alexander Peters <alpe@users.noreply.github.com> Co-authored-by: aljo242 <alex@interchainlabs.io>
1 parent 5ab318c commit 629f873

File tree

4 files changed

+269
-41
lines changed

4 files changed

+269
-41
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
3737

3838
* (x/staking) Fix a possible bypass of delagator slashing: [GHSA-86h5-xcpx-cfqc](https://github.com/cosmos/cosmos-sdk/security/advisories/GHSA-86h5-xcpx-cfqc)
3939
* Fix [ABS-0043/ABS-0044](https://github.com/cosmos/cosmos-sdk/security/advisories/GHSA-8wcc-m6j2-qxvm) Limit recursion depth for unknown field detection and unpack any
40+
* [GHSA-47ww-ff84-4jrg](https://github.com/cosmos/cosmos-sdk/security/advisories/GHSA-47ww-ff84-4jrg) Fix x/group can halt when erroring in EndBlocker
4041

4142
## [v0.46.16](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.16) - 2023-11-07
4243

proto/cosmos/group/v1/events.proto

+10
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,13 @@ message EventProposalPruned {
9292
// tally_result is the proposal tally result (when applicable).
9393
TallyResult tally_result = 3;
9494
}
95+
96+
// EventTallyError is an event emitted when a proposal tally failed with an error.
97+
message EventTallyError {
98+
99+
// proposal_id is the unique ID of the proposal.
100+
uint64 proposal_id = 1;
101+
102+
// error_message is the raw error output
103+
string error_message = 2;
104+
}

x/group/events.pb.go

+239-29
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x/group/keeper/msg_server.go

+19-12
Original file line numberDiff line numberDiff line change
@@ -678,33 +678,40 @@ func (k Keeper) Vote(goCtx context.Context, req *group.MsgVote) (*group.MsgVoteR
678678
// doTallyAndUpdate performs a tally, and, if the tally result is final, then:
679679
// - updates the proposal's `Status` and `FinalTallyResult` fields,
680680
// - prune all the votes.
681-
func (k Keeper) doTallyAndUpdate(ctx sdk.Context, p *group.Proposal, electorate group.GroupInfo, policyInfo group.GroupPolicyInfo) error {
681+
func (k Keeper) doTallyAndUpdate(ctx sdk.Context, proposal *group.Proposal, electorate group.GroupInfo, policyInfo group.GroupPolicyInfo) error {
682682
policy, err := policyInfo.GetDecisionPolicy()
683683
if err != nil {
684684
return err
685685
}
686686

687-
tallyResult, err := k.Tally(ctx, *p, policyInfo.GroupId)
688-
if err != nil {
689-
return err
687+
var result group.DecisionPolicyResult
688+
tallyResult, err := k.Tally(ctx, *proposal, policyInfo.GroupId)
689+
if err == nil {
690+
result, err = policy.Allow(tallyResult, electorate.TotalWeight)
690691
}
691-
692-
result, err := policy.Allow(tallyResult, electorate.TotalWeight)
693692
if err != nil {
694-
return sdkerrors.Wrap(err, "policy allow")
693+
if err := k.pruneVotes(ctx, proposal.Id); err != nil {
694+
return err
695+
}
696+
proposal.Status = group.PROPOSAL_STATUS_REJECTED
697+
return ctx.EventManager().EmitTypedEvents(
698+
&group.EventTallyError{
699+
ProposalId: proposal.Id,
700+
ErrorMessage: err.Error(),
701+
})
695702
}
696703

697704
// If the result was final (i.e. enough votes to pass) or if the voting
698705
// period ended, then we consider the proposal as final.
699-
if isFinal := result.Final || ctx.BlockTime().After(p.VotingPeriodEnd); isFinal {
700-
if err := k.pruneVotes(ctx, p.Id); err != nil {
706+
if isFinal := result.Final || ctx.BlockTime().After(proposal.VotingPeriodEnd); isFinal {
707+
if err := k.pruneVotes(ctx, proposal.Id); err != nil {
701708
return err
702709
}
703-
p.FinalTallyResult = tallyResult
710+
proposal.FinalTallyResult = tallyResult
704711
if result.Allow {
705-
p.Status = group.PROPOSAL_STATUS_ACCEPTED
712+
proposal.Status = group.PROPOSAL_STATUS_ACCEPTED
706713
} else {
707-
p.Status = group.PROPOSAL_STATUS_REJECTED
714+
proposal.Status = group.PROPOSAL_STATUS_REJECTED
708715
}
709716

710717
}

0 commit comments

Comments
 (0)