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

fix: agops: no I/O (errors) until command action #7299

Merged
merged 5 commits into from
Apr 1, 2023
Merged

Conversation

dckc
Copy link
Member

@dckc dckc commented Mar 31, 2023

refs: #6930
factoring out of #7256

Description

Each of commands/oracle.js, commands/ec.js etc. was calling makeRpcUtils on module import. Not only did this slow things down, it made catching I/O errors in the agops inter command infeasible.

Scaling Considerations

about 20 fewer RPC requests per agops command.

Security, Documentation Considerations

Not much... perhaps nicer diagnostics for agops inter is documentation.

Testing Considerations

no change in the (lack of) automated testing

@dckc dckc requested a review from turadg March 31, 2023 19:12
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.

Some cleanup suggested by not required. There are lint violations but I'll leave that between you and CI.

@@ -6,8 +6,6 @@ import { Command } from 'commander';
import { makeRpcUtils, storageHelper } from '../lib/rpc.js';
import { outputExecuteOfferAction } from '../lib/wallet.js';

const { vstorage, fromBoard, agoricNames } = await makeRpcUtils({ fetch });
Copy link
Member

Choose a reason for hiding this comment

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

ah yes. I think this was made one in rpc.js before but that was bad so it was factored it into a maker, but then didn't go the distance to only make where used.

}
return instance;
const rpcTools = async () => {
const { agoricNames, fromBoard, vstorage } = await makeRpcUtils({ fetch });
Copy link
Member

Choose a reason for hiding this comment

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

consider letting the object pass through,

Suggested change
const { agoricNames, fromBoard, vstorage } = await makeRpcUtils({ fetch });
const utils = await makeRpcUtils({ fetch });

and then,

const instance = utils.agoricNames.instance[name];

return {...utils, lookupPriceAggregatorInstance};

}
return instance;
const rpcTools = async () => {
const { vstorage, fromBoard, agoricNames } = await makeRpcUtils({ fetch });
Copy link
Member

Choose a reason for hiding this comment

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

ditto with comment above. if we do this often maybe worth another argument to makeRpcUtils that takes a maker for more utils.

const rpcTools = () => return makeRpcUtils(
  {fetch}, 
  base => {
    lookupPsmInstance: ([minted, anchor]) => {
      const name = `psm-${minted}-${anchor}`;
      const instance = base.agoricNames.instance[name];
      if (!instance) {
        logger.debug('known instances:', agoricNames.instance);
        throw new Error(`Unknown instance ${name}`);
      }
      return instance;
    }

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 usually go for the objects as closures pattern...

const makeThing = powers => {
  ...
  return harden({ method1, method2, ... });l
}

... and think about POLA while I'm at it. The bundles of rights that come to mind are:

  • an RPC client, including vstorage. it would know about network-config and ideally do failover
  • such a client that also has fromBoard state and knows about board marshalling
  • keyring access: just map names to addresses, no private key access
  • keyring+RPC: a sign-and-broadcast tool

@dckc dckc added the automerge:rebase Automatically rebase updates, then merge label Apr 1, 2023
@mergify mergify bot merged commit c548d92 into master Apr 1, 2023
@mergify mergify bot deleted the dc-delay-cli-io branch April 1, 2023 04:39
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.

2 participants