Skip to content

Commit

Permalink
Merge branch 'master' into 8868-gen-submissions
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] committed Feb 29, 2024
2 parents d03eaa2 + 3d13c09 commit 5a1226a
Show file tree
Hide file tree
Showing 74 changed files with 2,877 additions and 1,587 deletions.
2 changes: 1 addition & 1 deletion bin/agd
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ if $need_nodejs; then
esac
fi

(
${NO_BUILD:-false} || (
# Send the build output to stderr unless we're only building. This prevents
# the daemon's stdout from being polluted with build output.
$only_build || exec 1>&2
Expand Down
2 changes: 1 addition & 1 deletion packages/ERTP/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,6 @@
"access": "public"
},
"typeCoverage": {
"atLeast": 90.6
"atLeast": 90.56
}
}
2 changes: 1 addition & 1 deletion packages/SwingSet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,6 @@
"access": "public"
},
"typeCoverage": {
"atLeast": 75.36
"atLeast": 75.05
}
}
2 changes: 1 addition & 1 deletion packages/agoric-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,6 @@
"workerThreads": false
},
"typeCoverage": {
"atLeast": 77.5
"atLeast": 76.93
}
}
2 changes: 1 addition & 1 deletion packages/agoric-cli/src/lib/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const exampleAsset = {

/**
* @param {AssetDescriptor[]} assets
* @returns {(a: Amount & { brand: BoardRemote }) => [string, number | any[]]}
* @returns {(a: Amount & { brand: BoardRemote }) => [string | null, number | any[]]}
*/
export const makeAmountFormatter = assets => amt => {
const { brand, value } = amt;
Expand Down
2 changes: 1 addition & 1 deletion packages/base-zone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@
"workerThreads": false
},
"typeCoverage": {
"atLeast": 88.7
"atLeast": 89.25
}
}
4 changes: 3 additions & 1 deletion packages/boot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@agoric/internal": "^0.3.2",
"@agoric/inter-protocol": "^0.16.1",
"@agoric/kmarshal": "^0.1.0",
"@agoric/notifier": "^0.6.2",
"@agoric/swing-store": "^0.9.1",
"@agoric/swingset-vat": "^0.32.2",
"@agoric/telemetry": "^0.6.2",
Expand All @@ -33,6 +34,7 @@
"@agoric/vats": "^0.15.1",
"@agoric/vm-config": "^0.1.0",
"@agoric/zoe": "^0.26.2",
"@agoric/zone": "^0.2.2",
"@endo/marshal": "^1.3.0",
"@endo/bundle-source": "^3.1.0",
"@endo/captp": "^4.0.4",
Expand Down Expand Up @@ -84,6 +86,6 @@
"workerThreads": false
},
"typeCoverage": {
"atLeast": 88.05
"atLeast": 87.83
}
}
62 changes: 62 additions & 0 deletions packages/boot/test/bootstrapTests/test-vats-restart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,49 @@ test.serial('open vault', async t => {
});
});

test.serial('run network vat proposal', async t => {
const { controller, buildProposal } = t.context;

t.log('building network proposal');
const proposal = await buildProposal(
'@agoric/builders/scripts/vats/init-network.js',
);

for await (const bundle of proposal.bundles) {
await controller.validateAndInstallBundle(bundle);
}
t.log('installed', proposal.bundles.length, 'bundles');

t.log('executing proposal');
const bridgeMessage = {
type: 'CORE_EVAL',
evals: proposal.evals,
};
t.log({ bridgeMessage });
const { EV } = t.context.runUtils;
const coreEvalBridgeHandler: BridgeHandler = await EV.vat(
'bootstrap',
).consumeItem('coreEvalBridgeHandler');
await EV(coreEvalBridgeHandler).fromBridge(bridgeMessage);

t.log('network proposal executed');
t.pass(); // reached here without throws
});

test.serial('register network protocol before upgrade', async t => {
const { EV } = t.context.runUtils;
const net = await EV.vat('bootstrap').consumeItem('networkVat');
const h1 = await EV(net).makeLoopbackProtocolHandler();

t.log('register P1');
await EV(net).registerProtocolHandler(['P1'], h1);

t.log('register P1 again? No.');
await t.throwsAsync(EV(net).registerProtocolHandler(['P1'], h1), {
message: /key "P1" already registered/,
});
});

test.serial('run restart-vats proposal', async t => {
const { controller, buildProposal } = t.context;

Expand Down Expand Up @@ -126,6 +169,25 @@ test.serial('run restart-vats proposal', async t => {
t.pass(); // reached here without throws
});

test.serial('networkVat registrations are durable', async t => {
const { EV } = t.context.runUtils;
const net = await EV.vat('bootstrap').consumeItem('networkVat');

const h2 = await EV(net).makeLoopbackProtocolHandler();
t.log('register P1 again? No.');
await t.throwsAsync(EV(net).registerProtocolHandler(['P1'], h2), {
message: /key "P1" already registered/,
});

t.log('IBC protocol handler already registered?');
await t.throwsAsync(
EV(net).registerProtocolHandler(['/ibc-port', '/ibc-hop'], h2),
{
message: /key "\/ibc-port" already registered in collection "prefix"/,
},
);
});

test.serial('read metrics', async t => {
const { EV } = t.context.runUtils;

Expand Down
50 changes: 50 additions & 0 deletions packages/boot/test/upgrading/test-upgrade-vats.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,3 +444,53 @@ test('upgrade vat-priceAuthority', async t => {
matchRef(t, reincarnatedRegistry.priceAuthority, registry.priceAuthority);
matchRef(t, reincarnatedRegistry.adminFacet, registry.adminFacet);
});

test('upgrade vat-vow', async t => {
const bundles = {
vow: {
sourceSpec: bfile('./vat-vow.js'),
},
};

const { EV } = await makeScenario(t, { bundles });

t.log('create initial version');
const vowVatConfig = {
name: 'vow',
bundleCapName: 'vow',
};
const vowRoot = await EV.vat('bootstrap').createVat(vowVatConfig);

t.log('test incarnation 0');
/** @type {Record<string, [settlementValue?: unknown, isRejection?: boolean]>} */
const localPromises = {
forever: [],
fulfilled: ['hello'],
rejected: ['goodbye', true],
};
await EV(vowRoot).makeLocalPromiseWatchers(localPromises);
t.deepEqual(await EV(vowRoot).getWatcherResults(), {
fulfilled: { status: 'fulfilled', value: 'hello' },
forever: { status: 'unsettled' },
rejected: { status: 'rejected', reason: 'goodbye' },
});

t.log('restart');
const { incarnationNumber } =
await EV.vat('bootstrap').upgradeVat(vowVatConfig);
t.is(incarnationNumber, 1, 'vat must be reincarnated');

t.log('test incarnation 1');
t.deepEqual(await EV(vowRoot).getWatcherResults(), {
fulfilled: { status: 'fulfilled', value: 'hello' },
forever: {
status: 'rejected',
reason: {
name: 'vatUpgraded',
upgradeMessage: 'vat upgraded',
incarnationNumber: 0,
},
},
rejected: { status: 'rejected', reason: 'goodbye' },
});
});
47 changes: 47 additions & 0 deletions packages/boot/test/upgrading/vat-vow.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { prepareVowTools } from '@agoric/vat-data/vow.js';
import { makeDurableZone } from '@agoric/zone/durable.js';
import { Far } from '@endo/far';

export const buildRootObject = (_vatPowers, _args, baggage) => {
const zone = makeDurableZone(baggage);
const { watch } = prepareVowTools(zone.subZone('VowTools'));

/** @type {MapStore<string, { status: 'unsettled' } | PromiseSettledResult<any>>} */
const nameToResult = zone.mapStore('nameToResult');

const makeWatcher = zone.exoClass('Watcher', undefined, name => ({ name }), {
async onFulfilled(value) {
const { name } = this.state;
nameToResult.set(name, { status: 'fulfilled', value });
},
async onRejected(reason) {
const { name } = this.state;
nameToResult.set(name, { status: 'rejected', reason });
},
});

return Far('VowRoot', {
getWatcherResults() {
return harden(Object.fromEntries(nameToResult.entries()));
},
/** @param {Record<string, [settlementValue?: unknown, isRejection?: boolean]>} localPromises */
async makeLocalPromiseWatchers(localPromises) {
for (const [name, settlement] of Object.entries(localPromises)) {
nameToResult.init(name, harden({ status: 'unsettled' }));
let p;
if (!settlement.length) {
// Never settle.
p = new Promise(() => {});
} else {
const [settlementValue, isRejection] = settlement;
if (isRejection) {
p = Promise.reject(settlementValue);
} else {
p = Promise.resolve(settlementValue);
}
}
watch(p, makeWatcher(name));
}
},
});
};
2 changes: 1 addition & 1 deletion packages/builders/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,6 @@
"workerThreads": false
},
"typeCoverage": {
"atLeast": 67.05
"atLeast": 73.62
}
}
2 changes: 1 addition & 1 deletion packages/builders/scripts/pegasus/init-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const defaultProposalBuilder = async ({ publishRef, install }) =>
{
pegasusRef: publishRef(
install(
'@agoric/pegasus/src/pegasus.js',
'@agoric/pegasus/src/contract.js',
'../bundles/bundle-pegasus.js',
),
),
Expand Down
2 changes: 1 addition & 1 deletion packages/casting/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@
"workerThreads": false
},
"typeCoverage": {
"atLeast": 89.5
"atLeast": 89.58
}
}
2 changes: 1 addition & 1 deletion packages/cosmic-swingset/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@
"timeout": "20m"
},
"typeCoverage": {
"atLeast": 79.32
"atLeast": 79.84
}
}
2 changes: 1 addition & 1 deletion packages/deploy-script-support/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,6 @@
"access": "public"
},
"typeCoverage": {
"atLeast": 80.06
"atLeast": 81.47
}
}
2 changes: 1 addition & 1 deletion packages/deployment/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@
"readline-transform": "^1.0.0"
},
"typeCoverage": {
"atLeast": 60.14
"atLeast": 51.3
}
}
2 changes: 1 addition & 1 deletion packages/inter-protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@
"access": "public"
},
"typeCoverage": {
"atLeast": 95.83
"atLeast": 95.77
}
}
2 changes: 1 addition & 1 deletion packages/internal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@
"access": "public"
},
"typeCoverage": {
"atLeast": 92.28
"atLeast": 92.83
}
}
5 changes: 4 additions & 1 deletion packages/internal/src/batched-deliver.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// @jessie-check
// @ts-check

export const DEFAULT_BATCH_TIMEOUT_MS = 1000;

/**
* @typedef {(message: any[], ackNum: number) => Promise<void>} DeliverMessages
* @typedef {(message: unknown[], ackNum: number) => Promise<void>} DeliverMessages
*/

/**
Expand All @@ -16,8 +17,10 @@ export function makeBatchedDeliver(
{ clearTimeout, setTimeout },
batchTimeoutMs = DEFAULT_BATCH_TIMEOUT_MS,
) {
/** @type {unknown[]} */
let batchedMessages = [];
let latestAckNum = 0;
/** @type {NodeJS.Timeout} */
let deliverTimeout;

/**
Expand Down
Loading

0 comments on commit 5a1226a

Please sign in to comment.