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

feat: durable agoricNames, namesByAddress #7605

Merged
merged 44 commits into from
May 7, 2023
Merged

feat: durable agoricNames, namesByAddress #7605

merged 44 commits into from
May 7, 2023

Conversation

dckc
Copy link
Member

@dckc dckc commented May 4, 2023

refs: #4548

Description

  • durable makeNameHubKit with NameAdmin.provideChild()
  • move namesByAddress kit to vat-provisioning.js
  • move agoricNames kit to its own vat, vat-agoricNames.js
  • provideInertBrand() in vat-agoricNames to move oracleBrands out of bootstrap
  • eliminate a couple boot strap Far attenuators that were not worthwhile

Security Considerations

Reduce responsibilities of the bootstrap vat; after moving these two name services, after bootstrap, the bootstrap vat should only be used for core eval.

Scaling Considerations

namesByAddress is now virtualized and durable and out of the bootstrap vat

Documentation Considerations

none?

Testing Considerations

normal-to-light unit testing

@dckc dckc force-pushed the dc-durable-namehub branch from fb91ba4 to 4cc9fbb Compare May 4, 2023 18:07
@dckc dckc force-pushed the dc-space-reserve-any branch from 2f06b7e to 4e9bad6 Compare May 4, 2023 18:58
@dckc dckc marked this pull request as draft May 4, 2023 19:08
@dckc dckc force-pushed the dc-durable-namehub branch from 4cc9fbb to c7d9760 Compare May 4, 2023 21:58
@dckc dckc force-pushed the dc-space-reserve-any branch 2 times, most recently from b24025b to 717a002 Compare May 5, 2023 04:47
@dckc dckc force-pushed the dc-durable-namehub branch 7 times, most recently from 58f003e to 43ec75d Compare May 5, 2023 17:48
@dckc dckc changed the title WIP: toward durable namehub WIP: 4548 durable bootstrap May 5, 2023
@turadg turadg force-pushed the dc-space-reserve-any branch from 206d58c to 44fdc31 Compare May 5, 2023 18:15
@dckc dckc force-pushed the dc-durable-namehub branch from 43ec75d to 1d0cb37 Compare May 5, 2023 19:04
Base automatically changed from dc-space-reserve-any to master May 5, 2023 21:11
@dckc dckc force-pushed the dc-durable-namehub branch 4 times, most recently from 18ed498 to 4db2eb2 Compare May 6, 2023 05:51
@@ -163,7 +163,7 @@ export const makeBootstrap = (
vatData.set(name, { root });
}
}
void rawBootstrap(vats, devices).catch(e => {
return rawBootstrap(vats, devices).catch(e => {
Copy link
Member

Choose a reason for hiding this comment

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

😻

@@ -108,7 +108,7 @@
* @typedef {object} LiquidationStrategy
* @property {() => KeywordKeywordRecord} keywordMapping
* @property {(collateral: Amount, run: Amount) => Proposal} makeProposal
* @property {(runDebt: Amount) => Promise<Invitation>} makeInvitation
* @property {(debt: Amount) => Promise<Invitation>} makeInvitation
Copy link
Member

Choose a reason for hiding this comment

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

I pushed this stray commit by accident. It doesn't hurt but if you rebase please excise

packages/internal/test/test-callback.js Show resolved Hide resolved
packages/vats/src/core/chain-behaviors.js Outdated Show resolved Hide resolved
keys: () => {
return harden([...keyToRecord.keys()]);
},
export const prepareNameHubKit = (zone = heapZone) => {
Copy link
Member

Choose a reason for hiding this comment

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

a prepare without a zone argument doesn't make sense to me. you only ever make a prepare if you're eventually making it durable. I think we should require the zone.

Moreover to avoid dangling baggages I think the non-durable zones should warn when kinds are defined into them. It can only be an interim state during development. À propos,

Copy link
Member Author

Choose a reason for hiding this comment

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

a prepare without a zone argument doesn't make sense to me.

agreed. changing.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the non-durable zones should warn when kinds are defined into them.

good idea; not for this PR, OK?

const init1 = () => ({
/** @type {LegacyMap<string, PromiseKit<unknown>>} */
// Legacy because a promiseKit is not a passable
keyToPK: makeLegacyMap('nameKey'),
Copy link
Member

Choose a reason for hiding this comment

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

Then use JS Map. LegacyMap is not to be used for any new code. It's scheduled for deletion.

/** @type {any} */
const firstValue = keyToValue.has(first)
? keyToValue.get(first)
: keyToPK.get(first).promise; // or throw
Copy link
Member

Choose a reason for hiding this comment

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

JS Map doesn't throw on missing values. To get that back a clean option is our NonNullish checked cast:

Suggested change
: keyToPK.get(first).promise; // or throw
: NonNullish(keyToPK.get(first)).promise;


/** @param {import('@agoric/zone').Zone} zone */
const makeBrandStore = zone => {
const brandStore = zone.mapStore('Brand');
Copy link
Member

Choose a reason for hiding this comment

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

Took me a minute to see this wasn't making singletons. I'm still getting used to zones.

One thing that would help readability is moving const brandStore below the kind definition. Kinds should come first. Anything that the kind def depends on should be obvious so it's clear what has to happen in the first crank of restart.

Copy link
Member Author

Choose a reason for hiding this comment

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

right... refactored to just prepareNatBrand, without a closure for the state.

);

return {
provide: (keyword, displayInfo) =>
Copy link
Member

Choose a reason for hiding this comment

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

The plain provide is for when what is provided is specified by the make argument. In this case it's always making a brand (and that's not implied by the signature).

Suggested change
provide: (keyword, displayInfo) =>
provideBrand: (keyword, displayInfo) =>

@dckc dckc force-pushed the dc-durable-namehub branch 3 times, most recently from 66c4cd7 to 9cb0057 Compare May 6, 2023 20:29
@dckc dckc changed the title WIP: 4548 durable bootstrap feat: durable agoricNames, namesByAddress May 6, 2023
@dckc dckc force-pushed the dc-durable-namehub branch from b2d06fd to e21dc09 Compare May 6, 2023 20:53
@dckc dckc marked this pull request as ready for review May 6, 2023 21:00
@dckc dckc requested a review from turadg May 6, 2023 21:01
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.

:shipit: (after squashing the fixups and reverts)

@@ -67,7 +67,7 @@ const makeDefaultTestContext = async t => {
test.before(async t => {
t.context = await makeDefaultTestContext(t);
});
test.after.always(t => t.context.shutdown());
test.after.always(t => t.context.shutdown?.());
Copy link
Member

Choose a reason for hiding this comment

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

this seems like a bad idea to me. Every bootstrap test needs to shutdown the host storage.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok. gone.

michaelfig and others added 24 commits May 7, 2023 04:19
 - provideChild is async
 - update is _not_ async
home.myAddressNameAdmin is a NameAdmin with an extra getMyAddress()
method. Here we use exo "attenuators" to

 - add getMyAddress() to a NameAdmin, making a MyAddressNameAdmin
 - override provideChild() in NamesByAddressAdmin, providing
   a kit whose nameAdmin is a MyAddressNameAdmin

This obsoletes makeMyAddressNameAdmin and simplifies a previously
delicate and fragile coordination between the smart wallet and the
ag-solo wallet.
The datalock from pismo seems to be gone. This should facilitate
diagnostics.
Co-authored-by: Turadg Aleahmad <turadg@agoric.com>
@dckc dckc force-pushed the dc-durable-namehub branch from 31afd15 to a6f85f7 Compare May 7, 2023 04:19
@dckc dckc added this pull request to the merge queue May 7, 2023
Merged via the queue into master with commit 0ce9545 May 7, 2023
@dckc dckc deleted the dc-durable-namehub branch May 7, 2023 12:39
@mhofman mhofman mentioned this pull request May 8, 2023
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