Skip to content

Commit 689f53d

Browse files
committed
fix(disp_client): convertLegacyPaymentStateToNew quorums setting logic
1 parent e00a2ba commit 689f53d

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

api/clients/v2/disperser_client.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -453,13 +453,15 @@ func convertLegacyPaymentStateToNew(legacyReply *disperser_rpc.GetPaymentStateRe
453453
OnDemandQuorumNumbers: legacyReply.PaymentGlobalParams.OnDemandQuorumNumbers,
454454
}
455455

456-
// Apply the global params to all quorums mentioned in on-demand quorum numbers
457-
quorums := legacyReply.PaymentGlobalParams.OnDemandQuorumNumbers
458-
if len(quorums) == 0 {
456+
// Apply the global params to all quorums, both on-demand and reservation.
457+
onDemandQuorums := legacyReply.PaymentGlobalParams.OnDemandQuorumNumbers
458+
if len(onDemandQuorums) == 0 {
459459
return nil, fmt.Errorf("no on-demand quorums specified in legacy PaymentGlobalParams received from disperser")
460460
}
461+
reservationQuorums := legacyReply.Reservation.QuorumNumbers
462+
allQuorums := append(reservationQuorums, onDemandQuorums...)
461463

462-
for _, quorumID := range quorums {
464+
for _, quorumID := range allQuorums {
463465
paymentVaultParams.QuorumPaymentConfigs[quorumID] = &disperser_rpc.PaymentQuorumConfig{
464466
ReservationSymbolsPerSecond: 0, // Not available in legacy format
465467
OnDemandSymbolsPerSecond: legacyReply.PaymentGlobalParams.GlobalSymbolsPerSecond,
@@ -472,10 +474,13 @@ func convertLegacyPaymentStateToNew(legacyReply *disperser_rpc.GetPaymentStateRe
472474
// It was added for consistency with the onchain data structure but get removed in the future.
473475
ReservationAdvanceWindow: 0,
474476
ReservationRateLimitWindow: legacyReply.PaymentGlobalParams.ReservationWindow,
475-
OnDemandRateLimitWindow: 0, // Not available in legacy format
476-
OnDemandEnabled: true, // we are iterating over on-demand quorums, so this is always true
477+
OnDemandRateLimitWindow: 0, // Not available in legacy format
477478
}
478479
}
480+
481+
for _, quorumID := range onDemandQuorums {
482+
paymentVaultParams.QuorumProtocolConfigs[quorumID].OnDemandEnabled = true
483+
}
479484
}
480485

481486
// If no reservation is available, return early with only payment vault params and cumulative payment info.

0 commit comments

Comments
 (0)