Repository navigation
feat: index third-party bonder authorizations - #280
Conversation
|
🚀 Subgraph Studio preview deployed
curl -H 'Content-Type: application/json' \
-d '{"query":"{ protocol(id: \"0\") { inflation } }"}' \
https://api.studio.thegraph.com/query/31909/livepeer-ci/pr-280-7a8fd7d-46503430946 |
There was a problem hiding this comment.
🟡 Changes recommended
An active finding remains in schema.graphql at line 597: the new field description uses occured instead of occurred.
1 open issue
What changed in this PR
Adds indexing for BondingManager third-party bonder authorizations, making current permissions and grant/revoke history queryable. The new handler requires a full resync.
Changes:
- Store active delegator–bonder pairs and remove them on revoke.
- Record each authorization event with transaction, timestamp, and round references.
- Add the event ABI and handler registration; broader ABI synchronization remains separate under #252.
| File | Description |
|---|---|
| subgraph.template.yaml | Registers the authorization entities and event handler. |
| src/mappings/bondingManager.ts | Updates active authorizations and records event history. |
| schema.graphql | Defines current authorization and historical event entities. |
| abis/BondingManager.json | Adds the third-party bonder authorization event ABI. |
Review effort: Balanced
The BondingManager lets an account authorize the addresses allowed to add stake to it with bondForWithHint() or transferBond(). Index the ThirdPartyBonderAuthorization event so apps can list and check them. ThirdPartyBonderAuthorization holds only current pairs and is removed on revoke, so a query cannot return a revoked bonder. ThirdPartyBonderAuthorizationEvent keeps every grant and revoke. The ABI entry was added by hand from the BondingManagerTarget deployment artifact (0xbE3B607B990e3987CA28188ED2e73F52ebbD3bd2).
d3a6d67 to
24e731b
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
The fetched artifact targets a different BondingManager deployment and lacks the event, requiring human verification of the hand-copied ABI against the stated deployment artifact before the full resync.
No open issues 🎉
Review effort: Balanced
Lets apps list a delegator's authorized bonders from the Delegator entity, as with unbondingLocks.
There was a problem hiding this comment.
🔵 Needs a closer look
The cited deployment artifact targets a different address and lacks ThirdPartyBonderAuthorization, leaving the hand-copied ABI’s event shape unverifiable without human review before the required full resync.
No open issues 🎉
Review effort: Balanced
| "Reference to the round the event occurred in" | ||
| round: Round! | ||
| "Reference to the delegator that granted or revoked the authorization, null until it bonds" | ||
| delegator: Delegator |
An account authorizes a bonder before anyone bonds for it, so creating
its Delegator on the grant listed wallets with no stake as delegators.
The handler now stores the address only and the delegator link is
nullable: it resolves once the account bonds, and thirdPartyBonders
then includes grants made before that. Query a wallet's grants before
it bonds with thirdPartyBonderAuthorizations(where: { delegator }).
5d3771e to
0bc2222
Compare
This reverts commit 0bc2222 while the link type is settled on the PR.
| event: ThirdPartyBonderAuthorizationEventParam | ||
| ): void { | ||
| let round = createOrLoadRound(getBlockNum()); | ||
| let delegator = createOrLoadDelegator( |
There was a problem hiding this comment.
@adamsoffer I found a problem with the Delegator link: the wallet granting the authorization usually hasn't bonded yet, so it has no Delegator. The handler hid this by creating an empty Delegator on every grant, which lists unbonded wallets as delegators. If we stop creating it, the link is null for those wallets, and a grant followed by a revoke before bonding leaves history that doesn't say which wallet it was (Copilot flagged this).
I'd like to go back to delegator: String!. #885 then reads the list with thirdPartyBonderAuthorizations(where: { delegator: $addr }), which works for every wallet, staked or not.
Alternative: link to LivepeerAccount!, which exists for any wallet. That allows livepeerAccount(id) { thirdPartyBonders }, plus the granting wallet's stake in the same query. It also means changing createOrUpdateLivepeerAccount, which links new accounts to the zero-address Delegator. That change touches treasury accounts too.
Which do you prefer?
There was a problem hiding this comment.
Let's go with your recommendation, delegator: String!. livepeer/explorer#885 already reads thirdPartyBonderAuthorizations(where: { delegator: $addr }), so it shouldn't need a change.
There was a problem hiding this comment.
Thanks we can extend it later if needed and there is a feature for having a livepeerAccount instead.
A grant usually comes before the first bond. Linking it to Delegator
either created an empty Delegator, listing the wallet as one, or left
a null link that drops the address from the grant history. Store the
address instead; apps filter with where: { delegator }.


The BondingManager has a registry where an account authorizes the addresses allowed to add stake to it with
bondForWithHint()ortransferBond()(setThirdPartyBonderAuthorization(), which emitsThirdPartyBonderAuthorization). This indexes it.ThirdPartyBonderAuthorizationholds the current (delegator, bonder) pairs and is removed on revoke, so a query cannot return a revoked bonder. It can be filtered bydelegatororbonder.ThirdPartyBonderAuthorizationEventrecords every grant and revoke for activity history. The ABI entry was added by hand from theBondingManagerTargetdeployment artifact (0xbE3B607B990e3987CA28188ED2e73F52ebbD3bd2), see #252. The new handler requires a full resync.