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

make vat-bank reachably durable #5885

Closed
Tracked by #6553
warner opened this issue Aug 3, 2022 · 0 comments · Fixed by #7617
Closed
Tracked by #6553

make vat-bank reachably durable #5885

warner opened this issue Aug 3, 2022 · 0 comments · Fixed by #7617
Assignees
Labels
cosmic-swingset package: cosmic-swingset enhancement New feature or request ERTP package: ERTP vaults_triage DO NOT USE wallet
Milestone

Comments

@warner
Copy link
Member

warner commented Aug 3, 2022

What is the Problem Being Solved?

vat-bank holds "virtual Purses" which represent the balances of accounts that are managed by cosmos-sdk on the golang side of the bridge. There will be a whole lot of these, and currently vat-bank holds an in-RAM object for each one, so the memory footprint is a concern.

The final goal is to get flat memory usage despite an arbitrary number of accounts (each of which holds a virtual purse for each of some moderate number of denominations).

This will be complicated by the code it needs for making balance updates. ERTP-style clients want to use getCurrentAmount() to get the most recent amount, and also getCurrentAmountNotifier() to get a (lossy) stream of updates. The balances themselves live in the cosmos side, where they could be queried on demand, but currently the cosmos Bank module sends (large) update messages to JS for every change. This enables getCurrentAmountNotifier() and reduces the work needed by getCurrentAmount(), but leads to significant load for data that nobody is paying attention to (yet).

Issues around vat-bank performance:

The Notifier involves Promises. Our plan for a durable Notifier (#4567) still needs RAM for the Promises held by "active" notifiers (where some client is waiting on a new value). And we expect that clients like the on-chain smart wallet will be constantly fetching new balances, so it's likely that every Notifier will be active all the time. We may need fully-virtual Promises (#3787) achieve flat RAM usage under that constraint.

Description of the Design

Not entirely sure, but at the very least we need the bank object (one per account) and the VirtualPurse object (one per account times denomination) to become instances of virtual Kinds. These are the user-facing objects.

It looks like each bank object also has a balanceUpdater object to be the receiver of the cosmos-initiated new-balance messages. These should be virtual too. In our current "push" architecture, where cosmos sends an unsolicited message about balance updates, the virtual-object manager will reconstitute Representatives for them on-demand, so we'll only spend RAM on them if/when a balance changes, which is ideal. Their associated Notifiers may not have that property, of course.

I suspect we need to overhaul the way we manage balance updates at the same time. I don't yet know what approach might work and get us flat memory usage.

Security Considerations

vat-bank has a mint-like authority over "native" (cosmos-managed) tokens; at the very least it can transfer tokens between arbitrary accounts. So that authority must be carefully managed.

Test Plan

I don't know.. it's not clear how vat-bank is currently tested.

@warner warner added the enhancement New feature or request label Aug 3, 2022
@ivanlei ivanlei added the vaults_triage DO NOT USE label Dec 20, 2022
@dckc dckc added cosmic-swingset package: cosmic-swingset wallet labels Jan 27, 2023
@dckc dckc added the ERTP package: ERTP label Jan 27, 2023
dckc added a commit that referenced this issue May 2, 2023
CAUTION: this provides the walletFactory with
the capability to spend from the provisino pool.

TODO(#5885): vbank should provide a facet attenuated
to only provide getAssetSubscription
dckc added a commit that referenced this issue May 2, 2023
CAUTION: this provides the walletFactory with
the capability to spend from the provisino pool.

TODO(#5885): vbank should provide a facet attenuated
to only provide getAssetSubscription
dckc added a commit that referenced this issue May 2, 2023
CAUTION: this provides the walletFactory with
the capability to spend from the provisino pool.

TODO(#5885): vbank should provide a facet attenuated
to only provide getAssetSubscription
dckc added a commit that referenced this issue May 2, 2023
CAUTION: this provides the walletFactory with
the capability to spend from the provisino pool.

TODO(#5885): vbank should provide a facet attenuated
to only provide getAssetSubscription
dckc added a commit that referenced this issue May 2, 2023
CAUTION: this provides the walletFactory with
the capability to spend from the provisino pool.

TODO(#5885): vbank should provide a facet attenuated
to only provide getAssetSubscription
dckc added a commit that referenced this issue May 3, 2023
CAUTION: this provides the walletFactory with
the capability to spend from the provisino pool.

TODO(#5885): vbank should provide a facet attenuated
to only provide getAssetSubscription
@turadg turadg changed the title virtualize vat-bank, maybe make durable/upgradeable too make vat-bank reachably durable May 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cosmic-swingset package: cosmic-swingset enhancement New feature or request ERTP package: ERTP vaults_triage DO NOT USE wallet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants