Skip to content

Add lastFeeRound to Transcoder for independent fee factor fallback #230

@rickstaa

Description

@rickstaa

Problem

The contract's latestCumulativeFactorsPool() tracks reward and fee factors independently using separate lastRewardRound and lastFeeRound fields. The subgraph only has lastRewardRound on the Transcoder entity.

When a transcoder reactivates after being inactive, the roundsManager newRound handler falls back to lastRewardRound for both cumulativeRewardFactor and cumulativeFeeFactor. If fees were earned in a later round than the last reward (i.e. lastFeeRound > lastRewardRound), the propagated cumulativeFeeFactor will be stale.

Example

  • Round 98: reward() called, fees earned → lastRewardRound=98, lastFeeRound=98
  • Round 99: no reward(), fees earned → lastRewardRound=98, lastFeeRound=99
  • Rounds 100-104: deactivated
  • Round 105: reactivated → subgraph falls back to round 98 for both factors, missing the fee factor update from round 99

Fix

  1. Add lastFeeRound: Round to the Transcoder schema
  2. Set transcoder.lastFeeRound = round.id in the ticketBroker fee handler
  3. In roundsManager newRound, use separate fallback lookups:
    • cumulativeRewardFactor from lastRewardRound pool
    • cumulativeFeeFactor from lastFeeRound pool

This mirrors the contract's independent lastRewardRound/lastFeeRound lookups in latestCumulativeFactorsPool().

Context

Related to PR #217. The reactivation fallback to lastRewardRound was added in that PR but only covers the reward factor correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions