Skip to content

Commit a38e617

Browse files
f - a bunch of updates
1 parent d9c07c5 commit a38e617

File tree

16 files changed

+518
-445
lines changed

16 files changed

+518
-445
lines changed

IndexingPaymentsTodo.md

+21-13
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
11
# Still pending
22

33
* Arbitration Charter: Update to support disputing IndexingFee.
4-
* Economics
5-
* If service wants to collect more than collector allows. Collector limits but doesn't tell the service?
6-
* Since an allocation is required for collecting, do we want to expect that the allocation is not stale? Do we want to add code to collect rewards as part of the collection of fees? Make sure allocation is more than one epoch old if we attempt this.
7-
* What should happen if the escrow doesn't have enough funds?
8-
* Don't pay for entities on initial collection? Where did we land in terms of payment terms?
9-
* Should we set a different param for initial collection time max? Some subgraphs take a lot to catch up.
10-
* How do we solve for the case where an indexer has reached their max expected payout for the initial sync but haven't reached the current epoch (thus their POI is incorrect)?
11-
* Double check cancelation policy. Who can cancel when? Right now is either party at any time.
4+
* Double check cancelation policy. Who can cancel when? Right now is either party at any time. If gateway cancels allow collection till that point.
125
* Expose a function that indexers can use to calculate the tokens to be collected and other collection params?
13-
* Support a way for gateway to shop an agreement around? Deadline + dedup key? So only one agreement with the dedupe key can be accepted?
14-
* If an indexer closes an allocation, what should happen to the accepeted agreement?
156
* test_SubgraphService_CollectIndexingFee_Integration fails with PaymentsEscrowInconsistentCollection
16-
* Switch `duration` for `endsAt`?
7+
* Switch timestamps to uint64.
178
* Check that UUID-v4 fits in `bytes16`
18-
* Test `upgrade` paths
19-
* Test lock stake
9+
* Check code coverage
10+
* Check contract size
11+
* Add upgrade path to v2 collector terms
12+
* It's more like a collect + cancel since the indexer is expected to stop work then and there. When posting a POI that's < N-1 epoch. Answer: Emit signal that the collection is meant to be final.
13+
* Don't love cancel agreement on stop service / close stale allocation.
14+
* Place all agreement terms into one struct
2015

2116
# Done
2217

18+
* DONE: ~~If an indexer closes an allocation, what should happen to the accepeted agreement? Answer: Look into canceling agreement as part of stop service.~~
19+
* DONE: ~~Switch `duration` for `endsAt`? Answer: Do it.~~
20+
* DONE: ~~Support a way for gateway to shop an agreement around? Deadline + dedup key? So only one agreement with the dedupe key can be accepted? Answer: No. Agreements will be "signaled" as approved or rejected on the API call that sends the agreement. We'll trust (and verify) that that's the case.~~
21+
* DONE: ~~Test `upgrade` paths~~
22+
* DONE: ~~Fix upgrade.t.sol, lots of comments~~
23+
* DONE: ~~How do we solve for the case where an indexer has reached their max expected payout for the initial sync but haven't reached the current epoch (thus their POI is incorrect)? Answer: Signal in the event that the max amount was collected, so that fisherman understand the case.~~
24+
* DONE: ~~Debate epoch check protocol team. Maybe don't revert but store it in event. Pablo suggest block number instead of epoch.~~
25+
* DONE: ~~Should we set a different param for initial collection time max? Some subgraphs take a lot to catch up. Answer: Do nothing. Make sure that zero POIs allow to eventually sync~~
26+
* DONE: ~~Since an allocation is required for collecting, do we want to expect that the allocation is not stale? Do we want to add code to collect rewards as part of the collection of fees? Make sure allocation is more than one epoch old if we attempt this. Answer: Ignore stale allocation~~
27+
* DONE: ~~If service wants to collect more than collector allows. Collector limits but doesn't tell the service? Currently reverts. Answer: Allow for max allowed~~
28+
* DONE: ~~What should happen if the escrow doesn't have enough funds? Answer: Reverts~~
29+
* DONE: ~~Don't pay for entities on initial collection? Where did we land in terms of payment terms? Answer: pay initial~~
30+
* DONE: ~~Test lock stake~~
2331
* DONE: ~~Reduce the number of errors declared and returned~~
2432
* DONE: ~~Support `DisputeManager`~~
2533
* DONE: ~~Check upgrade conditions. Support indexing agreement upgradability, so that there is a mechanism to adjust the rates without having to cancel and start over.~~

packages/horizon/contracts/interfaces/IRecurringCollector.sol

+30-19
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector {
2727
bytes16 agreementId;
2828
// The deadline for accepting the RCA
2929
uint256 deadline;
30-
// The duration of the RCA in seconds
31-
uint256 duration;
30+
// The timestamp when the agreement ends
31+
uint256 endsAt;
3232
// The address of the payer the RCA was issued by
3333
address payer;
3434
// The address of the data service the RCA was issued to
@@ -62,8 +62,8 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector {
6262
bytes16 agreementId;
6363
// The deadline for upgrading
6464
uint256 deadline;
65-
// The duration of the agreement in seconds
66-
uint256 duration;
65+
// The timestamp when the agreement ends
66+
uint256 endsAt;
6767
// The maximum amount of tokens that can be collected in the first collection
6868
// on top of the amount allowed for subsequent collections
6969
uint256 maxInitialTokens;
@@ -90,8 +90,8 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector {
9090
uint256 acceptedAt;
9191
// The timestamp when the agreement was last collected at
9292
uint256 lastCollectionAt;
93-
// The duration of the agreement in seconds
94-
uint256 duration;
93+
// The timestamp when the agreement ends
94+
uint256 endsAt;
9595
// The maximum amount of tokens that can be collected in the first collection
9696
// on top of the amount allowed for subsequent collections
9797
uint256 maxInitialTokens;
@@ -120,14 +120,21 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector {
120120
* @param dataService The address of the data service
121121
* @param payer The address of the payer
122122
* @param serviceProvider The address of the service provider
123+
* @param agreementId The agreement ID
124+
* @param acceptedAt The timestamp when the agreement was accepted
125+
* @param endsAt The timestamp when the agreement ends
126+
* @param maxInitialTokens The maximum amount of tokens that can be collected in the first collection
127+
* @param maxOngoingTokensPerSecond The maximum amount of tokens that can be collected per second
128+
* @param minSecondsPerCollection The minimum amount of seconds that must pass between collections
129+
* @param maxSecondsPerCollection The maximum amount of seconds that can pass between collections
123130
*/
124131
event AgreementAccepted(
125132
address indexed dataService,
126133
address indexed payer,
127134
address indexed serviceProvider,
128135
bytes16 agreementId,
129136
uint256 acceptedAt,
130-
uint256 duration,
137+
uint256 endsAt,
131138
uint256 maxInitialTokens,
132139
uint256 maxOngoingTokensPerSecond,
133140
uint32 minSecondsPerCollection,
@@ -153,14 +160,21 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector {
153160
* @param dataService The address of the data service
154161
* @param payer The address of the payer
155162
* @param serviceProvider The address of the service provider
163+
* @param agreementId The agreement ID
164+
* @param upgradedAt The timestamp when the agreement was upgraded
165+
* @param endsAt The timestamp when the agreement ends
166+
* @param maxInitialTokens The maximum amount of tokens that can be collected in the first collection
167+
* @param maxOngoingTokensPerSecond The maximum amount of tokens that can be collected per second
168+
* @param minSecondsPerCollection The minimum amount of seconds that must pass between collections
169+
* @param maxSecondsPerCollection The maximum amount of seconds that can pass between collections
156170
*/
157171
event AgreementUpgraded(
158172
address indexed dataService,
159173
address indexed payer,
160174
address indexed serviceProvider,
161175
bytes16 agreementId,
162176
uint256 upgradedAt,
163-
uint256 duration,
177+
uint256 endsAt,
164178
uint256 maxInitialTokens,
165179
uint256 maxOngoingTokensPerSecond,
166180
uint32 minSecondsPerCollection,
@@ -183,6 +197,11 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector {
183197
uint256 dataServiceCut
184198
);
185199

200+
/**
201+
* Thrown when accepting an agreement with a zero ID
202+
*/
203+
error RecurringCollectorAgreementIdZero();
204+
186205
/**
187206
* Thrown when interacting with an agreement not owned by the message sender
188207
* @param agreementId The agreement ID
@@ -241,14 +260,14 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector {
241260
/**
242261
* Thrown when accepting or upgrading an agreement with invalid parameters
243262
*/
244-
error RecurringCollectorAgreementInvalidParameters();
263+
error RecurringCollectorAgreementInvalidParameters(string message);
245264

246265
/**
247266
* Thrown when calling collect() on an elapsed agreement
248267
* @param agreementId The agreement ID
249-
* @param agreementEnd The agreement end timestamp
268+
* @param endsAt The agreement end timestamp
250269
*/
251-
error RecurringCollectorAgreementElapsed(bytes16 agreementId, uint256 agreementEnd);
270+
error RecurringCollectorAgreementElapsed(bytes16 agreementId, uint256 endsAt);
252271

253272
/**
254273
* Thrown when calling collect() too soon
@@ -266,14 +285,6 @@ interface IRecurringCollector is IAuthorizable, IPaymentsCollector {
266285
*/
267286
error RecurringCollectorCollectionTooLate(bytes16 agreementId, uint256 secondsSinceLast, uint256 maxSeconds);
268287

269-
/**
270-
* Thrown when calling collect() too late
271-
* @param agreementId The agreement ID
272-
* @param tokens The amount of tokens to collect
273-
* @param maxTokens The maximum amount of tokens allowed to collect
274-
*/
275-
error RecurringCollectorCollectAmountTooHigh(bytes16 agreementId, uint256 tokens, uint256 maxTokens);
276-
277288
/**
278289
* @dev Accept an indexing agreement.
279290
* @param signedRCA The signed Recurring Collection Agreement which is to be accepted.

0 commit comments

Comments
 (0)