livepeer / livepeer/subgraph

Add lastFeeRound to Transcoder for independent fee factor fallback

Open
#230 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
5
Forks
7
Avg merge
4h 1m
Merged PRs (30d)
6

Description

## 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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Transcoder schema, the ticketBroker fee handler, and the roundsManager newRound handler described in the issue. Trace how lastRewardRound and cumulative factors are currently populated, then verify that reward and fee fallbacks use their independent rounds and that the Transcoder records the fee round.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.