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(vats): implement "big hammer" governance #4642

Merged
merged 7 commits into from
Feb 24, 2022

Conversation

michaelfig
Copy link
Member

closes: #4352

Description

Implement 'core' bridge handler to enable governance to evaluate core boot code. Update solo to allow new home objects to be pushed.

Remove "leftover actions" assertion, since it is fragile in the face of governance and has thus outlived its usefulness (all actions that make it through the actionQueue are precious, not just heuristically-determined ones).

Drive-by update faucet-helper.sh not to give away so many assets.

Demo

This is a demo of the end-to-end: passing a governance action to add something to every ag-solo's home:

cd packages/cosmic-swingset
make scenario2-setup scenario2-run-chain # in one console
make scenario2-run-client # in another console
# Wait for chain and client to boot, then type at the REPL: `agoric`
# propose and vote on gov-permit.json and gov-code.js:
make scenario2-core-eval scenario2-vote
agd query gov proposals
# Wait for the voting_end_time to happen, then voila, typing `agoric` at REPL results in `youAreGoverned`:

image

Security Considerations

No new security dependencies beyond what 2/3 validators could do anyway.

Documentation Considerations

Testing Considerations

Will be tested in earnest on the next Devnet.

@michaelfig michaelfig added cosmic-swingset package: cosmic-swingset Governance Governance labels Feb 23, 2022
@michaelfig michaelfig self-assigned this Feb 23, 2022
@michaelfig michaelfig requested a review from dckc February 23, 2022 01:43
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.

Looks great!

where is the .proto thingy?

I should probably test this a bit.

@@ -32,6 +33,58 @@ const { keys } = Object;

const NUM_IBC_PORTS = 3;

/**
* This is the code triggered by `agd tx gov submit-proposal swingset-core-eval
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
* This is the code triggered by `agd tx gov submit-proposal swingset-core-eval
* This registers the code triggered by `agd tx gov submit-proposal swingset-core-eval

Comment on lines 60 to 62
const { evals } = obj;
return Promise.all(
evals.map(({ json_permits: permit, js_code: code }) =>
Copy link
Member

Choose a reason for hiding this comment

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

I can haz static type plz?

Or a comment cross-referencing a .proto file?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, that helped me catch a bug. The json_permits needed parsing.

// Inspired by ../repl.js:
const globals = harden({
...farExports,
console,
Copy link
Member

Choose a reason for hiding this comment

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

console... hm... I guess that's reasonable.

How about assert while we're at 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.

How about assert while we're at it?

Added here and in repl.js for the pleasure of the ag-solo REPL.

}
},
});
await E(bridgeManager).register('core', handler);
Copy link
Member

Choose a reason for hiding this comment

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

I feel even more strongly about magic strings than I did before getting into this bootstrap stuff.

Suggested change
await E(bridgeManager).register('core', handler);
const CORE_BRIDGE_ID = 'core';
await E(bridgeManager).register(CORE_BRIDGE_ID, handler);

with the definition at the top. and exported.

Well... I dunno... Maybe I can stand to leave it alone until we have another piece of code that has to use the same string.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well... I dunno... Maybe I can stand to leave it alone until we have another piece of code that has to use the same string.

That day is today. I've created packages/vats/src/bridge-ids.js.

@@ -1,5 +1,6 @@
// @ts-check
const SHARED_BOOTSTRAP_MANIFEST = harden({
makeCoreEval: true,
Copy link
Member

Choose a reason for hiding this comment

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

is makeCoreEval useful on the sim-chain?

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've renamed it to bridgeCoreEval and moved it to just the chain manifest.

@michaelfig michaelfig force-pushed the mfig-core-eval-governance branch 2 times, most recently from c6bdfc9 to b1bfb16 Compare February 23, 2022 03:35
@michaelfig michaelfig requested a review from dckc February 23, 2022 03:36
dckc
dckc previously approved these changes Feb 23, 2022
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.

I verified that this works as advertised:

command[4] agoric.youAreGoverned
history[4] "agoric15ccjs5hmhrnsszd55npfr22gkfjeu4les90l4a"

I see the .proto was introduced in #4625 .

There I find discussion of documentation burden:

There will certainly be documentation, but this help string is not the place for it.
-- #4625 (comment)

I prefer that any such statements about the future come with references to issues by number, but I don't suppose that's critical to landing this PR.

I'm also a little hesitant that the bulk of the testing here is manual integration testing, but again, test-boot.js does seem to cover it at least a little.

@dckc dckc dismissed their stale review February 23, 2022 16:50

just realized: I should test starting the RUN protocol.

});

// Evaluate the code in the context of the globals.
return new Compartment(globals).evaluate(code);
Copy link
Member

Choose a reason for hiding this comment

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

Let's have the evaluated code return a function and pass the powers to that function, so that the evaluated code can be organized according to POLA rather than having powerful globals available ambiently.

@dckc
Copy link
Member

dckc commented Feb 24, 2022

I was able to start the RUN protocol, though it's a little twisty. I'll be thinking about ways to straighten it out.

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.

feel free to add powerless stuff such as utils, bootBehaviors, ... to the globals.

@michaelfig michaelfig force-pushed the mfig-core-eval-governance branch from bc5dbc5 to 7b063db Compare February 24, 2022 05:24
@michaelfig michaelfig added the automerge:no-update (expert!) Automatically merge without updates label Feb 24, 2022
@mergify mergify bot merged commit 2e6e57c into master Feb 24, 2022
@mergify mergify bot deleted the mfig-core-eval-governance branch February 24, 2022 05:40
dckc added a commit that referenced this pull request Mar 6, 2022
dckc added a commit that referenced this pull request Mar 6, 2022
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 Governance Governance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Big hammer" Cosmos governance via bootstrap code evaluation
2 participants