From fc3df899b30bfd8748704d701364bfb41cb00fe1 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Fri, 31 May 2024 13:06:04 -0400 Subject: [PATCH 1/2] chore: Integrate on top of upgrade-15 Fixes #9260 --- a3p-integration/package.json | 2 +- .../a:upgrade-next/exit-reclaim.test.js | 36 ------- .../proposals/a:upgrade-next/exitOffer.js | 97 ------------------- .../proposals/a:upgrade-next/prepare.sh | 20 ---- golang/cosmos/app/app.go | 10 +- 5 files changed, 5 insertions(+), 160 deletions(-) delete mode 100644 a3p-integration/proposals/a:upgrade-next/exit-reclaim.test.js delete mode 100644 a3p-integration/proposals/a:upgrade-next/exitOffer.js diff --git a/a3p-integration/package.json b/a3p-integration/package.json index c1d877f736c..4bb191ab7d8 100644 --- a/a3p-integration/package.json +++ b/a3p-integration/package.json @@ -1,7 +1,7 @@ { "private": true, "agoricSyntheticChain": { - "fromTag": "use-upgrade-14" + "fromTag": "latest" }, "scripts": { "build": "yarn run build:sdk && yarn run build:submissions && yarn run build:synthetic-chain", diff --git a/a3p-integration/proposals/a:upgrade-next/exit-reclaim.test.js b/a3p-integration/proposals/a:upgrade-next/exit-reclaim.test.js deleted file mode 100644 index c2bf31a5241..00000000000 --- a/a3p-integration/proposals/a:upgrade-next/exit-reclaim.test.js +++ /dev/null @@ -1,36 +0,0 @@ -import test from 'ava'; -import { $ } from 'execa'; -import { execFileSync } from 'node:child_process'; -import { makeAgd, waitForBlock } from './synthetic-chain-excerpt.js'; - -const offerId = 'bad-invitation-15'; // cf. prepare.sh -const from = 'gov1'; - -test('exitOffer tool reclaims stuck payment', async t => { - const showAndExec = (file, args, opts) => { - console.log('$', file, ...args); - return execFileSync(file, args, opts); - }; - const agd = makeAgd({ execFileSync: showAndExec }).withOpts({ - keyringBackend: 'test', - }); - - const addr = await agd.lookup(from); - t.log(from, 'addr', addr); - - const getBalance = async target => { - const { balances } = await agd.query(['bank', 'balances', addr]); - const { amount } = balances.find(({ denom }) => denom === target); - return Number(amount); - }; - - const before = await getBalance('uist'); - t.log('uist balance before:', before); - - await $`node ./exitOffer.js --id ${offerId} --from ${from}`; - - await waitForBlock(2); - const after = await getBalance('uist'); - t.log('uist balance after:', after); - t.true(after > before); -}); diff --git a/a3p-integration/proposals/a:upgrade-next/exitOffer.js b/a3p-integration/proposals/a:upgrade-next/exitOffer.js deleted file mode 100644 index fb6d2242b85..00000000000 --- a/a3p-integration/proposals/a:upgrade-next/exitOffer.js +++ /dev/null @@ -1,97 +0,0 @@ -// Note: limit imports to node modules for portability -import { parseArgs, promisify } from 'node:util'; -import { execFile } from 'node:child_process'; -import { writeFile, mkdtemp, rm } from 'node:fs/promises'; -import { join } from 'node:path'; - -const options = /** @type {const} */ ({ - id: { type: 'string' }, - from: { type: 'string' }, - bin: { type: 'string', default: '/usr/src/agoric-sdk/node_modules/.bin' }, -}); - -const Usage = ` -Try to exit an offer, reclaiming any associated payments. - - node exitOffer.js --id ID --from FROM [--bin PATH] - -Options: - --id - --from
- - --bin default: ${options.bin.default} -`; - -const badUsage = () => { - const reason = new Error(Usage); - reason.name = 'USAGE'; - throw reason; -}; - -const { stringify: q } = JSON; -// limited to JSON data: no remotables/promises; no undefined. -const toCapData = data => ({ body: `#${q(data)}`, slots: [] }); - -const { entries } = Object; -/** - * @param {Record} obj - e.g. { color: 'blue' } - * @returns {string[]} - e.g. ['--color', 'blue'] - */ -const flags = obj => - entries(obj) - .map(([k, v]) => [`--${k}`, v]) - .flat(); - -const execP = promisify(execFile); - -const showAndRun = (file, args) => { - console.log('$', file, ...args); - return execP(file, args); -}; - -const withTempFile = async (tail, fn) => { - const tmpDir = await mkdtemp('offers-'); - const tmpFile = join(tmpDir, tail); - try { - const result = await fn(tmpFile); - return result; - } finally { - await rm(tmpDir, { recursive: true, force: true }).catch(err => - console.error(err), - ); - } -}; - -const doAction = async (action, from) => { - await withTempFile('offer.json', async tmpOffer => { - await writeFile(tmpOffer, q(toCapData(action))); - - const out = await showAndRun('agoric', [ - 'wallet', - ...flags({ 'keyring-backend': 'test' }), - 'send', - ...flags({ offer: tmpOffer, from }), - ]); - return out.stdout; - }); -}; - -const main = async (argv, env) => { - const { values } = parseArgs({ args: argv.slice(2), options }); - const { id: offerId, from, bin } = values; - (offerId && from) || badUsage(); - - env.PATH = `${bin}:${env.PATH}`; - const action = { method: 'tryExitOffer', offerId }; - const out = await doAction(action, from); - console.log(out); -}; - -main(process.argv, process.env).catch(e => { - if (e.name === 'USAGE' || e.code === 'ERR_PARSE_ARGS_UNKNOWN_OPTION') { - console.error(e.message); - } else { - console.error(e); - } - process.exit(1); -}); diff --git a/a3p-integration/proposals/a:upgrade-next/prepare.sh b/a3p-integration/proposals/a:upgrade-next/prepare.sh index febb39d835f..cbf6c4d8fc1 100755 --- a/a3p-integration/proposals/a:upgrade-next/prepare.sh +++ b/a3p-integration/proposals/a:upgrade-next/prepare.sh @@ -7,23 +7,3 @@ set -uxeo pipefail # actions are executed in the previous chain software, and the effects are # persisted so they can be used in the steps after the upgrade is complete, # such as in the "use" or "test" steps, or further proposal layers. - -printISTBalance() { - addr=$(agd keys show -a "$1" --keyring-backend=test) - agd query bank balances "$addr" -o json \ - | jq -c '.balances[] | select(.denom=="uist")' - -} - -echo TEST: Offer with bad invitation -printISTBalance gov1 - -badInvitationOffer=$(mktemp) -cat > "$badInvitationOffer" << 'EOF' -{"body":"#{\"method\":\"executeOffer\",\"offer\":{\"id\":\"bad-invitation-15\",\"invitationSpec\":{\"callPipe\":[[\"badMethodName\"]],\"instancePath\":[\"reserve\"],\"source\":\"agoricContract\"},\"proposal\":{\"give\":{\"Collateral\":{\"brand\":\"$0.Alleged: IST brand\",\"value\":\"+15000\"}}}}}","slots":["board0257"]} -EOF - -PATH=/usr/src/agoric-sdk/node_modules/.bin:$PATH -agops perf satisfaction --keyring-backend=test send --executeOffer "$badInvitationOffer" --from gov1 || true - -printISTBalance gov1 diff --git a/golang/cosmos/app/app.go b/golang/cosmos/app/app.go index 49cf275096c..0c7bcf41d69 100644 --- a/golang/cosmos/app/app.go +++ b/golang/cosmos/app/app.go @@ -895,11 +895,9 @@ func unreleasedUpgradeHandler(app *GaiaApp, targetUpgrade string) func(sdk.Conte // Each CoreProposalStep runs sequentially, and can be constructed from // one or more modules executing in parallel within the step. CoreProposalSteps = []vm.CoreProposalStep{ - /* upgrade-15 evals */ // Upgrade ZCF only vm.CoreProposalStepForModules("@agoric/builders/scripts/vats/upgrade-zcf.js"), - // Upgrade walletFactory - vm.CoreProposalStepForModules("@agoric/builders/scripts/smart-wallet/build-wallet-factory2-upgrade.js"), + // upgrade the provisioning vat vm.CoreProposalStepForModules("@agoric/builders/scripts/vats/replace-provisioning.js"), // Enable low-level Orchestration. @@ -916,11 +914,11 @@ func unreleasedUpgradeHandler(app *GaiaApp, targetUpgrade string) func(sdk.Conte "@agoric/builders/scripts/vats/updateStkAtomPriceFeed.js", ), // Add new auction contract. The old one will be retired shortly. - vm.CoreProposalStepForModules( "@agoric/builders/scripts/vats/add-auction.js"), + vm.CoreProposalStepForModules("@agoric/builders/scripts/vats/add-auction.js"), // upgrade vaultFactory. - vm.CoreProposalStepForModules( "@agoric/builders/scripts/vats/upgradeVaults.js"), + vm.CoreProposalStepForModules("@agoric/builders/scripts/vats/upgradeVaults.js"), // upgrade scaledPriceAuthorities. - vm.CoreProposalStepForModules( "@agoric/builders/scripts/vats/upgradeScaledPriceAuthorities.js"), + vm.CoreProposalStepForModules("@agoric/builders/scripts/vats/upgradeScaledPriceAuthorities.js"), } } From 147ee962d04652495b28e33657c56f128d760517 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Mon, 3 Jun 2024 08:54:59 -0700 Subject: [PATCH 2/2] lint: noEmit for test packages --- a3p-integration/proposals/a:upgrade-next/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/a3p-integration/proposals/a:upgrade-next/tsconfig.json b/a3p-integration/proposals/a:upgrade-next/tsconfig.json index 38a0257a0e8..39de5a422e9 100644 --- a/a3p-integration/proposals/a:upgrade-next/tsconfig.json +++ b/a3p-integration/proposals/a:upgrade-next/tsconfig.json @@ -6,6 +6,7 @@ "checkJs": true, "strict": false, "strictNullChecks": true, + "noEmit": true, "noImplicitThis": true } }