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

Investigate TODOs in Network Vat #8854

Closed
Tracked by #8903
iomekam opened this issue Feb 1, 2024 · 2 comments · Fixed by #8979
Closed
Tracked by #8903

Investigate TODOs in Network Vat #8854

iomekam opened this issue Feb 1, 2024 · 2 comments · Fixed by #8979
Assignees
Labels
bug Something isn't working

Comments

@iomekam
Copy link
Contributor

iomekam commented Feb 1, 2024

Describe the bug

We've been doing a bunch of work to make the network and IBC vats durable. While doing that work, we've run into a few concerning comments that may need to be addressed before the network vat is ready for production

To Reproduce

/**
* Currently must be a single listenHandler. TODO: Do something sensible with
* multiple handlers?
*
* @type {MapStore<Endpoint, [Port, ListenHandler]>}
*/
const listening = makeScalarMapStore('localAddr');

// TODO: Check that the listener defines onAccept.

/**
* Currently must be a single listenHandler. TODO: Do something sensible with
* multiple handlers?
*
* @type {MapStore<Endpoint, [Port, ListenHandler]>}
*/
const listening = makeScalarMapStore('localAddr');

return Far('ProtocolHandler', {
// eslint-disable-next-line no-empty-function
async onCreate(_impl, _protocolHandler) {
// TODO
},
async generatePortID(_protocolHandler) {
return makePortID();
},
async onBind(_port, _localAddr, _protocolHandler) {
// TODO: Maybe handle a bind?
},
async onConnect(_port, localAddr, remoteAddr, _chandler, protocolHandler) {
const [lport, lhandler] = listeners.get(remoteAddr);
const rchandler =
/** @type {ConnectionHandler} */
(await E(lhandler).onAccept(lport, remoteAddr, localAddr, lhandler));
// console.log(`rchandler is`, rchandler);
const remoteInstance = await E(protocolHandler)
.onInstantiate(lport, remoteAddr, localAddr, protocolHandler)
.catch(rethrowUnlessMissing);
return {
remoteInstance,
handler: rchandler,
};
},
onInstantiate,
async onListen(port, localAddr, listenHandler, _protocolHandler) {
// TODO: Implement other listener replacement policies.
if (listeners.has(localAddr)) {
const lhandler = listeners.get(localAddr)[1];
if (lhandler !== listenHandler) {
// Last-one-wins.
listeners.set(localAddr, [port, listenHandler]);
}
} else {
listeners.init(localAddr, [port, listenHandler]);
}
},
async onListenRemove(port, localAddr, listenHandler, _protocolHandler) {
const [lport, lhandler] = listeners.get(localAddr);
lport === port || Fail`Port does not match listener on ${localAddr}`;
lhandler === listenHandler ||
Fail`Listen handler does not match listener on ${localAddr}`;
listeners.delete(localAddr);
},
async onRevoke(_port, _localAddr, _protocolHandler) {
// TODO: maybe clean up?
},
});

Expected behavior

These TODOs should be investigated to ensure that there isn't missing functionality/work that needs to be done. If we can launch with them in place, they should be replaced with issues tracking each item.

Platform Environment

all platforms since mainnet1B launch.

@iomekam iomekam added the bug Something isn't working label Feb 1, 2024
@dckc
Copy link
Member

dckc commented Feb 1, 2024

note also some commented-out code #8721 (comment)

@dckc
Copy link
Member

dckc commented Feb 22, 2024

@michaelfig The impact of these isn't clear to me. I'm going to have to interview you or @warner or somebody...

The loopback protocol ( prepareLoopbackProtocolHandler ) is mostly for testing, but it will be part of the network vat in production, right?
The onCreate body is marked TODO. We don't seem to be suffering from that.
Do I understand correctly that onCreate is an opportunity to do suff, but there is no obligation?

or is loopback used more than that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants