Skip to content

Commit

Permalink
Merge branch 'master' into iomekam-port-allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] committed Apr 30, 2024
2 parents 4a64a8a + d54b98a commit aa5e919
Show file tree
Hide file tree
Showing 35 changed files with 497 additions and 75 deletions.
2 changes: 1 addition & 1 deletion .github/actions/post-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ runs:
fi
- name: Upload coverage reports to Codecov
if: ${{ github.repository_owner == 'agoric' }} && ${{ steps.coverage-prep.outputs.skip == 'false' }} && (success() || failure())
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
continue-on-error: true
with:
token: ${{ inputs.codecov-token }}
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
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
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
2 changes: 1 addition & 1 deletion packages/builders/scripts/orchestration/init-stakeBld.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const defaultProposalBuilder = async ({ publishRef, install }) =>
{
installKeys: {
stakeBld: publishRef(
install('@agoric/orchestration/src/contracts/stakeBld.contract.js'),
install('@agoric/orchestration/src/examples/stakeBld.contract.js'),
),
},
},
Expand Down
14 changes: 14 additions & 0 deletions packages/builders/scripts/vats/add-auction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { makeHelpers } from '@agoric/deploy-script-support';

/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').ProposalBuilder} */
export const defaultProposalBuilder = async () => {
return harden({
sourceSpec: '@agoric/inter-protocol/src/proposals/add-auction.js',
getManifestCall: ['getManifestForAddAuction'],
});
};

export default async (homeP, endowments) => {
const { writeCoreProposal } = await makeHelpers(homeP, endowments);
await writeCoreProposal('add-auction', defaultProposalBuilder);
};
2 changes: 1 addition & 1 deletion packages/cosmic-proto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"ava": "^5.3.1",
"rimraf": "^5.0.0",
"tsimp": "^2.0.11",
"typescript": "^5.5.0-dev.20240327"
"typescript": "^5.5.0-beta"
},
"dependencies": {
"@cosmjs/amino": "^0.32.3",
Expand Down
Loading

0 comments on commit aa5e919

Please sign in to comment.