-
Notifications
You must be signed in to change notification settings - Fork 214
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
Conversation
There was a problem hiding this 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.
d5c5c45
to
e241ba0
Compare
95d9729
to
eaf72d5
Compare
33814ad
to
8e04f4e
Compare
@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. |
There was a problem hiding this 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.
packages/inter-protocol/test/smartWallet/test-psm-integration.js
Outdated
Show resolved
Hide resolved
* `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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why lose this part?
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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
agoric-sdk/packages/smart-wallet/src/smartWallet.js
Lines 540 to 541 in fac5c32
helper.watchPurse(invitationPurse); | |
}, |
Please restore the design note
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops... forgot gain. sorry
} | ||
|
||
// 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 |
There was a problem hiding this comment.
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 😬 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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
|
b63db15
to
ef986b1
Compare
@@ -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 => { |
There was a problem hiding this comment.
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
* `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. |
There was a problem hiding this comment.
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
agoric-sdk/packages/smart-wallet/src/smartWallet.js
Lines 540 to 541 in fac5c32
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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}`); |
There was a problem hiding this comment.
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
?
throw assert.error(`cannot find/make purse for ${brand}`); | |
throw Fail`cannot find/make purse for ${brand}`; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done.
1c2114f
to
f77e3a5
Compare
f77e3a5
to
20fd7a2
Compare
refs: #6652, #6184, #6870, #6788
Description
For balances such as BLD, IST, USDC_axl that are already published in
x/bank
, stop publishing them inx/vstorage
.TODO:
Security Considerations
Perhaps reduces a risk of inconsistency between what clients see via
x/vstorage
and what's actually stored inx/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.