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

Harmonise core/boot-psm.js with core/boot.js #6568

Merged
merged 15 commits into from
Dec 7, 2022
Merged

Conversation

michaelfig
Copy link
Member

@michaelfig michaelfig commented Nov 15, 2022

closes: #6490
#loadgen-branch: mfig-diagnostics

Description

Merge the changes from the core/boot-psm.js mechanism used in the first Agoric VM deployment with the manifest-based core/boot.js system.

Security Considerations

Documentation Considerations

Testing Considerations

The devnet configuration is now tested by the cosmic-swingset integration tests.

@michaelfig michaelfig added the cosmic-swingset package: cosmic-swingset label Nov 15, 2022
@michaelfig michaelfig requested a review from dckc November 15, 2022 02:13
@michaelfig michaelfig self-assigned this Nov 15, 2022
@dckc
Copy link
Member

dckc commented Nov 15, 2022

I tried the steps to reproduce from #6490 ; it doesn't look fixed.

command[9] E(home.agoricNames).lookup('instance', 'psm')
history[9] Promise.reject("Error: \"nameKey\" not found: (a string)")

@michaelfig
Copy link
Member Author

I tried the steps to reproduce from #6490 ; it doesn't look fixed.

command[9] E(home.agoricNames).lookup('instance', 'psm')
history[9] Promise.reject("Error: \"nameKey\" not found: (a string)")

Ahh, yes. That's because there's an instance per brand pair. Try E(E(home.agoricNames).lookup('instance')).entries()

packages/cosmic-swingset/Makefile Outdated Show resolved Hide resolved
options = {},
{ env = process.env } = {},
) => {
const { ROLE = env.ROLE || 'chain', econCommitteeOptions } = options;
Copy link
Member

Choose a reason for hiding this comment

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

better to pass process.env than rely on ambient authority, but why pass it at all if it can come in through options.ROLE? Multiple ways to express the same configuration makes the code harder to follow. It's not apparent without reading committeeProposalBuilder that env.ROLE is valid or takes precedence over options.ROLE.

Copy link
Member Author

Choose a reason for hiding this comment

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

Turns out ROLE was unnecessary. Removed.

Copy link
Member

Choose a reason for hiding this comment

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

Seems to still be there as of 2a2b288

Copy link
Member Author

Choose a reason for hiding this comment

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

Seems to still be there

I need to push. I'll rerequest your review when I do.

@@ -71,15 +71,16 @@ const installKeyGroups = {
* @param {(m: string, b: string, opts?: any) => I} opts.install
* @param {<T>(f: T) => T} [opts.wrapInstall]
*
* @param options
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* @param options
* @param {{ ROLE: 'chain' | 'whatever else', econCommitteeOptions: ??? }} options

[voterInvitation, nullInvitation],
[
invitationP,
// TODO: This null invitation is used just to identify the
Copy link
Member

Choose a reason for hiding this comment

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

TODO by when? Ticket?

Copy link
Member Author

Choose a reason for hiding this comment

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

{ restoreRef },
{ installKeys },
) => {
const { [installGovAndPSMContracts.name]: _toss, ...manifest } =
Copy link
Member

Choose a reason for hiding this comment

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

isn't simply _ the convention here for ignoring a param?

Suggested change
const { [installGovAndPSMContracts.name]: _toss, ...manifest } =
const { [installGovAndPSMContracts.name]: _, ...manifest } =

payments.map(async (paymentP, i) => {
const payment = await paymentP;
await E(depositFacet).receive(payment);
console.info(
Copy link
Member

Choose a reason for hiding this comment

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

nice diagnostic info


return E(namesByAddressAdmin).update(address, nameHub, myAddressNameAdmin);
// Don't clobber an existing myAddressNameAdmin or deposit facet.
Copy link
Member

Choose a reason for hiding this comment

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

this will silently fail if publishDepositFacet is called a second time and wallet.getDepositFacet() changes.

This does seem like an improvement to make it immutable, but shouldn't we error if something tries to change it? At least log?

Copy link
Member

Choose a reason for hiding this comment

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

More like it silently succeeds, yes?
This is saying "if there's already one there, leave it alone. Otherwise, use this one"

Copy link
Member

Choose a reason for hiding this comment

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

Success or failure depends on the intent ;-)

My point is: if what's already there doesn't match, isn't that a surprise? In what cases would you expect the existing value to be different than the new one?

Copy link
Member

Choose a reason for hiding this comment

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

In what cases would you expect the existing value to be different than the new one?

In case an ag-solo already registered it.

isn't that a surprise?

Not any longer, IIUC.

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'll add documentation to this effect.

@@ -0,0 +1,30 @@
import { makeHelpers } from '@agoric/deploy-script-support';

export const defaultProposalBuilder = async ({ publishRef, install }) =>
Copy link
Member

Choose a reason for hiding this comment

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

is "default" here meant like "default export" or are there expected to be multiple proposal builders in a module like this?

Copy link
Member Author

Choose a reason for hiding this comment

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

The coreProposals swingset config feature uses defaultProposalBuilder by default (i.e. if the config file does not specify a different entrypoint).

BRIDGE_ID.PROVISION_SMART_WALLET,
obj,
);
} else {
Copy link
Member

Choose a reason for hiding this comment

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

this is assuming the if SMART_WALLET isn't in the powerFlags that it should do this. why not validate the contents? I'm thinking the final else should be an error for an undefined case

Copy link
Member Author

Choose a reason for hiding this comment

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

Can you please be more specific? What kind of validation do you expect, since the Golang side of things already enforces that powerFlags is an array of strings?

@dckc
Copy link
Member

dckc commented Nov 15, 2022

Try entries()

I should have been clear: yes, I did that too. There are no PSMs

command[5] E(lookup('agoricNames', 'instance')).entries()
history[5] [...]

command[8] h[5].map(([n, _v]) => n)
history[8] ["economicCommittee","amm","ammGovernor","VaultFactory","feeDistributor","Treasury","VaultFactoryGovernor","stakeFactory","stakeFactoryGovernor","Pegasus","reserve","reserveGovernor","psmCharter","interchainPool","provisionPool","walletFactory"]

@dckc
Copy link
Member

dckc commented Nov 19, 2022

I see PSMs now:

command[0]
E(E(home.agoricNames).lookup('instance')).keys()
history[0]
["economicCommittee","amm","ammGovernor","VaultFactory","feeDistributor","Treasury","VaultFactoryGovernor","stakeFactory","stakeFactoryGovernor","Pegasus","reserve","reserveGovernor","psmCharter","interchainPool","provisionPool","walletFactory","psm-IST-USDC_axl","psm-IST-USDC_grv","psm-IST-USDT_axl","psm-IST-USDT_grv","psm-IST-AUSD"]

fyi, @thisispalash

Copy link
Member

@dckc dckc left a comment

Choose a reason for hiding this comment

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

In the interest of addressing #6490 , I'm ready to land this.

It relaxes some constraints that we introduced in boot-psm.js, so I re-opened #4165 and #5965 to re-consider our approach to those.

Comment on lines 514 to 515
const coreConfigPath = path.resolve(
'node_modules/@agoric/vats/decentral-core-config.json',
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 to assume that the current working directory has node_modules with the @agoric/vats package installed. That seems to be a new assumption. I suppose it's justified by the way agoric install works?

Elsewhere I've see a function that resolves paths like @agoric/vats/decentral-core-config.json. I'm not sure why we don't use it here.

But I don't feel strongly about it. The whole agoric-cli package seems to be a bit of a wild west w.r.t. ocap discipline.

Copy link
Member Author

Choose a reason for hiding this comment

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

The dependency on node_modules was ugly and unnecessary, so I've now abstracted it behind require.resolve.

Comment on lines +137 to +142
"provisioning": {
"sourceSpec": "@agoric/vats/src/vat-provisioning.js"
},
Copy link
Member

Choose a reason for hiding this comment

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

I suppose this calls for re-opening #5965 to think it over again.

Comment on lines +134 to +139
"priceAuthority": {
"sourceSpec": "@agoric/vats/src/vat-priceAuthority.js"
},
Copy link
Member

Choose a reason for hiding this comment

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

why does vat-priceAuthority.js belong here rather than in a vaults proposal?
(semi-rhetorical; I suppose I could figure it out if I looked around.)

Copy link
Member Author

Choose a reason for hiding this comment

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

vat-priceAuthority.js is not a Zoe contract, so doesn't easily fit into the current way proposals are implemented. But yes, ideally it would be part of a proposal, and we would make a separate decision whether to publish it to solo clients.

Comment on lines +128 to +136
"ibc": {
"sourceSpec": "@agoric/vats/src/vat-ibc.js"
},
"network": {
"sourceSpec": "@agoric/vats/src/vat-network.js"
},
Copy link
Member

Choose a reason for hiding this comment

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

@ivanlei the list of vats/contracts that I put together Nov 9 for planning purposes didn't include these two (ibc, network). I suppose they should be added to the list of things to make upgradeable (#6553). Ah... we already have #5696 for the network vat. I don't know whether we included it in any plans.

options = {},
{ env = process.env } = {},
) => {
const { ROLE = env.ROLE || 'chain', econCommitteeOptions } = options;
Copy link
Member

Choose a reason for hiding this comment

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

Seems to still be there as of 2a2b288

{ restoreRef },
{ installKeys },
) => {
const { [installGovAndPSMContracts.name]: _toss, ...manifest } =
Copy link
Member

Choose a reason for hiding this comment

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

Why are we removing installGovAndPSMContracts from the manifest returned by getManifestForPsmGovernance? It seems particularly relevant.

Copy link
Member Author

Choose a reason for hiding this comment

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

The installations property below subsumes what installGovAndPSMContracts does.

@@ -108,7 +108,8 @@ const startGovernedInstance = async (
* }>} powers
* @param {{
* options?: {
* perAccountInitialValue?: bigint
* perAccountInitialValue?: bigint,
* walletBridgeId?: string
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* walletBridgeId?: string
* walletBridgeId?: string,

@michaelfig michaelfig added the automerge:no-update (expert!) Automatically merge without updates label Nov 29, 2022
@mhofman mhofman added force:integration Force integration tests to run on PR and removed automerge:no-update (expert!) Automatically merge without updates labels Dec 5, 2022
@michaelfig michaelfig force-pushed the mfig-harmonise-pismo-boot branch 2 times, most recently from 81f7dbc to 77c5d31 Compare December 6, 2022 04:15
Copy link
Member

@dckc dckc left a comment

Choose a reason for hiding this comment

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

still looks good.

I have a few wishes...

Comment on lines +150 to +151
const { nickname, address, powerFlags: rawPowerFlags } = obj;
const powerFlags = rawPowerFlags || [];
Copy link
Member

Choose a reason for hiding this comment

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

don't we usually write it this way?

Suggested change
const { nickname, address, powerFlags: rawPowerFlags } = obj;
const powerFlags = rawPowerFlags || [];
const { nickname, address, powerFlags = [] } = obj;

Copy link
Member

Choose a reason for hiding this comment

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

  • wish: unit test
  • wish: pattern-based dynamic type check on obj

Copy link
Member Author

Choose a reason for hiding this comment

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

Turns out that obj.powerFlags can be null. The destructuring default values only work if obj.powerFlags is undefined.

Yeah, the dynamic checks would be better with patterns.

@@ -146,9 +147,24 @@ export const bridgeProvisioner = async ({
async fromBridge(_srcID, obj) {
Copy link
Member

Choose a reason for hiding this comment

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

how does fromBridge here relate to the one in provisionPool.js? I'd like to see compare/contrast comments on each.

@@ -690,8 +690,7 @@ ${chainID} chain does not yet know of address ${clientAddr}${adviseEgress(
console.debug(`helper said: ${stdout}`);
const out = JSON.parse(stdout);

out.code ||
0 ||
out.code === 0 ||
Copy link
Member

Choose a reason for hiding this comment

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

yikes. that looks like it was hairy to track down.

wish: unit test

@michaelfig michaelfig added the automerge:no-update (expert!) Automatically merge without updates label Dec 7, 2022
@mergify mergify bot merged commit 8e71c07 into master Dec 7, 2022
@mergify mergify bot deleted the mfig-harmonise-pismo-boot branch December 7, 2022 19:36
Comment on lines +155 to +157
provisionP = E(bridgeManager).fromBridge(
BRIDGE_ID.PROVISION_SMART_WALLET,
obj,
Copy link
Member

Choose a reason for hiding this comment

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

Where does this message actually end up? I do not see any bridge handler registered for it since boot-psm sets walletBridgeId to BridgeId.PROVISION.

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 cosmic-swingset package: cosmic-swingset force:integration Force integration tests to run on PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

how to get to PSM contract from repl / deploy script?
4 participants