Skip to content

Commit

Permalink
Merge branch 'master' into gibson-4558-chainStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] committed Jun 2, 2022
2 parents ebe7a57 + 43488e4 commit 8e88f2f
Show file tree
Hide file tree
Showing 155 changed files with 1,333 additions and 465 deletions.
63 changes: 63 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/* eslint-env node */
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: [
'@jessie.js/eslint-plugin',
'@typescript-eslint',
'eslint-plugin-import',
'eslint-plugin-prettier',
],
extends: ['@agoric'],
rules: {
'@typescript-eslint/prefer-ts-expect-error': 'warn',
'jsdoc/no-multi-asterisks': 'off',
'jsdoc/multiline-blocks': 'off',
// Use these rules to warn about JSDoc type problems, such as after
// upgrading eslint-plugin-jsdoc.
// Bump the 1's to 2's to get errors.
// "jsdoc/valid-types": 1,
// "jsdoc/no-undefined-types": [1, {"definedTypes": ["never", "unknown"]}],
'jsdoc/tag-lines': 'off',
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: [
'**/*.config.js',
'**/*.config.*.js',
'**/*test*/**/*.js',
'**/demo*/**/*.js',
'**/scripts/**/*.js',
],
},
],
// CI has a separate format check but keep this warn to maintain that "eslint --fix" prettifies
// UNTIL https://github.com/Agoric/agoric-sdk/issues/4339
'prettier/prettier': 'warn',
},
settings: {
jsdoc: {
mode: 'typescript',
},
},
ignorePatterns: [
'coverage/**',
'**/output/**',
'bundles/**',
'bundle-*',
'dist/**',
'examples/**',
'test262/**',
'*.html',
'ava*.config.js',
],
overrides: [
{
// disable type-aware linting in HTML
files: ['*.html'],
parserOptions: {
project: false,
},
},
],
};
5 changes: 0 additions & 5 deletions golang/cosmos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@
"url": "https://github.com/Agoric/agoric-sdk/issues"
},
"homepage": "https://github.com/Agoric/agoric-sdk/tree/HEAD/golang/cosmos",
"eslintConfig": {
"extends": [
"@agoric"
]
},
"files": [
"Makefile*",
"app",
Expand Down
15 changes: 9 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,20 @@
"@endo/eslint-config": "^0.4.10",
"@jessie.js/eslint-plugin": "^0.1.3",
"@types/node": "^16.7.10",
"@typescript-eslint/parser": "^5.15.0",
"@typescript-eslint/parser": "^5.27.0",
"ava": "^3.15.0",
"c8": "^7.11.0",
"conventional-changelog-conventionalcommits": "^4.6.0",
"eslint": "^7.32.0",
"eslint-config-airbnb-base": "^14.2.0",
"eslint-config-jessie": "^0.0.6",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-jsx-a11y": "^6.4.0",
"eslint-plugin-jsdoc": "^39.2.9",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react-hooks": "^4.3.0",
"eslint-plugin-react": "^7.28.0",
"eslint": "^7.32.0",
"lerna": "^3.22.1",
"npm-run-all": "^4.1.5",
"prettier": "^2.6.2",
Expand All @@ -29,9 +35,6 @@
"engines": {
"node": ">=14.15.0"
},
"eslintConfig": {
"root": true
},
"prettier": {
"arrowParens": "avoid",
"trailingComma": "all",
Expand Down
7 changes: 1 addition & 6 deletions packages/ERTP/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"test:xs-worker": "SWINGSET_WORKER_TYPE=xs-worker ava -c 2 'test/swingsetTests/**/test-*.js'",
"lint-fix": "yarn lint:eslint --fix",
"lint": "run-s --continue-on-error lint:*",
"lint:eslint": "eslint --ext .js,.ts .",
"lint:eslint": "eslint .",
"lint:types": "tsc --maxNodeModuleJsDepth 3 -p jsconfig.json"
},
"repository": {
Expand Down Expand Up @@ -65,11 +65,6 @@
],
"timeout": "2m"
},
"eslintConfig": {
"extends": [
"@agoric"
]
},
"publishConfig": {
"access": "public"
}
Expand Down
14 changes: 7 additions & 7 deletions packages/SwingSet/docs/vat-upgrade.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
(NOTE: none of this is implemented yet)

# Vat Upgrade

Dynamic vats can be upgraded to use a new code bundle. This might be used to fix a bug, to add new functionality, or merely to delete accumulated state and reduce memory usage.
Expand All @@ -13,13 +11,15 @@ For convenience, this description will use "v1" to describe the old version of t
Vat upgrade is triggered by an `upgrade()` message to the vat's "adminNode" (the one returned by `E(vatAdminService).createVat()`). This schedules an upgrade event on the kernel run-queue. When this event is processed, the following takes place:

* the vat's current worker (if any) is shut down
* outstanding promises are rejected
* non-durable exported objects are abandoned
* any heap snapshot for the vat is deleted
* the vat's transcript is deleted
* the vat's non-durable data is deleted
* the vat's transcript is (effectively) deleted
* (TODO) the vat's non-durable data is deleted
* the vat's source record is updated to point at the v2 source bundle
* a new worker is started, and loads the v2 source bundle
* the v2 code performs its "upgrade phase"
* TODO: how is it informed this has started? `buildRootObject()`? or `upgrade()` or something?
* this is signaled with a call to `buildRootObject()`
* the upgrade invocation gets new `vatParameters`
* the v2 upgrade phase rewires all durable virtual object kinds, and
reassociates objects with all export obligations
Expand Down Expand Up @@ -134,7 +134,7 @@ Upgrades use bundlecaps, just like the initial `createVat()` call. So the first

Once the governance object is holding the v2 bundlecap, it triggers the upgrade with `E(adminNode).upgrade(newBundlecap, options)`. This schedules the upgrade sequence (described above), and returns a Promise that resolves when the upgrade is complete. If the upgrade fails, the Promise is rejected and the old vat is reinstalled. An upgrade might fail because the new source bundle has a syntax error (preventing evaluation), or because the upgrade phase throws an exception or returns a Promise that rejects. It will also fail if the ugprade phase does not fulfill all of its obligations, such as leaving a durable Kind unattached.

An important property of the `options` bag is `vatParameters`. This value is passed to the upgrade phase (how? TBD) and can be used to communicate with the upgrade-time code before any external messages have a chance to be delivered. In the Zoe ZCF vat, this is how new contract code will be delivered, so it can be executed (and can assume responsibility for v1 obligations) to completion by the time the upgrade phase finishes.
An important property of the `options` bag is `vatParameters`. This value is passed to the upgrade phase (as the usual second argument to `buildRootObject()`) and can be used to communicate with the upgrade-time code before any external messages have a chance to be delivered. In the Zoe ZCF vat, this is how new contract code will be delivered, so it can be executed (and can assume responsibility for v1 obligations) to completion by the time the upgrade phase finishes.

## From Inside: V2 Executes the Upgrade

Expand All @@ -153,4 +153,4 @@ When `buildRootObject()` finishes and the upgrade phase completes successfully,

TBD: we might terminate any Durable exported objects which v2 does not reattach, or we might treat that as an error.

TBD: ideally, if the v2 code experiences an error during the upgrade phase, the entire upgrade is aborted and the v1 code is reinstated.
(TODO) If the v2 code experiences an error during the upgrade phase, the entire upgrade is aborted and the v1 code is reinstated.
10 changes: 9 additions & 1 deletion packages/SwingSet/jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,13 @@
"strictNullChecks": true,
"moduleResolution": "node",
},
"include": ["src/**/*.js", "exported.js"],
"include": [
"exported.js",
"demo/**/*.js",
"lib/**/*.js",
"src/**/*.js",
"misc-tools/**/*.js",
"test/**/*.js",
"tools/**/*.js",
],
}
7 changes: 1 addition & 6 deletions packages/SwingSet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"lint-fix": "yarn lint:eslint --fix",
"lint": "yarn lint:types&&yarn lint:eslint",
"lint:types": "tsc --maxNodeModuleJsDepth 3 -p jsconfig.json",
"lint:eslint": "eslint --ext .js,.ts ."
"lint:eslint": "eslint ."
},
"devDependencies": {
"@agoric/vat-data": "^0.3.1",
Expand Down Expand Up @@ -71,11 +71,6 @@
"directories": {
"example": "examples"
},
"eslintConfig": {
"extends": [
"@agoric"
]
},
"ava": {
"files": [
"test/**/test-*.js"
Expand Down
60 changes: 52 additions & 8 deletions packages/SwingSet/src/liveslots/collectionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,6 @@ export function makeCollectionManager(
keys,
values,
entries,
sizeInternal,
getSize,
snapshotSet,
snapshotMap,
Expand All @@ -631,7 +630,6 @@ export function makeCollectionManager(
keys,
values,
entries,
sizeInternal,
getSize,
snapshotSet,
snapshotMap,
Expand Down Expand Up @@ -736,7 +734,6 @@ export function makeCollectionManager(
init,
delete: del,
keys,
sizeInternal,
getSize,
snapshotSet,
clear,
Expand All @@ -760,7 +757,6 @@ export function makeCollectionManager(
keys: patt => keys(patt),
values: patt => keys(patt),
entries,
sizeInternal,
getSize: patt => getSize(patt),
snapshot: snapshotSet,
clear,
Expand Down Expand Up @@ -796,8 +792,17 @@ export function makeCollectionManager(
*/
function makeScalarBigMapStore(
label = 'map',
{ keySchema = M.scalar(), valueSchema = undefined, durable = false } = {},
{
keySchema = M.scalar(),
valueSchema = undefined,
durable = false,
fakeDurable = false,
} = {},
) {
assert(
!durable || !fakeDurable,
'durable and fakeDurable are mutually exclusive',
);
const kindName = durable ? 'scalarDurableMapStore' : 'scalarMapStore';
const [vobjID, collection] = makeCollection(
label,
Expand All @@ -807,6 +812,9 @@ export function makeCollectionManager(
);
const store = collectionToMapStore(collection);
registerValue(vobjID, store, false);
if (fakeDurable) {
vrm.registerFakeDurable(vobjID);
}
return store;
}

Expand Down Expand Up @@ -838,8 +846,17 @@ export function makeCollectionManager(
*/
function makeScalarBigWeakMapStore(
label = 'weakMap',
{ keySchema = M.scalar(), valueSchema = undefined, durable = false } = {},
{
keySchema = M.scalar(),
valueSchema = undefined,
durable = false,
fakeDurable = false,
} = {},
) {
assert(
!durable || !fakeDurable,
'durable and fakeDurable are mutually exclusive',
);
const kindName = durable
? 'scalarDurableWeakMapStore'
: 'scalarWeakMapStore';
Expand All @@ -851,6 +868,9 @@ export function makeCollectionManager(
);
const store = collectionToWeakMapStore(collection);
registerValue(vobjID, store, false);
if (fakeDurable) {
vrm.registerFakeDurable(vobjID);
}
return store;
}

Expand All @@ -865,8 +885,17 @@ export function makeCollectionManager(
*/
function makeScalarBigSetStore(
label = 'set',
{ keySchema = M.scalar(), valueSchema = undefined, durable = false } = {},
{
keySchema = M.scalar(),
valueSchema = undefined,
durable = false,
fakeDurable = false,
} = {},
) {
assert(
!durable || !fakeDurable,
'durable and fakeDurable are mutually exclusive',
);
const kindName = durable ? 'scalarDurableSetStore' : 'scalarSetStore';
const [vobjID, collection] = makeCollection(
label,
Expand All @@ -876,6 +905,9 @@ export function makeCollectionManager(
);
const store = collectionToSetStore(collection);
registerValue(vobjID, store, false);
if (fakeDurable) {
vrm.registerFakeDurable(vobjID);
}
return store;
}

Expand All @@ -890,8 +922,17 @@ export function makeCollectionManager(
*/
function makeScalarBigWeakSetStore(
label = 'weakSet',
{ keySchema = M.scalar(), valueSchema = undefined, durable = false } = {},
{
keySchema = M.scalar(),
valueSchema = undefined,
durable = false,
fakeDurable = false,
} = {},
) {
assert(
!durable || !fakeDurable,
'durable and fakeDurable are mutually exclusive',
);
const kindName = durable
? 'scalarDurableWeakSetStore'
: 'scalarWeakSetStore';
Expand All @@ -903,6 +944,9 @@ export function makeCollectionManager(
);
const store = collectionToWeakSetStore(collection);
registerValue(vobjID, store, false);
if (fakeDurable) {
vrm.registerFakeDurable(vobjID);
}
return store;
}

Expand Down
16 changes: 15 additions & 1 deletion packages/SwingSet/src/liveslots/virtualObjectManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,18 @@ export function makeVirtualObjectManager(
options,
durable,
) {
const finish = options ? options.finish : undefined;
let finish;
let fakeDurable;
if (options) {
({ finish, fakeDurable } = options);
}
if (fakeDurable) {
assert(
durable,
`the fakeDurable option may only be applied to durable objects`,
);
durable = false;
}
let nextInstanceID = 1;
let facetNames;
let behaviorTemplate;
Expand Down Expand Up @@ -742,6 +753,9 @@ export function makeVirtualObjectManager(
}
}
cache.markDirty(innerSelf);
if (fakeDurable) {
vrm.registerFakeDurable(baseRef);
}
return toExpose;
}

Expand Down
Loading

0 comments on commit 8e88f2f

Please sign in to comment.