Skip to content

Commit

Permalink
Merge pull request #7150 from Agoric/6111-rationalize-paths
Browse files Browse the repository at this point in the history
feat(vaults)!: vstorage index node for managers
  • Loading branch information
mergify[bot] authored May 2, 2023
2 parents 3a98338 + 4ccdf31 commit 609421b
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 28 deletions.
15 changes: 8 additions & 7 deletions packages/inter-protocol/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@ The canonical keys (under `published`) are as follows. Non-terminal nodes could
- `vaultFactory` - [snapshot of details](./test/vaultFactory/snapshots/test-vaultFactory.js.md)
- `governance`
- `metrics`
- `manager0`
- `metrics`
- `governance`
- `vaults`
- `vault0`
- `managers`
- `manager0`
- `metrics`
- `governance`
- `vaults`
- `vault0`
- `auction` - [snapshot of details](./test/auction/snapshots/test-auctionContract.js.md)
- `schedule`
- `governance`
Expand Down Expand Up @@ -84,9 +85,9 @@ Once you see a string like `block 17 commit` then the chain is available. In ano
# shows keys of the vaultFactory
agd query vstorage keys 'published.vaultFactory'
# lists vaults
agd query vstorage keys 'published.vaultFactory.manager0.vaults'
agd query vstorage keys 'published.vaultFactory.managers.manager0.vaults'
# follow metrics
agoric follow :published.vaultFactory.manager0.metrics
agoric follow :published.vaultFactory.managers.manager0.metrics
```

Start a new terminal to get a prompt.
Expand Down
3 changes: 2 additions & 1 deletion packages/inter-protocol/src/vaultFactory/vaultDirector.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export const prepareVaultDirector = (
wake: timestamp => func(timestamp),
});
};
const managersNode = E(storageNode).makeChildNode('managers');

const managerBaggages = provideChildBaggage(baggage, 'Vault Manager baggage');

Expand Down Expand Up @@ -296,7 +297,7 @@ export const prepareVaultDirector = (

// counter to be incremented at end of addVaultType
const managerId = `manager${state.managerCounter}`;
const managerStorageNode = await E(storageNode).makeChildNode(
const managerStorageNode = await E(managersNode).makeChildNode(
managerId,
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Generated by [AVA](https://avajs.dev).
},
],
[
'published.vaultFactory.manager0',
'published.vaultFactory.managers.manager0',
{
compoundedInterest: {
denominator: {
Expand Down Expand Up @@ -119,7 +119,7 @@ Generated by [AVA](https://avajs.dev).
},
],
[
'published.vaultFactory.manager0.governance',
'published.vaultFactory.managers.manager0.governance',
{
current: {
DebtLimit: {
Expand Down Expand Up @@ -220,7 +220,7 @@ Generated by [AVA](https://avajs.dev).
},
],
[
'published.vaultFactory.manager0.metrics',
'published.vaultFactory.managers.manager0.metrics',
{
liquidatingCollateral: {
brand: {
Expand Down Expand Up @@ -283,7 +283,7 @@ Generated by [AVA](https://avajs.dev).
},
],
[
'published.vaultFactory.manager0.quotes',
'published.vaultFactory.managers.manager0.quotes',
{
quoteAmount: {
brand: {
Expand Down Expand Up @@ -316,7 +316,7 @@ Generated by [AVA](https://avajs.dev).
},
],
[
'published.vaultFactory.manager0.vaults.vault0',
'published.vaultFactory.managers.manager0.vaults.vault0',
{
debtSnapshot: {
debt: {
Expand Down Expand Up @@ -350,7 +350,7 @@ Generated by [AVA](https://avajs.dev).
},
],
[
'published.vaultFactory.manager0.vaults.vault1',
'published.vaultFactory.managers.manager0.vaults.vault1',
{
debtSnapshot: {
debt: {
Expand Down Expand Up @@ -384,7 +384,7 @@ Generated by [AVA](https://avajs.dev).
},
],
[
'published.vaultFactory.manager0.vaults.vault2',
'published.vaultFactory.managers.manager0.vaults.vault2',
{
debtSnapshot: {
debt: {
Expand Down Expand Up @@ -418,7 +418,7 @@ Generated by [AVA](https://avajs.dev).
},
],
[
'published.vaultFactory.manager0.vaults.vault3',
'published.vaultFactory.managers.manager0.vaults.vault3',
{
debtSnapshot: {
debt: {
Expand Down Expand Up @@ -452,7 +452,7 @@ Generated by [AVA](https://avajs.dev).
},
],
[
'published.vaultFactory.manager0.vaults.vault4',
'published.vaultFactory.managers.manager0.vaults.vault4',
{
debtSnapshot: {
debt: {
Expand Down Expand Up @@ -486,7 +486,7 @@ Generated by [AVA](https://avajs.dev).
},
],
[
'published.vaultFactory.manager0.vaults.vault5',
'published.vaultFactory.managers.manager0.vaults.vault5',
{
debtSnapshot: {
debt: {
Expand Down Expand Up @@ -520,7 +520,7 @@ Generated by [AVA](https://avajs.dev).
},
],
[
'published.vaultFactory.manager0.vaults.vault6',
'published.vaultFactory.managers.manager0.vaults.vault6',
{
debtSnapshot: {
debt: {
Expand Down
Binary file not shown.
18 changes: 9 additions & 9 deletions packages/inter-protocol/test/vaultFactory/test-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ test('storage keys', async t => {
t,
managerA,
'asset',
'mockChainStorageRoot.vaultFactory.manager0',
'mockChainStorageRoot.vaultFactory.managers.manager0',
['compoundedInterest', 'interestRate', 'latestInterestUpdate'],
);
await assertTopicPathData(
t,
managerA,
'metrics',
'mockChainStorageRoot.vaultFactory.manager0.metrics',
'mockChainStorageRoot.vaultFactory.managers.manager0.metrics',
[
'liquidatingCollateral',
'liquidatingDebt',
Expand All @@ -77,7 +77,7 @@ test('storage keys', async t => {
collateralBrand: aeth.brand,
}),
),
'mockChainStorageRoot.vaultFactory.manager0.governance',
'mockChainStorageRoot.vaultFactory.managers.manager0.governance',
);

// Second manager
Expand All @@ -86,35 +86,35 @@ test('storage keys', async t => {
t,
E(managerC).getPublicFacet(),
'asset',
'mockChainStorageRoot.vaultFactory.manager1',
'mockChainStorageRoot.vaultFactory.managers.manager1',
);
await assertTopicPathData(
t,
E(managerC).getPublicFacet(),
'metrics',
'mockChainStorageRoot.vaultFactory.manager1.metrics',
'mockChainStorageRoot.vaultFactory.managers.manager1.metrics',
);
t.is(
await subscriptionKey(
E(vdp).getSubscription({
collateralBrand: chit.brand,
}),
),
'mockChainStorageRoot.vaultFactory.manager1.governance',
'mockChainStorageRoot.vaultFactory.managers.manager1.governance',
);

// First aeth vault
const vda1 = await d.makeVaultDriver(aeth.make(1000n), run.make(50n));
t.is(
await E.get(vda1.getVaultSubscriber()).storagePath,
'mockChainStorageRoot.vaultFactory.manager0.vaults.vault0',
'mockChainStorageRoot.vaultFactory.managers.manager0.vaults.vault0',
);

// Second aeth vault
const vda2 = await d.makeVaultDriver(aeth.make(1000n), run.make(50n));
t.is(
await E.get(vda2.getVaultSubscriber()).storagePath,
'mockChainStorageRoot.vaultFactory.manager0.vaults.vault1',
'mockChainStorageRoot.vaultFactory.managers.manager0.vaults.vault1',
);
});

Expand All @@ -129,7 +129,7 @@ test('quotes storage', async t => {
const storedNotifier = await E(aethManager).getQuotes();
t.is(
await E(storedNotifier).getPath(),
'mockChainStorageRoot.vaultFactory.manager0.quotes',
'mockChainStorageRoot.vaultFactory.managers.manager0.quotes',
);

let latest = await E(storedNotifier).getUpdateSince();
Expand Down

0 comments on commit 609421b

Please sign in to comment.