Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provide starter IST to newly provisoned accounts #6157

Merged
merged 21 commits into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6f4e845
feat(golang): add module account for provisioning
dckc Sep 8, 2022
0d9c8de
refactor(vats): caller updates namesByAddressAdmin
dckc Sep 8, 2022
e3f9621
feat(vats): provisionPool trades provided assets for IST
dckc Sep 3, 2022
aa535f5
feat(vats): provide initial IST to new accounts
dckc Sep 8, 2022
3b53b9b
feat(inter-protocol): introduce each PSM to the provisionPool
dckc Sep 9, 2022
e3774d5
feat(vats): provide essential issuers to smartWallet
dckc Sep 9, 2022
b4bfe2a
WIP(vats): diagnostic flailing to get initial IST working
dckc Sep 9, 2022
7084f8b
refactor(vats): no magic string for 'depositFacet'
dckc Sep 9, 2022
682151a
feat(vats): better bootstrap errors
dckc Sep 9, 2022
7a55b70
chore(vats): suppress some type errors, pending help
dckc Sep 10, 2022
ef425cb
test(cosmic-swingset): use SMART_WALLET in provision-acct rule
dckc Sep 10, 2022
9c21521
chore(vats): include provisionPool in swingset config files
dckc Sep 10, 2022
578aab3
test(wallet/contract): add provisionPool
dckc Sep 10, 2022
3d1ee48
chore: simplify BankManager type
turadg Sep 11, 2022
8e24ca7
refactor(vats): include -Kit in makeMyAddressNameAdminKit
dckc Sep 11, 2022
1ef8e90
chore(vats): startWalletFactory returns early on missing resources
dckc Sep 11, 2022
6b61390
refactor(vats): privateArgsShape
dckc Sep 11, 2022
aed9ca3
style(vats): lint
dckc Sep 11, 2022
52c17e3
fix(provisionPool): only provision an account if pool has funds
dckc Sep 11, 2022
be10f0d
test(inter-protocol): provide dummy provisionPool.creatorFacet
dckc Sep 12, 2022
f164232
chore(vats): clarify dummy home.X warning
dckc Sep 12, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion golang/cosmos/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ var (
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
vbank.ModuleName: {authtypes.Minter, authtypes.Burner},
vbanktypes.ReservePoolName: nil,
vbanktypes.ProvisionPoolName: nil,
vbanktypes.GiveawayPoolName: nil,
}
)
Expand Down Expand Up @@ -348,7 +349,7 @@ func NewAgoricApp(
keys[banktypes.StoreKey],
app.AccountKeeper,
app.GetSubspace(banktypes.ModuleName),
app.ModuleAccountAddrs(),
app.BlockedAddrs(),
)
app.AuthzKeeper = authzkeeper.NewKeeper(
keys[authzkeeper.StoreKey],
Expand Down Expand Up @@ -835,6 +836,21 @@ func (app *GaiaApp) ModuleAccountAddrs() map[string]bool {
return modAccAddrs
}

// BlockedAddrs returns the app's module account addresses that
// are blocked from receiving funds.
func (app *GaiaApp) BlockedAddrs() map[string]bool {
modAccAddrs := make(map[string]bool)
for acc := range maccPerms {
// The provision pool is not blocked from receiving funds.
if acc == vbanktypes.ProvisionPoolName {
continue
}
modAccAddrs[authtypes.NewModuleAddress(acc).String()] = true
}

return modAccAddrs
}

// LegacyAmino returns GaiaApp's amino codec.
//
// NOTE: This is solely to be used for testing purposes as it may be desirable
Expand Down
1 change: 1 addition & 0 deletions golang/cosmos/x/vbank/types/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ const (

ReservePoolName = "vbank/reserve"
GiveawayPoolName = "vbank/giveaway"
ProvisionPoolName = "vbank/provision"
)
2 changes: 1 addition & 1 deletion packages/cosmic-swingset/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ fund-acct: wait-for-cosmos
provision-acct: wait-for-cosmos
$(AGCH) --chain-id=$(CHAIN_ID) \
--home=t1/bootstrap --keyring-backend=test --from=bootstrap \
tx swingset provision-one t1/$(BASE_PORT) $(ACCT_ADDR) $(AGORIC_POWERS) \
tx swingset provision-one t1/$(BASE_PORT) $(ACCT_ADDR) SMART_WALLET \
--gas=auto --gas-adjustment=$(GAS_ADJUSTMENT) --broadcast-mode=block --yes

FROM_KEY=bootstrap
Expand Down
1 change: 0 additions & 1 deletion packages/inter-protocol/src/proposals/econ-behaviors.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ export const startInterchainPool = async (
{ Central: centralIssuer },
terms,
{
// @ts-expect-error XXX remotable types
bankManager,
},
);
Expand Down
24 changes: 17 additions & 7 deletions packages/inter-protocol/src/proposals/startPSM.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const startPSM = async (
feeMintAccess: feeMintAccessP,
economicCommitteeCreatorFacet,
psmCharterCreatorFacet,
provisionPoolStartResult,
chainStorage,
chainTimerService,
psmFacets,
Expand Down Expand Up @@ -163,13 +164,21 @@ export const startPSM = async (
psmFacetsMap.init(anchorBrand, newPsmFacets);
const instanceKey = `psm-${Stable.symbol}-${keyword}`;
const instanceAdmin = E(agoricNamesAdmin).lookupAdmin('instance');
await E(instanceAdmin).update(instanceKey, newPsmFacets.psm);
await E(psmCharterCreatorFacet).addInstance(
psm,
psmCreatorFacet,
anchorBrand,
stable,
);

await Promise.all([
E(instanceAdmin).update(instanceKey, newPsmFacets.psm),
E(psmCharterCreatorFacet).addInstance(
psm,
psmCreatorFacet,
anchorBrand,
stable,
),
// @ts-expect-error TODO type for provisionPoolStartResult
E(E.get(provisionPoolStartResult).creatorFacet).initPSM(
anchorBrand,
newPsmFacets.psm,
),
]);
};
harden(startPSM);

Expand Down Expand Up @@ -422,6 +431,7 @@ export const PSM_MANIFEST = harden({
zoe: 'zoe',
feeMintAccess: 'zoe',
economicCommitteeCreatorFacet: 'economicCommittee',
provisionPoolStartResult: true,
psmCharterCreatorFacet: 'psmCharter',
chainTimerService: 'timer',
psmFacets: true,
Expand Down
10 changes: 9 additions & 1 deletion packages/inter-protocol/test/psm/setupPsm.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check

import { makeLoopback } from '@endo/captp';
import { Far, makeLoopback } from '@endo/captp';
import { E } from '@endo/eventual-send';

import {
Expand Down Expand Up @@ -120,6 +120,14 @@ export const setupPsm = async (
brand.produce.IST.resolve(istBrand);
issuer.produce.IST.resolve(istIssuer);

space.produce.provisionPoolStartResult.resolve({
creatorFacet: Far('dummy', {
initPSM: () => {
t.log('dummy provisionPool.initPSM');
},
}),
});

await Promise.all([
startEconomicCommittee(space, {
options: { econCommitteeOptions: electorateTerms },
Expand Down
2 changes: 1 addition & 1 deletion packages/inter-protocol/test/test-gov-collateral.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ const makeScenario = async (t, { env = process.env } = {}) => {
space.produce.bridgeManager.resolve(undefined);
space.produce.lienBridge.resolve(undefined);

/** @type {Awaited<BankManager>} */
/** @type {BankManager} */
const bankManager = Far('mock BankManager', {
getAssetSubscription: () => assert.fail('not impl'),
getModuleAccountAddress: () => assert.fail('not impl'),
Expand Down
2 changes: 1 addition & 1 deletion packages/inter-protocol/test/test-interchainPool.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ test('make interchain pool', async t => {
/** @type {PromiseKit<{ mint: ERef<Mint>, issuer: ERef<Issuer>, brand: Brand}>} */
const ibcKitP = makePromiseKit();

/** @type {Awaited<BankManager>} */
/** @type {BankManager} */
const bankManager = Far('mock BankManager', {
getAssetSubscription: () => assert.fail('not impl'),
getModuleAccountAddress: () => assert.fail('not impl'),
Expand Down
3 changes: 3 additions & 0 deletions packages/smart-wallet/test/devices.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import bundleCentralSupply from '@agoric/vats/bundles/bundle-centralSupply.js';
import bundleMintHolder from '@agoric/vats/bundles/bundle-mintHolder.js';
import bundleWalletFactory from '@agoric/vats/bundles/bundle-legacy-walletFactory.js';
import bundleProvisionPool from '@agoric/vats/bundles/bundle-provisionPool.js';

export const devices = {
vatAdmin: {
Expand All @@ -14,6 +15,8 @@ export const devices = {
// TODO(PS0) replace this bundle with the non-legacy smart-wallet
case 'walletFactory':
return bundleWalletFactory;
case 'provisionPool':
return bundleProvisionPool;
default:
throw new Error(`unknown bundle ${name}`);
}
Expand Down
3 changes: 3 additions & 0 deletions packages/vats/decentral-core-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
"priceAuthority": {
"sourceSpec": "@agoric/vats/src/vat-priceAuthority.js"
},
"provisionPool": {
"sourceSpec": "@agoric/vats/src/provisionPool.js"
},
"provisioning": {
"sourceSpec": "@agoric/vats/src/vat-provisioning.js"
},
Expand Down
3 changes: 3 additions & 0 deletions packages/vats/decentral-demo-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
"provisioning": {
"sourceSpec": "@agoric/vats/src/vat-provisioning.js"
},
"provisionPool": {
"sourceSpec": "@agoric/vats/src/provisionPool.js"
},
"sharing": {
"sourceSpec": "@agoric/vats/src/vat-sharing.js"
},
Expand Down
3 changes: 3 additions & 0 deletions packages/vats/decentral-psm-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"walletFactory": {
"sourceSpec": "@agoric/smart-wallet/src/walletFactory.js"
},
"provisionPool": {
"sourceSpec": "@agoric/vats/src/provisionPool.js"
},
"committee": {
"sourceSpec": "@agoric/governance/src/committee.js"
},
Expand Down
1 change: 1 addition & 0 deletions packages/vats/scripts/build-bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const dirname = url.fileURLToPath(new URL('.', import.meta.url));
const sourceToBundle = [
[`../src/centralSupply.js`, `../bundles/bundle-centralSupply.js`],
[`../src/mintHolder.js`, `../bundles/bundle-mintHolder.js`],
[`../src/provisionPool.js`, `../bundles/bundle-provisionPool.js`],
[
`@agoric/wallet/contract/src/singleWallet.js`,
`../bundles/bundle-singleWallet.js`,
Expand Down
18 changes: 6 additions & 12 deletions packages/vats/src/core/basic-behaviors.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,11 @@ export const makeBoard = async ({
harden(makeBoard);

/**
* @param {NameAdmin} namesByAddressAdmin
* @param {string} address
*/
export const makeMyAddressNameAdmin = (namesByAddressAdmin, address) => {
export const makeMyAddressNameAdminKit = address => {
// Create a name hub for this address.
const { nameHub: myAddressNameHub, nameAdmin: rawMyAddressNameAdmin } =
makeNameHubKit();
const { nameHub, nameAdmin: rawMyAddressNameAdmin } = makeNameHubKit();

/** @type {MyAddressNameAdmin} */
const myAddressNameAdmin = Far('myAddressNameAdmin', {
Expand All @@ -201,10 +199,8 @@ export const makeMyAddressNameAdmin = (namesByAddressAdmin, address) => {
});
// reserve space for deposit facet
myAddressNameAdmin.reserve(WalletName.depositFacet);
// Register it with the namesByAddress hub.
namesByAddressAdmin.update(address, myAddressNameHub, myAddressNameAdmin);

return myAddressNameAdmin;
return { nameHub, myAddressNameAdmin };
};

/**
Expand Down Expand Up @@ -234,10 +230,7 @@ export const makeAddressNameHubs = async ({
produce.namesByAddressAdmin.resolve(namesByAddressAdmin);

const perAddress = address => {
const myAddressNameAdmin = makeMyAddressNameAdmin(
namesByAddressAdmin,
address,
);
const { myAddressNameAdmin } = makeMyAddressNameAdminKit(address);
return { agoricNames, namesByAddress, myAddressNameAdmin };
};

Expand Down Expand Up @@ -315,13 +308,14 @@ export const installBootContracts = async ({
devices: { vatAdmin },
consume: { zoe },
installation: {
produce: { centralSupply, mintHolder, walletFactory },
produce: { centralSupply, mintHolder, walletFactory, provisionPool },
},
}) => {
for (const [name, producer] of Object.entries({
centralSupply,
mintHolder,
walletFactory,
provisionPool,
})) {
// This really wants to be E(vatAdminSvc).getBundleIDByName, but it's
// good enough to do D(vatAdmin).getBundleIDByName
Expand Down
8 changes: 6 additions & 2 deletions packages/vats/src/core/boot-psm.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,12 @@ export const buildRootObject = (vatPowers, vatParameters) => {
const log = vatPowers.logger || console.info;

const { anchorAssets, economicCommitteeAddresses } = vatParameters;
fit(harden(anchorAssets), M.arrayOf(AnchorOptionsShape));
fit(harden(economicCommitteeAddresses), M.recordOf(M.string(), M.string()));
fit(harden(anchorAssets), M.arrayOf(AnchorOptionsShape), 'anchorAssets');
fit(
harden(economicCommitteeAddresses),
M.recordOf(M.string(), M.string()),
'economicCommitteeAddresses',
);

const { produce, consume } = makePromiseSpace(log);
const { agoricNames, agoricNamesAdmin, spaces } = makeAgoricNamesAccess(
Expand Down
1 change: 1 addition & 0 deletions packages/vats/src/core/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ const SHARED_CHAIN_BOOTSTRAP_MANIFEST = harden({
centralSupply: 'zoe',
mintHolder: 'zoe',
walletFactory: 'zoe',
provisionPool: 'zoe',
},
},
},
Expand Down
Loading