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

populate deliveryResult in all workers #1775

Closed
warner opened this issue Sep 16, 2020 · 0 comments
Closed

populate deliveryResult in all workers #1775

warner opened this issue Sep 16, 2020 · 0 comments
Labels
bug Something isn't working SwingSet package: SwingSet

Comments

@warner
Copy link
Member

warner commented Sep 16, 2020

Currently our various worker types aren't returning the deliveryResult from deliver messages sent to that worker. This causes a crash as soon as the first delivery is complete.

The necessary diff is something like this:

diff --git a/packages/SwingSet/src/kernel/vatManager/nodeWorker.js b/packages/SwingSet/src/kernel/vatManager/nodeWorker.js
index 651eb20f..90bd6ca7 100644
--- a/packages/SwingSet/src/kernel/vatManager/nodeWorker.js
+++ b/packages/SwingSet/src/kernel/vatManager/nodeWorker.js
@@ -98,7 +98,8 @@ export function makeNodeWorkerVatManagerFactory(tools) {
         if (waiting) {
           const resolve = waiting;
           waiting = null;
-          resolve();
+          const deliveryResult = args;
+          resolve(deliveryResult);
         }
       } else {
         parentLog(`unrecognized uplink message ${type}`);
diff --git a/packages/SwingSet/src/kernel/vatManager/nodeWorkerSupervisor.js b/packages/SwingSet/src/kernel/vatManager/nodeWorkerSupervisor.js
index 08cc1e91..723b6e02 100644
--- a/packages/SwingSet/src/kernel/vatManager/nodeWorkerSupervisor.js
+++ b/packages/SwingSet/src/kernel/vatManager/nodeWorkerSupervisor.js
@@ -66,7 +66,6 @@ function doNotify(vpid, vp) {
   }
 }
 
-let syscallLog;
 parentPort.on('message', ([type, ...margs]) => {
   workerLog(`received`, type);
   if (type === 'start') {
@@ -128,10 +129,10 @@ parentPort.on('message', ([type, ...margs]) => {
         ['deliver', targetSlot, msg.method, msg.args, msg.result],
         errmsg,
       ).then(() => {
-        sendUplink(['deliverDone']);
+        sendUplink(['deliverDone', 'ok']);
       });
     } else if (dtype === 'notify') {
-      doNotify(...dargs).then(() => sendUplink(['deliverDone', syscallLog]));
+      doNotify(...dargs).then(() => sendUplink(['deliverDone', 'ok'])); // TODO test in test-worker.js
     } else {
       throw Error(`bad delivery type ${dtype}`);
     }
diff --git a/packages/SwingSet/src/kernel/vatManager/subprocessSupervisor.js b/packages/SwingSet/src/kernel/vatManager/subprocessSupervisor.js
index 74326c46..218f724b 100644
--- a/packages/SwingSet/src/kernel/vatManager/subprocessSupervisor.js
+++ b/packages/SwingSet/src/kernel/vatManager/subprocessSupervisor.js
@@ -80,7 +80,6 @@ function sendUplink(msg) {
 //  toParent.write('child ack');
 // });
 
-let syscallLog;
 fromParent.on('data', data => {
   const [type, ...margs] = JSON.parse(data);
   workerLog(`received`, type);
@@ -143,10 +144,10 @@ fromParent.on('data', data => {
         ['deliver', targetSlot, msg.method, msg.args, msg.result],
         errmsg,
       ).then(() => {
-        sendUplink(['deliverDone']);
+        sendUplink(['deliverDone', 'ok']);
       });
     } else if (dtype === 'notify') {
-      doNotify(...dargs).then(() => sendUplink(['deliverDone', syscallLog]));
+      doNotify(...dargs).then(() => sendUplink(['deliverDone', 'ok'])); // TODO exercise this in test-worker.js
     } else {
       throw Error(`bad delivery type ${dtype}`);
     }
diff --git a/packages/SwingSet/src/kernel/vatManager/worker-subprocess-node.js b/packages/SwingSet/src/kernel/vatManager/worker-subprocess-node.js
index d4f5e03f..dca94811 100644
--- a/packages/SwingSet/src/kernel/vatManager/worker-subprocess-node.js
+++ b/packages/SwingSet/src/kernel/vatManager/worker-subprocess-node.js
@@ -98,7 +98,8 @@ export function makeNodeSubprocessFactory(tools) {
         if (waiting) {
           const resolve = waiting;
           waiting = null;
-          resolve();
+          const deliveryResult = args;
+          resolve(deliveryResult);
         }
       } else {
         parentLog(`unrecognized uplink message ${type}`);

except that we need to notify the kernel about failure cases too.

The XS worker needs the same change, something like:

diff --git a/packages/xs-vat-worker/src/vatWorker.js b/packages/xs-vat-worker/src/vatWorker.js
index cfdfc58a..8dfccc4e 100644
--- a/packages/xs-vat-worker/src/vatWorker.js
+++ b/packages/xs-vat-worker/src/vatWorker.js
@@ -82,7 +82,6 @@ function makeWorker(io, setImmediate) {
   //  toParent.write('child ack');
   // });
 
-  let syscallLog;
   const handle = harden(async ([type, ...margs]) => {
     workerLog(`received`, type);
     if (type === 'start') {
@@ -150,11 +151,11 @@ function makeWorker(io, setImmediate) {
           ['deliver', targetSlot, msg.method, msg.args, msg.result],
           errmsg,
         ).then(() => {
-          sendUplink(['deliverDone']);
+          sendUplink(['deliverDone', 'ok']);
         });
       } else if (dtype === 'notify') {
         await doNotify(...dargs).then(() =>
-          sendUplink(['deliverDone', syscallLog]),
+          sendUplink(['deliverDone', 'ok']),
         );
       } else {
         throw Error(`bad delivery type ${dtype}`);

There was a syscallLog entry left over in a couple of workers. I think that either goes away, or is replaced with a testLog array (to be merged into the log array that local workers write into with their own testLog).

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

No branches or pull requests

1 participant