Skip to content

Commit

Permalink
require bridge in cosmic-swingset (#9761)
Browse files Browse the repository at this point in the history
refs: #9725

## Description
On the path to,
- #9725 

Remove concessions in SwingSet to `@agoric/cosmic-swingset/src/sim-chain.js` by requiring a bridgeDevice.

Since `sim-chain` is no longer supported, we remove the ability to use it from `@agoric/solo`.  This makes several of the tests in `@agoric/solo` fail, so we skip those that relied on `sim-chain`, while continuing to test the `ag-solo` basic functionality.   We don't remove `@agoric/solo` because it serves as an example of a non-chain SwingSet application, and @michaelfig would like to refactor it into a configuration of a general `agvm` program.

### Security Considerations
none

### Scaling Considerations
none

### Documentation Considerations
none

### Testing Considerations
CI suffices

### Upgrade Considerations

On-chain uses always provide a bridge device. This does affect line numbers. It will go out with the next kernel upgrade.
  • Loading branch information
mergify[bot] authored Jul 26, 2024
2 parents 0c96ea5 + da75a03 commit bf791ed
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 44 deletions.
30 changes: 13 additions & 17 deletions packages/cosmic-swingset/src/launch-chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const getHostKey = path => `host.${path}`;

/**
* @param {Map<*, *>} mailboxStorage
* @param {undefined | ((dstID: string, obj: any) => any)} bridgeOutbound
* @param {((dstID: string, obj: any) => any)} bridgeOutbound
* @param {SwingStoreKernelStorage} kernelStorage
* @param {string | (() => string | Promise<string>)} vatconfig absolute path or thunk
* @param {unknown} bootstrapArgs JSON-serializable data
Expand All @@ -123,17 +123,15 @@ export async function buildSwingset(
const debugPrefix = debugName === undefined ? '' : `${debugName}:`;
const mbs = buildMailboxStateMap(mailboxStorage);

const bridgeDevice = bridgeOutbound && buildBridge(bridgeOutbound);
const bridgeDevice = buildBridge(bridgeOutbound);
const mailboxDevice = buildMailbox(mbs);
const timerDevice = buildTimer();

const deviceEndowments = {
mailbox: { ...mailboxDevice.endowments },
timer: { ...timerDevice.endowments },
bridge: { ...bridgeDevice.endowments },
};
if (bridgeDevice) {
deviceEndowments.bridge = { ...bridgeDevice.endowments };
}

async function ensureSwingsetInitialized() {
if (swingsetIsInitialized(kernelStorage)) {
Expand Down Expand Up @@ -175,18 +173,16 @@ export async function buildSwingset(
const bootVat =
swingsetConfig.vats[swingsetConfig.bootstrap || 'bootstrap'];

if (bridgeOutbound) {
const batchChainStorage = (method, args) =>
bridgeOutbound(BRIDGE_ID.STORAGE, { method, args });
const batchChainStorage = (method, args) =>
bridgeOutbound(BRIDGE_ID.STORAGE, { method, args });

// Extract data from chain storage as [path, value?] pairs.
const chainStorageEntries = exportStorage(
batchChainStorage,
exportStorageSubtrees,
clearStorageSubtrees,
);
bootVat.parameters = { ...bootVat.parameters, chainStorageEntries };
}
// Extract data from chain storage as [path, value?] pairs.
const chainStorageEntries = exportStorage(
batchChainStorage,
exportStorageSubtrees,
clearStorageSubtrees,
);
bootVat.parameters = { ...bootVat.parameters, chainStorageEntries };

// Since only on-chain swingsets like `agd` have a bridge (and thereby
// `CORE_EVAL` support), things like `ag-solo` will need to do the
Expand Down Expand Up @@ -238,7 +234,7 @@ export async function buildSwingset(
coreProposals,
controller,
mb: mailboxDevice,
bridgeInbound: bridgeDevice && bridgeDevice.deliverInbound,
bridgeInbound: bridgeDevice.deliverInbound,
timer: timerDevice,
};
}
Expand Down
8 changes: 0 additions & 8 deletions packages/solo/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import addChain from './add-chain.js';
import initBasedir from './init-basedir.js';
import resetState from './reset-state.js';
import setGCIIngress from './set-gci-ingress.js';
import setFakeChain from './set-fake-chain.js';
import start from './start.js';

const log = anylogger('ag-solo');
Expand Down Expand Up @@ -120,13 +119,6 @@ start
setGCIIngress(basedir, GCI, rpcAddresses, chainID);
break;
}
case 'set-fake-chain': {
const basedir = insistIsBasedir();
const { _: subArgs, delay } = parseArgs(argv.slice(1), {});
const GCI = subArgs[0];
setFakeChain(basedir, GCI, delay);
break;
}
case 'start': {
const basedir = insistIsBasedir();
await start(basedir, {
Expand Down
12 changes: 1 addition & 11 deletions packages/solo/src/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
} from '@agoric/cosmic-swingset/src/kernel-stats.js';

import { deliver, addDeliveryTarget } from './outbound.js';
import { connectToPipe } from './pipe.js';
// import { connectToPipe } from './pipe.js';
import { makeHTTPListener } from './web.js';

import { connectToChain } from './chain-cosmos-sdk.js';
Expand Down Expand Up @@ -518,16 +518,6 @@ const start = async (basedir, argv) => {
addDeliveryTarget(c.GCI, deliverator);
}
break;
case 'fake-chain': {
log(`adding follower/sender for fake chain ${c.GCI}`);
const deliverator = await connectToPipe({
method: 'connectToFakeChain',
args: [basedir, c.GCI, c.fakeDelay],
deliverInboundToMbx,
});
addDeliveryTarget(c.GCI, deliverator);
break;
}
case 'http': {
log(`adding HTTP/WS listener on ${c.host}:${c.port}`);
!broadcastJSON || Fail`duplicate type=http in connections.json`;
Expand Down
8 changes: 4 additions & 4 deletions packages/solo/test/home.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ test.before('setup', async t => {
// Now come the tests that use `home`...
// =========================================

test.serial('home.board', async t => {
test.skip('home.board', async t => {
const { home } = t.context;
const { board } = E.get(home);
await t.throwsAsync(
Expand All @@ -73,7 +73,7 @@ test.serial('home.board', async t => {
t.is(myId2, myId, `board gives the same id for the same value`);
});

test.serial('home.wallet - transfer funds to the feePurse', async t => {
test.skip('home.wallet - transfer funds to the feePurse', async t => {
const { home } = t.context;
const { wallet, faucet } = E.get(home);
const feePurse = E(faucet).getFeePurse();
Expand All @@ -86,7 +86,7 @@ test.serial('home.wallet - transfer funds to the feePurse', async t => {
t.deepEqual(deposited, feeAmount, `all fees deposited to feePurse`);
});

test.serial('home.wallet - receive zoe invite', async t => {
test.skip('home.wallet - receive zoe invite', async t => {
const { home, loadBundle } = t.context;
const { wallet, zoe, board } = E.get(home);

Expand Down Expand Up @@ -133,7 +133,7 @@ test.serial('home.wallet - receive zoe invite', async t => {
);
});

test.serial('home.wallet - central issuer setup', async t => {
test.skip('home.wallet - central issuer setup', async t => {
const { home } = t.context;
const { wallet } = E.get(home);

Expand Down
3 changes: 1 addition & 2 deletions packages/solo/test/startsolo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ AG_SOLO=$(cd .. && pwd)/bin/ag-solo

TDIR="${TMPDIR-/tmp}/startsolo.$$"
trap 'rm -rf "$TDIR"' EXIT
"$AG_SOLO" init "$TDIR" --egresses=fake --webport=$PORT --defaultManagerType=local
"$AG_SOLO" init "$TDIR" --webport=$PORT --defaultManagerType=local
cd "$TDIR"
"$AG_SOLO" set-fake-chain --delay=0 mySimGCI
exec "$AG_SOLO" start
9 changes: 7 additions & 2 deletions packages/vats/src/core/client-behaviors.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Fail } from '@endo/errors';
import { E, Far } from '@endo/far';
import { makePluginManager } from '@agoric/swingset-vat/src/vats/plugin-manager.js';
import { observeNotifier } from '@agoric/notifier';
Expand Down Expand Up @@ -136,7 +135,13 @@ export const startClient = async ({
}

const addChainPresences = async () => {
FIXME_GCI || Fail`client must be given GCI`;
if (!FIXME_GCI) {
chainBundle = {
DISCONNECTED: `Chain is disconnected: no GCI provided`,
};
void updatePresences();
return;
}
await addRemote(FIXME_GCI);
// addEgress(..., index, ...) is called in vat-provisioning.
const chainProvider = E(vats.comms).addIngress(
Expand Down
6 changes: 6 additions & 0 deletions packages/wallet/api/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default async function deployWallet(
// console.log('have home', home);
const {
agoric: {
DISCONNECTED,
agoricNames,
bank,
namesByAddress,
Expand All @@ -27,6 +28,11 @@ export default async function deployWallet(
local: { http, localTimerService, spawner, wallet: oldWallet, scratch },
} = home;

if (DISCONNECTED) {
console.warn(DISCONNECTED);
return;
}

let walletVat = await E(scratch).get('wallet/api');
if (!walletVat) {
// Bundle the wallet sources.
Expand Down

0 comments on commit bf791ed

Please sign in to comment.