Agoric / agoric-sdk

monorepo for the Agoric Javascript smart contract platform
Apache License 2.0
326 stars 206 forks source link

tsc failures during publish / pre-pack #7879

Open warner opened 1 year ago

warner commented 1 year ago

Our MAINTAINERS.md has a note to repeat the yarn lerna publish from-package step multiple times if any errors are encountered. The error I observed while publishing the mainnet1B-rc2 packages during this step were:

lerna info lifecycle @agoric/governance@0.10.2~prepack: @agoric/governance@0.10.2
lerna info lifecycle @agoric/smart-wallet@0.5.2~prepack: @agoric/smart-wallet@0.5.2

> @agoric/governance@0.10.2 prepack /home/node/trees/release/agoric-sdk/packages/governance
> echo "export {}; " | cat - src/types-ambient.js > src/types.js && tsc --build jsconfig.build.json

lerna info lifecycle @agoric/vats@0.15.0~prepack: @agoric/vats@0.15.0

> @agoric/smart-wallet@0.5.2 prepack /home/node/trees/release/agoric-sdk/packages/smart-wallet
> tsc --build jsconfig.build.json

../inter-protocol/src/auction/params.js:119:58 - error TS2304: Cannot find name 'GovernanceSubscriptionState'.

119  * @param {import('@agoric/notifier').StoredPublisherKit<GovernanceSubscriptionState>} publisherKit
                                                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~

../inter-protocol/src/auction/scheduler.js:78:31 - error TS2304: Cannot find name 'GovernanceSubscriptionState'.

78  * @param {StoredSubscription<GovernanceSubscriptionState>} paramUpdateSubscription
                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~

../inter-protocol/src/auction/auctioneer.js:381:16 - error TS2304: Cannot find name 'GovernanceTerms'.

381  * @param {ZCF<GovernanceTerms<typeof auctioneerParamTypes> & {
                   ~~~~~~~~~~~~~~~

../inter-protocol/src/auction/auctioneer.js:670:7 - error TS2578: Unused '@ts-expect-error' directive.

670       // @ts-expect-error types are correct. How to convince TS?
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../inter-protocol/src/econCommitteeCharter.js:58:33 - error TS2304: Cannot find name 'GovernorCreatorFacet'.

58   /** @type {MapStore<Instance, GovernorCreatorFacet<any>>} */
                                   ~~~~~~~~~~~~~~~~~~~~

../inter-protocol/src/econCommitteeCharter.js:173:18 - error TS2304: Cannot find name 'GovernorCreatorFacet'.

173        * @param {GovernorCreatorFacet<any>} governorFacet
                     ~~~~~~~~~~~~~~~~~~~~

../inter-protocol/src/psm/psm.js:106:16 - error TS2304: Cannot find name 'GovernanceTerms'.

106  * @param {ZCF<GovernanceTerms<{
                   ~~~~~~~~~~~~~~~

../vats/src/provisionPool.js:31:30 - error TS2304: Cannot find name 'GovernanceTerms'.

31  * @typedef {StandardTerms & GovernanceTerms<{
                                ~~~~~~~~~~~~~~~

../inter-protocol/src/reserve/assetReserve.js:29:16 - error TS2304: Cannot find name 'GovernanceTerms'.

29  * @param {ZCF<GovernanceTerms<{}> &
                  ~~~~~~~~~~~~~~~

../inter-protocol/src/reserve/assetReserve.js:101:16 - error TS2304: Cannot find name 'GovernedCreatorFacet'.

101     /** @type {GovernedCreatorFacet<typeof assetReserveKit.machine>} */
                   ~~~~~~~~~~~~~~~~~~~~

../inter-protocol/src/reserve/assetReserve.js:103:16 - error TS2304: Cannot find name 'GovernedPublicFacet'.

103     /** @type {GovernedPublicFacet<typeof assetReserveKit.public>} */
                   ~~~~~~~~~~~~~~~~~~~

../inter-protocol/src/vaultFactory/liquidation.js:67:12 - error TS2304: Cannot find name 'ParamStateRecord'.

67  * @param {ParamStateRecord} opts.params
              ~~~~~~~~~~~~~~~~

../inter-protocol/src/vaultFactory/liquidation.js:82:3 - error TS2578: Unused '@ts-expect-error' directive.

82   // @ts-expect-error Casting
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~

../inter-protocol/src/vaultFactory/liquidation.js:86:3 - error TS2578: Unused '@ts-expect-error' directive.

86   // @ts-expect-error Casting
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~

../inter-protocol/src/vaultFactory/vaultDirector.js:342:28 - error TS2304: Cannot find name 'GovernedApis'.

342         /** @returns {ERef<GovernedApis>} */
                               ~~~~~~~~~~~~

../inter-protocol/src/vaultFactory/vaultDirector.js:344:11 - error TS2578: Unused '@ts-expect-error' directive.

344           // @ts-expect-error cast
              ~~~~~~~~~~~~~~~~~~~~~~~~

../inter-protocol/src/vaultFactory/params.js:85:58 - error TS2304: Cannot find name 'GovernanceSubscriptionState'.

85  * @param {import('@agoric/notifier').StoredPublisherKit<GovernanceSubscriptionState>} publisherKit
                                                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~

../inter-protocol/src/vaultFactory/vaultFactory.js:37:18 - error TS2304: Cannot find name 'GovernanceTerms'.

37  * @typedef {ZCF<GovernanceTerms<import('./params').VaultDirectorParams> & {
                    ~~~~~~~~~~~~~~~

../vats/src/core/types.js:203:15 - error TS2304: Cannot find name 'GovernableStartFn'.

203  * @template {GovernableStartFn} SF
                  ~~~~~~~~~~~~~~~~~

../vats/src/core/types.js:215:26 - error TS2304: Cannot find name 'GovernableStartFn'.

215  * @typedef {<SF extends GovernableStartFn>(opts: StartGovernedUpgradableOpts<SF>) => Promise<GovernanceFacetKit<SF>>
                             ~~~~~~~~~~~~~~~~~

../vats/src/core/types.js:215:95 - error TS2304: Cannot find name 'GovernanceFacetKit'.

215  * @typedef {<SF extends GovernableStartFn>(opts: StartGovernedUpgradableOpts<SF>) => Promise<GovernanceFacetKit<SF>>
                                                                                                  ~~~~~~~~~~~~~~~~~~

../vats/src/core/types.js:273:47 - error TS2304: Cannot find name 'GovernanceFacetKit'.

273  *   governedContractKits: MapStore<Instance, GovernanceFacetKit<any> & {label: string}>,
                                                  ~~~~~~~~~~~~~~~~~~

Found 22 errors.

lerna info lifecycle @agoric/governance@0.10.2~postpack: @agoric/governance@0.10.2
lerna info lifecycle @agoric/smart-wallet@0.5.2~prepack: Failed to exec prepack script

> @agoric/vats@0.15.0 prepack /home/node/trees/release/agoric-sdk/packages/vats
> tsc --build jsconfig.build.json

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

This is after a full yarn build.

It seems to run prepack for all packages, runs into a type problem while building the type files for smart-wallet, which then halts the whole process. To resolve it, I had to delete all the generated files, then run yarn lerna publish from-package again.

warner commented 1 year ago

Actually, as a workaround, I use git restore packages/*/package.json packages/*/*/package.json to remove the changes it makes to all the package.json files (inserting a gitHead field in each), leaving all the generated files in place, then I run yarn lerna publish from-package a second time. This time, it fails like this:

Removing tools/types-ambient.d.ts
Removing tools/types-ambient.d.ts.map
Removing tools/types.d.ts
Removing tools/types.d.ts.map
lerna info lifecycle @agoric/smart-wallet@0.5.2~prepack: @agoric/smart-wallet@0.5.2
lerna info lifecycle @agoric/vats@0.15.0~prepack: @agoric/vats@0.15.0
lerna info lifecycle @agoric/governance@0.10.2~prepack: @agoric/governance@0.10.2

> @agoric/smart-wallet@0.5.2 prepack /home/node/trees/release/agoric-sdk/packages/smart-wallet
> tsc --build jsconfig.build.json

src/invitations.js:62:17 - error TS2304: Cannot find name 'NameHub'.

62  * @param {ERef<NameHub>} agoricNames
                   ~~~~~~~

Found 1 error.

lerna info lifecycle @agoric/smart-wallet@0.5.2~prepack: Failed to exec prepack script

> @agoric/vats@0.15.0 prepack /home/node/trees/release/agoric-sdk/packages/vats
> tsc --build jsconfig.build.json

error Command failed with exit code 1.

I do the same dance, a few times, and did a few git clean -i along the way. Eventually, I don't know why, the publish started working.

warner commented 1 year ago

Not sure if it's relevant, but when I did a git status after the publish finished, there was a single packages/zoe/tools/types.js remaining (generated by the process, but not automatically cleaned up).

michaelfig commented 1 year ago

I think the missing instruction is to do git reset --hard HEAD, as well as git clean -f . between from-package attempts. As to what caused the initial error, was it perhaps TOTP expiry or other interruption of the lerna publish process?