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

core bootstrap: subsume non-core #4541

Merged
merged 26 commits into from
Feb 22, 2022
Merged

core bootstrap: subsume non-core #4541

merged 26 commits into from
Feb 22, 2022

Conversation

dckc
Copy link
Member

@dckc dckc commented Feb 12, 2022

closes: #4165, #4021

I (sort of) recommend reviewing the commits separately. In particular, the run-protocol commits are separate from `vats and such. And demo stuff is in a separate commit from production stuff. This strategy fell down a bit with the move from the nameAdmins store to using promise spaces for issuers, brands, etc.

Security Considerations

completes the work of separating demo / test materials from production bootstrap begun in #4309, #4437

Documentation Considerations

and enumeration of what's in home is in here somewhere. (see also #4347)

Testing Considerations

unit test coverage is better but still not good. I'm still struggling to figure out what features to check for regressions.

production:

  • start VaultFactory, AMM (Bootstrap core: AMM, VaultFactory bootstrap with governance committee #4437 added this in in packages/run-protocol)
  • test-home.js in packages/solo tests wallet, board, etc. (pre-dates this PR)
    • client (solo) bootstrap
    • buildZoe
  • makeFeeCollector (unit tests, separate from bootstrap)
  • networking, IBC (unit tests, separate from bootstrap)
  • static checks on initial conditions
    • manifest permits are adequate for each bootstrap action
    • exactly one Producer for every item consumed.

demo/test:

  • faucet: demo data into wallet purses (faucet)
  • demo data for AMM, and VaultFactory
    • demo AMM calcluations
    • fundAMM unit test - not cost-effective?

Postponed to separate issues:

@dckc dckc force-pushed the bootstrap-core branch 10 times, most recently from cdccd78 to 90e8986 Compare February 14, 2022 00:03
@dckc dckc marked this pull request as ready for review February 14, 2022 00:32
@dckc dckc requested review from michaelfig, Chris-Hibbert and turadg and removed request for michaelfig February 14, 2022 00:32
@dckc dckc self-assigned this Feb 14, 2022
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.

I took a pass with some comments and questions. They're mostly superficial as I'm not well acquainted with the bootstrap.

Besides those, nothing stands out to me as problematic but I won't feel comfortable giving an Approval without a walk-through. I'm leaving a Comment review and hoping one of the other reviewers can provide assess whether it's merge-ready.

epochInterval: 60n * 60n, // 1 hour
};
const [centralIssuer, centralBrand] = await Promise.all([
E(agoricNames).lookup('issuer', 'RUN'), // TODO: constant for RUN
Copy link
Member

Choose a reason for hiding this comment

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

is this to do before merging or in the future? If the latter, it's best to have a ticket or a comment about who will do it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question. It's at least intended to start a conversation with reviewers.

Copy link
Member

Choose a reason for hiding this comment

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

I think last time this came up we discussed a set of "well known names". "RUN" would be one of them. Seems like it wouldn't hurt to have a constant file now for what would eventually be well-known names, as long as we understand what the semantics are of a name being well-known. Though I can't say that I'm certain.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yesterday I decided that both constants and static types were worth doing, as part of integrating agoricNames with the permits system:

// We reserve these keys in name hubs.
export const agoricNamesReserved = harden({
issuer: {
BLD: 'Agoric staking token',
RUN: 'Agoric RUN currency',

/**
* @typedef {{
* issuer: |
* 'RUN' | 'BLD',

...

* }} WellKnownName
*
* @typedef {{
* issuer: {
* nameHub: NameHub, nameAdmin: NameAdmin,
* produce: Record<WellKnownName['issuer'], Producer<Issuer>>,
* consume: Record<WellKnownName['issuer'], Promise<Issuer>>,
* },

epochTimerService,
harden(distributorParams),
)
.catch(e => console.error('Error building fee distributor', e));
Copy link
Member

Choose a reason for hiding this comment

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

why is this better than letting the error propagate?

Copy link
Member Author

@dckc dckc Feb 15, 2022

Choose a reason for hiding this comment

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

I'm not sure; I copied / moved this code from elsewhere. @Chris-Hibbert ? @michaelfig ?

Copy link
Member

Choose a reason for hiding this comment

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

I think this catch was done before we "only distribute fees if there is a collector". You can remove it with impunity.

allValues: async obj =>
fromEntries(Collect.zip(keys(obj), await Promise.all(values(obj)))),
};
/** @type { <T, U>(obj: Record<string, T>, f: (t: T) => U) => Record<string, U>} */
Copy link
Member

Choose a reason for hiding this comment

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

👌 I'm a fan of using as little JSDoc as necessary.

Copy link
Member

Choose a reason for hiding this comment

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

Also the named exports!

*/

/**
* @callback CreateUserBundle
* @param {string} nickname
* @param {string} clientAddress
* @param {string[]} powerFlags
* @returns {Promise<Record<string, unknown>>}
* @returns {Promise<Record<string, Promise<any>>>}
Copy link
Member

Choose a reason for hiding this comment

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

This looks like a regression in type safety. How hard would it be to keep the unknown instead of any?

Copy link
Member Author

Choose a reason for hiding this comment

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

this justification belongs in the code...

The userBundle really is an arbitrary pile of properties. And it's not like you can check them with typeof. You are either in a position to trust them or you're not. With unknown, each client that wants to call a method such as E(userBundle.bank).deposit(payment) has to cast userBundle.bank; ideally, the cast is to some useful type. But unknown can't be cast directly to some other type; it has to be cast to any first. I'm not sure all that hassle is cost-effective.

* ROLE: string,
* hardcodedClientAddresses: string[],
* noFakeCurrencies: boolean,
* FIXME_GCI: string,
Copy link
Member

Choose a reason for hiding this comment

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

is this FIXME a merge blocker?

Copy link
Member Author

Choose a reason for hiding this comment

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

it hasn't been for some number of years :)
again, this code is copied / moved from bootstrap.js.

@dckc
Copy link
Member Author

dckc commented Feb 16, 2022

I just added several commits based on testing in the context of work on getRUN bootstrap for a demo. Some of these could perhaps go in separate PRs; for example:

@dckc dckc changed the title core bootstrap: subsume non-core (WIP) core bootstrap: subsume non-core Feb 16, 2022
Copy link
Contributor

@Chris-Hibbert Chris-Hibbert left a comment

Choose a reason for hiding this comment

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

Just a bunch of observations. I don't have any objection to merging these changes in.

I don't feel like I've reviewed all the changes sufficiently to hit approve.

packages/run-protocol/src/econ-behaviors.js Show resolved Hide resolved
packages/run-protocol/src/econ-behaviors.js Outdated Show resolved Hide resolved
packages/vats/src/core/basic-behaviors.js Outdated Show resolved Hide resolved
packages/vats/src/core/basic-behaviors.js Show resolved Hide resolved
packages/vats/src/core/basic-behaviors.js Show resolved Hide resolved
packages/vats/src/core/basic-behaviors.js Outdated Show resolved Hide resolved
packages/vats/src/core/basic-behaviors.js Show resolved Hide resolved
vatPowers,
);

// TODO: Remove this alias when we can.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add an indication of the time frame or blocking factors?

Copy link
Member Author

Choose a reason for hiding this comment

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

That comment is unchanged from bootstrap.js. But it's a good question..

Maybe now is the time to remove home.uploads? @michaelfig ?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe now is the time to remove home.uploads?

I think so. We'd need to audit the dapps, but I'm pretty sure it's okay, and we can fix them if they break. But maybe in a follow-on PR.

Comment on lines +93 to +104
{ template } = {
template: {
agoricNames: true,
bank: true,
namesByAddress: true,
myAddressNameAdmin: true,
board: true,
faucet: true,
zoe: true,
},
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this better than

Suggested change
{ template } = {
template: {
agoricNames: true,
bank: true,
namesByAddress: true,
myAddressNameAdmin: true,
board: true,
faucet: true,
zoe: true,
},
},
template = {
agoricNames: true,
bank: true,
namesByAddress: true,
myAddressNameAdmin: true,
board: true,
faucet: true,
zoe: true,
},

Copy link
Member Author

Choose a reason for hiding this comment

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

This justification belongs in the code somewhere.

The idea is that the 2nd argument for all boostrap behaviors (functions) is an optional "config" argument that can be set in the bootstrap config file. So template isn't the whole config; it's one option in the config for this behavior.

packages/vats/src/core/chain-behaviors.js Show resolved Hide resolved
@dckc dckc force-pushed the bootstrap-core branch 6 times, most recently from c465d64 to 1a8fab6 Compare February 18, 2022 18:30
dckc added 2 commits February 21, 2022 16:54
 - consume pegasusBundle from the bootstrap promise space.
   - no need to exclude install-on-chain.js from lint, so move to src/
   - there's only one bundle, so never mind the Promise.all loop.
   - take care not to give Zoe.install a Promise<bundle>; that fails
     with: unrecognized moduleFormat ' undefined '
 - export CONTRACT_NAME = 'Pegasus' (capital P)
 - since we get nameAdmins from the promise space,
   use eventual send to call it.
 - never mind creatorFacet; Pegasus doesn't have one.
 - prune unused uiConfig
 - prune import of BootstrapPowers type
   ran into trouble with ambient types
closes #4021

BREAKING CHANGE: removes getBootstrapPayment from VaultFactory
dckc added 16 commits February 21, 2022 19:21
In order to test the new bootstrap with older versions of the UI,
publish the VaultFactory instance and uiConfig under 'Treasury'
as well as 'VaultFactory'.

 - combine awaits for vaultFactoryInstance, vaultFactoryCreator
 - we share vaultFactory instance in startVaultFactory;
   no need to do it again in configureVaultFactoryUI
 - docs: makeCollectFeesInvitation type conflicted with something
 - basic-behaviors:
   - mintInitialSupply, w/unit test
     - factor out BLD, RUN info as Tokens
     - example bootMsg for type
   - addBankAssets, w/unit test
     - publish runIssuer, runBrand here rather than buildZoe
     - subsume makeBLDKit
   - produce namesByAddress, namesByAddressAdmin
   - makeClientBanks: add home.bank
 - chain-behaviors:
   - makeClientManager: delay resolution of chainBundle
     until expected contents are available
     - TECHDEBT: factor out expected contents for
       use in solo's test-home.js
     - support multiple properties in E(client).assignBundle()
   - shareEconomyBundles: no getRUNBundle yet
   - registerNetworkProtocols: IBC, ...
     - update to use makePegasusConnectionKit
   - update Collect usage
   - integrate installPegasusOnChain behavior
     - manifest: installPegasusOnChain permit
     - share pegasusBundle from shareBootContractBundles
 - reserve Pegasus instance in nameHub
 - client-behaviors: startClient
 - parameterize logging in makePromiseSpace()
 - manifest:
   - track containing vat
     - TECHDEBT: not enforced as part of permit
   - track produce / consume for
     home: installation, instance, issuer, brand
 - parameterize governance actions by ROLE
 - core/types.js
   - factor BootstrapSpace, BootDevices<T> out of BootstrapPowers
   - chase down lots of vat, device types
     - SwingsetDevices was a misnomer; devices are chosen
       by the host application
     - resolve Device type conflicts
 - grantRunBehaviors
 - test connectFaucet
 - don't bother with ATOM, moola, simolean faucet payments
 - coordinate faucet, amm using provideIssuerKit in vat-mints.js
 - factor out fundAMM calculations for testing
   - demoIssuers: export utilities for testing
 - update Collect usage
  - don't try to startRewardDistributor on sim-chain
 - update CHAIN_BOOTSTRAP_VAT_CONFIG docs in env.md
fixes #4165

BREAKING CHANGE: decentral-config.json config file is no longer
available. Use decentral-core-config.js, which starts core
services by not RUN protocol etc., or decentral-demo-config.js,
which does start the RUN protocol and provides demo funds in
wallets, AMM.
Separate demo/test bootstrap from production.

BREAKING CHANGE: RUN protocol etc. is not started by default.

To start RUN protocol, Pegasus, etc., use:

CHAIN_BOOTSTRAP_VAT_CONFIG=@agoric/vats/decentral-demo-config.json \
  agoric start local-chain

Stay tuned for a mechanism to turn them on via governance.
This gives senders (such as a committee electorate sending out voter
invitations) a promise for the depositFacet rather than having
their lookup fail.
@dckc dckc added the automerge:no-update (expert!) Automatically merge without updates label Feb 22, 2022
dckc and others added 4 commits February 21, 2022 20:22
For static typing and integrating with the bootstrap permit system,
we expose { produce, consume } spaces rather than NameAdmins.

The idiom `E(agoricNames).lookup('instance', 'economicCommittee')`
becomes `instance.consume.economicCommittee`, replacing magic
strings with statically checked names.

Likewise, the idiom `E(instanceAdmin).update('economicCommittee', instance)`
becomes `economicCommittee.resolve(instance)`.

chore(vats): avoid magic strings for agoricNames (SQUASHME prod)

 - manifest: adapt permits from nameHubs to instance.produce and such
   - configureVaultFactoryUI: no need to produce amm instance;
     it's done in setupAMM
   - buildZoe doesn't produce the RUN issuer, brand;
     no need for agoricNames, nameAdmins, which are
     now obsolete in any case
   - test-boot.js to test manifest.js without starting the whole chain:
     test all 3 roles, with and without post-boot governance actions
   - makeAddressNameHubs: consume agoricNames,
     which is produced in boot.js
   - addBankVats no longer uses bootMsg
 - no more collectNameAdmins, rarely need to consume agoricNames
 - makeAgoricNames -> makeAgoricNamesAccess, which connects
   the promise spaces with the nameAdmins.
 - chore(pegasus): nameAdmins -> spaces
 - adapt startRewardDistributor to promise spaces for agoricNames
 - boot.js: parameterize logging higher
   - avoid harden() on module object
   - provide better diagnostic for bad behavior name
 - produce home.chainTimerService
 - docs: build scripts for visualizing initial conditions (SQUASHME prod)
 - vats: genesis typo
 - style(vats): mgr -> bankMgr
 - style(run-protocol): vats.distributeFees
 - makePriceAuthority -> makePriceAuthorityRegistry
   it's making more than a price authority
 - docs(vats): cite BLD issuer vat TODO issue
 - avoid hardening `deprecated` (SQUASHME prod)

   In a test, some calls that usually cross vats do not, so args get
   hardened. Since this deprecated thing should go away, let's copy it to
   make building the test easier.

 - test-clientBundle for spaces
 - fix(vats): fix home.chainTimerService
 - chore(run-protocol): fee distributor etc.
   - liquidate installation in configureVaultFactoryUI
   - bundles check is subsumed by permits
   - obsolete fee distributor .catch()
   - style(run-protocol): reformat in econ-behaviors
 - docs(vats): misc.
   - justify use of any in getChainBundle
   - TODO: shut down centralSupply contract?
   - NameHub, NameAdmin are not exposed in WellKnownSpaces

Co-authored-by: Chris Hibbert <Chris-Hibbert@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:no-update (expert!) Automatically merge without updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

separate production vat bootstrap from testing mechanisms
4 participants