-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
backport walletFactory upgrade to upgrade-11
- Loading branch information
Showing
25 changed files
with
1,362 additions
and
47 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
upgrade-walletFactory-permit.json | ||
upgrade-walletFactory.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/tools/mint-ist.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
if [ -z "$GOV1ADDR" ]; then | ||
echo run env_setup.sh to set GOV1ADDR | ||
exit 1 | ||
fi | ||
|
||
micro=000000 | ||
|
||
# send some collateral to gov1 | ||
agd tx bank send validator $GOV1ADDR 20123$micro${ATOM_DENOM} \ | ||
--keyring-backend=test --chain-id=agoriclocal --yes -bblock -o json | ||
|
||
export PATH=/usr/src/agoric-sdk/packages/agoric-cli/bin:$PATH | ||
agops vaults open --giveCollateral 5000 --wantMinted 20000 > /tmp/offer.json | ||
agops perf satisfaction --executeOffer /tmp/offer.json --from gov1 --keyring-backend=test |
41 changes: 41 additions & 0 deletions
41
...s/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/tools/parseProposals.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env node | ||
|
||
import fs from 'fs'; | ||
|
||
const Fail = (template, ...args) => { | ||
throw Error(String.raw(template, ...args.map(val => String(val)))); | ||
}; | ||
|
||
/** | ||
* Parse output of `agoric run proposal-builder.js` | ||
* | ||
* @param {string} txt | ||
* | ||
* adapted from packages/boot/test/bootstrapTests/supports.js | ||
*/ | ||
const parseProposalParts = txt => { | ||
const evals = [ | ||
...txt.matchAll(/swingset-core-eval (?<permit>\S+) (?<script>\S+)/g), | ||
].map(m => { | ||
if (!m.groups) throw Fail`Invalid proposal output ${m[0]}`; | ||
const { permit, script } = m.groups; | ||
return { permit, script }; | ||
}); | ||
evals.length || Fail`No swingset-core-eval found in proposal output: ${txt}`; | ||
|
||
const bundles = [...txt.matchAll(/swingset install-bundle @([^\n]+)/gm)].map( | ||
([, bundle]) => bundle, | ||
); | ||
bundles.length || Fail`No bundles found in proposal output: ${txt}`; | ||
|
||
return { evals, bundles }; | ||
}; | ||
|
||
const main = (stdin, readFileSync) => { | ||
const input = readFileSync(stdin.fd).toString(); | ||
const parts = parseProposalParts(input); | ||
// relies on console.log printing to stdout unmodified | ||
console.log(JSON.stringify(parts)); | ||
}; | ||
|
||
main(process.stdin, fs.readFileSync); |
116 changes: 116 additions & 0 deletions
116
...nt/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/wallet-all-ertp/gen-game-offer.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
/* eslint-disable @jessie.js/safe-await-separator */ | ||
/* global process */ | ||
import assert from 'assert'; | ||
import { execFile } from 'child_process'; | ||
|
||
const ISTunit = 1_000_000n; // aka displayInfo: { decimalPlaces: 6 } | ||
const CENT = ISTunit / 100n; | ||
|
||
const [_node, _script, ...choices] = process.argv; | ||
|
||
const toSec = ms => BigInt(Math.round(ms / 1000)); | ||
|
||
const id = `join-${Date.now()}`; | ||
|
||
// look up boardIDs for brands, instances in agoricNames | ||
|
||
// poor-man's zx | ||
const $ = cmd => { | ||
console.error(cmd); | ||
const [file, ...args] = cmd.split(' '); | ||
|
||
return new Promise((resolve, reject) => { | ||
execFile(file, args, { encoding: 'utf8' }, (err, out) => { | ||
if (err) return reject(err); | ||
resolve(out); | ||
}); | ||
}); | ||
}; | ||
|
||
const zip = (xs, ys) => xs.map((x, i) => [x, ys[i]]); | ||
const fromSmallCapsEntries = txt => { | ||
const { body, slots } = JSON.parse(txt); | ||
const theEntries = zip(JSON.parse(body.slice(1)), slots).map( | ||
([[name, ref], boardID]) => { | ||
const iface = ref.replace(/^\$\d+\./, ''); | ||
return [name, { iface, boardID }]; | ||
}, | ||
); | ||
return Object.fromEntries(theEntries); | ||
}; | ||
|
||
const wkInstance = fromSmallCapsEntries( | ||
await $('agoric follow -lF :published.agoricNames.instance -o text'), | ||
); | ||
assert(wkInstance.VaultFactory); | ||
|
||
const wkBrand = fromSmallCapsEntries( | ||
await $('agoric follow -lF :published.agoricNames.brand -o text'), | ||
); | ||
assert(wkBrand.IST); | ||
assert(wkBrand.Place); | ||
|
||
const slots = []; // XXX global mutable state | ||
|
||
// XXX should use @endo/marshal | ||
const smallCaps = { | ||
Nat: n => `+${n}`, | ||
replacer: (k, v) => | ||
typeof v === 'bigint' | ||
? `+${v}` | ||
: typeof v === 'symbol' | ||
? `%${v.description}` | ||
: v, | ||
// XXX mutates obj | ||
ref: obj => { | ||
if (obj.ix) return obj.ix; | ||
const ix = slots.length; | ||
slots.push(obj.boardID); | ||
obj.ix = `$${ix}.Alleged: ${obj.iface}`; | ||
return obj.ix; | ||
}, | ||
}; | ||
|
||
const AmountMath = { | ||
make: (brand, value) => ({ | ||
brand: smallCaps.ref(brand), | ||
value: typeof value === 'bigint' ? smallCaps.Nat(value) : value, | ||
}), | ||
}; | ||
|
||
const makeTagged = (tag, payload) => ({ | ||
'#tag': tag, | ||
payload, | ||
}); | ||
|
||
const makeCopyBag = entries => makeTagged('copyBag', entries); | ||
const want = { | ||
Places: AmountMath.make( | ||
wkBrand.Place, | ||
makeCopyBag(choices.map(name => [name, 1n])), | ||
), | ||
}; | ||
|
||
const give = { Price: AmountMath.make(wkBrand.IST, 25n * CENT) }; | ||
const body = { | ||
method: 'executeOffer', | ||
offer: { | ||
id, | ||
invitationSpec: { | ||
source: 'contract', | ||
instance: smallCaps.ref(wkInstance.game1), | ||
publicInvitationMaker: 'makeJoinInvitation', | ||
}, | ||
proposal: { give, want }, | ||
}, | ||
}; | ||
|
||
console.error(JSON.stringify(body.offer, smallCaps.replacer, 1)); | ||
|
||
const capData = { | ||
body: `#${JSON.stringify(body, smallCaps.replacer)}`, | ||
slots, | ||
}; | ||
const action = JSON.stringify(capData); | ||
|
||
console.log(action); |
32 changes: 32 additions & 0 deletions
32
...nt/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/wallet-all-ertp/wf-game-propose.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
|
||
# Propose and carry out starting game contract | ||
|
||
SDK=${SDK:-/usr/src/agoric-sdk} | ||
UP11=${UP11:-$SDK/upgrade-test-scripts/agoric-upgrade-11} | ||
WFUP=${WFUP:-$UP11/wallet-all-ertp} | ||
|
||
cd $WFUP | ||
|
||
. $SDK/upgrade-test-scripts/env_setup.sh | ||
. $UP11/env_setup.sh | ||
|
||
TITLE="Start Game1 Contract" | ||
|
||
DESC="Start Game1 and register well-known Place issuer" | ||
|
||
# TODO: fix error recovery (or don't bother with it at all) | ||
[ -f ./start-game1-permit.json ] || (echo run wf-install-bundle.sh first ; exit 1) | ||
|
||
agd tx gov submit-proposal \ | ||
swingset-core-eval ./start-game1-permit.json ./start-game1.js \ | ||
--title="$TITLE" --description="$DESC" \ | ||
--from=validator --keyring-backend=test \ | ||
--deposit=10000000ubld \ | ||
--gas=auto --gas-adjustment=1.2 \ | ||
--chain-id=agoriclocal --yes -b block -o json | ||
|
||
agd --chain-id=agoriclocal query gov proposals --output json | \ | ||
jq -c '.proposals[] | [.proposal_id,.voting_end_time,.status]'; | ||
|
||
voteLatestProposalAndWait |
34 changes: 34 additions & 0 deletions
34
...upgrade-test/upgrade-test-scripts/agoric-upgrade-11/wallet-all-ertp/wf-install-bundles.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash | ||
|
||
# Install bundles for walletFactory upgrade | ||
|
||
set -e | ||
|
||
SDK=${SDK:-/usr/src/agoric-sdk} | ||
UP11=${UP11:-$SDK/upgrade-test-scripts/agoric-upgrade-11} | ||
|
||
cd $UP11/wallet-all-ertp | ||
|
||
echo +++ run walletFactory, game upgrade proposal builders +++ | ||
(agoric run $SDK/packages/vats/scripts/build-walletFactory-upgrade.js; \ | ||
agoric run $SDK/packages/vats/scripts/build-game1-start.js | ||
)>/tmp/,run.log | ||
bundles=$($UP11/tools/parseProposals.mjs </tmp/,run.log | jq -r '.bundles[]' | sort -u ) | ||
|
||
echo +++ proposal evals for later +++ | ||
/bin/pwd | ||
ls ./upgrade-walletFactory* ./start-game1* | ||
|
||
echo +++++ install bundles +++++ | ||
|
||
# TODO: try `agoric publish` to better track outcome | ||
install_bundle() { | ||
agd tx swingset install-bundle "@$1" \ | ||
--from gov1 --keyring-backend=test --gas=auto \ | ||
--chain-id=agoriclocal -bblock --yes -o json | ||
} | ||
|
||
for b in $bundles; do | ||
echo installing $b | ||
install_bundle $b | ||
done |
37 changes: 37 additions & 0 deletions
37
...loyment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/wallet-all-ertp/wf-propose.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
|
||
# Propose and carry out Wallet Factory upgrade | ||
|
||
set -e | ||
|
||
SDK=${SDK:-/usr/src/agoric-sdk} | ||
UP11=${UP11:-$SDK/upgrade-test-scripts/agoric-upgrade-11} | ||
WFUP=${WFUP:-$UP11/wallet-all-ertp} | ||
|
||
cd $WFUP | ||
|
||
# import voteLatestProposalAndWait | ||
. $UP11/env_setup.sh | ||
. $UP11/../env_setup.sh | ||
|
||
TITLE="Add NFT/non-vbank support in WalletFactory" | ||
DESC="Upgrade WalletFactory to support arbitrary ERTP assets such as NFTs" | ||
|
||
if [ ! -f ./upgrade-walletFactory-permit.json ]; then | ||
file ./upgrade-walletFactory-permit.json | ||
echo run wfup.js proposal builder first | ||
exit 1 | ||
fi | ||
|
||
agd tx gov submit-proposal \ | ||
swingset-core-eval ./upgrade-walletFactory-permit.json ./upgrade-walletFactory.js \ | ||
--title="$TITLE" --description="$DESC" \ | ||
--from=validator --keyring-backend=test \ | ||
--deposit=10000000ubld \ | ||
--gas=auto --gas-adjustment=1.2 \ | ||
--chain-id=agoriclocal --yes -b block -o json | ||
|
||
agd query gov proposals --output json | \ | ||
jq -c '.proposals[] | [.proposal_id,.voting_end_time,.status]'; | ||
|
||
voteLatestProposalAndWait |
Oops, something went wrong.