Skip to content
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

pending request counter in vrf v2.5 coordinator #12425

Merged
merged 15 commits into from
Mar 18, 2024

Conversation

jinhoonbang
Copy link
Contributor

Implement pending request counter in vrf v2.5 coordinator

Copy link
Contributor

I see that you haven't updated any README files. Would it make sense to do so?

@jinhoonbang jinhoonbang changed the base branch from develop to vrfv2plus-unique-request-id March 14, 2024 00:23
@jinhoonbang jinhoonbang requested review from kidambisrinivas, ibrajer, leeyikjiun and vreff and removed request for a team March 14, 2024 00:23
Copy link
Contributor

Go solidity wrappers are out-of-date, regenerate them via the make wrappers-all command

leeyikjiun
leeyikjiun previously approved these changes Mar 14, 2024
Comment on lines +632 to +633
if (s_consumers[consumers[i]][subId].pendingReqCount > 0) {
return true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you removed the code above, that removed the only place where we had to recompute the request ID based on the consumer nonce. Now, I'm thinking if we can use s_subscriptions[rc.subId].reqCount together with pendingReqCount as a part of the request ID generation (instead of consumer nonce), would that also ensure uniqueness? So, reqCount is incremented every time a fulfillment is made on a subscription level (at the same time when pendingReqCount decrements) and pendingReqCount is incremented every time a new request has been made (but reqCount stays the same). Somehow, they always complement each other in a way that could ensure a unique combination every time a request has been made. Of course, in case I didn't miss any edge cases or started with wrong assumptions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I discussed this with @leeyikjiun and seems like this approach won't introduce any additional "wins" compared to the current solution we have. I think we can dismiss it.

ibrajer
ibrajer previously approved these changes Mar 14, 2024
if (s_requestCommitments[reqId] != 0) {
return true;
}
if (s_consumers[consumers[i]][subId].pendingReqCount > 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently both removeConsumer and cancelSubscription call pendingRequestExists, which checks if a subId has pendingRequests or not.

This means we would not be able to delete a consumer of a subId if another consumer of the same subId has pendingRequests. Is this a limiting factor?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pendingRequestsExists method tracks pending requests on an entire subscriptionID when we check to removeConsumer.
Shall we add a new method that just checks s_consumers[address][subId].pendingReqCounter when removeConsumer is called

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed this offline. We will leave as is because customers only removeConsumer when they want to cancel subscriptions anyways.

Base automatically changed from vrfv2plus-unique-request-id to develop March 14, 2024 15:34
@jinhoonbang jinhoonbang dismissed stale reviews from ibrajer and leeyikjiun March 14, 2024 15:34

The base branch was changed.

leeyikjiun
leeyikjiun previously approved these changes Mar 15, 2024
@cl-sonarqube-production
Copy link

@jinhoonbang jinhoonbang requested a review from leeyikjiun March 15, 2024 15:44
assertTrue(s_testCoordinator.pendingRequestExists(subId));
}

function testRequestRandomWords_MultipleConsumers_PendingRequestExists() public {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a test to check what happens when you have pending requests and you try to remove the consumer or cancel an entire subscription? Do we need it?

Copy link
Contributor Author

@jinhoonbang jinhoonbang Mar 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't look like we have those tests. I can add those in follow up PR

Copy link
Contributor

@ibrajer ibrajer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM left one comment but don't consider it blocking

@jinhoonbang jinhoonbang added this pull request to the merge queue Mar 15, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 15, 2024
@jinhoonbang jinhoonbang added this pull request to the merge queue Mar 15, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 15, 2024
@leeyikjiun leeyikjiun added this pull request to the merge queue Mar 18, 2024
Merged via the queue into develop with commit e3f4a6c Mar 18, 2024
110 checks passed
@leeyikjiun leeyikjiun deleted the vrfv2plus-pending-requests-counter branch March 18, 2024 06:20
kidambisrinivas pushed a commit that referenced this pull request Mar 18, 2024
* soft delete nonce in s_consumers so that request IDs do not repeat. WIP

* forge unit tests passing except for exact billing amount

* add forge tests and optimize gas

* regenerate wrappers

* remove comment

* address comments

* fix test

* add changeset

* implement pending request counter
pending request counter in vrf v2.5 coordinator

* run prettier and regenerate wrappers

* add changeset

* bump gas required for remove consumer
kidambisrinivas pushed a commit that referenced this pull request Mar 18, 2024
* soft delete nonce in s_consumers so that request IDs do not repeat. WIP

* forge unit tests passing except for exact billing amount

* add forge tests and optimize gas

* regenerate wrappers

* remove comment

* address comments

* fix test

* add changeset

* implement pending request counter
pending request counter in vrf v2.5 coordinator

* run prettier and regenerate wrappers

* add changeset

* bump gas required for remove consumer
kidambisrinivas pushed a commit that referenced this pull request Mar 18, 2024
* soft delete nonce in s_consumers so that request IDs do not repeat. WIP

* forge unit tests passing except for exact billing amount

* add forge tests and optimize gas

* regenerate wrappers

* remove comment

* address comments

* fix test

* add changeset

* implement pending request counter
pending request counter in vrf v2.5 coordinator

* run prettier and regenerate wrappers

* add changeset

* bump gas required for remove consumer
kidambisrinivas pushed a commit that referenced this pull request Mar 18, 2024
* soft delete nonce in s_consumers so that request IDs do not repeat. WIP

* forge unit tests passing except for exact billing amount

* add forge tests and optimize gas

* regenerate wrappers

* remove comment

* address comments

* fix test

* add changeset

* implement pending request counter
pending request counter in vrf v2.5 coordinator

* run prettier and regenerate wrappers

* add changeset

* bump gas required for remove consumer
kidambisrinivas pushed a commit that referenced this pull request Mar 27, 2024
* soft delete nonce in s_consumers so that request IDs do not repeat. WIP

* forge unit tests passing except for exact billing amount

* add forge tests and optimize gas

* regenerate wrappers

* remove comment

* address comments

* fix test

* add changeset

* implement pending request counter
pending request counter in vrf v2.5 coordinator

* run prettier and regenerate wrappers

* add changeset

* bump gas required for remove consumer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants