diff --git a/packages/SwingSet/src/kernel/kernel.js b/packages/SwingSet/src/kernel/kernel.js index c85373c467b..0e0674d7aa9 100644 --- a/packages/SwingSet/src/kernel/kernel.js +++ b/packages/SwingSet/src/kernel/kernel.js @@ -428,18 +428,13 @@ export default function buildKernel( // eslint-disable-next-line no-use-before-define assert(vatWarehouse.lookup(vatID)); const vatKeeper = kernelKeeper.provideVatKeeper(vatID); - const crankNum = kernelKeeper.getCrankNumber(); - const deliveryNum = vatKeeper.nextDeliveryNum(); // increments const { meterID } = vatKeeper.getOptions(); - /** @type { SlogFinishDelivery } */ - const finish = kernelSlog.delivery(vatID, crankNum, deliveryNum, kd, vd); // Ensure that the vatSlogger is available before clist translation. - kernelSlog.provideVatSlogger(vatID); + const vs = kernelSlog.provideVatSlogger(vatID).vatSlog; try { // eslint-disable-next-line no-use-before-define - const deliveryResult = await vatWarehouse.deliverToVat(vatID, vd); + const deliveryResult = await vatWarehouse.deliverToVat(vatID, kd, vd, vs); insistVatDeliveryResult(deliveryResult); - finish(deliveryResult); const [status, problem] = deliveryResult; if (status !== 'ok') { // probably a metering fault, or a bug in the vat's dispatch() diff --git a/packages/SwingSet/src/kernel/vatManager/vat-warehouse.js b/packages/SwingSet/src/kernel/vatManager/vat-warehouse.js index ceea90ec508..69ef0320dbc 100644 --- a/packages/SwingSet/src/kernel/vatManager/vat-warehouse.js +++ b/packages/SwingSet/src/kernel/vatManager/vat-warehouse.js @@ -1,6 +1,7 @@ // @ts-check import { assert, details as X, quote as q } from '@agoric/assert'; import { makeVatTranslators } from '../vatTranslator.js'; +import { insistVatDeliveryResult } from '../../message.js'; /** @param { number } max */ export const makeLRU = max => { @@ -257,14 +258,29 @@ export function makeVatWarehouse(kernelKeeper, vatLoader, policyOptions) { /** @type { string | undefined } */ let lastVatID; - /** @type {(vatID: string, d: VatDeliveryObject) => Promise } */ - async function deliverToVat(vatID, delivery) { + /** @type {(vatID: string, kd: KernelDeliveryObject, d: VatDeliveryObject, vs: VatSlog) => Promise } */ + async function deliverToVat(vatID, kd, vd, vs) { await applyAvailabilityPolicy(vatID); lastVatID = vatID; const recreate = true; // PANIC in the failure case + // create the worker and replay the transcript, if necessary const { manager } = await ensureVatOnline(vatID, recreate); - return manager.deliver(delivery); + + // then log the delivery so it appears after transcript replay + const vatKeeper = kernelKeeper.provideVatKeeper(vatID); + const crankNum = kernelKeeper.getCrankNumber(); + const deliveryNum = vatKeeper.nextDeliveryNum(); // increments + /** @type { SlogFinishDelivery } */ + const slogFinish = vs.delivery(crankNum, deliveryNum, kd, vd); + + // make the delivery + const deliveryResult = await manager.deliver(vd); + insistVatDeliveryResult(deliveryResult); + + // log the delivery results, and return to caller for evaluation + slogFinish(deliveryResult); + return deliveryResult; } /**