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

fix!(smart-wallet): omit redundant chainStorage balances updates #6807

Merged
merged 5 commits into from
Feb 10, 2023

Conversation

dckc
Copy link
Member

@dckc dckc commented Jan 17, 2023

refs: #6652, #6184, #6870, #6788

Description

For balances such as BLD, IST, USDC_axl that are already published in x/bank, stop publishing them in x/vstorage.

TODO:

Security Considerations

Perhaps reduces a risk of inconsistency between what clients see via x/vstorage and what's actually stored in x/bank.

Documentation Considerations

Presuming our x/vstorage paths and their contents were documented (which is only partly the case), those docs need updating.

Testing Considerations

I updated unit tests such as packages/inter-protocol/test/smartWallet/test-psm-integration.js.

I ran some of the live-blockchain smoketests, but I would appreciate if other would do more of that, or help me understand exactly which ones I should run and what I should expect them to do.

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.

Looking good. I see the Draft and todos so not reviewing fully.

Is this really a request to merge into https://github.com/Agoric/agoric-sdk/tree/6652-wallet-perf ? Might want to base off master.

If there's a lot more work to do, the CLI fixes are good to merge as is.

packages/inter-protocol/test/smartWallet/contexts.js Outdated Show resolved Hide resolved
packages/inter-protocol/test/smartWallet/contexts.js Outdated Show resolved Hide resolved
packages/smart-wallet/src/smartWallet.js Outdated Show resolved Hide resolved
@dckc
Copy link
Member Author

dckc commented Feb 8, 2023

@turadg @michaelfig @samsiegart PTAL.

@turadg I ran some of the live-blockchain smoketests, but I would appreciate if you would do more of that, or help me understand exactly which ones I should run and what I should expect them to do.

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.

live-blockchain smoketests

All the -smoketest.sh scripts should work. I run them by copy pasting commands into a terminal. If they're not, maybe I'm unwittingly modifying them on the fly. I can pair tomorrow.

I think we also need more coverage of the Ava integration tests, like the payment queue bug you discovered.

Comment on lines 77 to 79
* `balance` update supports forward-compatibility for more than one purse per
* brand. An additional key will be needed to disambiguate. For now the brand in
* the amount suffices.
Copy link
Member

Choose a reason for hiding this comment

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

why lose this part?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because this PR gets rid of balance updates, no? hm... maybe not for zoe invitations...

Copy link
Member

Choose a reason for hiding this comment

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

balance updates are still here, as they should be for Invitations

helper.watchPurse(invitationPurse);
},

Please restore the design note

Copy link
Member Author

Choose a reason for hiding this comment

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

oops... forgot gain. sorry

packages/smart-wallet/src/smartWallet.js Outdated Show resolved Hide resolved
}

// When there is no purse, queue the payment
if (queues.has(brand)) {
queues.get(brand).push(payment);
} else {
queues.init(brand, harden([payment]));
queues.init(brand, harden([payment])); // @@ this can't be right
Copy link
Member

Choose a reason for hiding this comment

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

oh yeah we must not have coverage of this. You can't push onto a hardened array.

Good catch! Care to add the failing test 😬 ?

Copy link
Member Author

@dckc dckc Feb 9, 2023

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

please replace @@ with a link to the ticket

packages/smart-wallet/src/utils.js Show resolved Hide resolved
@samsiegart
Copy link
Contributor

web-components changes LGTM. I'm unsure if anything in wallet-app needs to change but I'll have to make a pass on that soon anyway so LGTM, leaving approval for @turadg and @michaelfig

@dckc dckc added this to the Vaults Functional Testing milestone Feb 9, 2023
@dckc dckc requested a review from turadg February 10, 2023 00:23
@@ -369,6 +360,71 @@ test('deposit unknown brand', async t => {
t.deepEqual(result, { brand: rial.brand, value: 0n });
});

test.failing('deposit > 1 payment to unknown brand', async t => {
Copy link
Member

Choose a reason for hiding this comment

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

worth a link to the ticket #6961

Comment on lines 77 to 79
* `balance` update supports forward-compatibility for more than one purse per
* brand. An additional key will be needed to disambiguate. For now the brand in
* the amount suffices.
Copy link
Member

Choose a reason for hiding this comment

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

balance updates are still here, as they should be for Invitations

helper.watchPurse(invitationPurse);
},

Please restore the design note

@@ -101,12 +95,10 @@ const mapToRecord = map => Object.fromEntries(map.entries());
* walletStorageNode: StorageNode,
* }} UniqueParams
*
* @typedef {Pick<MapStore<Brand, BrandDescriptor>, 'has' | 'get' | 'values'>} ReadOnlyMapStore
Copy link
Member

Choose a reason for hiding this comment

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

ReadOnlyMapStore would be generic on the key/value types. Please pick a name that's specific to the Brand/BrandDescriptor mapping or this use case. BrandDescriptorRegistry?

@@ -150,7 +141,7 @@ export const prepareSmartWallet = (baggage, shared) => {
invitationDisplayInfo: DisplayInfoShape,
publicMarshaller: M.remotable('Marshaller'),
zoe: M.eref(M.remotable('ZoeService')),
registry: M.remotable('AssetRegistry'),
registry: M.remotable('AssetRegistry'), // XXX too strict
Copy link
Member

Choose a reason for hiding this comment

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

Since this needn't be far, let's drop the Far from const registry = Far in WalletFactory and give this a shape. That could be ReadonlyMapStoreShape.

Copy link
Member Author

Choose a reason for hiding this comment

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

The registry can't go thru shape validation of any kind as long as it's not passable. And function properties are only allowed on Far objects.

This seems to work:

  const { registry: _, ...passableShared } = shared;
  mustMatch(
    harden(passableShared),
    ...

}

// When there is no purse, queue the payment
if (queues.has(brand)) {
queues.get(brand).push(payment);
} else {
queues.init(brand, harden([payment]));
queues.init(brand, harden([payment])); // @@ this can't be right
Copy link
Member

Choose a reason for hiding this comment

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

please replace @@ with a link to the ticket

const purse = E(bank).getPurse(desc.brand);
await facets.helper.addBrand(desc, purse);
return purse;
throw assert.error(`cannot find/make purse for ${brand}`);
Copy link
Member

Choose a reason for hiding this comment

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

Is throw necessary for never?

Suggested change
throw assert.error(`cannot find/make purse for ${brand}`);
throw Fail`cannot find/make purse for ${brand}`;

Copy link
Member Author

Choose a reason for hiding this comment

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

assert.error is not never; it constructs an error. But Fail is fine

Copy link
Member

Choose a reason for hiding this comment

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

yeah I was asking why the throw. because without it assert.fail is an option.

Copy link
Member Author

Choose a reason for hiding this comment

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

Something about "arrow function needs return" IIRC

@dckc dckc requested a review from turadg February 10, 2023 04:17
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.

Well done.

@dckc dckc added the automerge:rebase Automatically rebase updates, then merge label Feb 10, 2023
@mergify mergify bot merged commit 6ca3660 into master Feb 10, 2023
@mergify mergify bot deleted the dc-wallet-balances-dry branch February 10, 2023 07:52
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants