Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 34 additions & 8 deletions .github/scripts/tests/test_validate_testnet_bens.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ def test_bens_database_password_is_not_hardcoded(self):

def test_bens_uses_canonical_testnet_rpcs(self):
public_rpc = "https://test.doschain.com/"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Instead of hardcoding the public RPC URL here, you can reference self.module.CANONICAL_TESTNET_BENS_RPC which is already defined in the validator script. This avoids duplication and ensures the test remains in sync with the validator automatically.

Suggested change
public_rpc = "https://test.doschain.com/"
public_rpc = self.module.CANONICAL_TESTNET_BENS_RPC

internal_rpc = (
"http://10.148.0.7:9650/ext/bc/"
"JASJZyVTWR7aviy4eY5yE8AVfdXtH33c1AinvzhLcVBARhcm9/rpc"
)
template = json.loads(
(ROOT / "docker-compose" / "bens" / "config.template.json").read_text(
encoding="utf-8"
Expand All @@ -72,11 +68,11 @@ def test_bens_uses_canonical_testnet_rpcs(self):
retry_script = RPC_RETRY_SCRIPT.read_text(encoding="utf-8")

self.assertEqual(
internal_rpc,
public_rpc,
template["subgraphs_reader"]["networks"]["3939"]["rpc_url"],
)
self.assertIn(f"ethereum: dos-testnet:{internal_rpc}", compose)
self.assertNotIn("ethereum: dos-testnet:https://test.doschain.com/", compose)
self.assertIn(f"ethereum: dos-testnet:{public_rpc}", compose)
self.assertNotIn("ethereum: dos-testnet:http://10.148.0.7:9650/", compose)
bytecode_gate = workflow.split('contract_code="$(\n', 1)[1].split(
'if [ "${contract_code}"', 1
)[0]
Expand Down Expand Up @@ -154,6 +150,36 @@ def test_account_abstraction_uses_the_canonical_blockscout_database(self):
)
self.assertNotIn("pg_dump -U postgres -Fc blockscout", testnet_deploy)

def test_push_deploys_only_affected_environment(self):
workflow = (
ROOT / ".github" / "workflows" / "deploy-config.yml"
).read_text(encoding="utf-8")
changes_job = workflow.split(" changes:", 1)[1].split(
"\n deploy-mainnet:", 1
)[0]
mainnet_job = workflow.split(" deploy-mainnet:", 1)[1].split(
"\n deploy-testnet:", 1
)[0]
testnet_job = workflow.split(" deploy-testnet:", 1)[1].split(
"\n deploy-beta:", 1
)[0]

self.assertIn("needs: changes", mainnet_job)
self.assertIn("needs.changes.outputs.mainnet == 'true'", mainnet_job)
self.assertIn("needs: changes", testnet_job)
self.assertIn("needs.changes.outputs.testnet == 'true'", testnet_job)
self.assertIn("fetch-depth: 0", changes_job)
self.assertIn("${{ github.event.before }}", changes_job)
self.assertIn('git hash-object -t tree /dev/null', changes_job)
self.assertIn('git diff --name-only "${diff_base}" "${GITHUB_SHA}"', changes_job)
self.assertIn("docker-compose/docker-compose-mainnet.yml", changes_job)
self.assertIn("docker-compose/docker-compose-testnet.yml", changes_job)
self.assertIn("docker-compose/bens/config.template.json", changes_job)
self.assertIn("DOS_NAMES_MAINNET_SUBGRAPH_REF", changes_job)
self.assertIn("DOS_NAMES_TESTNET_SUBGRAPH_REF", changes_job)
self.assertIn("mainnet=true", changes_job)
self.assertIn("testnet=true", changes_job)

def test_deployment_builds_and_verifies_immutable_account_abstraction_sources(
self,
):
Expand Down Expand Up @@ -521,7 +547,7 @@ def test_deployment_fetches_an_immutable_dos_names_revision(self):

self.assertRegex(
workflow,
r"DOS_NAMES_SUBGRAPH_REF: [0-9a-f]{40}",
r"DOS_NAMES_TESTNET_SUBGRAPH_REF: [0-9a-f]{40}",
)
self.assertIn(
"https://github.com/DOS/DOS-Names-Contracts.git",
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dependency-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ env:
ELIXIR_VERSION: "1.19.4"
MIX_ENV: prod
DOS_NAMES_REPOSITORY: https://github.com/DOS/DOS-Names-Contracts.git
DOS_NAMES_SUBGRAPH_REF: 6224395661280a739c20ebd8a420913a0dd7fd6e
DOS_NAMES_SUBGRAPH_REF: 130d42ae22881896cab89e33c3c3c096b9b8e989
AA_SOURCE_REPOSITORY: https://github.com/eth-infinitism/account-abstraction.git
AA_SOURCE_REF: 4cbc06072cdc19fd60f285c5997f4f7f57a588de

Expand Down
88 changes: 72 additions & 16 deletions .github/workflows/deploy-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,73 @@ env:
GCP_TESTNET_ZONE: asia-southeast1-a
GCP_TESTNET_INSTANCE: dos-testnet-r0
DOS_NAMES_REPOSITORY: https://github.com/DOS/DOS-Names-Contracts.git
DOS_NAMES_SUBGRAPH_REF: 6224395661280a739c20ebd8a420913a0dd7fd6e
DOS_NAMES_MAINNET_SUBGRAPH_REF: 6224395661280a739c20ebd8a420913a0dd7fd6e
DOS_NAMES_TESTNET_SUBGRAPH_REF: 130d42ae22881896cab89e33c3c3c096b9b8e989

jobs:
changes:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
outputs:
mainnet: ${{ steps.targets.outputs.mainnet }}
testnet: ${{ steps.targets.outputs.testnet }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0

- id: targets
shell: bash
run: |
set -euo pipefail
mainnet=false
testnet=false

if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
case "${{ inputs.environment }}" in
mainnet) mainnet=true ;;
testnet) testnet=true ;;
esac
else
before="${{ github.event.before }}"
if [[ "${before}" =~ ^0+$ ]]; then
diff_base="$(git hash-object -t tree /dev/null)"
else
diff_base="${before}"
fi
changed_files="$(git diff --name-only "${diff_base}" "${GITHUB_SHA}")"

printf '%s\n' "${changed_files}"
while IFS= read -r file; do
case "${file}" in
docker-compose/docker-compose-mainnet.yml|docker-compose/docker-compose-gcp-edge.yml|docker-compose/docker-compose-gcp-edge.override.yml|docker-compose/Caddyfile-gcp-mainnet|docker-compose/Caddyfile-gcp-edge|docker-compose/bens/config.mainnet.template.json|docker-compose/configs/interchain-indexer-chains.json|docker-compose/configs/interchain-indexer-bridges.json|docker-compose/envs/common-blockscout-mainnet.env|docker-compose/envs/common-frontend-scan.env|scripts/render-mainnet-bens.py|.github/scripts/extract-mainnet-aa-verification-inputs.mjs|.github/scripts/mainnet-aa-solc/*|.github/scripts/mainnet-bens-runtime.sh|.github/scripts/mainnet-bens-ui.spec.mjs|.github/scripts/mainnet-aa-source-ui.spec.mjs|.github/scripts/prepare-mainnet-aa-verification.sh|.github/scripts/verify-mainnet-aa-bytecode.mjs|.github/scripts/verify-mainnet-aa-sources.sh)
mainnet=true
;;
docker-compose/docker-compose-testnet.yml|docker-compose/Caddyfile-gcp-testnet|docker-compose/bens/config.template.json|docker-compose/envs/common-blockscout-testnet.env|docker-compose/envs/common-frontend-testnet.env|scripts/render-testnet-bens.py|scripts/validate-testnet-bens.py|.github/scripts/extract-aa-verification-inputs.mjs|.github/scripts/testnet-bens-ui.spec.mjs|.github/scripts/verify-testnet-aa-sources.sh)
testnet=true
;;
docker-compose/bens/*|docker-compose/envs/common-blockscout.env|docker-compose/envs/common-frontend.env|docker-compose/envs/common-smart-contract-verifier.env|docker-compose/envs/common-visualizer.env|scripts/validate-blockscout-env-parity.py)
mainnet=true
testnet=true
;;
esac
done <<< "${changed_files}"

workflow_diff="$(git diff --unified=0 "${diff_base}" "${GITHUB_SHA}" -- .github/workflows/deploy-config.yml)"
if grep -Eq '^[+-] DOS_NAMES_MAINNET_SUBGRAPH_REF:' <<< "${workflow_diff}"; then
mainnet=true
fi
if grep -Eq '^[+-] DOS_NAMES_TESTNET_SUBGRAPH_REF:' <<< "${workflow_diff}"; then
testnet=true
fi
fi

echo "mainnet=${mainnet}" >> "${GITHUB_OUTPUT}"
echo "testnet=${testnet}" >> "${GITHUB_OUTPUT}"

deploy-mainnet:
if: >
github.ref == 'refs/heads/main' &&
(github.event_name == 'push' ||
(github.event_name == 'workflow_dispatch' && inputs.environment == 'mainnet'))
needs: changes
if: needs.changes.outputs.mainnet == 'true'
runs-on: ubuntu-latest
environment: mainnet
env:
Expand Down Expand Up @@ -154,9 +213,9 @@ jobs:
git -C "${checkout}" fetch --filter=blob:none origin \
refs/heads/dos:refs/remotes/origin/dos
git -C "${checkout}" merge-base --is-ancestor \
"${DOS_NAMES_SUBGRAPH_REF}" refs/remotes/origin/dos
git -C "${checkout}" checkout --detach -q "${DOS_NAMES_SUBGRAPH_REF}"
[ "$(git -C "${checkout}" rev-parse HEAD)" = "${DOS_NAMES_SUBGRAPH_REF}" ]
"${DOS_NAMES_MAINNET_SUBGRAPH_REF}" refs/remotes/origin/dos
git -C "${checkout}" checkout --detach -q "${DOS_NAMES_MAINNET_SUBGRAPH_REF}"
[ "$(git -C "${checkout}" rev-parse HEAD)" = "${DOS_NAMES_MAINNET_SUBGRAPH_REF}" ]
test -f "${checkout}/subgraph/dos-names/subgraph.template.yaml"
test -f "${checkout}/contracts/deployments/dos-mainnet-7979.json"
cp -a "${checkout}/subgraph/dos-names" docker-compose/bens/subgraph
Expand Down Expand Up @@ -756,11 +815,8 @@ jobs:
--reporter=line

deploy-testnet:
if: >
github.ref == 'refs/heads/main' &&
(github.event_name == 'push' ||
(github.event_name == 'workflow_dispatch' && inputs.environment == 'testnet')
)
needs: changes
if: needs.changes.outputs.testnet == 'true'
runs-on: ubuntu-latest
environment: testnet
env:
Expand Down Expand Up @@ -825,9 +881,9 @@ jobs:
git -C "${checkout}" fetch --filter=blob:none origin \
refs/heads/dos:refs/remotes/origin/dos
git -C "${checkout}" merge-base --is-ancestor \
"${DOS_NAMES_SUBGRAPH_REF}" refs/remotes/origin/dos
git -C "${checkout}" checkout --detach -q "${DOS_NAMES_SUBGRAPH_REF}"
[ "$(git -C "${checkout}" rev-parse HEAD)" = "${DOS_NAMES_SUBGRAPH_REF}" ]
"${DOS_NAMES_TESTNET_SUBGRAPH_REF}" refs/remotes/origin/dos
git -C "${checkout}" checkout --detach -q "${DOS_NAMES_TESTNET_SUBGRAPH_REF}"
[ "$(git -C "${checkout}" rev-parse HEAD)" = "${DOS_NAMES_TESTNET_SUBGRAPH_REF}" ]
test -f "${checkout}/subgraph/dos-names/subgraph.template.yaml"
test -f "${checkout}/contracts/deployments/dos-testnet-3939.json"
cp -a "${checkout}/subgraph/dos-names" docker-compose/bens/subgraph
Expand Down
2 changes: 1 addition & 1 deletion docker-compose/bens/config.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"url": "http://backend:4000"
},
"use_protocols": ["dos-names"],
"rpc_url": "http://10.148.0.7:9650/ext/bc/JASJZyVTWR7aviy4eY5yE8AVfdXtH33c1AinvzhLcVBARhcm9/rpc"
"rpc_url": "https://test.doschain.com/"
}
},
"protocols": {
Expand Down
2 changes: 1 addition & 1 deletion docker-compose/docker-compose-testnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ services:
postgres_user: graph-node
postgres_db: graph-node
ipfs: bens-ipfs:5001
ethereum: dos-testnet:http://10.148.0.7:9650/ext/bc/JASJZyVTWR7aviy4eY5yE8AVfdXtH33c1AinvzhLcVBARhcm9/rpc
ethereum: dos-testnet:https://test.doschain.com/
GRAPH_LOG: info

bens:
Expand Down
15 changes: 6 additions & 9 deletions scripts/validate-testnet-bens.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@
SUBGRAPH_DEPLOY_SCRIPT = ROOT / "docker-compose" / "bens" / "deploy-subgraph.sh"
CANONICAL_TESTNET_BLOCKCHAIN = "JASJZyVTWR7aviy4eY5yE8AVfdXtH33c1AinvzhLcVBARhcm9"
RETIRED_TESTNET_BLOCKCHAIN = "2EhCz8u48mSCUzxEEGsqY7d1PnqUKkc2B1zkTQaJxbT99wshkJ"
CANONICAL_TESTNET_INTERNAL_RPC = (
"http://10.148.0.7:9650/ext/bc/"
f"{CANONICAL_TESTNET_BLOCKCHAIN}/rpc"
)
CANONICAL_TESTNET_BENS_RPC = "https://test.doschain.com/"
CANONICAL_BLOCKSCOUT_DB = "blockscout_jasj_20260809"


Expand Down Expand Up @@ -88,8 +85,8 @@ def validate() -> list[str]:
)
if caddy.count('X-DOS-RPC-Origin "dos-testnet-r0-JASJZyVT"') != 2:
errors.append("Caddy must identify both canonical Testnet RPC routes")
if f"ethereum: dos-testnet:{CANONICAL_TESTNET_INTERNAL_RPC}" not in compose:
errors.append("Graph Node must bootstrap from the canonical internal Testnet RPC")
if f"ethereum: dos-testnet:{CANONICAL_TESTNET_BENS_RPC}" not in compose:
errors.append("Graph Node must bootstrap from the canonical public Testnet RPC")

canonical_database_url = (
f"postgresql://postgres:@db:5432/{CANONICAL_BLOCKSCOUT_DB}"
Expand Down Expand Up @@ -190,10 +187,10 @@ def validate() -> list[str]:
errors.append("ENSv2 token IDs must not use the ENSv1 native NFT mapping")
if networks.get("3939", {}).get("use_protocols") != ["dos-names"]:
errors.append("BENS network 3939 must enable only dos-names")
if networks.get("3939", {}).get("rpc_url") != CANONICAL_TESTNET_INTERNAL_RPC:
errors.append("BENS must use the canonical internal Testnet RPC")
if networks.get("3939", {}).get("rpc_url") != CANONICAL_TESTNET_BENS_RPC:
errors.append("BENS must use the canonical public Testnet RPC")

ref_match = re.search(r"DOS_NAMES_SUBGRAPH_REF: ([0-9a-f]{40})", workflow)
ref_match = re.search(r"DOS_NAMES_TESTNET_SUBGRAPH_REF: ([0-9a-f]{40})", workflow)
if ref_match is None:
errors.append("The deployment workflow must pin a full DOS Names commit")
if "https://github.com/DOS/DOS-Names-Contracts.git" not in workflow:
Expand Down
Loading