Agoric / agoric-sdk

monorepo for the Agoric Javascript smart contract platform
Apache License 2.0
327 stars 207 forks source link

codegen RPC clients #9200

Open turadg opened 7 months ago

turadg commented 7 months ago

What is the Problem Being Solved?

For a few weeks we had RPC query clients using Telescope:

But the implementation broke using the library in vats, which is more urgent. So this ticket is for restoring that functionality.

Description of the Design

Some options:

  1. publish them as a separate package, versioned by agoric-upgrade-NN
  2. rework Telescope to output two hierarchies with one that is safe for vats
  3. rework Telescope to inject the dependencies instead of importing them (e.g. provide a generic query util, one of which works over HTTP and another that uses the local chain host)
  4. wait for https://github.com/cosmology-tech/interchainjs, probably ready by November 2024

Security Considerations

Scaling Considerations

Test Plan

Upgrade Considerations

michaelfig commented 7 months ago

Can you clarify "broke using the library in vats"? I believe there's at least an option 4:

  1. give instructions as to which @agoric/cosmic-proto modules can be imported within a contract/vat. This is also useful to minimize the amount of dead code bundled with your contract since @endo/bundle-source doesn't yet do tree shaking.
turadg commented 7 months ago

Can you clarify "broke using the library in vats"?

Getting the registry requires enabling amino types in codegen, which entails tendermint-rpc which entails axios and http which is not available in a vat.

E.g. if you revert the last three commits of https://github.com/Agoric/agoric-sdk/pull/9112 and run build:submissions in a3p-integration you'll get,

TypeError#1: Failed to load module "./src/proposals/localchain-test.js" in package "file:///opt/agoric/agoric-sdk/packages/vats/" (11 underlying failures: Cannot find external module "http" in package file:///opt/agoric/agoric-sdk/node_modules/axios/, Cannot find external module "https" in package file:///opt/agoric/agoric-sdk/node_modules/axios/, Cannot find external module "util" in package file:///opt/agoric/agoric-sdk/node_modules/axios/, Cannot find external module "zlib" in package file:///opt/agoric/agoric-sdk/node_modules/axios/, Cannot find external module "stream" in package file:///opt/agoric/agoric-sdk/node_modules/axios/, Cannot find external module "events" in package file:///opt/agoric/agoric-sdk/node_modules/axios/, Cannot find external module "stream" in package file:///opt/agoric/agoric-sdk/node_modules/axios/, Cannot find external module "util" in package file:///opt/agoric/agoric-sdk/node_modules/axios/, Cannot find external module "stream" in package file:///opt/agoric/agoric-sdk/node_modules/axios/, Cannot find external module "stream" in package file:///opt/agoric/agoric-sdk/node_modules/axios/, Cannot find external module "url" in package file:///opt/agoric/agoric-sdk/node_modules/axios/

I've pushed that as https://github.com/Agoric/agoric-sdk/pull/9202 so you can see it in CI.

Even a targeted import of a module has the same problem,

import { MsgDelegate } from '@agoric/cosmic-proto/cosmos/staking/v1beta1/tx';

This is why I enumerated option 3 to unencumber the codec modules with the client dependencies. I don't see how we could get much use out of detailed instructions while the modules mix dependencies in this way.

michaelfig commented 7 months ago

Thanks for the clear answer. I agree: my option 4 won't get us anywhere.

turadg commented 2 weeks ago

The scope of this is codegen for read-only queries. Transaction signing support can build on this and I'll track that in https://github.com/Agoric/agoric-sdk/issues/5912