Skip to content

Commit

Permalink
fix: don't get GCI from gci.js; use kernel argv.FIXME_GCI instead
Browse files Browse the repository at this point in the history
This is labeled FIXME_GCI because the method only supports a
single chain.  We ideally should move to connections-as-objects
so that they can have customised setup instead of cases in a
switch statement.
  • Loading branch information
michaelfig committed Apr 25, 2021
1 parent 959b3bc commit f994574
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 18 deletions.
6 changes: 0 additions & 6 deletions packages/cosmic-swingset/lib/ag-solo/set-gci-ingress.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,4 @@ export default function setGCIIngress(basedir, GCI, rpcAddresses, chainID) {
connections.push(...conns),
);
fs.writeFileSync(fn, `${JSON.stringify(connections, undefined, 2)}\n`);

const gciFileContents = `\
export const GCI = ${JSON.stringify(GCI)};
`;
const bfn = path.join(basedir, 'vats', 'gci.js');
fs.writeFileSync(bfn, gciFileContents);
}
16 changes: 15 additions & 1 deletion packages/cosmic-swingset/lib/ag-solo/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,25 @@ export default async function start(basedir, argv) {

const vatsDir = path.join(basedir, 'vats');
const stateDBDir = path.join(basedir, 'swingset-kernel-state');

// FIXME: Replace this functionality with per-connection bootstrap code.
const getLegacyGCI = () => {
for (const c of connections) {
switch (c.type) {
case 'chain-cosmos-sdk':
case 'fake-chain':
return { FIXME_GCI: c.GCI };
default:
}
}
return undefined;
};

const d = await buildSwingset(
stateDBDir,
mailboxStateFile,
vatsDir,
argv,
{ ...getLegacyGCI(), ...argv },
broadcast,
defaultManagerType,
);
Expand Down
16 changes: 10 additions & 6 deletions packages/cosmic-swingset/lib/ag-solo/vats/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@ import { makeStore } from '@agoric/store';
import { installOnChain as installTreasuryOnChain } from '@agoric/treasury/bundles/install-on-chain';
import { installOnChain as installPegasusOnChain } from '@agoric/pegasus/bundles/install-on-chain';

// this will return { undefined } until `ag-solo set-gci-ingress`
// has been run to update gci.js
import { makePluginManager } from '@agoric/swingset-vat/src/vats/plugin-manager';
import { assert, details as X } from '@agoric/assert';
import { makeRatio } from '@agoric/zoe/src/contractSupport';
import { amountMath, MathKind } from '@agoric/ertp';
import { GCI } from './gci';
import { makeBridgeManager } from './bridge';
import { makeNameHubKit } from './nameHub';
import {
Expand Down Expand Up @@ -678,6 +675,13 @@ export function buildRootObject(vatPowers, vatParameters) {
devices.bridge && makeBridgeManager(E, D, devices.bridge);
const {
ROLE,
// TODO: Don't make client bootstrap dependent on having just zero or
// one chains. Instead, supply all the connections as input to the
// bootstrap (or have other ways of initializing per-connection
// bootstrap code). Also use an abstract name for the connection
// instead of GCI so that a given chain can be followed across a GCI
// change such as in a hard-fork.
FIXME_GCI,
giveMeAllTheAgoricPowers,
noFakeCurrencies,
hardcodedClientAddresses,
Expand Down Expand Up @@ -724,7 +728,7 @@ export function buildRootObject(vatPowers, vatParameters) {

// ag-setup-solo runs this.
case 'client': {
assert(GCI, X`client must be given GCI`);
assert(FIXME_GCI, X`client must be given GCI`);

const localTimerService = await E(vats.timer).createTimerService(
devices.timer,
Expand All @@ -734,10 +738,10 @@ export function buildRootObject(vatPowers, vatParameters) {
await setupCommandDevice(vats.http, devices.command, {
client: true,
});
await addRemote(GCI);
await addRemote(FIXME_GCI);
// addEgress(..., index, ...) is called in vat-provisioning.
const demoProvider = await E(vats.comms).addIngress(
GCI,
FIXME_GCI,
PROVISIONER_INDEX,
);
const localBundle = await createLocalBundle(
Expand Down
5 changes: 0 additions & 5 deletions packages/cosmic-swingset/lib/ag-solo/vats/gci.js

This file was deleted.

0 comments on commit f994574

Please sign in to comment.