From dbe8cc149d9af141da3992c505b4cf03c680bb27 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Mon, 22 Jul 2024 16:30:00 -0700 Subject: [PATCH 1/2] BREAKING CHANGE: require bridgeDevice --- packages/cosmic-swingset/src/launch-chain.js | 30 +++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/packages/cosmic-swingset/src/launch-chain.js b/packages/cosmic-swingset/src/launch-chain.js index 430b531d1cf..25ae404c880 100644 --- a/packages/cosmic-swingset/src/launch-chain.js +++ b/packages/cosmic-swingset/src/launch-chain.js @@ -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)} vatconfig absolute path or thunk * @param {unknown} bootstrapArgs JSON-serializable data @@ -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)) { @@ -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 @@ -238,7 +234,7 @@ export async function buildSwingset( coreProposals, controller, mb: mailboxDevice, - bridgeInbound: bridgeDevice && bridgeDevice.deliverInbound, + bridgeInbound: bridgeDevice.deliverInbound, timer: timerDevice, }; } From da75a03f95828d773fa3f662d30f0e221030c2ca Mon Sep 17 00:00:00 2001 From: Michael FIG Date: Wed, 24 Jul 2024 18:24:14 -0600 Subject: [PATCH 2/2] fix(solo)!: remove `sim-chain` dependency --- packages/solo/src/main.js | 8 -------- packages/solo/src/start.js | 12 +----------- packages/solo/test/home.test.js | 8 ++++---- packages/solo/test/startsolo.sh | 3 +-- packages/vats/src/core/client-behaviors.js | 9 +++++++-- packages/wallet/api/deploy.js | 6 ++++++ 6 files changed, 19 insertions(+), 27 deletions(-) diff --git a/packages/solo/src/main.js b/packages/solo/src/main.js index 7d9fd993af1..f70fa8185c1 100644 --- a/packages/solo/src/main.js +++ b/packages/solo/src/main.js @@ -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'); @@ -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, { diff --git a/packages/solo/src/start.js b/packages/solo/src/start.js index d138d35d742..6fa76c05bb5 100644 --- a/packages/solo/src/start.js +++ b/packages/solo/src/start.js @@ -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'; @@ -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`; diff --git a/packages/solo/test/home.test.js b/packages/solo/test/home.test.js index 9821f264c9b..96ded71f14c 100644 --- a/packages/solo/test/home.test.js +++ b/packages/solo/test/home.test.js @@ -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( @@ -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(); @@ -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); @@ -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); diff --git a/packages/solo/test/startsolo.sh b/packages/solo/test/startsolo.sh index 13aad5a747f..f0e9cb7c6d6 100755 --- a/packages/solo/test/startsolo.sh +++ b/packages/solo/test/startsolo.sh @@ -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 diff --git a/packages/vats/src/core/client-behaviors.js b/packages/vats/src/core/client-behaviors.js index 5fae7cfced0..d7071a0bae3 100644 --- a/packages/vats/src/core/client-behaviors.js +++ b/packages/vats/src/core/client-behaviors.js @@ -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'; @@ -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( diff --git a/packages/wallet/api/deploy.js b/packages/wallet/api/deploy.js index deb72b241c7..0ee5eb17d48 100644 --- a/packages/wallet/api/deploy.js +++ b/packages/wallet/api/deploy.js @@ -16,6 +16,7 @@ export default async function deployWallet( // console.log('have home', home); const { agoric: { + DISCONNECTED, agoricNames, bank, namesByAddress, @@ -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.