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

workload/governance: fix case with multiple identical active proposals #3959

Merged
merged 1 commit into from
May 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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/3959.internal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
workload/governance: fix case with multiple equal active proposals
12 changes: 9 additions & 3 deletions go/oasis-node/cmd/debug/txsource/workload/governance.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,24 @@ func (g *governanceWorkload) submitProposalContent(pc *governance.ProposalConten
g.Logger.Debug("proposal submitted",
"proposal_content", pc,
)
// Ensure proposal exists.
// Find submitted proposal.
// In case there are multiple proposals with identical content, select the
// one with higher ID - since that is the more recently submitted proposal.
aps, err := g.governance.ActiveProposals(g.ctx, consensus.HeightLatest)
if err != nil {
return 0, fmt.Errorf("failed to query active proposals: %w", err)
}
var proposal *governance.Proposal
for _, ap := range aps {
if ap.Content.Equals(pc) {
proposal = ap
break
if proposal == nil || proposal.ID < ap.ID {
proposal = ap
}
}
}
if proposal == nil {
return 0, fmt.Errorf("submitted proposal not found: %v", pc)
}

return proposal.ID, nil
}
Expand Down