-
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.
chore(vat-upgrade): simulate what init-chain-info.js is doing
2195ace removes write-chain-info.js from f:fast-usdc. So we simulate what is does (relative to agoricNames) in order to test ephemeral onUpdate callbacks keep working after an agoricNames upgrade. Refs: #10408
- Loading branch information
1 parent
6dc28f7
commit 47c9309
Showing
6 changed files
with
167 additions
and
68 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -4,4 +4,4 @@ addUsdLemons/ | |
addUsdOlives/ | ||
upgradeProvisionPool/ | ||
upgradeAgoricNames/ | ||
appendChainInfo/ | ||
publishTestInfo/ |
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
5 changes: 5 additions & 0 deletions
5
...proposals/p:upgrade-19/agoricNamesCoreEvals/writeToTestInfo/write-to-testInfo-permit.json
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,5 @@ | ||
{ | ||
"consume": { | ||
"agoricNamesAdmin": true | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...egration/proposals/p:upgrade-19/agoricNamesCoreEvals/writeToTestInfo/write-to-testInfo.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// @ts-nocheck | ||
/* eslint-disable no-undef */ | ||
const writeToTestInfo = async powers => { | ||
const { | ||
consume: { agoricNamesAdmin }, | ||
} = powers; | ||
|
||
console.log('writing to testInfo...'); | ||
|
||
E(E(agoricNamesAdmin).lookupAdmin('testInfo')).update('ethereum', { | ||
isAwesome: 'yes', | ||
tech: ['Solidity', 'EVM'], | ||
}); | ||
|
||
console.log('DONE'); | ||
}; | ||
|
||
writeToTestInfo; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { makeTracer } from '@agoric/internal'; | ||
import { E, Far } from '@endo/far'; | ||
import { makeMarshal } from '@endo/marshal'; | ||
|
||
const trace = makeTracer('PublishTestInfo'); | ||
const { Fail } = assert; | ||
|
||
/** | ||
* @param {BootstrapPowers} powers | ||
*/ | ||
export const publishTestInfo = async powers => { | ||
const { | ||
consume: { agoricNamesAdmin, chainStorage: chainStorageP }, | ||
} = powers; | ||
|
||
const chainStorage = await chainStorageP; | ||
if (!chainStorage) { | ||
trace('no chain storage, not registering chain info'); | ||
return; | ||
} | ||
|
||
trace('publishing testInfo'); | ||
const agoricNamesNode = E(chainStorage).makeChildNode('agoricNames'); | ||
const testInfoNode = E(agoricNamesNode).makeChildNode('testInfo'); | ||
const { nameAdmin } = await E(agoricNamesAdmin).provideChild('testInfo'); | ||
|
||
trace('registering onUpdate...'); | ||
await E(nameAdmin).onUpdate( | ||
Far('chain info writer', { | ||
write(entries) { | ||
const marshalData = makeMarshal(_val => Fail`data only`); | ||
const value = JSON.stringify(marshalData.toCapData(entries)); | ||
void E(testInfoNode) | ||
.setValue(value) | ||
.catch(() => | ||
console.log('cannot update vstorage after write to testInfo'), | ||
); | ||
}, | ||
}), | ||
); | ||
|
||
trace('writing to testInfo...'); | ||
await E(nameAdmin).update('agoric', { | ||
isAwesome: 'yes', | ||
tech: ['HardenedJs', 'Orchestration', 'Async_Execution'], | ||
}); | ||
|
||
trace('Done.'); | ||
}; | ||
|
||
export const getManifestForPublishTestInfo = () => { | ||
return { | ||
manifest: { | ||
[publishTestInfo.name]: { | ||
consume: { | ||
agoricNamesAdmin: true, | ||
chainStorage: true, | ||
}, | ||
}, | ||
}, | ||
}; | ||
}; | ||
|
||
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').CoreEvalBuilder} */ | ||
export const defaultProposalBuilder = async () => | ||
harden({ | ||
// Somewhat unorthodox, source the exports from this builder module | ||
sourceSpec: '@agoric/builders/scripts/testing/publish-test-info.js', | ||
getManifestCall: ['getManifestForPublishTestInfo'], | ||
}); | ||
|
||
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').DeployScriptFunction} */ | ||
export default async (homeP, endowments) => { | ||
// import dynamically so the module can work in CoreEval environment | ||
const dspModule = await import('@agoric/deploy-script-support'); | ||
const { makeHelpers } = dspModule; | ||
const { writeCoreEval } = await makeHelpers(homeP, endowments); | ||
await writeCoreEval('publish-test-info', defaultProposalBuilder); | ||
}; |