Skip to content

Commit

Permalink
refactor: payment vault param new names
Browse files Browse the repository at this point in the history
  • Loading branch information
hopeyen committed Dec 12, 2024
1 parent 7b12ebf commit f6319f3
Show file tree
Hide file tree
Showing 9 changed files with 322 additions and 291 deletions.
39 changes: 35 additions & 4 deletions contracts/bindings/EigenDAServiceManager/binding.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/bindings/MockRollup/binding.go

Large diffs are not rendered by default.

524 changes: 262 additions & 262 deletions contracts/bindings/PaymentVault/binding.go

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions core/eth/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ func (t *Reader) GetOnDemandPayments(ctx context.Context, accountIDs []gethcommo
return nil, errors.New("payment vault not deployed")
}
paymentsMap := make(map[gethcommon.Address]*core.OnDemandPayment)
payments, err := t.bindings.PaymentVault.GetOnDemandAmounts(&bind.CallOpts{
payments, err := t.bindings.PaymentVault.GetOnDemandTotalDeposits(&bind.CallOpts{
Context: ctx,
}, accountIDs)
if err != nil {
Expand All @@ -759,7 +759,7 @@ func (t *Reader) GetOnDemandPaymentByAccount(ctx context.Context, accountID geth
if t.bindings.PaymentVault == nil {
return nil, errors.New("payment vault not deployed")
}
onDemandPayment, err := t.bindings.PaymentVault.GetOnDemandAmount(&bind.CallOpts{
onDemandPayment, err := t.bindings.PaymentVault.GetOnDemandTotalDeposit(&bind.CallOpts{
Context: ctx,
}, accountID)
if err != nil {
Expand All @@ -777,26 +777,26 @@ func (t *Reader) GetGlobalSymbolsPerSecond(ctx context.Context) (uint64, error)
if t.bindings.PaymentVault == nil {
return 0, errors.New("payment vault not deployed")
}
globalSymbolsPerSecond, err := t.bindings.PaymentVault.GlobalRateBinInterval(&bind.CallOpts{
globalSymbolsPerSecond, err := t.bindings.PaymentVault.GlobalRatePeriodInterval(&bind.CallOpts{
Context: ctx,
})
if err != nil {
return 0, err
}
return globalSymbolsPerSecond.Uint64(), nil
return globalSymbolsPerSecond, nil
}

func (t *Reader) GetGlobalRateBinInterval(ctx context.Context) (uint32, error) {
func (t *Reader) GetGlobalRatePeriodInterval(ctx context.Context) (uint32, error) {
if t.bindings.PaymentVault == nil {
return 0, errors.New("payment vault not deployed")
}
globalRateBinInterval, err := t.bindings.PaymentVault.GlobalRateBinInterval(&bind.CallOpts{
globalRateBinInterval, err := t.bindings.PaymentVault.GlobalRatePeriodInterval(&bind.CallOpts{
Context: ctx,
})
if err != nil {
return 0, err
}
return uint32(globalRateBinInterval.Uint64()), nil
return uint32(globalRateBinInterval), nil
}

func (t *Reader) GetMinNumSymbols(ctx context.Context) (uint32, error) {
Expand All @@ -809,7 +809,7 @@ func (t *Reader) GetMinNumSymbols(ctx context.Context) (uint32, error) {
if err != nil {
return 0, err
}
return uint32(minNumSymbols.Uint64()), nil
return uint32(minNumSymbols), nil
}

func (t *Reader) GetPricePerSymbol(ctx context.Context) (uint32, error) {
Expand All @@ -822,20 +822,20 @@ func (t *Reader) GetPricePerSymbol(ctx context.Context) (uint32, error) {
if err != nil {
return 0, err
}
return uint32(pricePerSymbol.Uint64()), nil
return uint32(pricePerSymbol), nil
}

func (t *Reader) GetReservationWindow(ctx context.Context) (uint32, error) {
if t.bindings.PaymentVault == nil {
return 0, errors.New("payment vault not deployed")
}
reservationWindow, err := t.bindings.PaymentVault.ReservationBinInterval(&bind.CallOpts{
reservationWindow, err := t.bindings.PaymentVault.ReservationPeriodInterval(&bind.CallOpts{
Context: ctx,
})
if err != nil {
return 0, err
}
return uint32(reservationWindow.Uint64()), nil
return uint32(reservationWindow), nil
}

func (t *Reader) GetOperatorSocket(ctx context.Context, operatorId core.OperatorID) (string, error) {
Expand Down
2 changes: 1 addition & 1 deletion core/meterer/meterer.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ func (m *Meterer) SymbolsCharged(numSymbols uint) uint32 {

// IncrementBinUsage increments the bin usage atomically and checks for overflow
func (m *Meterer) IncrementGlobalBinUsage(ctx context.Context, symbolsCharged uint64) error {
globalPeriod := GetReservationPeriod(uint64(time.Now().Unix()), m.ChainPaymentState.GetGlobalRateBinInterval())
globalPeriod := GetReservationPeriod(uint64(time.Now().Unix()), m.ChainPaymentState.GetGlobalRatePeriodInterval())

newUsage, err := m.OffchainStore.UpdateGlobalBin(ctx, globalPeriod, symbolsCharged)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion core/meterer/meterer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func TestMetererReservations(t *testing.T) {
ctx := context.Background()
paymentChainState.On("GetReservationWindow", testifymock.Anything).Return(uint32(1), nil)
paymentChainState.On("GetGlobalSymbolsPerSecond", testifymock.Anything).Return(uint64(1009), nil)
paymentChainState.On("GetGlobalRateBinInterval", testifymock.Anything).Return(uint32(1), nil)
paymentChainState.On("GetGlobalRatePeriodInterval", testifymock.Anything).Return(uint32(1), nil)
paymentChainState.On("GetMinNumSymbols", testifymock.Anything).Return(uint32(3), nil)

reservationPeriod := meterer.GetReservationPeriod(uint64(time.Now().Unix()), mt.ChainPaymentState.GetReservationWindow())
Expand Down
18 changes: 9 additions & 9 deletions core/meterer/onchain_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type OnchainPayment interface {
GetOnDemandPaymentByAccount(ctx context.Context, accountID gethcommon.Address) (*core.OnDemandPayment, error)
GetOnDemandQuorumNumbers(ctx context.Context) ([]uint8, error)
GetGlobalSymbolsPerSecond() uint64
GetGlobalRateBinInterval() uint32
GetGlobalRatePeriodInterval() uint32
GetMinNumSymbols() uint32
GetPricePerSymbol() uint32
GetReservationWindow() uint32
Expand All @@ -40,12 +40,12 @@ type OnchainPaymentState struct {
}

type PaymentVaultParams struct {
GlobalSymbolsPerSecond uint64
GlobalRateBinInterval uint32
MinNumSymbols uint32
PricePerSymbol uint32
ReservationWindow uint32
OnDemandQuorumNumbers []uint8
GlobalSymbolsPerSecond uint64
GlobalRatePeriodInterval uint32
MinNumSymbols uint32
PricePerSymbol uint32
ReservationWindow uint32
OnDemandQuorumNumbers []uint8
}

func NewOnchainPaymentState(ctx context.Context, tx *eth.Reader) (*OnchainPaymentState, error) {
Expand Down Expand Up @@ -194,8 +194,8 @@ func (pcs *OnchainPaymentState) GetGlobalSymbolsPerSecond() uint64 {
return pcs.PaymentVaultParams.Load().GlobalSymbolsPerSecond
}

func (pcs *OnchainPaymentState) GetGlobalRateBinInterval() uint32 {
return pcs.PaymentVaultParams.Load().GlobalRateBinInterval
func (pcs *OnchainPaymentState) GetGlobalRatePeriodInterval() uint32 {
return pcs.PaymentVaultParams.Load().GlobalRatePeriodInterval
}

func (pcs *OnchainPaymentState) GetMinNumSymbols() uint32 {
Expand Down
2 changes: 1 addition & 1 deletion core/mock/payment_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (m *MockOnchainPaymentState) GetGlobalSymbolsPerSecond() uint64 {
return args.Get(0).(uint64)
}

func (m *MockOnchainPaymentState) GetGlobalRateBinInterval() uint32 {
func (m *MockOnchainPaymentState) GetGlobalRatePeriodInterval() uint32 {
args := m.Called()
return args.Get(0).(uint32)
}
Expand Down
2 changes: 1 addition & 1 deletion disperser/apiserver/server_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ func newTestServerV2(t *testing.T) *testComponents {
mockState.On("GetReservationWindow", tmock.Anything).Return(uint32(1), nil)
mockState.On("GetPricePerSymbol", tmock.Anything).Return(uint32(2), nil)
mockState.On("GetGlobalSymbolsPerSecond", tmock.Anything).Return(uint64(1009), nil)
mockState.On("GetGlobalRateBinInterval", tmock.Anything).Return(uint32(1), nil)
mockState.On("GetGlobalRatePeriodInterval", tmock.Anything).Return(uint32(1), nil)
mockState.On("GetMinNumSymbols", tmock.Anything).Return(uint32(3), nil)

now := uint64(time.Now().Unix())
Expand Down

0 comments on commit f6319f3

Please sign in to comment.