Skip to content

Conversation

@rickstaa
Copy link
Member

@rickstaa rickstaa commented Nov 16, 2025

This pull request adds gateway fee tracking with daily snapshots and rolling-window metrics similar to what we currently do for transcoders. It also stores the active gateway set on Protocol so that newRound can efficiently recompute the 30/60/90-day aggregates. The goal is to make it straightforward to build a gateway dashboard in the explorer.

@victorges, @yondonfu, @mikezupper, @ecmulli does this approach make sense, and do you see any potential issues, variables which you want to see added? I kept the existing “broadcaster” naming to avoid divergence for now, we can rename and deprecate it later if needed, but it’s not a priority.

TODOs

  • Test in Graph Studio -> test it here
  • Request review from another core contributor

@rickstaa rickstaa marked this pull request as draft November 16, 2025 14:41
Copy link

@mikezupper mikezupper left a comment

Choose a reason for hiding this comment

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

All of the changes look good. The changes shows consideration for backwards compatibility.

Caveat: I am not able to run these change to ensure they work with the current subgraph.

@mikezupper
Copy link

@rickstaa I am unable to use the test link provided (Test in Graph Studio), is there some other mechanism I can run some tests?

Also, have we tested running this subgraph from scratch? I know its a bit out of scope for your change, but I had many issues when I attempted this process last year.

@rickstaa rickstaa marked this pull request as ready for review November 19, 2025 16:28
Added gateway fee tracking with daily snapshots and rolling-window metrics
like transcoders, and stored the active gateway set on Protocol so newRound
can recompute 30/60/90 day sums efficiently.
@rickstaa rickstaa force-pushed the feat/track-gateway-fees branch from bf0e9f1 to 2762102 Compare November 19, 2025 16:39
@github-actions
Copy link

🚀 Subgraph studio preview deployed

Item Details
Version label pr-168-7e4d7c4-19509005431
Query endpoint https://api.studio.thegraph.com/query/31909/livepeer-ci/pr-168-7e4d7c4-19509005431
curl -H 'Content-Type: application/json' \
  -d '{"query":"{ protocol(id: \"0\") { inflation } }"}' \
  https://api.studio.thegraph.com/query/31909/livepeer-ci/pr-168-7e4d7c4-19509005431

Ensure that peopel can query the day a broadcaster joined the network
(i.e. funded reserve/deposit).
@github-actions
Copy link

🚀 Subgraph studio preview deployed

Item Details
Version label pr-168-b602361-19536247588
Query endpoint https://api.studio.thegraph.com/query/31909/livepeer-ci/pr-168-b602361-19536247588
curl -H 'Content-Type: application/json' \
  -d '{"query":"{ protocol(id: \"0\") { inflation } }"}' \
  https://api.studio.thegraph.com/query/31909/livepeer-ci/pr-168-b602361-19536247588

Copy link
Contributor

@jmulq jmulq left a comment

Choose a reason for hiding this comment

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

This functionally looks all good, however I had a few comments that'd be worth your reviewal @rickstaa.

Edit: One further thing I would add is that the use of the term volume in the fields for fees feels a bit ambigious. It seems to track the fees paid out to broadcasters, as well as winning ticket redemptions (which I believe are also a form of fees). I'm not sure whether you want to bundle these together, but I'd suggest the following:

  • Rename relevant fields to something less ambigious (e.g. totalFeesPaidETH)
  • If nuanced tracking of what fees were paid out by which events (rounds vs tickets), then update the types and mappings accordingly. For example there could be one field for each form of payout, alongside a total fees field.

Bear in mind I have less context on the protocol and data needs of the subgraph than yourself, so I might be wrong with some of these suggestions :)

utils/helpers.ts Outdated
protocol.save();
}

// Ensure backwards compatibility
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the rationale behind this backwards compatibility logic?

Are you planning to utilise grafting for these subgraphs?

Copy link
Member Author

Choose a reason for hiding this comment

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

@jmulq I initially (incorrectly) assumed grafting was enabled by default. After reviewing the grafting docs, it appears it’s not, and that new subgraph deployments reindex from scratch while the previous deployment remains available. Can you confirm this and that it’s safe to remove this logic? I’ve already applied the commit.

One question to double-check: most of our apps query the Subgraph ID (not a pinned Deployment ID—see explorer). Based on the querying docs (link), my understanding is that publishing a new version should not cause downtime: the network may continue routing queries to the previous deployment while the new one syncs, with the main caveats being potential version skew or schema-breaking changes. Can you confirm this matches your understanding?

Copy link
Contributor

Choose a reason for hiding this comment

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

I can confirm you are safe to remove this logic.

Yep your understanding is correct. Until there is a synced indexer on the latest deployment, it will route traffic to n-1.

Simplify and improve documentation around the logic that captures the
first active day for a gateway.

Co-authored-by: jmulq <james.mulqueeny@outlook.com>
@github-actions
Copy link

github-actions bot commented Dec 24, 2025

🚀 Subgraph Studio preview deployed

Item Details
Version label pr-168-27a2d04-20483564032
Query endpoint https://api.studio.thegraph.com/query/31909/livepeer-ci/pr-168-27a2d04-20483564032
curl -H 'Content-Type: application/json' \
  -d '{"query":"{ protocol(id: \"0\") { inflation } }"}' \
  https://api.studio.thegraph.com/query/31909/livepeer-ci/pr-168-27a2d04-20483564032

rickstaa and others added 2 commits December 24, 2025 10:53
Co-authored-by: jmulq <james.mulqueeny@outlook.com>
Grafting is not enabled, so the compatibility code is unnecessary.

Co-authored-by: jmulq <james.mulqueeny@outlook.com>
@rickstaa rickstaa force-pushed the feat/track-gateway-fees branch from 8b3829f to 4728c85 Compare December 24, 2025 10:34
@rickstaa rickstaa linked an issue Dec 24, 2025 that may be closed by this pull request
@rickstaa rickstaa requested a review from jmulq December 24, 2025 14:18
@rickstaa
Copy link
Member Author

This functionally looks all good, however I had a few comments that'd be worth your reviewal @rickstaa.

Edit: One further thing I would add is that the use of the term volume in the fields for fees feels a bit ambigious. It seems to track the fees paid out to broadcasters, as well as winning ticket redemptions (which I believe are also a form of fees). I'm not sure whether you want to bundle these together, but I'd suggest the following:

  • Rename relevant fields to something less ambigious (e.g. totalFeesPaidETH)
  • If nuanced tracking of what fees were paid out by which events (rounds vs tickets), then update the types and mappings accordingly. For example there could be one field for each form of payout, alongside a total fees field.

Bear in mind I have less context on the protocol and data needs of the subgraph than yourself, so I might be wrong with some of these suggestions :)

@jmulq Thanks for your quick review. Your reasoning makes sense. I created a low priority issue so the community can pick this up if they want.

@rickstaa
Copy link
Member Author

@mehrdadmms this pull request can be merged and you can work with @yondonfu to deploy it after @jmulq has looked at #168 (comment) and approvied it. This will unblock livepeer/explorer#291 which is not part of the original Explorer RFP but is a nice to have for the community. You can decide when you want to schedule it in.

Copy link
Contributor

@jmulq jmulq left a comment

Choose a reason for hiding this comment

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

Looks good to me following the prior reviewal.

@yondonfu yondonfu merged commit a21dc17 into main Jan 6, 2026
1 check passed
@yondonfu yondonfu deleted the feat/track-gateway-fees branch January 6, 2026 21:08
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.

Track gateway fees and activity for Explorer dashboards

5 participants