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-eval needs mechanism to create+pass a Meter to zoe.startInstance #8217

Open
warner opened this issue Aug 17, 2023 · 3 comments
Open

core-eval needs mechanism to create+pass a Meter to zoe.startInstance #8217

warner opened this issue Aug 17, 2023 · 3 comments
Labels
core-eval enhancement New feature or request resource-exhaustion Threats to availability from resource exhaustion attacks

Comments

@warner
Copy link
Member

warner commented Aug 17, 2023

What is the Problem Being Solved?

Our plan for protecting the chain against runaway contract-vat execution (#7938) depends upon new contract vats being created with a Meter. Issue #8216 is about adding this functionality to Zoe, but @mhofman noticed that we also need to somehow change or add behavior to vat-bootstrap, to allow CORE_EVAL snippets to pass this meter through to Zoe.

I may be wrong, but I think that CORE_EVAL snippets will call startUpgradable to ask for Zoe to create a new instance.

/** @type {StartUpgradable} */
const startUpgradable = async ({
installation,
issuerKeywordRecord,
terms,
privateArgs,
label,
}) => {
const started = await E(zoe).startInstance(
installation,
issuerKeywordRecord,
terms,
privateArgs,
label,
);
label ||= NonNullish(getInterfaceOf(started.instance));
const kit = harden({ ...started, label });
contractKits.init(kit.instance, kit);
await E(diagnostics).savePrivateArgs(kit.instance, privateArgs);
return kit;
};

This wraps the call to E(zoe).startInstance(), and already has five arguments hard-coded into it, with no simple provision for passing additional/arbitrary options. So we don't currently have a way to reach the new argument that #8216 would add.

One possibility is to somehow add the Meter to one of the existing arguments. However the contract code should not be allowed to access its own Meter object (if it could, it could refill it as much as it wanted, negating the computrons limits).

Can we do a CORE_EVAL that adds a new startUpgradableWithMeter to the promise space?

Description of the Design

unknown

Security Considerations

Scaling Considerations

Test Plan

Upgrade Considerations

@warner warner added enhancement New feature or request resource-exhaustion Threats to availability from resource exhaustion attacks core-eval labels Aug 17, 2023
@warner
Copy link
Member Author

warner commented Aug 18, 2023

@dckc pointed out that CORE_EVAL code can access zoe directly, and is not limited to the startUpgradable function, however they'll need to stash the other stuff themselves.. the suffix of that function:

   label ||= NonNullish(getInterfaceOf(started.instance)); 
   const kit = harden({ ...started, label }); 
   contractKits.init(kit.instance, kit); 
   await E(diagnostics).savePrivateArgs(kit.instance, privateArgs); 
   return kit; 

(and assuming that diagnostics is available too)

So this might not require a new feature in the vat-bootstrap promise space, but could probably be achieved with a different pattern in our instantiate-contract proposals.

@mhofman
Copy link
Member

mhofman commented Aug 18, 2023

I'm not sure what the shape of a contractKit is supposed to be, but we do want to stash the meter somewhere, and it might be a good place for it.

@dckc
Copy link
Member

dckc commented Aug 18, 2023

fwiw...
https://github.com/Agoric/agoric-sdk/blob/mainnet1B/packages/vats/src/core/types.js#L271

StartedInstanceKitWithLabel is what you get back from E(zoe).install() plus a label: string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-eval enhancement New feature or request resource-exhaustion Threats to availability from resource exhaustion attacks
Projects
None yet
Development

No branches or pull requests

3 participants