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

Support IBC for comm #259

Closed
dtribble opened this issue Oct 19, 2019 · 7 comments
Closed

Support IBC for comm #259

dtribble opened this issue Oct 19, 2019 · 7 comments
Assignees
Labels
cosmic-swingset package: cosmic-swingset

Comments

@dtribble
Copy link
Member

dtribble commented Oct 19, 2019

Use IBC instead of VatTP for chain/chain communication. See #1670 for chain/solo communication.

Demo Script

Convey an ocap across a Network API "Connection".

  1. Run relayer/scripts/nchainz init agoric to start two Agoric chains connected by IBC. In this case, the first ag-solo web interface is localhost:8000. We'll call the user driving localhost:8000 "Alice" and localhost:8001 is "Bob'. (If you want to test locally instead of over IBC, you don't need nchainz, just agoric start and you can use localhost:8000 for both "Alice" and "Bob".)
  2. On Alice:
helloObj = harden({
  hello(name) {
    console.log(`Alice's object got called by`, name);
    return `Hello, ${name}!`;
  },
});
E(agoric.ibcport[0]).addListener({
  async onAccept() {
    const { handler, host } = await E(agoric.vattp).makeNetworkHost('some-inbound');
    localHost = host;
    const helloAddress = await E(host).publish(helloObj);
    console.log('helloAddress = ', JSON.stringify(helloAddress));
    return handler;
  },
});
// during the next step (2), this (Alice's) console will print something like:
// helloAddress = "/alleged-name/some-inbound/egress/${clistIndex}"
  1. On Bob (don't set nchainz = true if running without nchainz):
nchainz = true;
ibcAddr = '/ibc-port/portbvmnfb/ordered/vattp';
ibcAddr = nchainz ? '/ibc-hop/ibczerolink' + ibcAddr : ibcAddr;
E(agoric.vattp).makeNetworkHost('some-outbound', console).then(
  ({ handler, host }) => {
    hostAlice = host;
    E(agoric.ibcport[1]).connect(ibcAddr, handler).catch(console.error);
  });
// Supply the address string that was printed on Alice's console after the above resolves.
obj = E(hostAlice).lookup(helloAddress);
E(obj).hello('Bob');
// See the message appear on Alices's console, and call resolve to 'Hello, Bob!'

To create a VatTP-over-IBC connection between an ag-solo and a chain, we will need the solo client implementation cosmos/cosmos-sdk#6267

Low-level vattp interface

const name = 'remote1';
const { transmitter, setReceiver } = await E(vats.vattp).addRemote(name);
const receiver = await E(vats.comms).addRemote(name, transmitter);
await E(setReceiver).setReceiver(receiver);
@warner
Copy link
Member

warner commented Dec 4, 2019

in the old repo. this was cosmic-swingset issue 101

@warner warner transferred this issue from another repository Dec 4, 2019
@warner warner added the cosmic-swingset package: cosmic-swingset label Dec 4, 2019
@michaelfig michaelfig self-assigned this Feb 29, 2020
warner added a commit that referenced this issue Jul 28, 2020
warner added a commit that referenced this issue Jul 28, 2020
michaelfig pushed a commit that referenced this issue Aug 1, 2020
michaelfig pushed a commit that referenced this issue Aug 2, 2020
@michaelfig
Copy link
Member

While running the above steps against actual IBC, I get the following error message from chain A:

SwingSet: v8: IBC fromBridge dibc Object <[Object: null prototype] {}> {
  type: 'IBC_EVENT',
  event: 'receivePacket',
  packet: Object <[Object: null prototype] {}> {
    sequence: 1,
    source_port: 'porteykyi',
    source_channel: 'channeltoivkps',
    destination_port: 'portbvmnfb',
    destination_channel: 'channeltocdeyhb',
    data: 'ZGVsaXZlcjpybyswOmxvb2t1cDpycC00MDtbIi9hbGxlZ2VkLW5hbWUvc29tZS1pbmJvdW5kL2VncmVzcy83Il0=',
    timeout_height: 2027
  },
  blockHeight: 1030,
  blockTime: 1597169357
}
SwingSet: kernel: doProcess: vat[v2].promise[p+60] fulfilledToPresence failed: [Error <Object <[Object: null prototype] {}>>: unimplemented three-party handoff (object o+14) from remote1 to undefined)
  at Object.mapOutbound (v2/packages/SwingSet/src/vats/comms/clist.js:56:15)
  at Object.resolvePromiseToRemote (v2/packages/SwingSet/src/vats/comms/outbound.js:117:33)
  at Object.notifyFulfillToPresence (v2/packages/SwingSet/src/vats/comms/dispatch.js:97:14)
  at eval (kernel/packages/SwingSet/src/kernel/vatManager/deliver.js:48:48)]

The decoded packet is deliver:ro+0:lookup:rp-40;["/alleged-name/some-inbound/egress/7"].

@warner can you PTAL?

@michaelfig
Copy link
Member

michaelfig commented Aug 11, 2020

This message came from ibc1's lookup of ibc0's helloObj, the log message was on ibc0:

SwingSet: kernel: doProcess: vat[v2].promise[p+60] fulfilledToPresence failed: [Error <Object <[Object: nul
l prototype] {}>>: unimplemented three-party handoff (object o+14) from remote1 agoric125ld3sdv2umlcqf9agnt
v2sm6g79cl9yntq39y to remote2 connection-7)
  at Object.mapOutbound (v2/packages/SwingSet/src/vats/comms/clist.js:56:15)
  at Object.resolvePromiseToRemote (v2/packages/SwingSet/src/vats/comms/outbound.js:117:33)
  at Object.notifyFulfillToPresence (v2/packages/SwingSet/src/vats/comms/dispatch.js:97:14)
  at eval (kernel/packages/SwingSet/src/kernel/vatManager/deliver.js:48:48)]

And this one came from ibc1's lookup of ibc0's agoric.zoe, the log message was on ibc1:

SwingSet: kernel: doProcess: vat[v2].promise[p+60] fulfilledToPresence failed: [Error <Object <[Object: nul
l prototype] {}>>: unimplemented three-party handoff (object o+16) from remote2 connection-7 to remote1 ago
ric1qwfhhxgpwz37s3zajx22d69scrdq0gn3caq5m9)
  at Object.mapOutbound (v2/packages/SwingSet/src/vats/comms/clist.js:56:15)
  at Object.resolvePromiseToRemote (v2/packages/SwingSet/src/vats/comms/outbound.js:117:33)
  at Object.notifyFulfillToPresence (v2/packages/SwingSet/src/vats/comms/dispatch.js:97:14)
  at eval (kernel/packages/SwingSet/src/kernel/vatManager/deliver.js:48:48)]

@michaelfig
Copy link
Member

michaelfig commented Aug 11, 2020

[UPDATED: for current behaviour on master.]

Local repro using just agoric start --reset -v

helloObj = harden({
  hello(name) {
    console.log('Sending reply to', name);
    return `Hello, ${name}!`;
  },
});
E(agoric.ibcport[0]).addListener({
  async onAccept() {
    const { handler, host } = await E(local.vattp).makeNetworkHost('some-inbound');
    localHost = host;
    helloAddress = await E(localHost).publish(helloObj);
    console.log('helloAddress = ', JSON.stringify(helloAddress));
    return handler;
  },
});
nchainz = false;
ibcAddr = '/ibc-port/portbvmnfb/ordered/vattp';
ibcAddr = nchainz ? '/ibc-hop/ibczerolink' + ibcAddr : ibcAddr;
E(agoric.vattp).makeNetworkHost('some-outbound', console).then(
  ({ handler, host }) => {
    hostA = host;
    E(agoric.ibcport[1]).connect(ibcAddr, handler).catch(console.error);
  });
obj = E(hostA).lookup(helloAddress);

I then get (note that this is in the lookup agoric.vattp's SwingSet):

sim-chain: SwingSet: kernel: doProcess: vat[v2].promise[p+60] fulfilledToPresence failed: [Error <Object <[Object: null prototype] {}>>: unimplemented three-party handoff (object o+18) from remote2 connection-7 to remote1 sim-chain-client)
  at Object.mapOutbound (v2/packages/SwingSet/src/vats/comms/clist.js:56:15)
  at Object.resolvePromiseToRemote (v2/packages/SwingSet/src/vats/comms/outbound.js:117:33)
  at Object.notifyFulfillToPresence (v2/packages/SwingSet/src/vats/comms/dispatch.js:97:14)
  at eval (kernel/packages/SwingSet/src/kernel/vatManager/deliver.js:48:48)]

With:

E(localHost).publish(agoric.zoe).then(addr => zoeAddress = addr);

and:

obj2 = E(hostA).lookup(zoeAddress)

I get (note that this is in the publishing local.vattp's SwingSet):

SwingSet: kernel: doProcess: vat[v2].promise[p+27] fulfilledToPresence failed: [Error <Object <[Object: null prototype] {}>>: unimplemented three-party handoff (object o+22) from remote1 sim-chain to remote2 connection-7)
  at Object.mapOutbound (v2/packages/SwingSet/src/vats/comms/clist.js:56:15)
  at Object.resolvePromiseToRemote (v2/packages/SwingSet/src/vats/comms/outbound.js:117:33)
  at Object.notifyFulfillToPresence (v2/packages/SwingSet/src/vats/comms/dispatch.js:97:14)
  at eval (kernel/packages/SwingSet/src/kernel/vatManager/deliver.js:48:48)]

@michaelfig
Copy link
Member

@warner, I updated the above comment to indicate which SwingSet the error messages came from. I hope this will be illuminating.

@michaelfig
Copy link
Member

With the above two PRs, the demo described at the top of this issue now works correctly over IBC.

@michaelfig michaelfig mentioned this issue Sep 2, 2020
6 tasks
@michaelfig
Copy link
Member

Closing, as POC is done and future development has moved to #1670.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cosmic-swingset package: cosmic-swingset
Projects
None yet
Development

No branches or pull requests

3 participants