Skip to content

refactor: improve governance participation logic#538

Open
rickstaa wants to merge 7 commits intomainfrom
refactor-310-participation
Open

refactor: improve governance participation logic#538
rickstaa wants to merge 7 commits intomainfrom
refactor-310-participation

Conversation

@rickstaa
Copy link
Member

@rickstaa rickstaa commented Feb 3, 2026

Fix participation logic so it works when orchestrators are activated and deactivated. Also improve caching behavoir.

@rickstaa rickstaa requested a review from ECWireless as a code owner February 3, 2026 20:59
@vercel
Copy link
Contributor

vercel bot commented Feb 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
explorer-arbitrum-one Ready Ready Preview, Comment Mar 3, 2026 0:26am

Request Review

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the governance participation calculation logic to properly handle orchestrator activation and deactivation cycles, ensuring that only proposals from periods when an orchestrator was active are counted toward their participation rate. The refactoring also improves caching behavior by using cache-and-network fetch policy consistently.

Changes:

  • Replaced the generic transcoderActivatedEvents query with a specific transcoderActivationHistory query that fetches both activation and deactivation events
  • Created a new useGovernanceParticipation hook that encapsulates the logic for calculating governance participation based on activation windows
  • Refactored OrchestratingView component to use the new hook instead of inline query logic

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
queries/transcoderActivationHistory.graphql New GraphQL query that fetches both activation and deactivation events for a delegate in chronological order
queries/transcoderActivatedEvents.graphql Removed generic query that only fetched activation events with flexible parameters
hooks/useGovernanceParticipation.tsx New hook implementing window-based participation calculation logic with activation/deactivation tracking
components/OrchestratingView/index.tsx Simplified to use new hook, extracted participation calculation to improve readability
apollo/subgraph.ts Updated generated TypeScript types reflecting query changes and added JSDoc formatting improvements

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Base automatically changed from 310-showcase-orchestrator-voting-activity-in-the-ui to main February 4, 2026 03:16
Fix participation logic so it works when orchestrators are activated and
deactivated. Also improve caching behavoir.
Co-authored-by: copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Ensure pending proposals are ommited in the participation calculation.
@rickstaa rickstaa requested a review from Copilot February 5, 2026 10:33
@rickstaa
Copy link
Member Author

rickstaa commented Feb 5, 2026

@ECWireless ready for your review.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

round: Number(d.deactivationRound),
type: "deactivation" as const,
})),
].sort((a, b) => a.round - b.round || (a.type === "deactivation" ? -1 : 1));
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sort tiebreaker at line 49 prioritizes deactivation over activation when both events occur in the same round: (a.type === "deactivation" ? -1 : 1). This means that if a transcoder is both activated and deactivated in the same round, the deactivation is processed first.

This could lead to counterintuitive behavior. If the same round has both an activation and deactivation event:

  • With current logic: deactivation comes first, so the activation creates a window starting at that round
  • Expected behavior might be: activation comes first, creating a zero-length or instant window

Consider documenting this behavior or revisiting whether this is the correct handling for same-round activation/deactivation events.

Suggested change
].sort((a, b) => a.round - b.round || (a.type === "deactivation" ? -1 : 1));
].sort((a, b) => {
if (a.round !== b.round) {
return a.round - b.round;
}
if (a.type === b.type) {
return 0;
}
// When in the same round, process activation events before deactivation events
return a.type === "activation" ? -1 : 1;
});

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if this comment sounds reasonable to you @rickstaa . Will ignore if not

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated logic. Ignored warning.

Copy link
Collaborator

@ECWireless ECWireless left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mainly had comments on what the bots had to say

round: Number(d.deactivationRound),
type: "deactivation" as const,
})),
].sort((a, b) => a.round - b.round || (a.type === "deactivation" ? -1 : 1));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if this comment sounds reasonable to you @rickstaa . Will ignore if not

- Sort same-round events with activation before deactivation to avoid dangling windows
- Return false from isActiveProposal when currentRoundId is undefined
- Filter votes by firstActivationRound to prevent voted exceeding eligible count

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Collaborator

@ECWireless ECWireless left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The calculated total looks wrong. For instance, all orchestrators should be should x out of 39 treasury proposals (at the time of writing this comment), no?

Image

In this PR's preview, I'm getting a different treasury proposal total for each orchestrator page ^^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants