Agoric / agoric-sdk

monorepo for the Agoric Javascript smart contract platform
Apache License 2.0
323 stars 200 forks source link

swingset-runner demos are not runnable #3699

Open danwt opened 2 years ago

danwt commented 2 years ago

Surfaced from @informalsystems audit of Agoric/agoric-sdk/SwingSet at hash d0a731799eaaca92ec94107fa81363a0cae37d33

The bug

The demos in swingset-runner/demo are not runnable using bin/runner run demo/<bot name> for even the simplest demos that should not require additional flags (encouragementBot, ect).

To Reproduce

Steps to reproduce the behavior:

  1. Checkout latest commit (d0a7317)
  2. Try to run demos

Expected behavior

The demos should run but instead this error or similar is given

UnhandledPromiseRejectionWarning: (SyntaxError#1)
SyntaxError#1: Unexpected token u in JSON at position 0

  at JSON.parse (<anonymous>)
  at makeSwingsetController (packages/SwingSet/src/controller.js:208:29)
  at main (packages/swingset-runner/src/main.js:412:28)
  at packages/swingset-runner/src/runner-entrypoint.js:21:1

Platform Environment

warner commented 2 years ago

@arirubinstein and found that bin/runner --init run demo/encouragementBot works correctly.

The JSON problem means that the DB was not initialized prior to execution. The --init means "initialize the DB, then run". Omitting --init requires that you've initialized the DB already (I think there's some other command to initialize but not run).

The docs need to be updated to reflect this usage. I think we went back and forth on the best way for a CLI tool to express the different combinations (and not accidentally clobbering the DB when you didn't mean to) and settled on this one, but it assumes that running one step at a time (thus calling runner more than once) is the most common usage, and I think it'd probably be nicer to have the shortest command also be standalone.