Skip to content

Commit

Permalink
Merge branch 'master' into markm-delegate-is-passable
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Apr 30, 2024
2 parents 3ba8c71 + d15cb41 commit 979fe17
Show file tree
Hide file tree
Showing 46 changed files with 675 additions and 173 deletions.
2 changes: 2 additions & 0 deletions .github/actions/restore-node/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ runs:
${{ inputs.path }}/endo-sha.txt
- uses: kenchan0130/actions-system-info@master
id: system-info
- run: corepack enable
shell: bash
- name: restore built files
id: built
uses: actions/cache@v4
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,7 @@ jobs:
ignore-endo-branch: 'true'
id: restore-node
- name: setup a3p-integration
run: |
corepack enable
yarn install
run: yarn install
working-directory: a3p-integration
- name: verify SDK image didn't change
# In the future when we can rebuild the SDK image with resolved endo packages, it would
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ to use.
## Prerequisites

* Git
* Node.js LTS (version 16.13.0 or higher)
* Go ^1.20.2
* Node.js ^18.12 or ^20.9
* we generally support the latest LTS release: use [nvm](https://github.com/nvm-sh/nvm) to keep your local system up-to-date
* Yarn (`npm install -g yarn`)
* gcc-10 or newer, or a compiler with `__has_builtin()`
* gcc >=10, clang >=10, or another compiler with `__has_builtin()`

Any version of Yarn will do: the `.yarnrc` file should ensure that all
commands use the specific checked-in version of Yarn (stored in
Expand Down
3 changes: 2 additions & 1 deletion a3p-integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"doctor": "yarn synthetic-chain doctor"
},
"dependencies": {
"@agoric/synthetic-chain": "^0.0.10"
"@agoric/synthetic-chain": "^0.0.10",
"@types/better-sqlite3": "^7.6.9"
},
"packageManager": "[email protected]",
"license": "Apache-2.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import test from 'ava';
import { getDetailsMatchingVats } from './vatDetails.js';

test('new auction vat', async t => {
const details = await getDetailsMatchingVats('auctioneer');
// This query matches both the auction and its governor, so 2*2
t.is(Object.keys(details).length, 4);
});
100 changes: 100 additions & 0 deletions a3p-integration/proposals/a:upgrade-next/vatDetails.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import dbOpenAmbient from 'better-sqlite3';

const HOME = process.env.HOME;

/** @type {<T>(val: T | undefined) => T} */
export const NonNullish = val => {
if (!val) throw Error('required');
return val;
};

/**
* @file look up vat incarnation from kernel DB
* @see {getIncarnation}
*/

const swingstorePath = `${HOME}/.agoric/data/agoric/swingstore.sqlite`;

/**
* SQL short-hand
*
* @param {import('better-sqlite3').Database} db
*/
export const dbTool = db => {
const prepare = (strings, ...params) => {
const dml = strings.join('?');
return { stmt: db.prepare(dml), params };
};
const sql = (strings, ...args) => {
const { stmt, params } = prepare(strings, ...args);
return stmt.all(...params);
};
sql.get = (strings, ...args) => {
const { stmt, params } = prepare(strings, ...args);
return stmt.get(...params);
};
return sql;
};

/**
* @param {import('better-sqlite3').Database} db
*/
const makeSwingstore = db => {
const sql = dbTool(db);

/** @param {string} key */
const kvGet = key => sql.get`select * from kvStore where key = ${key}`.value;
/** @param {string} key */
const kvGetJSON = key => JSON.parse(kvGet(key));

/** @param {string} vatID */
const lookupVat = vatID => {
return Object.freeze({
source: () => kvGetJSON(`${vatID}.source`),
options: () => kvGetJSON(`${vatID}.options`),
currentSpan: () =>
sql.get`select * from transcriptSpans where isCurrent = 1 and vatID = ${vatID}`,
});
};

return Object.freeze({
/** @param {string} vatName */
findVat: vatName => {
/** @type {string[]} */
const dynamicIDs = kvGetJSON('vat.dynamicIDs');
const targetVat = dynamicIDs.find(vatID =>
lookupVat(vatID).options().name.includes(vatName),
);
if (!targetVat) throw Error(`vat not found: ${vatName}`);
return targetVat;
},
/** @param {string} vatName */
findVats: vatName => {
/** @type {string[]} */
const dynamicIDs = kvGetJSON('vat.dynamicIDs');
return dynamicIDs.filter(vatID =>
lookupVat(vatID).options().name.includes(vatName),
);
},
lookupVat,
});
};

/** @param {string} vatName */
export const getDetailsMatchingVats = async vatName => {
const kStore = makeSwingstore(
dbOpenAmbient(swingstorePath, { readonly: true }),
);

const vatIDs = kStore.findVats(vatName);
const infos = [];
for (const vatID of vatIDs) {
const vatInfo = kStore.lookupVat(vatID);
const source = vatInfo.source();
// @ts-expect-error cast
const { incarnation } = vatInfo.currentSpan();
infos.push({ vatName, vatID, incarnation, ...source });
}

return infos;
};
26 changes: 26 additions & 0 deletions a3p-integration/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,24 @@ __metadata:
languageName: node
linkType: hard

"@types/better-sqlite3@npm:^7.6.9":
version: 7.6.9
resolution: "@types/better-sqlite3@npm:7.6.9"
dependencies:
"@types/node": "npm:*"
checksum: 10c0/7d77add3993968982374cd73586a100fc5b9c29570a167b5798a415744983041d9ae3dcbdfd83fcf807247b777e3b8dc4e045fb7dae4a3d8484c9366ab371680
languageName: node
linkType: hard

"@types/node@npm:*":
version: 20.11.30
resolution: "@types/node@npm:20.11.30"
dependencies:
undici-types: "npm:~5.26.4"
checksum: 10c0/867cfaf969c6d8850d8d7304e7ab739898a50ecb1395b61ff2335644f5f48d7a46fbc4a14cee967aed65ec134b61a746edae70d1f32f11321ccf29165e3bc4e6
languageName: node
linkType: hard

"abbrev@npm:^2.0.0":
version: 2.0.0
resolution: "abbrev@npm:2.0.0"
Expand Down Expand Up @@ -973,6 +991,7 @@ __metadata:
resolution: "root-workspace-0b6124@workspace:."
dependencies:
"@agoric/synthetic-chain": "npm:^0.0.10"
"@types/better-sqlite3": "npm:^7.6.9"
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -1190,6 +1209,13 @@ __metadata:
languageName: node
linkType: hard

"undici-types@npm:~5.26.4":
version: 5.26.5
resolution: "undici-types@npm:5.26.5"
checksum: 10c0/bb673d7876c2d411b6eb6c560e0c571eef4a01c1c19925175d16e3a30c4c428181fb8d7ae802a261f283e4166a0ac435e2f505743aa9e45d893f9a3df017b501
languageName: node
linkType: hard

"unique-filename@npm:^3.0.0":
version: 3.0.0
resolution: "unique-filename@npm:3.0.0"
Expand Down
1 change: 1 addition & 0 deletions docs/node-version.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ When a new version becomes Active LTS:
- [ ] update the .node-version hint to use it
- [ ] update Node.js test ranges to remove the EOLed version and add the new LTS
- [ ] update package.json engines to allow the two LTS versions
- [ ] update README.md to document the new supported versions
2 changes: 2 additions & 0 deletions golang/cosmos/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,8 @@ func unreleasedUpgradeHandler(app *GaiaApp, targetUpgrade string) func(sdk.Conte
"@agoric/builders/scripts/vats/updateStOsmoPriceFeed.js",
"@agoric/builders/scripts/vats/updateStTiaPriceFeed.js",
),
// Add new auction contract. The old one will be retired shortly.
vm.CoreProposalStepForModules( "@agoric/builders/scripts/vats/add-auction.js"),
}
}

Expand Down
12 changes: 2 additions & 10 deletions golang/cosmos/x/vstorage/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,6 @@ var _ ChangeManager = (*BatchingChangeManager)(nil)
// 2 ** 256 - 1
var MaxSDKInt = sdk.NewIntFromBigInt(new(big.Int).Sub(new(big.Int).Exp(big.NewInt(2), big.NewInt(256), nil), big.NewInt(1)))

// TODO: Use bytes.CutPrefix once we can rely upon go >= 1.20.
func cutPrefix(s, prefix []byte) (after []byte, found bool) {
if !bytes.HasPrefix(s, prefix) {
return s, false
}
return s[len(prefix):], true
}

// Keeper maintains the link to data storage and exposes getter/setter methods
// for the various parts of the state machine
type Keeper struct {
Expand Down Expand Up @@ -164,7 +156,7 @@ func (k Keeper) ExportStorageFromPrefix(ctx sdk.Context, pathPrefix string) []*t
if !strings.HasPrefix(path, pathPrefix) {
continue
}
value, hasPrefix := cutPrefix(rawValue, types.EncodedDataPrefix)
value, hasPrefix := bytes.CutPrefix(rawValue, types.EncodedDataPrefix)
if !hasPrefix {
panic(fmt.Errorf("value at path %q starts with unexpected prefix", path))
}
Expand Down Expand Up @@ -266,7 +258,7 @@ func (k Keeper) GetEntry(ctx sdk.Context, path string) agoric.KVEntry {
if bytes.Equal(rawValue, types.EncodedNoDataValue) {
return agoric.NewKVEntryWithNoValue(path)
}
value, hasPrefix := cutPrefix(rawValue, types.EncodedDataPrefix)
value, hasPrefix := bytes.CutPrefix(rawValue, types.EncodedDataPrefix)
if !hasPrefix {
panic(fmt.Errorf("value at path %q starts with unexpected prefix", path))
}
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
"type-coverage": "^2.27.1",
"typedoc": "^0.25.13",
"typedoc-plugin-markdown": "^3.17.1",
"typescript": "^5.5.0-dev.20240327",
"typescript-eslint": "^7.3.1"
"typescript": "^5.5.0-beta",
"typescript-eslint": "^7.7.1"
},
"resolutions": {
"**/protobufjs": "^7.2.6",
"**/@typescript-eslint/typescript-estree": "^7.2.0"
"**/@typescript-eslint/typescript-estree": "^7.7.1"
},
"engines": {
"node": "^18.12 || ^20.9"
Expand Down
8 changes: 4 additions & 4 deletions packages/boot/test/bootstrapTests/ibcClientMock.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import { V as E } from '@agoric/vat-data/vow.js';
/**
* @param {ZCF} zcf
* @param {{
* address: string,
* networkVat: ERef<ReturnType<typeof import('@agoric/vats/src/vat-network').buildRootObject>>;
* portAllocator: ERef<PortAllocator>;
* }} privateArgs
* @param {import("@agoric/vat-data").Baggage} _baggage
*/
export const start = async (zcf, privateArgs, _baggage) => {
const { address, networkVat } = privateArgs;
const myPort = await E(networkVat).bindPort(address);
const { portAllocator } = privateArgs;

const myPort = await E(portAllocator).allocateCustomIBCPort();

const { log } = console;
let connP;
Expand Down
6 changes: 3 additions & 3 deletions packages/boot/test/bootstrapTests/ibcServerMock.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ const { log } = console;
* @param {ZCF} zcf
* @param {{
* address: string,
* networkVat: ERef<ReturnType<typeof import('@agoric/vats/src/vat-network').buildRootObject>>;
* portAllocator: ERef<PortAllocator>;
* }} privateArgs
* @param {import("@agoric/vat-data").Baggage} _baggage
*/
export const start = async (zcf, privateArgs, _baggage) => {
const { address, networkVat } = privateArgs;
const { portAllocator } = privateArgs;

const boundPort = await E(networkVat).bindPort(address);
const boundPort = await E(portAllocator).allocateCustomIBCPort();

/** @type {Array<[label: string, resolve: (value: any) => void, reject: (reason: any) => void]>} */
const queue = [];
Expand Down
6 changes: 3 additions & 3 deletions packages/boot/test/bootstrapTests/test-net-ibc-upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const upgradeVats = async (t, EV, vatsToUpgrade) => {
test.serial('upgrade at many points in network API flow', async t => {
const { installation } = t.context;
const { EV } = t.context.runUtils;
const networkVat = await EV.vat('bootstrap').consumeItem('networkVat');
const portAllocator = await EV.vat('bootstrap').consumeItem('portAllocator');
const zoe: ZoeService = await EV.vat('bootstrap').consumeItem('zoe');

const flow = entries({
Expand All @@ -122,7 +122,7 @@ test.serial('upgrade at many points in network API flow', async t => {
installation.ibcServerMock,
{},
{},
{ address: '/ibc-port/', networkVat },
{ portAllocator },
);
t.truthy(started.creatorFacet, `${label} ibcServerMock`);
return [label, { server: started.creatorFacet }];
Expand All @@ -140,7 +140,7 @@ test.serial('upgrade at many points in network API flow', async t => {
installation.ibcClientMock,
{},
{},
{ address: '/ibc-port/', networkVat },
{ portAllocator },
);
t.truthy(started.creatorFacet, `${label} ibcClientMock`);
return [label, { ...opts, client: started.creatorFacet }];
Expand Down
2 changes: 1 addition & 1 deletion packages/boot/test/bootstrapTests/test-orchestration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { TestFn } from 'ava';

import { Fail } from '@agoric/assert';
import { AmountMath } from '@agoric/ertp';
import type { start as stakeBldStart } from '@agoric/orchestration/src/contracts/stakeBld.contract.js';
import type { start as stakeBldStart } from '@agoric/orchestration/src/examples/stakeBld.contract.js';
import type { Instance } from '@agoric/zoe/src/zoeService/utils.js';
import { M, matches } from '@endo/patterns';
import { makeWalletFactoryContext } from './walletFactory.ts';
Expand Down
33 changes: 0 additions & 33 deletions packages/boot/test/bootstrapTests/test-vats-restart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,6 @@ test.serial('run network vat proposal', async t => {
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('make IBC callbacks before upgrade', async t => {
const { EV } = t.context.runUtils;
const vatStore = await EV.vat('bootstrap').consumeItem('vatStore');
Expand Down Expand Up @@ -155,25 +141,6 @@ test.serial('use IBC callbacks after upgrade', async t => {
t.truthy(h.bridgeHandler, 'bridgeHandler');
});

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
4 changes: 1 addition & 3 deletions packages/builders/scripts/orchestration/init-stakeAtom.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ export const defaultProposalBuilder = async (
{
installKeys: {
stakeAtom: publishRef(
install(
'@agoric/orchestration/src/contracts/stakeAtom.contract.js',
),
install('@agoric/orchestration/src/examples/stakeAtom.contract.js'),
),
},
hostConnectionId,
Expand Down
Loading

0 comments on commit 979fe17

Please sign in to comment.