diff --git a/packages/SwingSet/src/controller.js b/packages/SwingSet/src/controller.js index 5be5f7c9625..2b16c852610 100644 --- a/packages/SwingSet/src/controller.js +++ b/packages/SwingSet/src/controller.js @@ -27,7 +27,9 @@ import { insistCapData } from './capdata'; import { parseVatSlot } from './parseVatSlots'; // FIXME: Put this somewhere better. -process.on('unhandledRejection', e => console.log('unhandledRejection', e)); +process.on('unhandledRejection', e => + console.log('UnhandledPromiseRejectionWarning:', e), +); const ADMIN_DEVICE_PATH = require.resolve('./kernel/vatAdmin/vatAdmin-src'); const ADMIN_VAT_PATH = require.resolve('./kernel/vatAdmin/vatAdminWrapper'); diff --git a/packages/cosmic-swingset/Makefile b/packages/cosmic-swingset/Makefile index 138af4babdd..5701e1386dd 100644 --- a/packages/cosmic-swingset/Makefile +++ b/packages/cosmic-swingset/Makefile @@ -3,8 +3,8 @@ CHAIN_ID = agoric INITIAL_TOKENS = 1000agmedallion # By default, make the fake chain in scenario3 produce -# "blocks" at 5-second intervals. -FAKE_CHAIN_DELAY = 5 +# "blocks" as soon as they come in. +FAKE_CHAIN_DELAY = 0 NUM_SOLOS?=1 BASE_PORT?=8000 @@ -102,13 +102,14 @@ scenario2-run-client: scenario3-setup: rm -rf t3 bin/ag-solo init t3 --egresses=fake - (cd t3 && \ - ../bin/ag-solo set-fake-chain --role=two_chain --delay=$(FAKE_CHAIN_DELAY) myFakeGCI) @echo 'Execute `make scenario3-run` to run the client and simulated chain' # This runs both the client and the fake chain. scenario3-run-client: scenario3-run +# Set the fake chain here in case the delay has changed. scenario3-run: + (cd t3 && \ + ../bin/ag-solo set-fake-chain --role=two_chain --delay=$(FAKE_CHAIN_DELAY) myFakeGCI) cd t3 && ../bin/ag-solo start --role=two_client # These rules are the old scenario3. No fake delay at all. diff --git a/packages/cosmic-swingset/lib/ag-solo/fake-chain.js b/packages/cosmic-swingset/lib/ag-solo/fake-chain.js index 9df16309d73..efc7ea21a98 100644 --- a/packages/cosmic-swingset/lib/ag-solo/fake-chain.js +++ b/packages/cosmic-swingset/lib/ag-solo/fake-chain.js @@ -51,16 +51,10 @@ export async function connectToFakeChain(basedir, GCI, role, delay, inbound) { try { const commitStamp = pretendLast + PRETEND_BLOCK_DELAY * 1000; const blockTime = Math.floor(commitStamp / 1000); - await deliverStartBlock(blockHeight, blockTime); + await deliverStartBlock(blockHeight, blockTime, true); for (let i = 0; i < thisBlock.length; i += 1) { const [newMessages, acknum] = thisBlock[i]; - await deliverInbound( - bootAddress, - newMessages, - acknum, - blockHeight, - blockTime, - ); + await deliverInbound(bootAddress, newMessages, acknum, true); } // Done processing, "commit the block". diff --git a/packages/cosmic-swingset/lib/ag-solo/html/main.js b/packages/cosmic-swingset/lib/ag-solo/html/main.js index 3844036a4c1..a9602c66eec 100644 --- a/packages/cosmic-swingset/lib/ag-solo/html/main.js +++ b/packages/cosmic-swingset/lib/ag-solo/html/main.js @@ -125,6 +125,14 @@ function run() { console.error(`error resetting`, e); } } + call({ type: 'getHighestHistory' }) + .then(res => { + // eslint-disable-next-line no-use-before-define + setNextHistNum(res.highestHistory + 1); + // console.log(`nextHistNum is now ${nextHistNum}`, res); + }) + .then(_ => call({ type: 'rebroadcastHistory' })) + .catch(_ => ws.close()); }); const inp = document.getElementById('input'); diff --git a/packages/cosmic-swingset/lib/ag-solo/start.js b/packages/cosmic-swingset/lib/ag-solo/start.js index a2ab3d8f67e..c3941b6de6d 100644 --- a/packages/cosmic-swingset/lib/ag-solo/start.js +++ b/packages/cosmic-swingset/lib/ag-solo/start.js @@ -117,8 +117,8 @@ async function buildSwingset( async function processKernel() { await controller.run(); - await saveState(); if (swingSetRunning) { + await saveState(); deliverOutbound(); } } @@ -128,7 +128,7 @@ async function buildSwingset( throw new Error(`inbound given non-Array: ${messages}`); } // console.log(`deliverInboundToMbx`, messages, ack); - if (mb.deliverInbound(sender, messages, ack)) { + if (mb.deliverInbound(sender, messages, ack, true)) { await processKernel(); } }