clrfund/monorepo

Create new project problem.

ChiHaoLu opened this issue · 14 comments

Hi there, I have to tried to deploy the whole project to rinkeby with the document in repo, but after I open the website and try to create a new project, the final step is stucked.


  • Here is my deploy logs:
$ npx hardhat run --network rinkeby scripts/deployRound.ts
 ·--------------------------------------|-------------·
 |  Contract Name                       ·  Size (Kb)  │
 ·······································|··············
 |  Address                             ·       0.08  │
 ·······································|··············
 │ ...                                  ·             │ 
 ·······································|··············
 |  VerifyTally                         ·       2.33  │
 ·--------------------------------------|-------------·
*******************
Deploying a new clr.fund instance of contracts!
*******************
deployer.address:  0xB42faBF7BCAE8bc5E368716B568a6f8Fdf3F84ec
maciFactory.address:  0x806EE0951A74E4A3DA61AEfb3600a9e54286A4B8
fundingRoundFactory.address:  0x82BA798f523fF464D8397493Ff97672416ED3A98
userRegistry.address:  0x7340E74cF375B9bDA775eCE372b1C8981164840a
recipientRegistry.address:  0x11Ef1898448376EEC4eE33Bbd83FA775271a4F08
serializedCoordinatorPrivKey:  macisk.236bf3b50b07b2444d5f946e8a88d1b8d7e4ac3f49f4d091152d8aaa4dcdc3c7
serializedCoordinatorPubKey:  macipk.bed1ddab4f3c710eee1fb561b617b16d75ba27967441b977a00ccfeef544c30a
  • This is my .env in contracts:
# Recipient registry type for local deployment: simple, optimistic
RECIPIENT_REGISTRY_TYPE=simple

# Supported values: simple, brightid
USER_REGISTRY_TYPE=simple
# clr.fund (prod) or CLRFundTest (testing)
BRIGHTID_CONTEXT=clr.fund
# BrightId node addr that signs verifications. Node One uses this one
BRIGHTID_VERIFIER_ADDR=0xb1d71F62bEe34E9Fc349234C201090c33BCdF6DB

# JSON-RPC endpoint to the selected network
JSONRPC_HTTP_URL=https://eth-rinkeby.alchemyapi.io/v2/1YRsY....g1TU

# One of the two options
WALLET_MNEMONIC=attract ... hover
WALLET_PRIVATE_KEY=

# Token address for funding round .setToken
NATIVE_TOKEN_ADDRESS=0x5592ec0cfb4dbc12d3ab100b257153436a1f0fea

# Required to use in the tally and finalize scripts
FACTORY_ADDRESS=0x806EE0951A74E4A3DA61AEfb3600a9e54286A4B8
ROUND_ADDRESS=0x82BA798f523fF464D8397493Ff97672416ED3A98
COORDINATOR_PK=macisk.236bf3b50b07b2444d5f946e8a88d1b8d7e4ac3f49f4d091152d8aaa4dcdc3c7
COORDINATOR_ETH_PK=macipk.bed1ddab4f3c710eee1fb561b617b16d75ba27967441b977a00ccfeef544c30a
  • This is my .env in vue-app:
# Chain details where contract is deployed
VUE_APP_ETHEREUM_API_URL=https://eth-rinkeby.alchemyapi.io/v2/1YRsY5...g1TU
VUE_APP_ETHEREUM_API_CHAINID=4
VUE_APP_INFURA_ID=4521b5...1a2b
VUE_APP_IPFS_GATEWAY_URL=https://ipfs.io
VUE_APP_SUBGRAPH_URL=http://localhost:8000/subgraphs/name/daodesigner/clrfund

# Comma-separated list of URLs
VUE_APP_GUN_PEERS=http://localhost:8765/gun

VUE_APP_CLRFUND_FACTORY_ADDRESS=0x82BA798f523fF464D8397493Ff97672416ED3A98

# Supported values: simple, brightid
VUE_APP_USER_REGISTRY_TYPE=simple
# clr.fund (prod) or CLRFundTest (testing)
# Learn more about BrightID and context in /docs/brightid.md
VUE_APP_BRIGHTID_CONTEXT=clr.fund

# Supported values: simple, optimistic, kleros
VUE_APP_RECIPIENT_REGISTRY_TYPE=simple

VUE_APP_RECIPIENT_REGISTRY_POLICY=QmeygKjvrpidJeFHv6ywjUrj718nwtFQgCCPPR4r5nL87R

# Comma-separated list of IPFS hashes
VUE_APP_EXTRA_ROUNDS=

# Operator of clr.fund instance
VUE_APP_OPERATOR=

# Google Service Account credentials in JSON format
GOOGLE_APPLICATION_CREDENTIALS=
# Spreadsheet ID to send recipients data
VUE_APP_GOOGLE_SPREADSHEET_ID=

Because I don't really know what VUE_APP_RECIPIENT_REGISTRY_POLICY, VUE_APP_SUBGRAPH_URL and VUE_APP_GUN_PEERS to do, I think there may be some network setting error here?

I'll update the doc with clarification. So, here's how to fix your errors:

  1. connection to ws://localhost:8765/gun failed
    you can fix this error by running a gun peer service: docker run -p 8765:8765 gundb/gun. See https://github.com/amark/gun#docker for more details. Even with the error, it should be able to add project.. though, it might fail when making donation as some user reported missing key issue.

  2. VUE_APP_RECIPIENT_REGISTRY_TYPE=optimistic
    Currently the ui only supports optimistic recipient registry, see issue #510

  3. USER_REGISTRY_TYPE=brightid
    I think the UI doesn't currently work well with the simple user registry. The brightid user registry is the one I tested

  4. BRIGHTID_CONTEXT=CLRFundTest
    Better use this context for testing in rinkeby

  5. Redeploy new rounds with new recipient and user registry contracts

  6. VUE_APP_SUBGRAPH_URL
    You'll need to deloy the subgraph and set VUE_APP_SUBGRAPH_URL to your own subgraph. You can follow the Running local subgraph guide, but I find it easier to deploy to theGraph hosted service. The subgraph scripts are in the subgraph folder. You'll have to create the rinkeby.json with your funding round factory address and run the command to generate subgraph.yaml before deploying.

npx mustache config/rinkeby.json subgraph.template.yaml > subgraph.yaml
npm run codegen
npm run build
npx graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ <yourname>/clrfund

Hello, @yuetloo !

Thanks for the answering and careful teaching!!!

I'm sorry for not able to solve this problem quickly, I will do my best to follow the steps!

Hi, @yuetloo!

Sorry for bothering you again, here is my new deploy try:

  1. With new argument
contracts/.env:
USER_REGISTRY_TYPE=brightid
BRIGHTID_CONTEXT=CLRFundTest

vue-app/.env:
VUE_APP_RECIPIENT_REGISTRY_TYPE=optimistic
  1. Deploy new round
*******************
Deploying a new clr.fund instance of contracts!
*******************
deployer.address:  0xB42faBF7BCAE8bc5E368716B568a6f8Fdf3F84ec
maciFactory.address:  0xe5208b357307092A501C428cd0aD1Dde1583ea5E
fundingRoundFactory.address:  0xaD841958a0B80105661A0E2Bf78D97190A45e820
userRegistry.address:  0x384d46B0604dd9Ea881AE034f4fc3895117812dc
recipientRegistry.address:  0xed97ccD94C05555A42c42160CAfC82bC635e73BA
serializedCoordinatorPrivKey:  macisk.294313a792989e2f8dfe93e3694c011195d36b308294c22a563bcd34e694d7c
serializedCoordinatorPubKey:  macipk.63652f6ad4ac46a3880db128dc38b938be5f6db9473c7f9fb37871e21cef2990
  1. With new arguments in contracts/.env:
# Required to use in the tally and finalize scripts
FACTORY_ADDRESS=0x806EE0951A74E4A3DA61AEfb3600a9e54286A4B8
ROUND_ADDRESS=0xaD841958a0B80105661A0E2Bf78D97190A45e820
COORDINATOR_PK=macisk.294313a792989e2f8dfe93e3694c011195d36b308294c22a563bcd34e694d7c
COORDINATOR_ETH_PK=macipk.63652f6ad4ac46a3880db128dc38b938be5f6db9473c7f9fb37871e21cef2990
  1. Install subgraph:
$ npm install -g @graphprotocol/graph-cli
$ graph
> Welcome to graph CLI version 0.31.0!
  Type graph --help to view common commands.
  1. Init subgraph:
$ graph init --product hosted-service chihaolu/qf
>
√ Protocol · ethereum
√ Subgraph name · chihaolu/qf
√ Directory to create the subgraph in · qf
? Ethereum network ... 
? Ethereum network ... 
? Ethereum network ... 
√ Ethereum network · rinkeby
√ Contract address · 0xaD841958a0B80105661A0E2Bf78D97190A45e820
× Failed to fetch ABI from Etherscan: ABI not found, try loading it from a local file
√ ABI file (path) · C:\Users\qazws\Desktop\Blockchain\clf\monorepo\subgraph\abis\FundingRoundFactory.json
√ Contract Name · FundingRoundFactory
———
  Generate subgraph
  Write subgraph to directory
√ Create subgraph scaffold
√ Initialize networks config
√ Initialize subgraph repository
√ Install dependencies with yarn
√ Generate ABI and schema types with yarn codegen
√ Add another contract? (y/N) · false

Subgraph chihaolu/qf created in qf

Next steps:

  1. Run `graph auth` to authenticate with your deploy key.

  2. Type `cd qf` to enter the subgraph.

  3. Run `yarn deploy` to deploy the subgraph.

Make sure to visit the documentation on https://thegraph.com/docs/ for further information.
  1. Create subgraph/config/rinkeby.json
{
  "network": "rinkeby",
  "address": "0xaD841958a0B80105661A0E2Bf78D97190A45e820",
  "factoryStartBlock": 10924092,
  "recipientRegistryStartBlock": 10924096
}

  1. Revise subgraph.yaml and deploy to IPFS:
$ cd subgraph
$ npx mustache config/rinkeby.json subgraph.template.yaml > subgraph.yaml
$ yarn run codegen
$ npm run build
$ npx graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ chihaolu/qf

But in the step.7, the command $ npm run codegen returns the error:

yarn run v1.22.18
$ graph codegen
  Skip migration: Bump mapping apiVersion from 0.0.1 to 0.0.2 (graph-ts dependency not installed yet)
  Skip migration: Bump mapping apiVersion from 0.0.2 to 0.0.3 (graph-ts dependency not installed yet)
  Skip migration: Bump mapping apiVersion from 0.0.3 to 0.0.4 (graph-ts dependency not installed yet)
× Failed to apply migrations: end of the stream or a document separator is expected at line 1, column 4:
    ��s
       ^
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

May I ask you for a help again😥

@ChiHaoLu , what branch of clrfund did you use? I used the develop branch and no error from the codegen command. Was the codegen command failing in the clrfund/monorepo/subgraph folder or in the qf folder generated from the graph init command?

Check to make sure you didn't accidentally modify some subgraph files and the changes were not complete. The error looks like some files are corrupt or has incomplete changes..

@yuetloo I am using develop branch, I have solve the problem because I didn't command the codegen in qf folder. But the create project stuck still happens. Here is my continue steps after above.

  1. Revise subgraph/subgraph.yaml and deploy to IPFS:
$ npx mustache config/rinkeby.json subgraph.template.yaml > subgraph.yaml
$ cd qf
$ npm run codegen
$ npm run build
$ npx graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ chihaolu/qf
  1. Deploy Subgraph(in subgraph/qf)
$ graph auth --product hosted-service 35b6af8330584ac6ab0cfaaad4cf6832
> Deploy key set for https://api.thegraph.com/deploy/
$ graph deploy --product hosted-service chihaolu/qf
  1. Revise vue-app/.env
VUE_APP_SUBGRAPH_URL=https://api.thegraph.com/subgraphs/name/chihaolu/qf

# Comma-separated list of URLs
VUE_APP_GUN_PEERS=http://localhost:8765/gun

VUE_APP_CLRFUND_FACTORY_ADDRESS=0xaD841958a0B80105661A0E2Bf78D97190A45e820

# Supported values: simple, brightid
VUE_APP_USER_REGISTRY_TYPE=simple
# clr.fund (prod) or CLRFundTest (testing)
# Learn more about BrightID and context in /docs/brightid.md
VUE_APP_BRIGHTID_CONTEXT=clr.fund

# Supported values: simple, optimistic, kleros
VUE_APP_RECIPIENT_REGISTRY_TYPE=optimistic

VUE_APP_RECIPIENT_REGISTRY_POLICY=QmYmiHfAh7mGMFxRpP1pTNLv1pjuYNW8nmxsCAJU2XoAKF

# Comma-separated list of IPFS hashes
VUE_APP_EXTRA_ROUNDS=

# Operator of clr.fund instance
VUE_APP_OPERATOR=

# Google Service Account credentials in JSON format
GOOGLE_APPLICATION_CREDENTIALS=
# Spreadsheet ID to send recipients data
VUE_APP_GOOGLE_SPREADSHEET_ID=
  1. Build & Deploy Vue-App(UI)
$ cd vue-app
$ yarn build
$ ipfs add -r vue-app/dist/
$ yarn start:web

However the create project problem still here, the error in the inspect are:


I have compared my hosted service with yours, it seems like I didn't fetch the right contract interface or schema?

And in the inspect error:

fundingRoundAddress: 0x4377660ed8fb7ab84c0f88dd06f583be8ccff292

seems not match my deploy contract address.

I couldn't deploy the subgraph in subgraph folder... It return the error:

end of the stream or a document separator is expected at line 1, column 4:
    ��s
       ^

However I didn't change the any files except the rinkeby.json in subgraph/config...

Hmm.. you definitely cannot use the qf folder generated from the graph init command because it was generated using 1 contract and clrfund indexes more than 1 contract.

I would suggest getting a clean copy of the source code, e.g. git pull, and using git status to check that no new changes are introduced other than the config/rinkeby.json

Remove the build and generated folders which will be created by the codegen and build commands. If you noticed the generated/FundingRoundFactory/MACI.ts is deleted, you can ignore this as that file is not needed to deploy the subgraph.

Remove the node_modules folder and run the yarn command to reinstall all dependencies.

I also usually use theGraph explorer to create the subgraph manually instead of using the graph init command. After creation, you should see a subgraph created with undeployed status on the explorer

Here's the commands I used after creating the subgraph on the explorer

$ cd subgraph
$ rm -rf build generated node_modules
$ yarn
$ npx mustache config/rinkeby.json subgraph.template.yaml > subgraph.yaml
$ yarn codegen
$ yarn build
$ npx graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ chihaolu/qf

Give that a try, hope it works, because I tested the steps, and they work for me.

I have never had an issue with subgraph and node versions, but just in case, here are my versions
➜ subgraph git:(develop) ✗ node -v
v16.13.2
➜ subgraph git:(develop) ✗ npm -v
8.1.2
➜ subgraph git:(develop) ✗ yarn -v
1.22.18

I have REDO all steps above with the new document in goerli network.

After the deployment in georli, I make sure the file in subgraph haven't change except config/goerli.json, and remove all of the generated folders. And did not use init but follow your step above.

Here is the same error when run yarn codegen in subgraph folder::

yarn run v1.22.18
$ graph codegen
  Skip migration: Bump mapping apiVersion from 0.0.1 to 0.0.2 (graph-ts dependency not installed yet)
  Skip migration: Bump mapping apiVersion from 0.0.2 to 0.0.3 (graph-ts dependency not installed yet)
  Skip migration: Bump mapping apiVersion from 0.0.3 to 0.0.4 (graph-ts dependency not installed yet)
× Failed to apply migrations: end of the stream or a document separator is expected at line 1, column 4:
    ��s
       ^
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Here is my debug.log:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'codegen'
1 verbose cli ]
2 info using npm@6.14.15
3 info using node@v14.18.1
4 verbose run-script [ 'precodegen', 'codegen', 'postcodegen' ]
5 info lifecycle @clrfund/subgraph@0.7.0~precodegen: @clrfund/subgraph@0.7.0
6 info lifecycle @clrfund/subgraph@0.7.0~codegen: @clrfund/subgraph@0.7.0
7 verbose lifecycle @clrfund/subgraph@0.7.0~codegen: unsafe-perm in lifecycle true
8 verbose lifecycle @clrfund/subgraph@0.7.0~codegen: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\qazws\Desktop\Blockchain\clf\monorepo\subgraph\node_modules\.bin;C:\gurobi951\win64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\nodejs\;C:\Users\qazws\AppData\Local\Programs\Python\Python39\;C:\Users\qazws\AppData\Local\Programs\Python\Python39\Scripts;C:\Program Files\Geth;C:\Program Files\Git\cmd;C:\ProgramData\chocolatey\bin;;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Docker\Docker\resources\bin;C:\ProgramData\DockerDesktop\version-bin;C:\Users\qazws\.cargo\bin;C:\Users\qazws\AppData\Local\Microsoft\WindowsApps;;C:\Users\qazws\AppData\Local\Programs\Microsoft VS Code\bin;C:\Program Files\Bandizip\;C:\Users\qazws\AppData\Roaming\npm;C:\Users\qazws\AppData\Local\Pandoc\;;12345678;;C:\Users\qazws\Apps\go-ipfs_v0.13.0\go-ipfs
9 verbose lifecycle @clrfund/subgraph@0.7.0~codegen: CWD: C:\Users\qazws\Desktop\Blockchain\clf\monorepo\subgraph
10 silly lifecycle @clrfund/subgraph@0.7.0~codegen: Args: [ '/d /s /c', 'graph codegen' ]
11 silly lifecycle @clrfund/subgraph@0.7.0~codegen: Returned: code: 1  signal: null
12 info lifecycle @clrfund/subgraph@0.7.0~codegen: Failed to exec codegen script
13 verbose stack Error: @clrfund/subgraph@0.7.0 codegen: `graph codegen`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:400:28)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:400:28)
13 verbose stack     at maybeClose (internal/child_process.js:1058:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5)
14 verbose pkgid @clrfund/subgraph@0.7.0
15 verbose cwd C:\Users\qazws\Desktop\Blockchain\clf\monorepo\subgraph
16 verbose Windows_NT 10.0.22000
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "codegen"
18 verbose node v14.18.1
19 verbose npm  v6.14.15
20 error code ELIFECYCLE
21 error errno 1
22 error @clrfund/subgraph@0.7.0 codegen: `graph codegen`
22 error Exit status 1
23 error Failed at the @clrfund/subgraph@0.7.0 codegen script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

Does the problem come from the some .yaml file? or because of the version of @graphprotocol/graph-cli?(I have the latest version of the @graphprotocol/graph-cli)

@ChiHaoLu I just noticed you're running on windows. I have not deployed the instance on windows before and have not seen this error. I'm not sure but it looks like graph codegen crashed on the machine. Have you tried deploying a simple subgraph from your machine?

I would suggest deploying the instance from a Linux machine as that's the tested platform. Even if you can resolve all these issues and eventually be able to start the web app, you'll still need to run theMACI commands to tally votes from a Linux machine because there's Linux dependency from the ZK tools that MACI uses.

I got it. I have redo the whole steps in my Linux VM, but after the yarn codegen, the another problem appears:

chihaolu@chihaolu-VirtualBox:~/blockchain/monorepo/subgraph$ yarn codegen
yarn run v1.22.19
$ graph codegen
The current version of graph-cli can't be used with mappings on apiVersion less than '0.0.5'
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I guess this may be relative with the @graphprotocol/graph-cli version?


Edited: I solve the codegen problem by downgrading the @graphprotocol/graph-cli to 0.18.0, however, there is another problem when using yarn build:

chihaolu@chihaolu-VirtualBox:~/blockchain/monorepo/subgraph$ yarn build
yarn run v1.22.19
$ graph build
  Skip migration: Bump mapping apiVersion from 0.0.1 to 0.0.2 (graph-ts dependency not installed yet)
  Skip migration: Bump mapping apiVersion from 0.0.2 to 0.0.3 (graph-ts dependency not installed yet)
  Skip migration: Bump mapping apiVersion from 0.0.3 to 0.0.4 (graph-ts dependency not installed yet)
  Skip migration: Bump mapping specVersion from 0.0.1 to 0.0.2
✔ Apply migrations
✔ Load subgraph from subgraph.yaml
  Compile data source: FundingRoundFactory => build/FundingRoundFactory/FundingRoundFactory.wasm
✖ Failed to compile subgraph: Failed to compile data source mapping: Import file '~lib/@graphprotocol/graph-ts.ts' not found.
Error: Failed to compile data source mapping: Import file '~lib/@graphprotocol/graph-ts.ts' not found.
    at Compiler._compileDataSourceMapping (/usr/local/share/.config/yarn/global/node_modules/@graphprotocol/graph-cli/src/compiler.js:308:13)
    at /usr/local/share/.config/yarn/global/node_modules/@graphprotocol/graph-cli/src/compiler.js:184:20
    at updateInDeepMap (/usr/local/share/.config/yarn/global/node_modules/immutable/dist/immutable.js:1971:22)
    at updateInDeepMap (/usr/local/share/.config/yarn/global/node_modules/immutable/dist/immutable.js:1980:23)
    at updateInDeepMap (/usr/local/share/.config/yarn/global/node_modules/immutable/dist/immutable.js:1980:23)
    at Map.updateIn (/usr/local/share/.config/yarn/global/node_modules/immutable/dist/immutable.js:1278:26)
    at /usr/local/share/.config/yarn/global/node_modules/@graphprotocol/graph-cli/src/compiler.js:183:24
    at /usr/local/share/.config/yarn/global/node_modules/immutable/dist/immutable.js:3016:46
    at List.__iterate (/usr/local/share/.config/yarn/global/node_modules/immutable/dist/immutable.js:2206:13)
    at IndexedIterable.mappedSequence.__iterateUncached (/usr/local/share/.config/yarn/global/node_modules/immutable/dist/immutable.js:3015:23)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

If I upgrade the @graphprotocol/graph-cli to latest after yarn codegen before yarn build, the error will be:

chihaolu@chihaolu-VirtualBox:~/blockchain/monorepo/subgraph$ yarn build
yarn run v1.22.19
$ graph build
/usr/local/share/.config/yarn/global/node_modules/gluegun/build/index.js:13
    throw up;
    ^

Error: Could not locate `@graphprotocol/graph-ts` package in parent directories of subgraph manifest.
    at new Compiler (/usr/local/share/.config/yarn/global/node_modules/@graphprotocol/graph-cli/src/compiler/index.js:47:13)
    at createCompiler (/usr/local/share/.config/yarn/global/node_modules/@graphprotocol/graph-cli/src/command-helpers/compiler.js:32:10)
    at Command.run (/usr/local/share/.config/yarn/global/node_modules/@graphprotocol/graph-cli/src/commands/build.js:109:20)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

May I ask what is your @graphprotocol/graph-ts version?
I meet some problem about yarn build after the steps:

$ rm -rf build generated node_modules
$ yarn
$ npx mustache config/goerli.json subgraph.template.yaml > subgraph.yaml
$ yarn codegen
$ yarn build
>
yarn run v1.22.19
$ graph build
  Skip migration: Bump mapping apiVersion from 0.0.1 to 0.0.2 (graph-ts dependency not installed yet)
  Skip migration: Bump mapping apiVersion from 0.0.2 to 0.0.3 (graph-ts dependency not installed yet)
  Skip migration: Bump mapping apiVersion from 0.0.3 to 0.0.4 (graph-ts dependency not installed yet)
  Skip migration: Bump mapping specVersion from 0.0.1 to 0.0.2
✔ Apply migrations
✔ Load subgraph from subgraph.yaml
  Compile data source: FundingRoundFactory => build/FundingRoundFactory/FundingRoundFactory.wasm
⠋ Compile subgraphERROR TS2304: Cannot find name '__alloc'.

 __alloc(0);
 ~~~~~~~
 in ~lib/@graphprotocol/graph-ts/common/eager_offset.ts(41,0)

ERROR TS2339: Property 'log' does not exist on type '~lib/@graphprotocol/graph-ts/index/log.log'.

     log.log(Level.INFO, format(msg, args))
         ~~~
 in ~lib/@graphprotocol/graph-ts/index.ts(134,8)

WARNING AS102: User-defined: "Calling 'memory.allocate' requires a memory manager to be present."

     WARNING("Calling 'memory.allocate' requires a memory manager to be present.");
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 in ~lib/memory.ts(41,4)

WARNING AS102: User-defined: "Calling 'memory.allocate' requires a memory manager to be present."

     WARNING("Calling 'memory.allocate' requires a memory manager to be present.");
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 in ~lib/memory.ts(41,4)

WARNING AS102: User-defined: "Calling 'memory.free' requires a memory manager to be present."

     WARNING("Calling 'memory.free' requires a memory manager to be present.");
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 in ~lib/memory.ts(47,4)

WARNING AS102: User-defined: "Calling 'memory.allocate' requires a memory manager to be present."

     WARNING("Calling 'memory.allocate' requires a memory manager to be present.");
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 in ~lib/memory.ts(41,4)

ERROR TS2304: Cannot find name '__alloc'.

 __alloc(0);
 ~~~~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/common/eager_offset.ts(41,0)

ERROR TS2304: Cannot find name 'idof'.

       return idof<string>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(64,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<ArrayBuffer>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(66,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Int8Array>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(68,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Int16Array>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(70,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Int32Array>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(72,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Int64Array>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(74,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Uint8Array>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(76,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Uint16Array>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(78,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Uint32Array>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(80,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Uint64Array>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(82,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Float32Array>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(84,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Float64Array>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(86,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<BigDecimal>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(88,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Array<bool>>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(90,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Array<Uint8Array>>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(92,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Array<ethereum.Value>>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(94,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Array<Value>>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(96,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Array<JSONValue>>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(98,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Array<string>>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(100,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Array<ethereum.EventParam>>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(102,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Array<TypedMapEntry<string, JSONValue>>>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(104,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Array<Entity>>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(106,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Wrapped<TypedMapEntry<string, JSONValue>>>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(108,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Wrapped<boolean>>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(110,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Wrapped<JSONValue>>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(112,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<ethereum.SmartContractCall>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(114,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<ethereum.EventParam>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(116,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<ethereum.Transaction>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(118,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<ethereum.Block>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(120,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<ethereum.Call>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(122,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<ethereum.Value>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(124,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Value>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(126,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<JSONValue>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(128,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<ethereum.Event>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(130,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Entity>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(132,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<TypedMap<string, JSONValue>>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(134,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<TypedMap<string, Value>>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(136,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<TypedMap<string, JSONValue>>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(138,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<TypedMap<string, TypedMap<string, JSONValue>>>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(140,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Result<TypedMap<string, JSONValue>, boolean>>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(142,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Result<JSONValue, boolean>>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(144,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Array<u8>>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(146,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Array<u16>>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(148,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Array<u32>>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(150,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Array<u64>>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(152,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Array<i8>>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(154,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Array<i16>>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(156,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Array<i32>>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(158,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Array<i64>>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(160,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Array<f32>>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(162,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Array<f64>>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(164,13)

ERROR TS2304: Cannot find name 'idof'.

       return idof<Array<BigDecimal>>()
              ~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(166,13)

ERROR TS2304: Cannot find name '__alloc'.

   return __alloc(size)
          ~~~~~~~
 in ../../../node_modules/@graphprotocol/graph-ts/global/global.ts(173,9)

✖ Failed to compile subgraph: Failed to compile data source mapping: Compile error
Error: Failed to compile data source mapping: Compile error
    at Compiler._compileDataSourceMapping (/usr/local/share/.config/yarn/global/node_modules/@graphprotocol/graph-cli/src/compiler.js:312:13)
    at /usr/local/share/.config/yarn/global/node_modules/@graphprotocol/graph-cli/src/compiler.js:206:20
    at updateInDeepMap (/usr/local/share/.config/yarn/global/node_modules/immutable/dist/immutable.js:1971:22)
    at updateInDeepMap (/usr/local/share/.config/yarn/global/node_modules/immutable/dist/immutable.js:1980:23)
    at updateInDeepMap (/usr/local/share/.config/yarn/global/node_modules/immutable/dist/immutable.js:1980:23)
    at Map.updateIn (/usr/local/share/.config/yarn/global/node_modules/immutable/dist/immutable.js:1278:26)
    at /usr/local/share/.config/yarn/global/node_modules/@graphprotocol/graph-cli/src/compiler.js:205:24
    at /usr/local/share/.config/yarn/global/node_modules/immutable/dist/immutable.js:3016:46
    at List.__iterate (/usr/local/share/.config/yarn/global/node_modules/immutable/dist/immutable.js:2206:13)
    at IndexedIterable.mappedSequence.__iterateUncached (/usr/local/share/.config/yarn/global/node_modules/immutable/dist/immutable.js:3015:23)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@ChiHaoLu , I have @graphprotocol/graph-ts@0.20.0.
Make sure you remove the top-level node_modules (at the monorepo folder) in addition to the node_modules in the subgraph folder.

Also, what Linux flavor do you use? I tested the steps using Ubuntu, 22.04 LTS, amd64 (an AWS instance) and on MacBook Air.