Skip to content

Commit

Permalink
fix(solo): get repl working again
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Mar 2, 2020
1 parent 0890171 commit a42cfec
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
4 changes: 3 additions & 1 deletion packages/SwingSet/src/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
9 changes: 5 additions & 4 deletions packages/cosmic-swingset/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
10 changes: 2 additions & 8 deletions packages/cosmic-swingset/lib/ag-solo/fake-chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -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".
Expand Down
8 changes: 8 additions & 0 deletions packages/cosmic-swingset/lib/ag-solo/html/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions packages/cosmic-swingset/lib/ag-solo/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ async function buildSwingset(

async function processKernel() {
await controller.run();
await saveState();
if (swingSetRunning) {
await saveState();
deliverOutbound();
}
}
Expand All @@ -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();
}
}
Expand Down

0 comments on commit a42cfec

Please sign in to comment.