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

soft delete nonce in s_consumers so that request IDs do not repeat #12405

Merged
merged 10 commits into from
Mar 14, 2024

Conversation

jinhoonbang
Copy link
Contributor

soft delete nonce in s_consumers so that request IDs do not repeat
unit tests need to be fixed and gethwrappers need to be regenerated

@jinhoonbang jinhoonbang requested review from a team as code owners March 12, 2024 23:54
@jinhoonbang jinhoonbang requested review from kidambisrinivas, leeyikjiun, vreff and ibrajer and removed request for a team March 12, 2024 23:54
Copy link
Contributor

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

leeyikjiun
leeyikjiun previously approved these changes Mar 13, 2024
ibrajer
ibrajer previously approved these changes Mar 13, 2024
mapping(uint256 => uint64) storage nonces = s_consumers[consumer];
if (nonces[subId] != 0) {
ConsumerConfig storage consumerConfig = s_consumers[consumer][subId];
if (consumerConfig.active) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we move this check before if (consumers.length == MAX_CONSUMERS) {, since attempting to add same consumer again should be an idempotent operation instead of reverting

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that makes sense technically. Can change it

// Idempotence - do nothing if already added.
// Ensures uniqueness in s_subscriptions[subId].consumers.
return;
}
// Initialize the nonce to 1, indicating the consumer is allocated.
nonces[subId] = 1;
// consumerConfig.nonce is 0 if the consumer had never sent a request to this subscription
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we consider starting nonce at 1, to maintain parity with previous implementation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think 0 makes more sense because previously 0 indicated inactive consumer but now, we have a active boolean flag.

Also, we increment nonce before generating the first requestID here. So if we start the nonce at 1 here, first requestID will be generated with nonce 2

Copy link
Contributor

@vreff vreff Mar 13, 2024

Choose a reason for hiding this comment

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

Also, as long as the boolean is true to start the next SSTORE will not be cold.

@@ -49,7 +49,7 @@ var rcTemplate = `{
callbackGasLimit: %d,
numWords: %d,
sender: %s,
nativePayment: %t
nativePayment: %s
Copy link
Contributor

Choose a reason for hiding this comment

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

why has this changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure why we had %t here initially. makes more sense to print hex-encoded string of the extraArgs instead of the type. this should be renamed to extraArgs actually.

Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't lowercase %t boolean in Go? Or am I mixing that up?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh right. yeah it was trying to display bytes as bool

vreff
vreff previously approved these changes Mar 13, 2024
@cl-sonarqube-production
Copy link

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

@jinhoonbang jinhoonbang added this pull request to the merge queue Mar 14, 2024
@vreff
Copy link
Contributor

vreff commented Mar 14, 2024

nit: maybe if it's in merge queue we can drop the WIP from the PR title?

@jinhoonbang jinhoonbang changed the title soft delete nonce in s_consumers so that request IDs do not repeat. WIP soft delete nonce in s_consumers so that request IDs do not repeat Mar 14, 2024
Merged via the queue into develop with commit 2bd210b Mar 14, 2024
109 checks passed
@jinhoonbang jinhoonbang deleted the vrfv2plus-unique-request-id branch March 14, 2024 15:34
kidambisrinivas pushed a commit that referenced this pull request Mar 18, 2024
…IP (#12405)

* 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
kidambisrinivas pushed a commit that referenced this pull request Mar 18, 2024
…IP (#12405)

* 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
kidambisrinivas pushed a commit that referenced this pull request Mar 18, 2024
…IP (#12405)

* 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
kidambisrinivas pushed a commit that referenced this pull request Mar 18, 2024
…IP (#12405)

* 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
kidambisrinivas pushed a commit that referenced this pull request Mar 27, 2024
…IP (#12405)

* 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
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.

5 participants