From 8d603177380e1cbaa6ebc4ac54b424b58cf548e9 Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Mon, 13 Nov 2023 19:50:31 -0500 Subject: [PATCH] subgraph actions --- .github/workflows/bench.yml | 65 +++++++++++ benchmarks/docker-compose.yml | 2 +- benchmarks/package.json | 7 +- benchmarks/ponder/ponder.config.ts | 2 +- benchmarks/src/ponder.ts | 4 +- benchmarks/subgraph/package.json | 4 + benchmarks/subgraph/subgraph.yaml | 4 +- pnpm-lock.yaml | 171 +++++++++++++++++------------ 8 files changed, 177 insertions(+), 82 deletions(-) diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index 2fedab0cf..5ae93eb13 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -65,3 +65,68 @@ jobs: env: ANVIL_FORK_URL: ${{ secrets.ANVIL_FORK_URL }} DATABASE_URL: postgresql://postgres:postgres@localhost:5432/postgres + bench-ponder: + bench-subgraph: + name: Bench:Subgraph + runs-on: ubuntu-latest + services: + postgres: + image: postgres + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: postgres + POSTGRES_INITDB_ARGS: -E UTF8 --locale=C + options: >- + --health-cmd pg_isready + --health-interval 5s + --health-timeout 5s + --health-retries 10 + ports: + - 5432:5432 + anvil: + image: ghcr.io/0xolias/simple-anvil-image:main + env: + ANVIL_FORK_URL: ${{ secrets.ANVIL_FORK_URL }} + ANVIL_FORK_BLOCK_NUMBER: 17500000 + ports: + - 8545:8545 + ipfs: + image: ipfs/go-ipfs:v0.10.0 + ports: + - 5001:5001 + graph-node: + image: graphprotocol/graph-node:latest + # Would be best to get this health check working, but so far it hasn't been an issue. + # options: >- + # --health-cmd "curl --fail http://graph-node:8040" + env: + postgres_host: postgres + postgres_user: postgres + postgres_pass: postgres + postgres_db: postgres + ipfs: ipfs:5001 + ethereum: mainnet:${{ secrets.ANVIL_FORK_URL }} + ETHEREUM_REORG_THRESHOLD: 0 + GRAPH_LOG: debug + ports: + - 8000:8000 + - 8001:8001 + - 8020:8020 + - 8030:8030 + - 8040:8040 + steps: + - name: Clone repository + uses: actions/checkout@v3 + + - name: Setup + uses: ./.github/actions/setup + + - name: Codegen + run: cd benchmarks && pnpm graph codegen subgraph/subgraph.yaml + + - name: Bench + run: pnpm bench:subgraph:ci + env: + ANVIL_FORK_URL: ${{ secrets.ANVIL_FORK_URL }} + DATABASE_URL: postgresql://postgres:postgres@localhost:5432/postgres diff --git a/benchmarks/docker-compose.yml b/benchmarks/docker-compose.yml index e0beb4979..9bc2fc200 100644 --- a/benchmarks/docker-compose.yml +++ b/benchmarks/docker-compose.yml @@ -26,7 +26,7 @@ services: image: ghcr.io/0xolias/simple-anvil-image:main environment: ANVIL_FORK_URL: "${ANVIL_FORK_URL}" - # ANVIL_FORK_BLOCK_NUMBER: 17500000 + ANVIL_FORK_BLOCK_NUMBER: 17500000 ports: - 8545:8545 graph-node: diff --git a/benchmarks/package.json b/benchmarks/package.json index ead9dbf06..183828f0f 100644 --- a/benchmarks/package.json +++ b/benchmarks/package.json @@ -2,17 +2,16 @@ "name": "ponder-benchmarks", "private": true, "scripts": { - "bench:ponder": "export $(grep -v '^#' .env.local | xargs) && rm -rf data/ && docker-compose up --detach -p 8545:8545 && (bun run src/ponder.ts || true) && docker-compose down", - "bench:ponder:ci": "bun run src/ponder.ts", + "bench:ponder": "export $(grep -v '^#' .env.local | xargs) && rm -rf data/ && docker-compose up --detach -p 8545:8545 && tsup-node && (node dist/ponder.mjs|| true) && docker-compose down", + "bench:ponder:ci": "tsup-node && node dist/ponder.mjs", "bench:subgraph": "export $(grep -v '^#' .env.local | xargs) && rm -rf data/ && docker-compose up --detach && tsup-node && (node dist/subgraph.mjs || true) && docker-compose down", "bench:subgraph:ci": "tsup-node && node dist/subgraph.mjs" }, "devDependencies": { - "@graphprotocol/graph-cli": "0.54.0-alpha-20230727052453-1e0e6e5", + "@graphprotocol/graph-cli": "0.61.0", "@graphprotocol/graph-ts": "^0.31.0", "@ponder/core": "workspace:*", "@types/node": "^20.9.0", - "bun": "^1.0.11", "execa": "^8.0.1", "parse-prometheus-text-format": "^1.1.1", "tsup": "^7.2.0", diff --git a/benchmarks/ponder/ponder.config.ts b/benchmarks/ponder/ponder.config.ts index 57cd7042f..43478b57c 100644 --- a/benchmarks/ponder/ponder.config.ts +++ b/benchmarks/ponder/ponder.config.ts @@ -8,7 +8,7 @@ export const config = createConfig({ { name: "mainnet", chainId: 1, - transport: http("http://127.0.0.1:8545"), + transport: http(process.env.ANVIL_FORK_URL), }, ], contracts: [ diff --git a/benchmarks/src/ponder.ts b/benchmarks/src/ponder.ts index 8cbb2aa08..db3f73f4b 100644 --- a/benchmarks/src/ponder.ts +++ b/benchmarks/src/ponder.ts @@ -37,7 +37,7 @@ const waitForSetupComplete = async () => { timeout = setTimeout(() => { clearInterval(interval); - reject(new Error("Timed out waiting for subgraph to sync")); + reject(new Error("Timed out waiting for ponder to sync")); }, 60_000); }); @@ -66,7 +66,7 @@ const waitForSyncComplete = async () => { timeout = setTimeout(() => { clearInterval(interval); - reject(new Error("Timed out waiting for subgraph to sync")); + reject(new Error("Timed out waiting for ponder to sync")); }, 60_000); }); diff --git a/benchmarks/subgraph/package.json b/benchmarks/subgraph/package.json index 22858dc80..506a55811 100644 --- a/benchmarks/subgraph/package.json +++ b/benchmarks/subgraph/package.json @@ -9,5 +9,9 @@ "remove-local": "graph remove --node http://localhost:8020/ test/subgraph", "deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 test/subgraph", "test": "graph test" + }, + "dependencies": { + "@graphprotocol/graph-cli": "0.61.0", + "@graphprotocol/graph-ts": "^0.31.0" } } diff --git a/benchmarks/subgraph/subgraph.yaml b/benchmarks/subgraph/subgraph.yaml index 14c853da7..c2e08ed1c 100644 --- a/benchmarks/subgraph/subgraph.yaml +++ b/benchmarks/subgraph/subgraph.yaml @@ -1,4 +1,4 @@ -specVersion: 0.0.9 +specVersion: 0.0.5 schema: file: ./schema.graphql dataSources: @@ -11,7 +11,7 @@ dataSources: startBlock: 17490000 mapping: kind: ethereum/events - apiVersion: 0.0.8 + apiVersion: 0.0.7 language: wasm/assemblyscript entities: - Approval diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7d9608758..56a3962b5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -56,8 +56,8 @@ importers: benchmarks: devDependencies: '@graphprotocol/graph-cli': - specifier: 0.54.0-alpha-20230727052453-1e0e6e5 - version: 0.54.0-alpha-20230727052453-1e0e6e5(@types/node@20.9.0)(node-fetch@3.3.2)(typescript@5.2.2) + specifier: 0.61.0 + version: 0.61.0(@types/node@20.9.0)(node-fetch@3.3.2)(typescript@5.2.2) '@graphprotocol/graph-ts': specifier: ^0.31.0 version: 0.31.0 @@ -67,9 +67,6 @@ importers: '@types/node': specifier: ^20.9.0 version: 20.9.0 - bun: - specifier: ^1.0.11 - version: 1.0.11 execa: specifier: ^8.0.1 version: 8.0.1 @@ -86,8 +83,6 @@ importers: specifier: 1.19.1 version: 1.19.1(typescript@5.2.2) - benchmarks/subgraph: {} - docs: dependencies: '@segment/analytics-node': @@ -2393,13 +2388,15 @@ packages: js-yaml: 4.1.0 dev: true - /@graphprotocol/graph-cli@0.54.0-alpha-20230727052453-1e0e6e5(@types/node@20.9.0)(node-fetch@3.3.2)(typescript@5.2.2): - resolution: {integrity: sha512-pxZAJvUXHRMtPIoMTSvVyIjqrfMGCtaqWG9qdRDrLMxUKrIuGWniMKntxaFnHPlgz6OQznN9Zt8wV6uScD/4Sg==} + /@graphprotocol/graph-cli@0.61.0(@types/node@20.9.0)(node-fetch@3.3.2)(typescript@5.2.2): + resolution: {integrity: sha512-gc3+DioZ/K40sQCt6DsNvbqfPTc9ZysuSz3I9MJ++bD6SftaSSweWwfpPysDMzDuxvUAhLAsJ6QjBACPngT2Kw==} engines: {node: '>=14'} hasBin: true dependencies: '@float-capital/float-subgraph-uncrashable': 0.0.0-internal-testing.5 '@oclif/core': 2.8.6(@types/node@20.9.0)(typescript@5.2.2) + '@oclif/plugin-autocomplete': 2.3.10(@types/node@20.9.0)(typescript@5.2.2) + '@oclif/plugin-not-found': 2.4.3(@types/node@20.9.0)(typescript@5.2.2) '@whatwg-node/fetch': 0.8.8 assemblyscript: 0.19.23 binary-install-raw: 0.0.13(debug@4.3.4) @@ -2861,6 +2858,45 @@ packages: '@nodelib/fs.scandir': 2.1.5 fastq: 1.15.0 + /@oclif/core@2.15.0(@types/node@20.9.0)(typescript@5.2.2): + resolution: {integrity: sha512-fNEMG5DzJHhYmI3MgpByTvltBOMyFcnRIUMxbiz2ai8rhaYgaTHMG3Q38HcosfIvtw9nCjxpcQtC8MN8QtVCcA==} + engines: {node: '>=14.0.0'} + dependencies: + '@types/cli-progress': 3.11.5 + ansi-escapes: 4.3.2 + ansi-styles: 4.3.0 + cardinal: 2.1.1 + chalk: 4.1.2 + clean-stack: 3.0.1 + cli-progress: 3.12.0 + debug: 4.3.4(supports-color@8.1.1) + ejs: 3.1.9 + get-package-type: 0.1.0 + globby: 11.1.0 + hyperlinker: 1.0.0 + indent-string: 4.0.0 + is-wsl: 2.2.0 + js-yaml: 3.14.1 + natural-orderby: 2.0.3 + object-treeify: 1.1.33 + password-prompt: 1.1.3 + slice-ansi: 4.0.0 + string-width: 4.2.3 + strip-ansi: 6.0.1 + supports-color: 8.1.1 + supports-hyperlinks: 2.3.0 + ts-node: 10.9.1(@types/node@20.9.0)(typescript@5.2.2) + tslib: 2.6.2 + widest-line: 3.1.0 + wordwrap: 1.0.0 + wrap-ansi: 7.0.0 + transitivePeerDependencies: + - '@swc/core' + - '@swc/wasm' + - '@types/node' + - typescript + dev: true + /@oclif/core@2.8.6(@types/node@20.9.0)(typescript@5.2.2): resolution: {integrity: sha512-1QlPaHMhOORySCXkQyzjsIsy2GYTilOw3LkjeHkCgsPJQjAT4IclVytJusWktPbYNys9O+O4V23J44yomQvnBQ==} engines: {node: '>=14.0.0'} @@ -2901,58 +2937,39 @@ packages: - typescript dev: true - /@opentelemetry/api@1.7.0: - resolution: {integrity: sha512-AdY5wvN0P2vXBi3b29hxZgSFvdhdxPB9+f0B6s//P9Q8nibRWeA3cHm8UmLpio9ABigkVHJ5NMPk+Mz8VCCyrw==} - engines: {node: '>=8.0.0'} - dev: false - - /@oven/bun-darwin-aarch64@1.0.11: - resolution: {integrity: sha512-6wCO37lyGNcqefEDQ7IJp4LW7ElKMH50/hlvW5agIBN/XbTwwtv3788dJ9NczEV7RQSlkOI6J3dUoQJ6Pgav6w==} - cpu: [arm64] - os: [darwin] - requiresBuild: true - dev: true - optional: true - - /@oven/bun-darwin-x64-baseline@1.0.11: - resolution: {integrity: sha512-is9liFB10GUN/UsSZVkO5tfMIJcBkiDqRvVzNkDHix/i5aXyaBb0vX+uOdJTlHDZyNGi+vHhbRMq3c3ezjJKPA==} - cpu: [x64] - os: [darwin] - requiresBuild: true - dev: true - optional: true - - /@oven/bun-darwin-x64@1.0.11: - resolution: {integrity: sha512-5eCtrlOfMuhg7es/6p/rZw5+4khBao/hhGKCPHl9LBok1Mrf5QQjGbXj9OoA2RC2Lxm9av4nrAZG/5nMM01B2g==} - cpu: [x64] - os: [darwin] - requiresBuild: true - dev: true - optional: true - - /@oven/bun-linux-aarch64@1.0.11: - resolution: {integrity: sha512-P8hI+vQ+8ffsMLRi2TNzkxsHukrNQD8G2luWo/ndJ55+1uuAMScWZooxm9rgWL6baoB/TL9/Hvi/6INGoE8UlQ==} - cpu: [arm64] - os: [linux] - requiresBuild: true + /@oclif/plugin-autocomplete@2.3.10(@types/node@20.9.0)(typescript@5.2.2): + resolution: {integrity: sha512-Ow1AR8WtjzlyCtiWWPgzMyT8SbcDJFr47009riLioHa+MHX2BCDtVn2DVnN/E6b9JlPV5ptQpjefoRSNWBesmg==} + engines: {node: '>=12.0.0'} + dependencies: + '@oclif/core': 2.15.0(@types/node@20.9.0)(typescript@5.2.2) + chalk: 4.1.2 + debug: 4.3.4(supports-color@8.1.1) + transitivePeerDependencies: + - '@swc/core' + - '@swc/wasm' + - '@types/node' + - supports-color + - typescript dev: true - optional: true - /@oven/bun-linux-x64-baseline@1.0.11: - resolution: {integrity: sha512-Asx4pEMDXfmu9Sa0jX4PE1Wijtg1oCfUx8o4FeQEvnVz2+cGG+VoqZXuITmoQC6A4IzAZuJ1tcWOZ8jQCDtvJA==} - cpu: [x64] - os: [linux] - requiresBuild: true + /@oclif/plugin-not-found@2.4.3(@types/node@20.9.0)(typescript@5.2.2): + resolution: {integrity: sha512-nIyaR4y692frwh7wIHZ3fb+2L6XEecQwRDIb4zbEam0TvaVmBQWZoColQyWA84ljFBPZ8XWiQyTz+ixSwdRkqg==} + engines: {node: '>=12.0.0'} + dependencies: + '@oclif/core': 2.15.0(@types/node@20.9.0)(typescript@5.2.2) + chalk: 4.1.2 + fast-levenshtein: 3.0.0 + transitivePeerDependencies: + - '@swc/core' + - '@swc/wasm' + - '@types/node' + - typescript dev: true - optional: true - /@oven/bun-linux-x64@1.0.11: - resolution: {integrity: sha512-F9ZcgVHsPQk6ooHXIeydiLcVcMwhGRjSlOVeHBuHEJ+bI24e/dCY73UKEEz8/hLNA32ocDMmkAGE79qv0ccEIA==} - cpu: [x64] - os: [linux] - requiresBuild: true - dev: true - optional: true + /@opentelemetry/api@1.7.0: + resolution: {integrity: sha512-AdY5wvN0P2vXBi3b29hxZgSFvdhdxPB9+f0B6s//P9Q8nibRWeA3cHm8UmLpio9ABigkVHJ5NMPk+Mz8VCCyrw==} + engines: {node: '>=8.0.0'} + dev: false /@peculiar/asn1-schema@2.3.8: resolution: {integrity: sha512-ULB1XqHKx1WBU/tTFIA+uARuRoBVZ4pNdOA878RDrRbBfBGcSzi5HBkdScC6ZbHn8z7L8gmKCgPC1LHRrP46tA==} @@ -4207,6 +4224,11 @@ packages: resolution: {integrity: sha512-OH/2E5Fg20h2aPrbe+QL8JZQFko0YZaF+j4mnQ7BGhfavO7OpSLa8a0y9sBwomHdSbkhTS8TQNayBfnW5DwbvQ==} dev: true + /astral-regex@2.0.0: + resolution: {integrity: sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==} + engines: {node: '>=8'} + dev: true + /astring@1.8.6: resolution: {integrity: sha512-ISvCdHdlTDlH5IpxQJIex7BWBywFWgjJSVdwst+/iQCoEYnyOaQ95+X1JGshuBjGp6nxKUy1jMgE3zPqN7fQdg==} hasBin: true @@ -4567,21 +4589,6 @@ packages: base64-js: 1.5.1 ieee754: 1.2.1 - /bun@1.0.11: - resolution: {integrity: sha512-cKyQAQOfWNIP511UpQjkABUp7z/5+1ci2kXfhjL9PozHoCaCtnYFtVjeqU1LovpqEP1agAsMiDpGNKbJP89RIw==} - cpu: [arm64, x64] - os: [darwin, linux] - hasBin: true - requiresBuild: true - optionalDependencies: - '@oven/bun-darwin-aarch64': 1.0.11 - '@oven/bun-darwin-x64': 1.0.11 - '@oven/bun-darwin-x64-baseline': 1.0.11 - '@oven/bun-linux-aarch64': 1.0.11 - '@oven/bun-linux-x64': 1.0.11 - '@oven/bun-linux-x64-baseline': 1.0.11 - dev: true - /bundle-require@4.0.2(esbuild@0.18.20): resolution: {integrity: sha512-jwzPOChofl67PSTW2SGubV9HBQAhhR2i6nskiOThauo9dzwDUgOWQScFVaJkjEfYX+UXiD+LEx8EblQMc2wIag==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -6676,6 +6683,12 @@ packages: /fast-levenshtein@2.0.6: resolution: {integrity: sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==} + /fast-levenshtein@3.0.0: + resolution: {integrity: sha512-hKKNajm46uNmTlhHSyZkmToAc56uZJwYq7yrciZjqOxnlfQwERDQJmHPUp7m1m9wx8vgOe8IaCKZ5Kv2k1DdCQ==} + dependencies: + fastest-levenshtein: 1.0.16 + dev: true + /fast-printf@1.6.9: resolution: {integrity: sha512-FChq8hbz65WMj4rstcQsFB0O7Cy++nmbNfLYnD9cYv2cRn8EG6k/MGn9kO/tjO66t09DLDugj3yL+V2o6Qftrg==} engines: {node: '>=10.0'} @@ -6704,6 +6717,11 @@ packages: punycode: 1.4.1 dev: true + /fastest-levenshtein@1.0.16: + resolution: {integrity: sha512-eRnCtTTtGZFpQCwhJiUOuxPQWRXVKYDn0b2PeHfXL6/Zi53SLAzAHfVhVWK2AryC/WH05kGfxhFIPvTF0SXQzg==} + engines: {node: '>= 4.9.1'} + dev: true + /fastq@1.15.0: resolution: {integrity: sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==} dependencies: @@ -11505,6 +11523,15 @@ packages: engines: {node: '>=12'} dev: true + /slice-ansi@4.0.0: + resolution: {integrity: sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==} + engines: {node: '>=10'} + dependencies: + ansi-styles: 4.3.0 + astral-regex: 2.0.0 + is-fullwidth-code-point: 3.0.0 + dev: true + /slice-ansi@5.0.0: resolution: {integrity: sha512-FC+lgizVPfie0kkhqUScwRu1O/lF6NOgJmlCgK+/LYxDCTk8sGelYaHDhFcDN+Sn3Cv+3VSa4Byeo+IMCzpMgQ==} engines: {node: '>=12'}