Skip to content

Conversation

samlaf
Copy link
Collaborator

@samlaf samlaf commented Jun 26, 2025

Why are these changes needed?

#1664 made the current clients incompatible with our current testnet and mainnet network. This PR is an attempt to make them backwards compatible, but the conversion function was generated by Claude, so @hopeyen please take a look. We can discuss whether this approach makes sense at all.

If it doesn't, then we probably should not have merged this client to master until the testnet and mainnet dispersers are updated with the new disperser apiserver API.

See also this slack thread.

Checks

  • I've made sure the tests are passing. Note that there might be a few flaky tests, in that case, please comment that they are not relevant.
  • I've checked the new test coverage and the coverage percentage didn't drop.
  • Testing Strategy
    • Unit tests
    • Integration tests
    • This PR is not tested :(

samlaf added 2 commits June 26, 2025 18:25
TODO: review the Claude generated getPaymentStateFromLegacyAPI... no idea if its OK or not.
@samlaf samlaf requested a review from a team as a code owner June 26, 2025 10:27
@samlaf samlaf requested a review from hopeyen June 26, 2025 10:27
@samlaf samlaf marked this pull request as draft June 26, 2025 10:27
Comment on lines 436 to 437
// TODO: this was generated by Claude. I haven't checked that it actually makes sense.... SO DO NOT MERGE BEFORE CHECKING THIS.
func convertLegacyPaymentStateToNew(legacyReply *disperser_rpc.GetPaymentStateReply) *disperser_rpc.GetPaymentStateForAllQuorumsReply {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@hopeyen can you take a look at this function please?

Copy link
Contributor

@hopeyen hopeyen left a comment

Choose a reason for hiding this comment

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

I think the check for conversion makes sense for backward compatibility, and left a few small comments

if legacyReply.Reservation != nil {
// Apply the reservation to all quorums mentioned in the reservation
quorums := legacyReply.Reservation.QuorumNumbers
if len(quorums) == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be invalid and error out

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@samlaf samlaf marked this pull request as ready for review June 26, 2025 17:00
@samlaf samlaf requested a review from hopeyen June 26, 2025 17:23
Copy link

github-actions bot commented Jun 27, 2025

The latest Buf updates on your PR. Results from workflow Buf Proto / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedJun 30, 2025, 2:48 PM

@samlaf samlaf requested a review from litt3 June 27, 2025 15:08
@samlaf
Copy link
Collaborator Author

samlaf commented Jun 27, 2025

@hopeyen @litt3 added documentation to the proto files. PTAL to make sure it makes sense: e2a0493

litt3
litt3 previously approved these changes Jun 27, 2025
bytes cumulative_payment = 4;
// on-chain on-demand payment deposited
// The bytes are parsed to a big.Int value.
// This value should always be <= cumulative_payment, as the disperser cumulative_payment kept offchain is only periodically updated onchain.
Copy link
Contributor

Choose a reason for hiding this comment

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

we currently don't have payment updates on-chain at all, still something to add in the future. It would look something like disperser sees a request containing payment header, account id, and signature. disperser submits the message onchain, contract verifies, update cumulative_payment_used which would always be onchain_cumulative_payment_used <= onchain_cumulative_payment. then the field above cumulative_payment must be within these onchain two ranges

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

return early when no reservation exists, which makes the logic much simpler
@samlaf samlaf requested review from hopeyen and litt3 June 30, 2025 10:10
hopeyen
hopeyen previously approved these changes Jun 30, 2025
MinNumSymbols: legacyReply.PaymentGlobalParams.MinNumSymbols,
// ReservationAdvanceWindow is not used offchain at the moment so it's okay to set to any value.
// It was added for consistency with the onchain data structure but get removed in the future.
ReservationAdvanceWindow: legacyReply.PaymentGlobalParams.ReservationWindow,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: perhaps we set this to 0 similar to all the other "Not available in legacy format" fields, for consistency.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

}

// Apply the global params to all quorums mentioned in on-demand quorum numbers
quorums := legacyReply.PaymentGlobalParams.OnDemandQuorumNumbers
Copy link
Contributor

Choose a reason for hiding this comment

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

quorums won't be able to cover custom quorums, but reservations would rely on quorum configurations and the client should apply global params to all quorums it might use. I would suggest constructing quorums by taking an union of legacyReply.PaymentGlobalParams.OnDemandQuorumNumbers and legacyReply.Reservation.QuorumNumbers

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good catch. fixed in 689f53d

ReservationAdvanceWindow: legacyReply.PaymentGlobalParams.ReservationWindow,
ReservationRateLimitWindow: legacyReply.PaymentGlobalParams.ReservationWindow,
OnDemandRateLimitWindow: 0, // Not available in legacy format
OnDemandEnabled: true, // we are iterating over on-demand quorums, so this is always true
Copy link
Contributor

Choose a reason for hiding this comment

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

if we update the content of quorums, we might need a separate loop to set field to true for ondemand quorum numbers whereas the default is false

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

// dispersers unlimited to EigenLabs.
// off-chain on-demand payment usage.
// The bytes are parsed to a big.Int value.
// This value should always be <= cumulative_payment, as the disperser cumulative_payment kept offchain is only periodically updated onchain.
Copy link
Contributor

Choose a reason for hiding this comment

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

this description isn't accurate atm. updating the onchain balance is something we have been putting off for the future. There's some proposal on how it updates, verifies, and handling refunds... but nothing has been decided

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

litt3
litt3 previously approved these changes Jun 30, 2025
@samlaf samlaf merged commit 26c612f into master Jun 30, 2025
22 checks passed
@samlaf samlaf deleted the fix--make-disperser-client-backwards-compatible branch June 30, 2025 15:05
hopeyen pushed a commit that referenced this pull request Jul 1, 2025
* chore(apiserver): refactor GetPaymentState to highlight legacy conversion

* wip: attempt to make disperser_client backwards compatible

TODO: review the Claude generated getPaymentStateFromLegacyAPI... no idea if its OK or not.

* docs(apiserver): document convertAllQuorumsReplyToLegacy function

* fix(disperser_client): convertLegacyPaymentStateToNew returns error

* fix(disperser_client): set correct value for ReservationRateLimitWindow

* style: targetting -> targeting

* docs: remove outdated TODO comment

* docs: add docstring for getPaymentStateFromLegacyAPI

* fix: return error if PaymentGlobalParams==nil

* docs(proto): document GetPaymentStateReply fields

also GetPaymentStateForAllQuorumsReply fields

* docs(proto): document why GetPaymentStateRequest is separate type

from GetPaymentStateForAllQuorumsRequest

* style: remove outdated comment

* fix(disperser_client): onDemandEnabled value in convertLegacyPaymentStateToNew

* style: better error message in convertLegacyPaymentStateToNew

* refactor: convertLegacyPaymentStateToNew function

return early when no reservation exists, which makes the logic much simpler

* docs(proto): fix inaccurate cumulative_payment docstring

* style(disperser_client): set reservationAdvanceWindow to 0

in convertLegacyPaymentStateToNew

* fix(disp_client): convertLegacyPaymentStateToNew quorums setting logic

* docs(proto): remove wrong cumulative_payment comment

* style: remove unneeded comments

* style: add comment explaining why append is ok

* docs: move reservation_advance_window comment to proto
hopeyen pushed a commit that referenced this pull request Jul 7, 2025
* chore(apiserver): refactor GetPaymentState to highlight legacy conversion

* wip: attempt to make disperser_client backwards compatible

TODO: review the Claude generated getPaymentStateFromLegacyAPI... no idea if its OK or not.

* docs(apiserver): document convertAllQuorumsReplyToLegacy function

* fix(disperser_client): convertLegacyPaymentStateToNew returns error

* fix(disperser_client): set correct value for ReservationRateLimitWindow

* style: targetting -> targeting

* docs: remove outdated TODO comment

* docs: add docstring for getPaymentStateFromLegacyAPI

* fix: return error if PaymentGlobalParams==nil

* docs(proto): document GetPaymentStateReply fields

also GetPaymentStateForAllQuorumsReply fields

* docs(proto): document why GetPaymentStateRequest is separate type

from GetPaymentStateForAllQuorumsRequest

* style: remove outdated comment

* fix(disperser_client): onDemandEnabled value in convertLegacyPaymentStateToNew

* style: better error message in convertLegacyPaymentStateToNew

* refactor: convertLegacyPaymentStateToNew function

return early when no reservation exists, which makes the logic much simpler

* docs(proto): fix inaccurate cumulative_payment docstring

* style(disperser_client): set reservationAdvanceWindow to 0

in convertLegacyPaymentStateToNew

* fix(disp_client): convertLegacyPaymentStateToNew quorums setting logic

* docs(proto): remove wrong cumulative_payment comment

* style: remove unneeded comments

* style: add comment explaining why append is ok

* docs: move reservation_advance_window comment to proto
samlaf added a commit that referenced this pull request Jul 11, 2025
samlaf added a commit that referenced this pull request Jul 16, 2025
* Revert "refactor: account ledger interface incorporates debit slip (#1732)"

This reverts commit b4cf3d9.

* Revert "fix: period record circular wrapping refresh (#1731)"

This reverts commit 1091f46.

* Revert "fix: disperser_client v2 nil ptr bug (#1710)"

This reverts commit a5acd93.

* Revert "fix: disperser_client v2 should use default onDemandQuorums (#1700)"

This reverts commit 005e0a6.

* Revert "refactor: unify accountant debit slip (#1695)"

This reverts commit a9c0868.

* Revert "feat: AccountantLedger interface for next step unifications (#1694)"

This reverts commit 354e42f.

* Revert "feat: extract generic payment logic (#1693)"

This reverts commit 1003b98.

* Revert "fix: make disperser client backwards compatible (#1686)"

This reverts commit 26c612f.

* Revert "fix: payment state api doesn't fail at zero valued reservations/ondemand (#1682)"

This reverts commit 2031c1d.

* Revert "refactor: quorum specific metrics for metered bytes (#1668)"

This reverts commit 7ac688d.

* Revert "feat: GetPaymentStateForAllQuorums api impl (#1664)"

This reverts commit ed89588.

* Revert "refactor: core meterer consolidation (#1663)"

This reverts commit 319a865.

* Revert "refactor: onchain state interface (#1662)"

This reverts commit d795dfa.

* Revert "refactor: core meterer period record module (#1661)"

This reverts commit afbef90.

* Revert "refactor: payment common functions (#1653)"

This reverts commit 36a3d33.

* Revert "fix: period index calculation (#1641)"

This reverts commit c229748.

* Revert "refactor: use generic column name (#1626)"

This reverts commit 4d1994e.

* Revert "feat: payment onchain state interface (#1625)"

This reverts commit 61e46ac.

* Revert "feat: offchain quorum period record getter (#1620)"

This reverts commit a309139.

* Revert "feat: protobuf payment state api quorum specific variant (#1613)"

This reverts commit 58acdfd.

* Revert "fix: nil assignment to new account (#1612)"

This reverts commit bcbf9f5.

* Revert "feat: offchain batch writes (#1580)"

This reverts commit ce4d2f5.

* Revert "feat: validator authenticate on-demand request by disperser key (#1539)"

This reverts commit f545b16.

* fix: issues after series of reverts (scary)

* chore: add back ErrZeroSymbols error

This error was likely removed by mistake during a revert conflict fix from one of the previous set of reverted PRs.

* style: fix lint

* test: fix accountant_test hardcoded error string

* Revert "Revert "fix: period index calculation (#1641)""

This reverts commit b8767ae.
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