Skip to content

Commit

Permalink
fix(cosmic-swingset): finish reorganization
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Apr 25, 2021
1 parent 0780be8 commit 7aa778f
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 70 deletions.
21 changes: 11 additions & 10 deletions packages/cosmic-swingset/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ INITIAL_HEIGHT = 17
GENESIS_TIME = $(shell TZ=UTC date +%Y-%m-%dT%H:%M:%SZ)

GOSRC = ../../golang/cosmos
AG_SOLO = $(shell cd ../solo/bin && pwd)/ag-solo

# By default, make the fake chain in scenario3 produce
# "blocks" as soon as they come in.
Expand Down Expand Up @@ -32,7 +33,7 @@ scenario0-setup:
rm -rf t9/$(BASE_PORT)

scenario0-run scenario0-run-client:
AG_SOLO_BASEDIR=$$PWD/t9/$(BASE_PORT) bin/ag-solo setup --webport=$(BASE_PORT)
AG_SOLO_BASEDIR=$$PWD/t9/$(BASE_PORT) $(AG_SOLO) setup --webport=$(BASE_PORT)
scenario0-run-chain:
@echo 'We use the Agoric testnet, not a local chain.'

Expand All @@ -43,7 +44,7 @@ scenario1-run-chain:
AG_SETUP_COSMOS_HOME=t8 ../deployment/ag-setup-cosmos bootstrap

scenario1-run-client:
AG_SOLO_BASEDIR=$$PWD/t9/$(BASE_PORT) bin/ag-solo setup --network-config=http://localhost:8001/network-config --webport=$(BASE_PORT)
AG_SOLO_BASEDIR=$$PWD/t9/$(BASE_PORT) $(AG_SOLO) setup --network-config=http://localhost:8001/network-config --webport=$(BASE_PORT)

AGC = ./bin/ag-chain-cosmos
AGCH = ag-cosmos-helper
Expand All @@ -55,7 +56,7 @@ scenario2-setup-nobuild:
$(AGCH) --home=t1/n0 init scenario2-chain --chain-id=$(CHAIN_ID)
# Init all the ag-solos.
set -e; for port in `seq $(BASE_PORT) $$(($(BASE_PORT) + $(NUM_SOLOS) - 1))`; do \
bin/ag-solo init t1/$$port --webport=$$port; \
$(AG_SOLO) init t1/$$port --webport=$$port; \
done
# Create the bootstrap account.
$(AGCH) --home=t1/bootstrap keys add bootstrap --keyring-backend=test
Expand Down Expand Up @@ -97,7 +98,7 @@ t1-provision-one:

# Actually start the ag-solo.
t1-start-ag-solo:
cd t1/$(BASE_PORT) && ../../bin/ag-solo start
cd t1/$(BASE_PORT) && $(AG_SOLO) start

# scenario3 is a single JS process without any Golang. However,
# the client and the chain within the process run two separate
Expand All @@ -110,18 +111,18 @@ t1-start-ag-solo:
VATWORKER=local
scenario3-setup:
rm -rf t3
bin/ag-solo init t3 --egresses=fake --webport=$(BASE_PORT) --defaultManagerType=$(VATWORKER)
$(AG_SOLO) init t3 --egresses=fake --webport=$(BASE_PORT) --defaultManagerType=$(VATWORKER)
@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 --delay=$(FAKE_CHAIN_DELAY) mySimGCI
$(AG_SOLO) set-fake-chain --delay=$(FAKE_CHAIN_DELAY) mySimGCI
cd t3 && \
OTEL_EXPORTER_PROMETHEUS_PORT=$(OTEL_EXPORTER_PROMETHEUS_PORT) \
../bin/ag-solo start
$(AG_SOLO) start

docker-pull:
for f in '' -setup -solo; do \
Expand All @@ -146,8 +147,8 @@ install:

start-ag-solo:
rm -rf t1
bin/ag-solo init t1
cd t1 && ../bin/ag-solo start
$(AG_SOLO) init t1
cd t1 && $(AG_SOLO) start

show-local-gci:
@./calc-gci.js ~/.ag-chain-cosmos/config/genesis.json
Expand All @@ -158,5 +159,5 @@ set-local-gci-ingress:
rpcport=`./calc-rpcport.js t1/n0/config/config.toml`; \
for dir in t1/[0-9]*; do \
(cd $$dir && \
../../bin/ag-solo set-gci-ingress --chainID=$(CHAIN_ID) $$gci $$rpcport); \
$(AG_SOLO) set-gci-ingress --chainID=$(CHAIN_ID) $$gci $$rpcport); \
done
2 changes: 1 addition & 1 deletion packages/cosmic-swingset/bin/ag-chain-cosmos
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ while test $# -gt 0; do
shift
done

exec node ${nodeFlags[@]} "$thisdir/../lib/chain-entrypoint.js" ${1+"$@"}
exec node ${nodeFlags[@]} "$thisdir/../src/chain-entrypoint.cjs" ${1+"$@"}
2 changes: 1 addition & 1 deletion packages/cosmic-swingset/jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
"strictNullChecks": true,
"moduleResolution": "node",
},
"include": ["lib/**/*.js", "exported.js", "globals.d.ts"],
"include": ["src/**/*.js", "exported.js"],
}
42 changes: 6 additions & 36 deletions packages/cosmic-swingset/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
"parsers": {
"js": "mjs"
},
"main": "lib/ag-solo/main.js",
"bin": {
"ag-chain-cosmos": "./src/chain-entrypoint.cjs"
},
"main": "src/chain-main.js",
"repository": "https://github.com/Agoric/agoric-sdk",
"scripts": {
"build": "exit 0",
Expand All @@ -25,53 +28,20 @@
"license": "Apache-2.0",
"dependencies": {
"@agoric/assert": "^0.2.9",
"@agoric/babel-parser": "^7.6.4",
"@agoric/bundle-source": "^1.3.4",
"@agoric/captp": "^1.7.10",
"@agoric/cosmos": "^0.25.4",
"@agoric/dapp-svelte-wallet": "^0.9.4",
"@agoric/ertp": "^0.10.8",
"@agoric/eventual-send": "^0.13.11",
"@agoric/import-bundle": "^0.2.11",
"@agoric/install-metering-and-ses": "^0.2.10",
"@agoric/install-ses": "^0.5.10",
"@agoric/marshal": "^0.4.8",
"@agoric/nat": "^4.0.0",
"@agoric/notifier": "^0.3.11",
"@agoric/pegasus": "^0.2.4",
"@agoric/promise-kit": "^0.2.10",
"@agoric/registrar": "^0.2.11",
"@agoric/same-structure": "^0.1.10",
"@agoric/sharing-service": "^0.1.11",
"@agoric/sparse-ints": "^0.1.6",
"@agoric/spawner": "^0.4.11",
"@agoric/store": "^0.4.11",
"@agoric/swing-store-lmdb": "^0.4.9",
"@agoric/swing-store-simple": "^0.3.6",
"@agoric/swingset-vat": "^0.16.4",
"@agoric/transform-eventual-send": "^1.4.6",
"@agoric/treasury": "^0.3.4",
"@agoric/zoe": "^0.15.4",
"@babel/generator": "^7.6.4",
"@agoric/vats": "^0.1.0",
"@iarna/toml": "^2.2.3",
"@opentelemetry/exporter-prometheus": "^0.16.0",
"@opentelemetry/metrics": "^0.16.0",
"agoric": "^0.12.13",
"anylogger": "^0.21.0",
"chalk": "^2.4.2",
"deterministic-json": "^1.0.5",
"esm": "^3.2.25",
"express": "^4.17.1",
"minimist": "^1.2.0",
"morgan": "^1.9.1",
"n-readlines": "^1.0.0",
"node-fetch": "^2.6.0",
"node-lmdb": "^0.9.4",
"polycrc": "https://github.com/agoric-labs/node-polycrc",
"rollup": "^1.26.2",
"rollup-plugin-node-resolve": "^5.2.0",
"temp": "^0.9.1",
"ws": "^7.2.0"
"esm": "^3.2.25"
},
"devDependencies": {
"ava": "^3.12.1",
Expand Down
12 changes: 4 additions & 8 deletions packages/cosmic-swingset/src/chain-main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global __dirname setInterval */
/* global require setInterval */
import stringify from '@agoric/swingset-vat/src/kernel/json-stable-stringify';
import {
importMailbox,
Expand Down Expand Up @@ -77,11 +77,7 @@ const makeChainStorage = (call, prefix = '', imp = x => x, exp = x => x) => {
return storage;
};

export default async function main(
progname,
args,
{ path, env, homedir, agcc },
) {
export default async function main(progname, args, { env, homedir, agcc }) {
const portNums = {};

// TODO: use the 'basedir' pattern
Expand Down Expand Up @@ -224,7 +220,7 @@ export default async function main(
}
}

const vatsdir = path.resolve(__dirname, '../lib/ag-solo/vats');
const vatconfig = require.resolve('@agoric/vats/decentral-config.json');
const argv = {
ROLE: 'chain',
noFakeCurrencies: env.NO_FAKE_CURRENCIES,
Expand All @@ -235,7 +231,7 @@ export default async function main(
stateDBDir,
mailboxStorage,
doOutboundBridge,
vatsdir,
vatconfig,
argv,
undefined,
meterProvider,
Expand Down
12 changes: 6 additions & 6 deletions packages/cosmic-swingset/src/launch-chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
loadSwingsetConfigFile,
} from '@agoric/swingset-vat';
import { assert, details as X } from '@agoric/assert';
import { getBestSwingStore } from './check-lmdb';
import { getBestSwingStore } from '@agoric/swing-store-lmdb/check-lmdb';
import {
DEFAULT_METER_PROVIDER,
exportKernelStats,
Expand All @@ -32,14 +32,14 @@ async function buildSwingset(
mailboxStorage,
bridgeOutbound,
storage,
vatsDir,
vatconfig,
argv,
{ debugName = undefined, slogCallbacks, slogFile },
) {
const debugPrefix = debugName === undefined ? '' : `${debugName}:`;
let config = loadSwingsetConfigFile(`${vatsDir}/chain-config.json`);
let config = loadSwingsetConfigFile(vatconfig);
if (config === null) {
config = loadBasedir(vatsDir);
config = loadBasedir(vatconfig);
}
const mbs = buildMailboxStateMap(mailboxStorage);
const timer = buildTimer();
Expand Down Expand Up @@ -89,7 +89,7 @@ export async function launch(
kernelStateDBDir,
mailboxStorage,
bridgeOutbound,
vatsDir,
vatconfig,
argv,
debugName = undefined,
meterProvider = DEFAULT_METER_PROVIDER,
Expand All @@ -115,7 +115,7 @@ export async function launch(
mailboxStorage,
bridgeOutbound,
storage,
vatsDir,
vatconfig,
argv,
{
debugName,
Expand Down
16 changes: 8 additions & 8 deletions packages/cosmic-swingset/src/sim-chain.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global process setTimeout clearTimeout */
/* global require process setTimeout clearTimeout */
/* eslint-disable no-await-in-loop */
import path from 'path';
import fs from 'fs';
Expand All @@ -11,11 +11,11 @@ import {
import anylogger from 'anylogger';

import { assert, details as X } from '@agoric/assert';
import { launch } from '../launch-chain';
import makeBlockManager from '../block-manager';
import { makeWithQueue } from './vats/queue';
import { makeBatchedDeliver } from './batched-deliver';
import { getMeterProvider } from '../kernel-stats';
import { makeWithQueue } from '@agoric/vats/src/queue';
import { makeBatchedDeliver } from '@agoric/vats/src/batched-deliver';
import { launch } from './launch-chain';
import makeBlockManager from './block-manager';
import { getMeterProvider } from './kernel-stats';

const console = anylogger('fake-chain');

Expand Down Expand Up @@ -51,7 +51,7 @@ export async function connectToFakeChain(basedir, GCI, delay, inbound) {

const mailboxStorage = await makeMapStorage(mailboxFile);

const vatsdir = path.join(basedir, 'vats');
const vatconfig = require.resolve('@agoric/vats/decentral-config.json');
const argv = {
ROLE: 'sim-chain',
giveMeAllTheAgoricPowers: true,
Expand All @@ -68,7 +68,7 @@ export async function connectToFakeChain(basedir, GCI, delay, inbound) {
stateDBdir,
mailboxStorage,
undefined,
vatsdir,
vatconfig,
argv,
GCI, // debugName
meterProvider,
Expand Down

0 comments on commit 7aa778f

Please sign in to comment.