-
Notifications
You must be signed in to change notification settings - Fork 215
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
chore(vat-upgrade): upgrade agoricNames, test old values are preserved #10616
Conversation
Deploying agoric-sdk with Cloudflare Pages
|
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.
Could you please take a look at this file and let me know the test coverage (including the skipped one) here makes sense and is enough? @Chris-Hibbert
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.
I think this only tests reading via vstorage
. I'd like to ensure that objects (issuers, brands, etc.) retrieved from it after upgrade are still valid unbroken objects. I presume this can be done from inside a proposal.
Is there anything here that tests onUpdate
?
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.
I think this only tests reading via vstorage. I'd like to ensure that objects (issuers, brands, etc.) retrieved from it after upgrade are still valid unbroken objects. I presume this can be done from inside a proposal.
Yeah we check the vstorage but the way nameHub
works is that when a hub is written new data, ALL of its entries are published to vstorage. See;
agoric-sdk/packages/vats/src/nameHub.js
Lines 113 to 122 in e596a01
const updated = (updateCallback, hub, _newValue = undefined) => { | |
if (!updateCallback) { | |
return; | |
} | |
// wait for values to settle before writing | |
return E.when(deeplyFulfilledObject(hub.entries()), settledEntries => | |
E(updateCallback).write(settledEntries), | |
); | |
}; |
So what we do is;
- we read the vstorage before writing new data to agoricNames' children (brand, issuer, instance...)
- write data to
agoricNames
via a core-eval - expect that the child hubs of
agoricNames
publish ALL their entries to vstorage along with the new data - read vstorage again and make sure the agoricNames read from the vstorage BEFORE the core-eval is the same as the one read AFTER the core-eval (with the addition of newly written data of course).
...still valid unbroken objects
My plan for making sure the objects are unbroken is to go over the contracts that use agoricNames
and make sure they still function as expected. For example, in order to open a vault there needs to be a valid instance object in published.agoricNames.instance
for VaultFactory
.
Is there anything here that tests onUpdate?
Test named check we can add new chains
appends a new chain to published.agoricNames.chain
and published.agoricNames.chainConnection
. Both of these paths have their onUpdate
callback registered here:
agoric-sdk/packages/orchestration/src/proposals/init-chain-info.js
Lines 46 to 67 in e596a01
await E(nameAdmin).onUpdate( | |
// XXX will live on the heap in the bootstrap vat. When we upgrade or kill | |
// that this handler will sever and vat-agoricNames will need to be upgraded | |
// to allow changing the handler, or to use pubsub mechanics instead. | |
Far('chain info writer', { | |
write(entries) { | |
// chainInfo has no cap data but we need to marshal bigints | |
const marshalData = makeMarshal(_val => Fail`data only`); | |
for (const [chainName, info] of entries) { | |
const value = JSON.stringify(marshalData.toCapData(info)); | |
if (prev[chainName] === value) { | |
continue; | |
} | |
const chainNode = E(chainNamesNode).makeChildNode(chainName); | |
prev[chainName] = value; | |
void E(chainNode) | |
.setValue(value) | |
.catch(() => delete prev[chainName]); | |
} | |
}, | |
}), | |
); |
The fact that we are able to append and observe new chain info after an upgrade shows that onUpdate
callback above works.
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.
in order to open a vault there needs to be a valid instance object in published.agoricNames.instance for VaultFactory.
sounds good.
The fact that we are able to append and observe new chain info after an upgrade shows that onUpdate callback above works.
Great!
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.
a3p-integration/proposals/p:upgrade-19/writeToAgoricNames/write-to-agoricNames-permit.json
Outdated
Show resolved
Hide resolved
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.
I think this only tests reading via vstorage
. I'd like to ensure that objects (issuers, brands, etc.) retrieved from it after upgrade are still valid unbroken objects. I presume this can be done from inside a proposal.
Is there anything here that tests onUpdate
?
1e4beba
to
e5cacf8
Compare
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.
Your approach seems like it covers the bases. I think you're not done yet, so I didn't do a complete review. Let me know if/when it's ready.
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.
in order to open a vault there needs to be a valid instance object in published.agoricNames.instance for VaultFactory.
sounds good.
The fact that we are able to append and observe new chain info after an upgrade shows that onUpdate callback above works.
Great!
Oh actually I’ve got nothing to add (other than fixing the CI of course) assuming you’ve read the parts under |
Yep. I've seen that. I don't believe that's a problem. |
18a38da
to
47c9309
Compare
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.
looks fine. One question.
@@ -135,59 +163,28 @@ test.serial('check all existing values are preserved', async t => { | |||
); | |||
}); | |||
|
|||
test.serial('check we can add new chains', 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.
Why is it okay to drop this 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.
2195ace removes write-chain-info.js from f:fast-usdc. So we simulate what is does (relative to agoricNames) in order to test ephemeral onUpdate callbacks keep working after an agoricNames upgrade.
Because of this.
47c9309
to
cd35800
Compare
closes: #10408
Description
As stated in #8158, we need to be able to upgrade any vat we want and make sure the system keeps working. This PR focuses on upgrading
vat-agoricNames
.Security Considerations
I consider
vat-agoricNames
as a critical vat as it's the source trust for object identities. So it's crucial it keeps working after the upgrade. It's important to point out that if there were any keywords reserved before the upgrade, they will be lost after the upgrade as the reservations stored in ephemera. If this is important, we might consider re-reserving in the core eval.Scaling Considerations
None.
Documentation Considerations
Don't think it's necessary as the functionality of
nameHub
is left untouched.Testing Considerations
If we decide to re-reserve some keywords, we will need to add a test that verifies the core eval has indeed reserved those keywords. Please see below for the test plan I followed:
agoric-sdk/a3p-integration/proposals/p:upgrade-19/agoricNames.test.js
Lines 3 to 46 in 1e4beba
EDIT
2195ace removes
write-chain-info.js
fromf:fast-usdc
. So we simulate what is does (relative toagoricNames
) in order to test ephemeralonUpdate
callbacks keep working after anagoricNames
upgrade.Upgrade Considerations
This PR itself upgrade
vat-agoricNames
and comes with a3p tests to verify the upgrade goes through andagoricNames
keep working.