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

synchronous makeVstorageKit #10670

Merged
merged 10 commits into from
Dec 11, 2024
Merged

synchronous makeVstorageKit #10670

merged 10 commits into from
Dec 11, 2024

Conversation

turadg
Copy link
Member

@turadg turadg commented Dec 11, 2024

incidental

refs: agoric-labs/vstorage-viewer#2

Description

In the course of working on agoric-labs/vstorage-viewer#3 it was hard to work with an async makeVstorageKit. It was async because construction of the kit required fetching a bunch of data from vstorage to populate agoricNames.

That concern is a higher level than vstorage so this pulls it out. That allows makeVstorageKit to be synchronous.

I added a test of makeAgoricNames both before and after.

Eventually I think something should make it easy to make an AgoricNamesKit that wraps VstorageKit the way VstorageKit wraps Vstorage. makeWalletUtils does that but needs more work. At least renaming to SmartWallet but it would help to have a rethink of the layering and vstorage decoding in client-utils.

Security Considerations

none

Scaling Considerations

none

Documentation Considerations

not documented but this will make it less complex

Testing Considerations

new test

While refactoring, tsc really let me down by not detecting destuctured properies that were no longer on the source object. I suppose our settings aren't strict enough. I enabled noImplicitAny to detect those (by then filtering for makeVstorageKit)

Upgrade Considerations

n/a

@turadg turadg requested a review from a team as a code owner December 11, 2024 02:09
@turadg turadg added the force:integration Force integration tests to run on PR label Dec 11, 2024
Copy link

cloudflare-workers-and-pages bot commented Dec 11, 2024

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: 501be3a
Status: ✅  Deploy successful!
Preview URL: https://89f8ac69.agoric-sdk.pages.dev
Branch Preview URL: https://ta-sync-vstoragekit.agoric-sdk.pages.dev

View logs

Copy link
Contributor

@samsiegart samsiegart left a comment

Choose a reason for hiding this comment

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

The CI failure looks like it might be related to the changes, will TAL after that's passing

@turadg turadg force-pushed the ta/sync-VstorageKit branch from 614397f to bb7daca Compare December 11, 2024 17:32
@turadg turadg force-pushed the ta/sync-VstorageKit branch from bb7daca to a9b385a Compare December 11, 2024 17:46
@turadg turadg requested a review from samsiegart December 11, 2024 18:36
Copy link
Contributor

@samsiegart samsiegart left a comment

Choose a reason for hiding this comment

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

LGTM mostly but please see my non-blocking request to add a comment

/**
* Stop-gap using execFileSync until we have a pure JS signing client.
*
* @param {object} root0
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: this root0 seems a little out of place, yet familiar... is this codegen or something?

Copy link
Member Author

Choose a reason for hiding this comment

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

it's what the eslint autofixer for missing jsdoc params does

@@ -1,4 +1,5 @@
// @ts-nocheck FIXME
// XXX uses agoric.follow to read data through spawned processes; replace with VstorageKit
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: is agoric.follow deprecated? Just not preferred? Is there a larger pattern of work to replace it with vstorage kit that we should file?

Copy link
Member Author

Choose a reason for hiding this comment

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

Deprecated, yeah. The larger pattern is in the comment, "replace with VstorageKit". That gets the vstorage data without shelling out, making it more portable and less dependent on the process env (e.g. PATH)

@@ -0,0 +1,352 @@
# Snapshot report for `test/vstorage-kit.test.js`
Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome

@@ -50,7 +55,7 @@ const parseUSDCAmount = (amountString, usdc) => {
*/
export const addLPCommands = (
program,
{ fetch, vstorageKit, stderr, stdout, env, now },
{ fetch, agoricNames, vstorageKit, stderr, stdout, env, now },
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems a little fickle to inject both agoricNames and vstorageKit because agoricNames should always come from the vstorageKit's queries. Being able to independently craft them allows them to have conflicting results. I.e. vstorageKit could return something when querying published.agoricNames.brands that doesn't match the agoricNames arg. It would be helpful to at least document these options as test-only to avoid confusion. So request: please add a doc/comment saying these are for testing.

Copy link
Member Author

Choose a reason for hiding this comment

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

It seems a little fickle to inject both agoricNames and vstorageKit because agoricNames should always come from the vstorageKit's queries

Not anymore, right? The PR is about removing agoricNames from VstorageKit.

Copy link
Contributor

Choose a reason for hiding this comment

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

I thought this PR is about making vstorageKit synchronous. If there's a context where looking at a provided agoricNames object contradicts what would result by calling the provided vstorageKit.readPublished("agoricNames...") then I think that's a bad consequence. Perhaps make vstorageKit.agoricNames a promise instead of removing it then?

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps make vstorageKit.agoricNames a promise instead of removing it then?

I don't think it's necessary to do this. My main concern is that we have a function with two arguments that can be two different sources of truth for the same data, it would just be nice to highlight this hazard somehow with a comment.

Copy link
Member Author

Choose a reason for hiding this comment

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

My main concern is that we have a function with two arguments that can be two different sources of truth for the same data, it would just be nice to highlight this hazard somehow with a comment.

Oh, I see. Yes that is a hazard. I'll work on that.

Copy link
Member Author

Choose a reason for hiding this comment

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

@turadg turadg force-pushed the ta/sync-VstorageKit branch from a9b385a to 501be3a Compare December 11, 2024 20:51
@turadg turadg added the automerge:rebase Automatically rebase updates, then merge label Dec 11, 2024
@mergify mergify bot merged commit 8f9f075 into master Dec 11, 2024
86 of 95 checks passed
@mergify mergify bot deleted the ta/sync-VstorageKit branch December 11, 2024 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:rebase Automatically rebase updates, then merge force:integration Force integration tests to run on PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants