Skip to content

Commit

Permalink
fix: incorporate review feedback and other bits of tidying up
Browse files Browse the repository at this point in the history
  • Loading branch information
FUDCo committed Apr 9, 2021
1 parent a9b826f commit 235957b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
11 changes: 5 additions & 6 deletions packages/SwingSet/src/vats/comms/clist-inbound.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ export function makeInbound(state, stateKit) {
const remote = getRemote(state, remoteID);
const lpid = remote.fromRemote.get(rpid);
assert(lpid, X`unknown remote ${remoteID} promise ${rpid}`);
assert(
remote.toRemote.has(lpid),
X`unmapped remote ${remoteID} promise ${lpid}`,
);
const p = state.promiseTable.get(lpid);
assert(
!p.subscribers || p.subscribers.indexOf(remoteID) === -1,
Expand All @@ -46,10 +42,13 @@ export function makeInbound(state, stateKit) {
cdebug(`comms delete mapping r<->k ${remoteID} {rpid}<=>${lpid}`);
}

function enqueueRemotePromiseIDRetirement(remoteID, rpid) {
function beginRemotePromiseIDRetirement(remoteID, rpid) {
insistRemoteType('promise', rpid);
const remote = getRemote(state, remoteID);
const lpid = remote.fromRemote.get(flipRemoteSlot(rpid));
remote.toRemote.delete(lpid);
remote.retirementQueue.push([remote.nextSendSeqNum, rpid]);
cdebug(`comms begin retiring ${remoteID} ${rpid} ${lpid}`);
}

function retireAcknowledgedRemotePromiseIDs(remoteID, ackSeqNum) {
Expand Down Expand Up @@ -145,7 +144,7 @@ export function makeInbound(state, stateKit) {
getLocalForRemote,
provideLocalForRemoteResult,
retireRemotePromiseID,
enqueueRemotePromiseIDRetirement,
beginRemotePromiseIDRetirement,
retireAcknowledgedRemotePromiseIDs,
});
}
4 changes: 2 additions & 2 deletions packages/SwingSet/src/vats/comms/clist.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function makeCListKit(state, syscall, stateKit) {
getLocalForRemote,
provideLocalForRemoteResult,
retireRemotePromiseID,
enqueueRemotePromiseIDRetirement,
beginRemotePromiseIDRetirement,
retireAcknowledgedRemotePromiseIDs,
} = makeInbound(state, stateKit);

Expand Down Expand Up @@ -87,7 +87,7 @@ export function makeCListKit(state, syscall, stateKit) {
getLocalForRemote,
provideLocalForRemoteResult,
retireRemotePromiseID,
enqueueRemotePromiseIDRetirement,
beginRemotePromiseIDRetirement,
retireAcknowledgedRemotePromiseIDs,

getRemoteForLocal,
Expand Down
12 changes: 9 additions & 3 deletions packages/SwingSet/src/vats/comms/delivery.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-check
/* eslint-disable no-use-before-define */

import { assert, details as X } from '@agoric/assert';
Expand All @@ -22,7 +23,7 @@ export function makeDeliveryKit(state, syscall, transmit, clistKit, stateKit) {
provideLocalForRemote,
provideLocalForRemoteResult,
retireRemotePromiseID,
enqueueRemotePromiseIDRetirement,
beginRemotePromiseIDRetirement,
retireAcknowledgedRemotePromiseIDs,

getKernelForLocal,
Expand Down Expand Up @@ -123,13 +124,15 @@ export function makeDeliveryKit(state, syscall, transmit, clistKit, stateKit) {
handleResolutions(localResolutions);
}

/** @type { (remoteID: string, ackSeqNum: number) => void } */
function handleAckFromRemote(remoteID, ackSeqNum) {
retireAcknowledgedRemotePromiseIDs(remoteID, ackSeqNum);
}

// dispatch.deliver with msg from vattp lands here, containing a message
// from some remote machine. figure out whether it's a deliver or a
// resolve, parse, merge with handleSend/handleResolutions
/** @type { (remoteID: string, message: string, result?: string) => void} */
function messageFromRemote(remoteID, message, result) {
if (result) {
// TODO: eventually, the vattp vat will be changed to send the 'receive'
Expand All @@ -156,7 +159,10 @@ export function makeDeliveryKit(state, syscall, transmit, clistKit, stateKit) {
delim2 >= 0,
X`received message ${message} lacks ackSeqNum delimiter`,
);
const ackSeqNum = message.substring(delim1 + 1, delim2);
const ackSeqNum = Number.parseInt(
message.substring(delim1 + 1, delim2),
10,
);
handleAckFromRemote(remoteID, ackSeqNum);

const msgBody = message.substring(delim2 + 1);
Expand Down Expand Up @@ -489,7 +495,7 @@ export function makeDeliveryKit(state, syscall, transmit, clistKit, stateKit) {
const rejectedTag = rejected ? 'reject' : 'fulfill';
// prettier-ignore
msgs.push(`resolve:${rejectedTag}:${rpid}${mapSlots()};${data.body}`);
enqueueRemotePromiseIDRetirement(remoteID, rpid);
beginRemotePromiseIDRetirement(remoteID, rpid);
}
transmit(remoteID, msgs.join('\n'));
}
Expand Down
3 changes: 1 addition & 2 deletions packages/SwingSet/test/message-patterns.js
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,6 @@ export function buildPatterns(log) {
const pa3 = (await pa2)[0];
const pb3 = (await pb2)[0];
log(`${pb3 !== pa3}`);
log(`${pb3 === pa2}`);
log(`${pa3 === pb2}`);
} catch (e) {
log(`a100 await failed with ${e}`);
Expand All @@ -947,7 +946,7 @@ export function buildPatterns(log) {
p2.resolve(apa);
};
}
out.a100 = ['true', 'true', 'true'];
out.a100 = ['true', 'true'];

// TODO: kernel-allocated promise, either comms or kernel resolves it,
// comms needs to send into kernel again
Expand Down

0 comments on commit 235957b

Please sign in to comment.