Skip to content

feat: index third-party bonder authorizations - #280

Merged
rickstaa merged 5 commits into
mainfrom
feat/third-party-bonder-authorization
Nov 30, 2026
Merged

rickstaa merged 5 commits into
mainfrom
feat/third-party-bonder-authorization

Conversation

@rickstaa

Copy link
Copy Markdown
Member

The BondingManager has a registry where an account authorizes the addresses allowed to add stake to it with bondForWithHint() or transferBond() (setThirdPartyBonderAuthorization(), which emits ThirdPartyBonderAuthorization). This indexes it.

ThirdPartyBonderAuthorization holds the current (delegator, bonder) pairs and is removed on revoke, so a query cannot return a revoked bonder. It can be filtered by delegator or bonder. ThirdPartyBonderAuthorizationEvent records every grant and revoke for activity history. The ABI entry was added by hand from the BondingManagerTarget deployment artifact (0xbE3B607B990e3987CA28188ED2e73F52ebbD3bd2), see #252. The new handler requires a full resync.

Copilot AI balanced review requested due to automatic review settings November 25, 2026 18:41
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

🚀 Subgraph Studio preview deployed

Item Details
Version label pr-280-7a8fd7d-46503430946
Query endpoint https://api.studio.thegraph.com/query/31909/livepeer-ci/pr-280-7a8fd7d-46503430946
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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 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

Comment thread schema.graphql Resolved
@rickstaa
rickstaa requested review from adamsoffer and a balanced review from Copilot November 25, 2026 18:56
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).
@rickstaa
rickstaa force-pushed the feat/third-party-bonder-authorization branch from d3a6d67 to 24e731b Compare November 25, 2026 18:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues block the third-party bonder authorization indexing change.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 25, 2026 18:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 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

adamsoffer
adamsoffer previously approved these changes Nov 25, 2026

@adamsoffer adamsoffer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM.

Comment thread schema.graphql Resolved
Lets apps list a delegator's authorized bonders from the Delegator
entity, as with unbondingLocks.
Copilot AI balanced review requested due to automatic review settings November 26, 2026 09:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Authorization history cannot reliably identify a never-bonded account after access is granted and revoked because the delegator relationship is null and no required delegator address is retained.

1 open issue

Review effort: Balanced

Comment thread schema.graphql Outdated
"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 }).
@rickstaa
rickstaa force-pushed the feat/third-party-bonder-authorization branch from 5d3771e to 0bc2222 Compare November 30, 2026 10:56
Copilot AI balanced review requested due to automatic review settings November 30, 2026 10:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Authorization history loses the delegator’s identity when the account never bonded, so the raw delegator address must be persisted alongside the optional relationship.

1 open issue

Review effort: Balanced

This reverts commit 0bc2222 while the link type is settled on the PR.
Copilot AI balanced review requested due to automatic review settings November 30, 2026 11:12
Comment thread src/mappings/bondingManager.ts Outdated
event: ThirdPartyBonderAuthorizationEventParam
): void {
let round = createOrLoadRound(getBlockNum());
let delegator = createOrLoadDelegator(

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@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?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's go with your recommendation, delegator: String!. livepeer/explorer#885 already reads thirdPartyBonderAuthorizations(where: { delegator: $addr }), so it shouldn't need a change.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks we can extend it later if needed and there is a feature for having a livepeerAccount instead.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The hand-copied ThirdPartyBonderAuthorization ABI requires human verification against the cited deployment because the upstream artifact targets a different address and omits the event.

1 open issue

Review effort: Balanced

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 }.
Copilot AI balanced review requested due to automatic review settings November 30, 2026 20:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

There are no active review issues for the third-party bonder authorization indexing change.

1 open issue

Review effort: Balanced

@rickstaa
rickstaa merged commit 32730c6 into main Nov 30, 2026
7 checks passed
@rickstaa
rickstaa deleted the feat/third-party-bonder-authorization branch November 30, 2026 20:25
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