Skip to content

feat: catch execution reverts in announceWinner to prevent stuck proposals #140

@hudsonhrh

Description

@hudsonhrh

Problem

When a proposal wins and its execution batch reverts (e.g., insufficient funds, invalid target, contract error), the entire announceWinner transaction reverts. The Winner event never emits, so the subgraph never updates the proposal status. The proposal stays "Active" forever in the frontend even after voting has ended.

Example: Argus org has proposals #1, #10, #12 stuck as "Active" despite their voting period ending.

Root Cause

HybridVotingCore.sol line 225:
```solidity
l.executor.execute(id, batch); // reverts → whole tx reverts → no Winner event
```

Fix (Smart Contracts) — DONE

Wrapped executor call in try-catch in both HybridVoting and DirectDemocracyVoting:
```solidity
try l.executor.execute(id, batch) {
didExecute = true;
emit ProposalExecuted(id, winner, batch.length);
} catch (bytes memory reason) {
emit ProposalExecutionFailed(id, winner, reason);
}
emit Winner(id, winner, valid, didExecute, uint64(block.timestamp));
```

New event: `ProposalExecutionFailed(uint256 indexed id, uint256 indexed winningIdx, bytes reason)`

Tests pass (1211). Needs beacon upgrade (HybridVoting v9 + DirectDemocracyVoting v9).

Remaining Work

Subgraph

  • Add `ProposalExecutionFailed` event handler
  • Set proposal status to "ExecutionFailed" or "Completed" when this event fires
  • Add `executionFailed` and `executionError` fields to Proposal entity

Frontend

  • Display "Execution Failed" status for proposals that won but failed to execute
  • Show the revert reason if available
  • Allow re-calling `announceWinner` for proposals where the underlying issue has been fixed

Deploy

  • Deploy HybridVoting v9 + DirectDemocracyVoting v9 via existing `UpgradeVotingSelfTarget.s.sol` script

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions