From 60d8449288e91443197d6499397fa326d5783db2 Mon Sep 17 00:00:00 2001 From: 0xdavinchee <0xdavinchee@gmail.com> Date: Mon, 8 Apr 2024 16:35:12 +0300 Subject: [PATCH 1/4] get token symbol (#1923) --- packages/subgraph/src/mappingHelpers.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/subgraph/src/mappingHelpers.ts b/packages/subgraph/src/mappingHelpers.ts index 261e168f14..91a1a6e6db 100644 --- a/packages/subgraph/src/mappingHelpers.ts +++ b/packages/subgraph/src/mappingHelpers.ts @@ -148,6 +148,12 @@ export function getOrInitSuperToken( return token as Token; } + if (token.symbol == "") { + const tokenContract = SuperToken.bind(tokenAddress); + const symbolResult = tokenContract.try_symbol(); + token.symbol = symbolResult.reverted ? "" : symbolResult.value; + } + token.save(); return token as Token; From ba685447c6f3ab971d5f682375238f6a9c418c66 Mon Sep 17 00:00:00 2001 From: Kaspar Kallas Date: Tue, 9 Apr 2024 00:53:57 +0300 Subject: [PATCH 2/4] [subgraph][spike] deploy protocol subgraphs to Goldsky (#1918) * change the deploy script to be able to deploy subgraphs to Goldsky * update graph cli-s * fix workflow schema * Update call.upload-coverage-reports.yml * update codecov * Update call.upload-coverage-reports.yml * Update call.upload-coverage-reports.yml --------- Co-authored-by: Miao ZhiCheng --- .github/workflows/call.deploy-subgraph.yml | 18 ++++++----- .../call.upload-coverage-reports.yml | 7 ++--- packages/subgraph/package.json | 4 +-- packages/subgraph/tasks/deploy.sh | 30 +++++++++++++++++-- yarn.lock | 16 +++++----- 5 files changed, 51 insertions(+), 24 deletions(-) diff --git a/.github/workflows/call.deploy-subgraph.yml b/.github/workflows/call.deploy-subgraph.yml index c97e28b380..90d5e0403e 100644 --- a/.github/workflows/call.deploy-subgraph.yml +++ b/.github/workflows/call.deploy-subgraph.yml @@ -10,24 +10,27 @@ on: deployment_env: required: true type: string - description: 'The subgraph deployment env: v1, dev, feature' + description: "The subgraph deployment env: v1, dev, feature" network: required: true type: string - description: 'The network you want to deploy to (matic, xdai, eth-mainnet, etc.) or `all` for all networks.' + description: "The network you want to deploy to (matic, xdai, eth-mainnet, etc.) or `all` for all networks." secrets: SUBGRAPH_URL_TEMPLATE: - description: 'Subgraph endpoint url template' + description: "Subgraph endpoint url template" required: false SATSUMA_DEPLOY_KEY: - description: 'Satsuma deploy key' + description: "Satsuma deploy key" required: false THE_GRAPH_ACCESS_TOKEN: - description: 'The Graph (hosted service) access token for deploying subgraphs' + description: "The Graph (hosted service) access token for deploying subgraphs" + required: false + GOLDSKY_API_KEY: + description: "Goldsky API key for deploying subgraphs" required: false SUPERFLUID_IPFS_API: - description: 'Superfluid IPFS API endpoint' + description: "Superfluid IPFS API endpoint" required: false jobs: @@ -112,7 +115,7 @@ jobs: - uses: olegtarasov/get-tag@v2.1.2 id: "getSubgraphTag" with: - tagRegex: "subgraph@(.*)" + tagRegex: "subgraph@(.*)" # Version is the git tag or revision - name: "Deploy to a node" @@ -126,3 +129,4 @@ jobs: SUPERFLUID_IPFS_API: ${{ secrets.SUPERFLUID_IPFS_API }} THE_GRAPH_ACCESS_TOKEN: ${{ secrets.THE_GRAPH_ACCESS_TOKEN }} SATSUMA_DEPLOY_KEY: ${{ secrets.SATSUMA_DEPLOY_KEY }} + GOLDSKY_API_KEY: ${{ secrets.GOLDSKY_API_KEY }} diff --git a/.github/workflows/call.upload-coverage-reports.yml b/.github/workflows/call.upload-coverage-reports.yml index 21a59df2de..1be4bac3be 100644 --- a/.github/workflows/call.upload-coverage-reports.yml +++ b/.github/workflows/call.upload-coverage-reports.yml @@ -3,7 +3,6 @@ name: Reusable Workflow | Upload Coverage Reports on: workflow_call: - jobs: upload-coverage-reports: name: Upload coverage reports @@ -19,7 +18,7 @@ jobs: name: ethereum-contracts-coverage path: packages/ethereum-contracts/coverage - name: Upload ethereum-contracts-coverage to codecov - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4.2.0 with: token: ${{ secrets.CODECOV_TOKEN }} files: packages/ethereum-contracts/coverage/lcov.info @@ -33,10 +32,10 @@ jobs: name: sdk-core-coverage path: packages/sdk-core/coverage - name: Upload sdk-core-coverage to codecov - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4.2.0 with: token: ${{ secrets.CODECOV_TOKEN }} files: packages/sdk-core/coverage/lcov.info name: sdk-core-coverage flags: sdk-core - fail_ci_if_error: true \ No newline at end of file + fail_ci_if_error: true diff --git a/packages/subgraph/package.json b/packages/subgraph/package.json index 1243e2ecd0..5f82179a2b 100644 --- a/packages/subgraph/package.json +++ b/packages/subgraph/package.json @@ -50,8 +50,8 @@ "cloc": "cloc src" }, "dependencies": { - "@graphprotocol/graph-cli": "0.67.4", - "@graphprotocol/graph-ts": "0.32.0", + "@graphprotocol/graph-cli": "0.69.1", + "@graphprotocol/graph-ts": "0.34.0", "@superfluid-finance/sdk-core": "^0.6.13", "mustache": "^4.2.0" }, diff --git a/packages/subgraph/tasks/deploy.sh b/packages/subgraph/tasks/deploy.sh index 18864e05f7..bd6fb52022 100755 --- a/packages/subgraph/tasks/deploy.sh +++ b/packages/subgraph/tasks/deploy.sh @@ -5,8 +5,10 @@ set -eux JQ="jq" # shellcheck disable=SC2207 -GRAPH_CLI="npx --package=@graphprotocol/graph-cli -- graph" -SUPPORTED_VENDORS=( "graph" "satsuma" "superfluid" ) +GRAPH_CLI="npx --package=@graphprotocol/graph-cli --yes -- graph" +# shellcheck disable=SC2207 +GOLDSKY_CLI="npx --package=@goldskycom/cli --yes -- goldsky" +SUPPORTED_VENDORS=( "graph" "satsuma" "superfluid" "goldsky" ) # list of supported networks by vendor @@ -16,11 +18,14 @@ GRAPH_NETWORKS=( $($JQ -r .[] ./hosted-service-networks.json) ) || exit 1 SATSUMA_NETWORKS=( "polygon-mainnet" "xdai-mainnet" "eth-mainnet" "eth-sepolia" "optimism-mainnet" "base-mainnet") # shellcheck disable=SC2034 SUPERFLUID_NETWORKS=( "polygon-mainnet" "xdai-mainnet" "base-mainnet" "optimism-mainnet" "arbitrum-one" "celo-mainnet" "bsc-mainnet" "avalanche-c" "optimism-sepolia" "scroll-sepolia" "scroll-mainnet") +# shellcheck disable=SC2034 +GOLDSKY_NETWORKS=( "polygon-mainnet" "xdai-mainnet" "base-mainnet" "optimism-mainnet" "arbitrum-one" "celo-mainnet" "bsc-mainnet" "avalanche-c" "optimism-sepolia" "scroll-sepolia" "scroll-mainnet") declare -A VENDOR_NETWORKS=( ["graph"]="${GRAPH_NETWORKS[@]}" ["satsuma"]="${SATSUMA_NETWORKS[@]}" ["superfluid"]="${SUPERFLUID_NETWORKS[@]}" + ["goldsky"]="${GOLDSKY_NETWORKS[@]}" ) VENDOR="" @@ -29,7 +34,7 @@ DEPLOYMENT_ENV="" VERSION_LABEL="" print_usage_and_exit() { - echo "Usage: $0 -o graph|satsuma|superfluid -n -r -v " + echo "Usage: $0 -o graph|satsuma|superfluid|goldsky -n -r -v " exit 1 } @@ -115,6 +120,22 @@ deploy_to_superfluid() { --ipfs "$SUPERFLUID_IPFS_API" } +deploy_to_goldsky() { + local network="$1" + local subgraphName="protocol-$DEPLOYMENT_ENV-$network/1.0.0" + # TODO: use tagging? + # TODO: how to handle versions? + + cp subgraph.yaml ./build/subgraph.yaml + # TODO: not sure the cp is necessary + + echo "********* Deploying $network subgraph $subgraphName to Goldsky. **********" + $GOLDSKY_CLI subgraph deploy \ + "$subgraphName" \ + --path . \ + --token "$GOLDSKY_API_KEY" +} + # Vendor specific function dispatcher # Expected arguments: # $1 - vendor @@ -149,6 +170,9 @@ deploy_to() { superfluid) deploy_to_superfluid "$network" ;; + goldsky) + deploy_to_goldsky "$network" + ;; *) print_usage_and_exit ;; diff --git a/yarn.lock b/yarn.lock index 188e81bf7f..121b372b9b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1499,10 +1499,10 @@ optionalDependencies: "@trufflesuite/bigint-buffer" "1.1.9" -"@graphprotocol/graph-cli@0.67.4": - version "0.67.4" - resolved "https://registry.yarnpkg.com/@graphprotocol/graph-cli/-/graph-cli-0.67.4.tgz#da8fd87c20c64bb3ab78664bd2af0ab965f9d12f" - integrity sha512-U2LDemWwmYUxf7PloAcDPXK1UeceRphGJJKrhNbDZB32hlp3LY+GI6HnRK4F9Oeri2azB3t3/humNxIDgbim0w== +"@graphprotocol/graph-cli@0.69.1": + version "0.69.1" + resolved "https://registry.yarnpkg.com/@graphprotocol/graph-cli/-/graph-cli-0.69.1.tgz#2ea248fb1636b46afb6101236e3f387e9d2f3275" + integrity sha512-PekTli4hsBkF48y2NA2ufNjtdG/VL4N+E7GAavNXxFmSHM9VoCWbR4OBeJ93dAOpgHRGyx8yO1NE9DDT7yEZsg== dependencies: "@float-capital/float-subgraph-uncrashable" "^0.0.0-alpha.4" "@oclif/core" "2.8.6" @@ -1532,10 +1532,10 @@ which "2.0.2" yaml "1.10.2" -"@graphprotocol/graph-ts@0.32.0": - version "0.32.0" - resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.32.0.tgz#36f8cd8e4ef42c3c32536cceb9995ab990f51d29" - integrity sha512-YfKLT2w+ItXD/VPYQiAKtINQONVsAOkcqVFMHlhUy0fcEBVWuFBT53hJNI0/l5ujQa4TSxtzrKW/7EABAdgI8g== +"@graphprotocol/graph-ts@0.34.0": + version "0.34.0" + resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.34.0.tgz#ca47398295b114f25b412faa364b98af31fa2bb7" + integrity sha512-gnhjai65AV4YMYe9QHGz+HP/jdzI54z/nOfEXZFfh6m987EP2iy3ycLXrTi+ahcogHH7vtoWFdXbUzZbE8bCAg== dependencies: assemblyscript "0.19.10" From 6a53cc55dab601e300bafb0546b1bb8019d04b10 Mon Sep 17 00:00:00 2001 From: Kaspar Kallas Date: Tue, 9 Apr 2024 13:18:44 +0300 Subject: [PATCH 3/4] [subgraph][fix] explicitly build in the subgraph deploy script for Goldsky (#1925) * explicitly build in the subgraph deploy script for goldsky * fix comment typo * Update flake.nix * Update flake.nix --------- Co-authored-by: Miao ZhiCheng --- .github/workflows/call.deploy-subgraph.yml | 2 +- flake.nix | 13 ++++++++++--- packages/subgraph/tasks/deploy.sh | 4 ++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/call.deploy-subgraph.yml b/.github/workflows/call.deploy-subgraph.yml index 90d5e0403e..3af1262ff6 100644 --- a/.github/workflows/call.deploy-subgraph.yml +++ b/.github/workflows/call.deploy-subgraph.yml @@ -5,7 +5,7 @@ on: inputs: vendor: required: true - description: "Where to deploy subgraph to; superfluid, graph, or satsuma" + description: "Where to deploy subgraph to; superfluid, graph, satsuma, or goldsky" type: string deployment_env: required: true diff --git a/flake.nix b/flake.nix index 452b27b5c5..24cbb6488c 100644 --- a/flake.nix +++ b/flake.nix @@ -66,6 +66,12 @@ node18DevInputs = nodeDevInputsWith pkgs.nodejs_18; node20DevInputs = nodeDevInputsWith pkgs.nodejs_20; + # CI inputs + ciInputs = with pkgs; [ + # codecov requries gnupg binary + gnupg + ]; + # minimem development shell minimumDevInputs = commonDevInputs ++ ethDevInputs ++ node18DevInputs; @@ -132,17 +138,18 @@ ++ whitehatInputs ++ specInputs; }; + # CI shells devShells.ci-node18 = mkShell { - buildInputs = commonDevInputs ++ ethDevInputs ++ node18DevInputs; + buildInputs = ciInputs ++ commonDevInputs ++ ethDevInputs ++ node18DevInputs; }; devShells.ci-node20 = mkShell { - buildInputs = commonDevInputs ++ ethDevInputs ++ node20DevInputs; + buildInputs = ciInputs ++ commonDevInputs ++ ethDevInputs ++ node20DevInputs; }; devShells.ci-spec-ghc92 = ci-spec-with-ghc ghcVer92; devShells.ci-spec-ghc94 = ci-spec-with-ghc ghcVer94; devShells.ci-hot-fuzz = mkShell { - buildInputs = with pkgs; commonDevInputs ++ ethDevInputs ++ [ + buildInputs = with pkgs; ciInputs ++ commonDevInputs ++ ethDevInputs ++ [ slither-analyzer echidna ]; diff --git a/packages/subgraph/tasks/deploy.sh b/packages/subgraph/tasks/deploy.sh index bd6fb52022..b267098a9a 100755 --- a/packages/subgraph/tasks/deploy.sh +++ b/packages/subgraph/tasks/deploy.sh @@ -126,8 +126,8 @@ deploy_to_goldsky() { # TODO: use tagging? # TODO: how to handle versions? - cp subgraph.yaml ./build/subgraph.yaml - # TODO: not sure the cp is necessary + $GRAPH_CLI build + # Note: when using Graph CLI to deploy, it implicitly triggers build too, but Goldsky CLI doesn't. echo "********* Deploying $network subgraph $subgraphName to Goldsky. **********" $GOLDSKY_CLI subgraph deploy \ From 73d0c7fe26f00dac2ebaf5484168ea3544dc717c Mon Sep 17 00:00:00 2001 From: Miao ZhiCheng Date: Tue, 9 Apr 2024 15:32:00 +0300 Subject: [PATCH 4/4] Update handler.deploy-production-subgraphs.yml --- .github/workflows/handler.deploy-production-subgraphs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/handler.deploy-production-subgraphs.yml b/.github/workflows/handler.deploy-production-subgraphs.yml index 4d1d4df7af..85a5cc5c63 100644 --- a/.github/workflows/handler.deploy-production-subgraphs.yml +++ b/.github/workflows/handler.deploy-production-subgraphs.yml @@ -52,3 +52,4 @@ jobs: SATSUMA_DEPLOY_KEY: ${{ secrets.SATSUMA_DEPLOY_KEY }} SUBGRAPH_URL_TEMPLATE: ${{ secrets.SUBGRAPH_URL_TEMPLATE }} SUPERFLUID_IPFS_API: ${{ secrets.SUPERFLUID_IPFS_API }} + GOLDSKY_API_KEY: ${{ secrets.GOLDSKY_API_KEY }}