@@ -17,10 +17,7 @@ import (
17
17
"github.com/Layr-Labs/eigenda/encoding/rs"
18
18
"github.com/Layr-Labs/eigensdk-go/logging"
19
19
"github.com/docker/go-units"
20
- gethcommon "github.com/ethereum/go-ethereum/common"
21
20
"google.golang.org/grpc"
22
- "google.golang.org/grpc/codes"
23
- "google.golang.org/grpc/status"
24
21
)
25
22
26
23
type DisperserClientConfig struct {
@@ -393,135 +390,7 @@ func (c *disperserClient) GetPaymentState(ctx context.Context) (*disperser_rpc.G
393
390
Signature : signature ,
394
391
Timestamp : timestamp ,
395
392
}
396
- allQuorumsReply , err := c .client .GetPaymentStateForAllQuorums (ctx , request )
397
- if err != nil {
398
- // Check if error is "method not found" or "unimplemented"
399
- if isMethodNotFoundError (err ) {
400
- // Fall back to old method
401
- return c .getPaymentStateFromLegacyAPI (ctx , accountID , signature , timestamp )
402
- }
403
- return nil , err
404
- }
405
-
406
- return allQuorumsReply , nil
407
- }
408
-
409
- // this is true if we are targeting a disperser that hasn't upgraded to the new API yet.
410
- func isMethodNotFoundError (err error ) bool {
411
- if st , ok := status .FromError (err ); ok {
412
- return st .Code () == codes .Unimplemented
413
- }
414
- return false
415
- }
416
-
417
- // getPaymentStateFromLegacyAPI retrieves the payment state from the legacy GetPaymentState grpc method.
418
- // It is needed until we have upgraded all dispersers (testnet and mainnet) to the new API.
419
- // Check those endpoints for GetPaymentStateForAllQuorums using:
420
- // `grpcurl disperser-testnet-holesky.eigenda.xyz:443 list disperser.v2.Disperser`
421
- // `grpcurl disperser.eigenda.xyz:443 list disperser.v2.Disperser`
422
- func (c * disperserClient ) getPaymentStateFromLegacyAPI (
423
- ctx context.Context , accountID gethcommon.Address , signature []byte , timestamp uint64 ,
424
- ) (* disperser_rpc.GetPaymentStateForAllQuorumsReply , error ) {
425
- oldRequest := & disperser_rpc.GetPaymentStateRequest {
426
- AccountId : accountID .Hex (),
427
- Signature : signature ,
428
- Timestamp : timestamp ,
429
- }
430
-
431
- oldResult , err := c .client .GetPaymentState (ctx , oldRequest )
432
- if err != nil {
433
- return nil , err
434
- }
435
-
436
- return convertLegacyPaymentStateToNew (oldResult )
437
- }
438
-
439
- // convertLegacyPaymentStateToNew converts the old GetPaymentStateReply to the new GetPaymentStateForAllQuorumsReply format
440
- func convertLegacyPaymentStateToNew (legacyReply * disperser_rpc.GetPaymentStateReply ) (* disperser_rpc.GetPaymentStateForAllQuorumsReply , error ) {
441
-
442
- if legacyReply .PaymentGlobalParams == nil {
443
- return nil , fmt .Errorf ("legacy payment state received from disperser does not contain global params" )
444
- }
445
- // Convert PaymentGlobalParams to PaymentVaultParams
446
- var paymentVaultParams * disperser_rpc.PaymentVaultParams
447
- {
448
- paymentVaultParams = & disperser_rpc.PaymentVaultParams {
449
- QuorumPaymentConfigs : make (map [uint32 ]* disperser_rpc.PaymentQuorumConfig ),
450
- QuorumProtocolConfigs : make (map [uint32 ]* disperser_rpc.PaymentQuorumProtocolConfig ),
451
- OnDemandQuorumNumbers : legacyReply .PaymentGlobalParams .OnDemandQuorumNumbers ,
452
- }
453
-
454
- // Apply the global params to all quorums, both on-demand and reservation.
455
- onDemandQuorums := legacyReply .PaymentGlobalParams .OnDemandQuorumNumbers
456
- if len (onDemandQuorums ) == 0 {
457
- return nil , fmt .Errorf ("no on-demand quorums specified in legacy PaymentGlobalParams received from disperser" )
458
- }
459
- reservationQuorums := legacyReply .Reservation .QuorumNumbers
460
- // There may be overlapping quorums but it doesn't matter since we will apply the same global params to all of them.
461
- allQuorums := append (reservationQuorums , onDemandQuorums ... )
462
-
463
- for _ , quorumID := range allQuorums {
464
- paymentVaultParams .QuorumPaymentConfigs [quorumID ] = & disperser_rpc.PaymentQuorumConfig {
465
- ReservationSymbolsPerSecond : 0 , // Not available in legacy format
466
- OnDemandSymbolsPerSecond : legacyReply .PaymentGlobalParams .GlobalSymbolsPerSecond ,
467
- OnDemandPricePerSymbol : legacyReply .PaymentGlobalParams .PricePerSymbol ,
468
- }
469
-
470
- paymentVaultParams .QuorumProtocolConfigs [quorumID ] = & disperser_rpc.PaymentQuorumProtocolConfig {
471
- MinNumSymbols : legacyReply .PaymentGlobalParams .MinNumSymbols ,
472
- // ReservationAdvanceWindow is not used offchain at the moment so it's okay to set to any value.
473
- ReservationAdvanceWindow : 0 ,
474
- ReservationRateLimitWindow : legacyReply .PaymentGlobalParams .ReservationWindow ,
475
- OnDemandRateLimitWindow : 0 , // Not available in legacy format
476
- }
477
- }
478
-
479
- for _ , quorumID := range onDemandQuorums {
480
- paymentVaultParams .QuorumProtocolConfigs [quorumID ].OnDemandEnabled = true
481
- }
482
- }
483
-
484
- // If no reservation is available, return early with only payment vault params and cumulative payment info.
485
- if legacyReply .Reservation == nil {
486
- return & disperser_rpc.GetPaymentStateForAllQuorumsReply {
487
- PaymentVaultParams : paymentVaultParams ,
488
- CumulativePayment : legacyReply .CumulativePayment ,
489
- OnchainCumulativePayment : legacyReply .OnchainCumulativePayment ,
490
- }, nil
491
- }
492
-
493
- // Otherwise there is a reservation available, so we need to convert it to the per-quorum format.
494
-
495
- // We first make sure that the disperser returned valid data.
496
- if len (legacyReply .PeriodRecords ) == 0 {
497
- return nil , fmt .Errorf ("legacy payment state received from disperser does not contain period records" )
498
- }
499
- if len (legacyReply .Reservation .QuorumNumbers ) == 0 {
500
- return nil , fmt .Errorf ("legacy payment state received from disperser does not contain reservation quorums" )
501
- }
502
-
503
- reservations := make (map [uint32 ]* disperser_rpc.QuorumReservation )
504
- periodRecords := make (map [uint32 ]* disperser_rpc.PeriodRecords )
505
-
506
- // Apply the reservation to all reservationQuorums mentioned in the reservation
507
- for _ , quorumID := range legacyReply .Reservation .QuorumNumbers {
508
- reservations [quorumID ] = & disperser_rpc.QuorumReservation {
509
- SymbolsPerSecond : legacyReply .Reservation .SymbolsPerSecond ,
510
- StartTimestamp : legacyReply .Reservation .StartTimestamp ,
511
- EndTimestamp : legacyReply .Reservation .EndTimestamp ,
512
- }
513
- periodRecords [quorumID ] = & disperser_rpc.PeriodRecords {
514
- Records : legacyReply .PeriodRecords ,
515
- }
516
- }
517
-
518
- return & disperser_rpc.GetPaymentStateForAllQuorumsReply {
519
- PaymentVaultParams : paymentVaultParams ,
520
- PeriodRecords : periodRecords ,
521
- Reservations : reservations ,
522
- CumulativePayment : legacyReply .CumulativePayment ,
523
- OnchainCumulativePayment : legacyReply .OnchainCumulativePayment ,
524
- }, nil
393
+ return c .client .GetPaymentStateForAllQuorums (ctx , request )
525
394
}
526
395
527
396
// GetBlobCommitment is a utility method that calculates commitment for a blob payload.
0 commit comments