trufflesuite / ganache

:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
https://consensys.io/blog/consensys-announces-the-sunset-of-truffle-and-ganache-and-new-hardhat?utm_source=github&utm_medium=referral&utm_campaign=2023_Sep_truffle-sunset-2023_announcement_
MIT License
2.62k stars 676 forks source link

Ganache doesn't build due type error when calling IPFS method #4103

Open adob opened 1 year ago

adob commented 1 year ago

The following error occurs when attempting build from a clean respository:

npm run build

> build
> npm run tsc && cross-env NODE_OPTIONS=--max_old_space_size=4096 lerna run build

> tsc
> tsc --build src

src/chains/filecoin/filecoin/src/blockchain.ts:716:46 - error TS2345: Argument of type 'string' is not assignable to parameter of type 'CID'.

716       await this.ipfsServer.node.object.stat(cid, {
                                                 ~~~

src/chains/filecoin/filecoin/src/blockchain.ts:730:57 - error TS2345: Argument of type 'string' is not assignable to parameter of type 'CID'.

730     const stat = await this.ipfsServer.node.object.stat(cid, {
                                                            ~~~

Found 2 errors.
davidmurdoch commented 1 year ago

What node version are you running?

adob commented 1 year ago

This issue occurred when building from a fresh repo at head HEAD on the devel branch as well as on the v7.7.2 tag.

  git clone --depth 1 https://github.com/trufflesuite/ganache.git
  cd ganache
  ...
  npm run build
davidmurdoch commented 1 year ago

What node version are you running?

adob commented 1 year ago

I'm running Node v18.2.1

$ node --version
v18.12.1

I just tried reproducing again and the issue is still there. Full repro steps:

$ git clone --depth 1 https://github.com/trufflesuite/ganache.git
$ npm install

The following output is observed:


> postinstall
> cd scripts && ts-node postinstall

lerna notice cli v4.0.0
lerna info versioning independent
lerna info Bootstrapping 21 packages
lerna info Installing external dependencies
lerna info Symlinking packages and binaries
lerna info lifecycle @ganache/ethereum@0.8.2~postinstall: @ganache/ethereum@0.8.2

> @ganache/ethereum@0.8.2 postinstall /home/user/temp/ganache/src/chains/ethereum/ethereum
> npx patch-package@6.5.0

patch-package 6.5.0
Applying patches...
@ethereumjs/block@4.0.1 ✔
lerna info lifecycle @ganache/console.log@0.3.0~prepare: @ganache/console.log@0.3.0

> @ganache/console.log@0.3.0 prepare /home/user/temp/ganache/src/chains/ethereum/console.log
> cd scripts && ts-node generate

lerna success Bootstrapped 21 packages

> tsc
> tsc --build src

src/chains/filecoin/filecoin/src/blockchain.ts:716:46 - error TS2345: Argument of type 'string' is not assignable to parameter of type 'CID'.

716       await this.ipfsServer.node.object.stat(cid, {
                                                 ~~~

src/chains/filecoin/filecoin/src/blockchain.ts:730:57 - error TS2345: Argument of type 'string' is not assignable to parameter of type 'CID'.

730     const stat = await this.ipfsServer.node.object.stat(cid, {
                                                            ~~~

Found 2 errors.

Error: Command failed: npm run tsc
    at checkExecSyncError (node:child_process:871:11)
    at execSync (node:child_process:943:15)
    at Object.<anonymous> (/home/user/temp/ganache/scripts/postinstall.ts:30:9)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module.m._compile (/home/user/temp/ganache/node_modules/ts-node/src/index.ts:1618:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Object.require.extensions.<computed> [as .ts] (/home/user/temp/ganache/node_modules/ts-node/src/index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Function.Module._load (node:internal/modules/cjs/loader:878:12) {
  status: 2,
  signal: null,
  output: [ null, null, null ],
  pid: 21971,
  stdout: null,
  stderr: null
}
npm ERR! code 1
npm ERR! path /home/user/temp/ganache
npm ERR! command failed
npm ERR! command sh -c -- cd scripts && ts-node postinstall

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/user/.npm/_logs/2023-01-15T23_04_56_343Z-debug-0.log
davidmurdoch commented 1 year ago

Hm, it works okay for me, as well as in CI:

$ node --version
v18.12.1

$ git clone --depth 1 https://github.com/trufflesuite/ganache.git ganache-test && cd ganache-test
Cloning into 'ganache-test'...
remote: Enumerating objects: 763, done.
remote: Counting objects: 100% (763/763), done.
remote: Compressing objects: 100% (625/625), done.
remote: Total 763 (delta 116), reused 421 (delta 79), pack-reused 0
Receiving objects: 100% (763/763), 7.64 MiB | 3.68 MiB/s, done.
Resolving deltas: 100% (116/116), done.

$ npm install

> postinstall
> cd scripts && ts-node postinstall

lerna notice cli v4.0.0
lerna info versioning independent
lerna info Bootstrapping 21 packages
lerna info Installing external dependencies
lerna info Symlinking packages and binaries
lerna info lifecycle @ganache/ethereum@0.8.2~postinstall: @ganache/ethereum@0.8.2

> @ganache/ethereum@0.8.2 postinstall /home/david/work/ganache-test/src/chains/ethereum/ethereum
> npx patch-package@6.5.0

patch-package 6.5.0
Applying patches...
@ethereumjs/block@4.0.1 ✔
lerna info lifecycle @ganache/console.log@0.3.0~prepare: @ganache/console.log@0.3.0

> @ganache/console.log@0.3.0 prepare /home/david/work/ganache-test/src/chains/ethereum/console.log
> cd scripts && ts-node generate

lerna success Bootstrapped 21 packages

> tsc
> tsc --build src

Tip: run source completions.sh to supply bash completions for npm scripts

added 887 packages, and audited 888 packages in 1m

21 vulnerabilities (1 low, 8 moderate, 8 high, 4 critical)

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.

$