-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[v2] disperser server payments api #902
base: master
Are you sure you want to change the base?
Conversation
c0652fa
to
4cf7d2c
Compare
89af572
to
e306bc7
Compare
@@ -55,3 +56,36 @@ func (*authenticator) AuthenticateBlobRequest(header *core.BlobHeader) error { | |||
|
|||
return nil | |||
} | |||
|
|||
func (*authenticator) AuthenticatePaymentStateRequest(request *pb.GetPaymentStateRequest) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably belongs in apiserver/server_v2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't this function doing similar authentications?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you mean. Then let's take the signature bytes as the input vs. the request protobuf in this method, and use this as a library from the api server?
} | ||
|
||
type BinRecord struct { | ||
Index uint32 | ||
Usage uint64 | ||
} | ||
|
||
func NewAccountant(reservation *core.ActiveReservation, onDemand *core.OnDemandPayment, reservationWindow uint32, pricePerSymbol uint32, minNumSymbols uint32, paymentSigner core.PaymentSigner, numBins uint32) *accountant { | ||
func NewAccountant(accountID string, reservation *core.ActiveReservation, onDemand *core.OnDemandPayment, reservationWindow uint32, pricePerSymbol uint32, minNumSymbols uint32, numBins uint32) *accountant { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are reservationWindow
, pricePerSymbol
, minNumSymbols
, numBins
different for each account?
Aren't these globally available somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reservationWindow
, pricePerSymbol
, minNumSymbols
should be set through the contract. I linked a PR in the previous comment about this. numBins
can be set by the accountants preferences, doesn't really matter but restricted by a minimum of 3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in which case does it make sense to account for more than 3 bins?
I'm wondering if we should fix/hardcode this number everywhere vs. making it a variable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a nice functionality considered for disperser clients who want to track more history in-memory. The data isn't really used and not critical
1ae3e3c
to
8ea4f03
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, last few comments
@@ -55,3 +56,36 @@ func (*authenticator) AuthenticateBlobRequest(header *core.BlobHeader) error { | |||
|
|||
return nil | |||
} | |||
|
|||
func (*authenticator) AuthenticatePaymentStateRequest(request *pb.GetPaymentStateRequest) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you mean. Then let's take the signature bytes as the input vs. the request protobuf in this method, and use this as a library from the api server?
@@ -237,3 +237,79 @@ func (s *OffchainStore) GetRelevantOnDemandRecords(ctx context.Context, accountI | |||
|
|||
return prevPayment, nextPayment, nextDataLength, nil | |||
} | |||
|
|||
func (s *OffchainStore) GetBinUsages(ctx context.Context, accountID string, binIndex uint32) (uint64, uint64, uint64, error) { | |||
// Fetch the 3 bins start from the current bin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it depend on MinNumBins
? Looks like it will always return 3 bin records no matter what MinNumBins
is.
} | ||
|
||
type BinRecord struct { | ||
Index uint32 | ||
Usage uint64 | ||
} | ||
|
||
func NewAccountant(reservation *core.ActiveReservation, onDemand *core.OnDemandPayment, reservationWindow uint32, pricePerSymbol uint32, minNumSymbols uint32, paymentSigner core.PaymentSigner, numBins uint32) *accountant { | ||
func NewAccountant(accountID string, reservation *core.ActiveReservation, onDemand *core.OnDemandPayment, reservationWindow uint32, pricePerSymbol uint32, minNumSymbols uint32, numBins uint32) *accountant { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in which case does it make sense to account for more than 3 bins?
I'm wondering if we should fix/hardcode this number everywhere vs. making it a variable
Why are these changes needed?
Adding payments to disperser v2 api and server; disperser v2 client is not available yet
Checks