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

Update deprecated vstorage queries #55

Merged
merged 3 commits into from
Nov 3, 2023
Merged

Update deprecated vstorage queries #55

merged 3 commits into from
Nov 3, 2023

Conversation

samsiegart
Copy link
Contributor

@samsiegart samsiegart commented Nov 2, 2023

refs: #53

For the chain storage watcher, no longer use the deprecated RPC method to query vstorage. Instead, use the JSON API. There's a lot of ways to handle the query logic, but for now this just keeps the same internal logic and makes a shotgun of requests instead of a batch query. Bandwidth consumption seems roughly similar after increasing the polling period a bit, and the increased request count should have minimal impact with connection coalescing.

Also, updates the wallet connection component because it was relying on the watcher having an RPC node.

Updated unit tests and validated with Agoric/dapp-inter#209 locally using yarn link

Copy link
Member

@turadg turadg left a comment

Choose a reason for hiding this comment

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

Some code quality suggestions, none blocking

Comment on lines 27 to 29
.then(responseDatas => {
return Promise.all(responseDatas.map(res => res.json()));
})
Copy link
Member

Choose a reason for hiding this comment

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

nit, optional

Suggested change
.then(responseDatas => {
return Promise.all(responseDatas.map(res => res.json()));
})
.then(responseDatas => Promise.all(responseDatas.map(res => res.json())

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

return Promise.all(responseDatas.map(res => res.json()));
})
.then(responses =>
responses.map((res, index) => {
Copy link
Member

Choose a reason for hiding this comment

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

this handler is quite complex at this depth.

consider factoring it out into a named function and adding a unit test for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The logic could be pulled out into some other functions, but the code-paths are well tested, and I prefer having the unit tests be more encompassing of the entire logic with chainStorageWatcher.ts, I'll just leave as-is for now

@@ -12,8 +12,8 @@ type Subscriber<T> = {

const defaults = {
newPathQueryDelayMs: 20,
refreshLowerBoundMs: 2000,
refreshUpperBoundMs: 4000,
refreshLowerBoundMs: 4000,
Copy link
Member

Choose a reason for hiding this comment

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

is Product good with this doubling of minimal refresh time?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question, I think since these are just defaults and configurable, erring on the side of less spam would be safer, but we can always pass in smaller values for certain queries in certain dapps

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.

2 participants