From 2db1d992d51a33f9bd619bccc28c21a5d99ca03c Mon Sep 17 00:00:00 2001 From: Pedro Fontana Date: Mon, 2 Sep 2024 15:39:05 -0300 Subject: [PATCH] Remove testnet (#424) Co-authored-by: pefontana --- .env.example | 3 - .github/workflows/ci.yml | 3 +- .github/workflows/deploy-production.yaml | 100 +++++----- .github/workflows/deploy-testing.yaml | 99 +++++----- README.md | 12 +- ansible/playbooks/deployment.yaml | 187 +++++++++--------- ansible/playbooks/templates/.env.j2 | 2 - config/config.exs | 2 +- config/runtime.exs | 7 - lib/cache_request_warmer.ex | 2 +- lib/starknet_explorer/application.ex | 16 +- lib/starknet_explorer/block/block.ex | 2 +- lib/starknet_explorer/cache.ex | 2 - lib/starknet_explorer/class.ex | 2 +- lib/starknet_explorer/contract.ex | 2 +- lib/starknet_explorer/events.ex | 2 +- lib/starknet_explorer/message.ex | 2 +- lib/starknet_explorer/token.ex | 37 +--- lib/starknet_explorer/transaction.ex | 2 +- lib/starknet_explorer/transaction_receipt.ex | 2 +- .../components/layouts/root.html.heex | 8 - .../live/common_assigns.ex | 2 +- lib/starknet_explorer_web/live/utils.ex | 5 - lib/starknet_rpc.ex | 7 +- 24 files changed, 208 insertions(+), 300 deletions(-) diff --git a/.env.example b/.env.example index 08836e65..c7d2d240 100644 --- a/.env.example +++ b/.env.example @@ -1,12 +1,9 @@ export DB_TYPE= # set to postgresql if you want to use postgresql, empty otherwise (sqlite). export DISABLE_MAINNET_SYNC=true # Set to true if you want to disable mainnet sync -export DISABLE_TESTNET_SYNC=true # Set to true if you want to disable testnet sync export DISABLE_SEPOLIA_SYNC=true # Set to true if you want to disable sepolia sync export RPC_API_HOST= # Set to your mainnet rpc api host, is will be used in the explorer as "Mainnet" -export TESTNET_RPC_API_HOST= # Set to your testnet rpc api host, is will be used in the explorer as "Testnet" export SEPOLIA_RPC_API_HOST= # Set to your sepolia rpc api host, is will be used in the explorer as "Sepolia" export DB_NAME= # set DB creds export DB_USER= export DB_PASS= export DB_HOST= - diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2c99187e..248be1d9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,9 +15,8 @@ permissions: jobs: build: - env: + env: RPC_API_HOST: ${{ secrets.RPC_API_HOST }} - TESTNET_RPC_API_HOST: ${{ secrets.TESTNET_RPC_API_HOST }} SEPOLIA_RPC_API_HOST: ${{ secrets.SEPOLIA_RPC_API_HOST }} name: Build and test runs-on: ubuntu-latest diff --git a/.github/workflows/deploy-production.yaml b/.github/workflows/deploy-production.yaml index 783e8892..d8857577 100644 --- a/.github/workflows/deploy-production.yaml +++ b/.github/workflows/deploy-production.yaml @@ -9,7 +9,6 @@ on: - v** jobs: - build-deploy: name: Build and deploy to production runs-on: ubuntu-latest @@ -17,58 +16,55 @@ jobs: name: production url: https://starkcompass.com/ steps: + - name: Checkout + uses: actions/checkout@v3.3.0 - - name: Checkout - uses: actions/checkout@v3.3.0 - - - name: Tailscale - uses: tailscale/github-action@v2 - with: - oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }} - oauth-secret: ${{ secrets.TS_OAUTH_SECRET }} - tags: tag:ci + - name: Tailscale + uses: tailscale/github-action@v2 + with: + oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }} + oauth-secret: ${{ secrets.TS_OAUTH_SECRET }} + tags: tag:ci - - name: Create ssh private key file from env var - env: - SSH_KEY: ${{ secrets.SSH_KEY }} - TS_HOST: ${{ vars.TS_HOST }} - run: | - mkdir ~/.ssh/ - sed -E 's/(-+(BEGIN|END) OPENSSH PRIVATE KEY-+) *| +/\1\n/g' <<< "$SSH_KEY" > ~/.ssh/id_ed25519 - chmod 400 ~/.ssh/id_ed25519 - retries=5; until ssh-keyscan $TS_HOST >> ~/.ssh/known_hosts || [ $retries -eq 0 ]; do ((retries--)); sleep 5; done + - name: Create ssh private key file from env var + env: + SSH_KEY: ${{ secrets.SSH_KEY }} + TS_HOST: ${{ vars.TS_HOST }} + run: | + mkdir ~/.ssh/ + sed -E 's/(-+(BEGIN|END) OPENSSH PRIVATE KEY-+) *| +/\1\n/g' <<< "$SSH_KEY" > ~/.ssh/id_ed25519 + chmod 400 ~/.ssh/id_ed25519 + retries=5; until ssh-keyscan $TS_HOST >> ~/.ssh/known_hosts || [ $retries -eq 0 ]; do ((retries--)); sleep 5; done - - name: Install ansible - run: | - pip install ansible + - name: Install ansible + run: | + pip install ansible - - name: "Deploy with ansible" - env: - MIX_ENV: ${{ vars.MIX_ENV }} - DB_TYPE: ${{ vars.DB_TYPE }} - DATABASE_URL: ${{ secrets.DATABASE_URL }} - SECRET_KEY_BASE: ${{ secrets.SECRET_KEY_BASE }} - PHX_HOST: ${{ vars.PHX_HOST }} - PHX_SERVER: ${{ vars.PHX_SERVER }} - RPC_API_HOST: ${{ secrets.RPC_API_HOST }} - TESTNET_RPC_API_HOST: ${{ secrets.TESTNET_RPC_API_HOST }} - SEPOLIA_RPC_API_HOST: ${{ secrets.SEPOLIA_RPC_API_HOST }} - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_REGION: ${{ vars.AWS_REGION }} - PROVER_STORAGE: ${{ vars.PROVER_STORAGE }} - ANSIBLE_SSH_PKEY_DIR: "~/.ssh/id_ed25519" - TS_HOST: ${{ vars.TS_HOST }} - TS_USER: ${{ vars.TS_USER }} - GIT_BRANCH: ${{ github.head_ref || github.ref_name }} - ANSIBLE_STDOUT_CALLBACK: "yaml" - NEWRELIC_KEY: ${{ secrets.NEWRELIC_KEY }} - NEWRELIC_APP_NAME: ${{ vars.NEWRELIC_APP_NAME }} - SENTRY_ENV: "production" - SENTRY_DSN: ${{ secrets.SENTRY_DSN }} - ENABLE_MAINNET_SYNC: "true" - ENABLE_TESTNET_SYNC: "true" - ENABLE_SEPOLIA_SYNC: "true" - ENABLE_GATEWAY_DATA: "true" - run: | - ansible-playbook -i ansible/inventory.yaml ansible/playbooks/deployment.yaml + - name: "Deploy with ansible" + env: + MIX_ENV: ${{ vars.MIX_ENV }} + DB_TYPE: ${{ vars.DB_TYPE }} + DATABASE_URL: ${{ secrets.DATABASE_URL }} + SECRET_KEY_BASE: ${{ secrets.SECRET_KEY_BASE }} + PHX_HOST: ${{ vars.PHX_HOST }} + PHX_SERVER: ${{ vars.PHX_SERVER }} + RPC_API_HOST: ${{ secrets.RPC_API_HOST }} + SEPOLIA_RPC_API_HOST: ${{ secrets.SEPOLIA_RPC_API_HOST }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_REGION: ${{ vars.AWS_REGION }} + PROVER_STORAGE: ${{ vars.PROVER_STORAGE }} + ANSIBLE_SSH_PKEY_DIR: "~/.ssh/id_ed25519" + TS_HOST: ${{ vars.TS_HOST }} + TS_USER: ${{ vars.TS_USER }} + GIT_BRANCH: ${{ github.head_ref || github.ref_name }} + ANSIBLE_STDOUT_CALLBACK: "yaml" + NEWRELIC_KEY: ${{ secrets.NEWRELIC_KEY }} + NEWRELIC_APP_NAME: ${{ vars.NEWRELIC_APP_NAME }} + SENTRY_ENV: "production" + SENTRY_DSN: ${{ secrets.SENTRY_DSN }} + ENABLE_MAINNET_SYNC: "true" + ENABLE_SEPOLIA_SYNC: "true" + ENABLE_GATEWAY_DATA: "true" + run: | + ansible-playbook -i ansible/inventory.yaml ansible/playbooks/deployment.yaml diff --git a/.github/workflows/deploy-testing.yaml b/.github/workflows/deploy-testing.yaml index be6746f4..529ad712 100644 --- a/.github/workflows/deploy-testing.yaml +++ b/.github/workflows/deploy-testing.yaml @@ -10,7 +10,6 @@ on: workflow_dispatch: jobs: - build-deploy: name: Build and deploy to testing runs-on: ubuntu-latest @@ -19,57 +18,55 @@ jobs: url: https://testing.starkcompass.com/ steps: - - name: Checkout - uses: actions/checkout@v3.3.0 + - name: Checkout + uses: actions/checkout@v3.3.0 - - name: Tailscale - uses: tailscale/github-action@v2 - with: - oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }} - oauth-secret: ${{ secrets.TS_OAUTH_SECRET }} - tags: tag:ci + - name: Tailscale + uses: tailscale/github-action@v2 + with: + oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }} + oauth-secret: ${{ secrets.TS_OAUTH_SECRET }} + tags: tag:ci - - name: Create ssh private key file from env var - env: - SSH_KEY: ${{ secrets.SSH_KEY }} - TS_HOST: ${{ vars.TS_HOST }} - run: | - mkdir ~/.ssh/ - sed -E 's/(-+(BEGIN|END) OPENSSH PRIVATE KEY-+) *| +/\1\n/g' <<< "$SSH_KEY" > ~/.ssh/id_ed25519 - chmod 400 ~/.ssh/id_ed25519 - retries=5; until ssh-keyscan $TS_HOST >> ~/.ssh/known_hosts || [ $retries -eq 0 ]; do ((retries--)); sleep 5; done + - name: Create ssh private key file from env var + env: + SSH_KEY: ${{ secrets.SSH_KEY }} + TS_HOST: ${{ vars.TS_HOST }} + run: | + mkdir ~/.ssh/ + sed -E 's/(-+(BEGIN|END) OPENSSH PRIVATE KEY-+) *| +/\1\n/g' <<< "$SSH_KEY" > ~/.ssh/id_ed25519 + chmod 400 ~/.ssh/id_ed25519 + retries=5; until ssh-keyscan $TS_HOST >> ~/.ssh/known_hosts || [ $retries -eq 0 ]; do ((retries--)); sleep 5; done - - name: Install ansible - run: | - pip install ansible + - name: Install ansible + run: | + pip install ansible - - name: "Deploy with ansible" - env: - MIX_ENV: ${{ vars.MIX_ENV }} - DB_TYPE: ${{ vars.DB_TYPE }} - DATABASE_URL: ${{ secrets.DATABASE_URL }} - SECRET_KEY_BASE: ${{ secrets.SECRET_KEY_BASE }} - PHX_HOST: ${{ vars.PHX_HOST }} - PHX_SERVER: ${{ vars.PHX_SERVER }} - RPC_API_HOST: ${{ secrets.RPC_API_HOST }} - TESTNET_RPC_API_HOST: ${{ secrets.TESTNET_RPC_API_HOST }} - SEPOLIA_RPC_API_HOST: ${{ secrets.SEPOLIA_RPC_API_HOST }} - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_REGION: ${{ vars.AWS_REGION }} - PROVER_STORAGE: ${{ vars.PROVER_STORAGE }} - ANSIBLE_SSH_PKEY_DIR: "~/.ssh/id_ed25519" - TS_HOST: ${{ vars.TS_HOST }} - TS_USER: ${{ vars.TS_USER }} - GIT_BRANCH: ${{ github.head_ref || github.ref_name }} - ANSIBLE_STDOUT_CALLBACK: "yaml" - ENABLE_MAINNET_SYNC: "true" - ENABLE_TESTNET_SYNC: "true" - ENABLE_SEPOLIA_SYNC: "true" - ENABLE_GATEWAY_DATA: "true" - NEWRELIC_KEY: ${{ secrets.NEWRELIC_KEY }} - NEWRELIC_APP_NAME: ${{ vars.NEWRELIC_APP_NAME }} - SENTRY_ENV: "testing" - SENTRY_DSN: ${{ secrets.SENTRY_DSN }} - run: | - ansible-playbook -i ansible/inventory.yaml ansible/playbooks/deployment.yaml + - name: "Deploy with ansible" + env: + MIX_ENV: ${{ vars.MIX_ENV }} + DB_TYPE: ${{ vars.DB_TYPE }} + DATABASE_URL: ${{ secrets.DATABASE_URL }} + SECRET_KEY_BASE: ${{ secrets.SECRET_KEY_BASE }} + PHX_HOST: ${{ vars.PHX_HOST }} + PHX_SERVER: ${{ vars.PHX_SERVER }} + RPC_API_HOST: ${{ secrets.RPC_API_HOST }} + SEPOLIA_RPC_API_HOST: ${{ secrets.SEPOLIA_RPC_API_HOST }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_REGION: ${{ vars.AWS_REGION }} + PROVER_STORAGE: ${{ vars.PROVER_STORAGE }} + ANSIBLE_SSH_PKEY_DIR: "~/.ssh/id_ed25519" + TS_HOST: ${{ vars.TS_HOST }} + TS_USER: ${{ vars.TS_USER }} + GIT_BRANCH: ${{ github.head_ref || github.ref_name }} + ANSIBLE_STDOUT_CALLBACK: "yaml" + ENABLE_MAINNET_SYNC: "true" + ENABLE_SEPOLIA_SYNC: "true" + ENABLE_GATEWAY_DATA: "true" + NEWRELIC_KEY: ${{ secrets.NEWRELIC_KEY }} + NEWRELIC_APP_NAME: ${{ vars.NEWRELIC_APP_NAME }} + SENTRY_ENV: "testing" + SENTRY_DSN: ${{ secrets.SENTRY_DSN }} + run: | + ansible-playbook -i ansible/inventory.yaml ansible/playbooks/deployment.yaml diff --git a/README.md b/README.md index cd4711eb..f098767a 100644 --- a/README.md +++ b/README.md @@ -26,9 +26,9 @@ ## Local development -If you run `make` it will print out the available targets: +If you run `make` it will print out the available targets: ``` -% make +% make Usage: run : Starts the Elixir backend server. setup : Sets up everything necessary to build and run the explorer. @@ -37,7 +37,7 @@ Usage: ``` ### Setup -Once you have the requirements installed and set up, you can proceed to building and running the project. +Once you have the requirements installed and set up, you can proceed to building and running the project. ```bash make setup @@ -58,7 +58,6 @@ Set the following environment variables: ```bash export RPC_API_HOST=your_rpc_hostname -export TESTNET_RPC_API_HOST=testnet_rpc_hostname export SEPOLIA_RPC_API_HOST=sepolia_rpc_hostname ``` @@ -102,7 +101,6 @@ The synchronization process is activated by default, you can turn it off by conf ```bash export DISABLE_MAINNET_SYNC=true -export DISABLE_TESTNET_SYNC=true export DISABLE_SEPOLIA_SYNC=true ``` @@ -114,7 +112,7 @@ There are 3 things to keep in mind here: 1. Amount of requests: If you have any constraint on how many requests you can make: keep an eye on that, because the State Synchronization System can do a lot of requests per second. -2. Disk Usage: We're still measuring it, but we expect it to be considerable +2. Disk Usage: We're still measuring it, but we expect it to be considerable after running it for a couple of days. 3. If you are going to sync a large amount of blocks, we *strongly* suggest to use PostgreSQL instead of SQLite. You can check how to swap the DB in [this section](#using-stark-compass-with-postgresql). @@ -156,7 +154,7 @@ docker-compose up postgres ## Contributing -We appreciate your interest in contributing to the Stark Compass Explorer! Your contributions can help make this project even better. +We appreciate your interest in contributing to the Stark Compass Explorer! Your contributions can help make this project even better. PRs are more than welcome if you want to collaborate to the project. If you don't know how to implement a feature, you are still welcome to create an issue! diff --git a/ansible/playbooks/deployment.yaml b/ansible/playbooks/deployment.yaml index 6d08fdb3..8a912132 100644 --- a/ansible/playbooks/deployment.yaml +++ b/ansible/playbooks/deployment.yaml @@ -7,109 +7,104 @@ become_user: "{{ lookup('ansible.builtin.env', 'TS_USER') }}" pre_tasks: + - name: Delete tmp repo + file: + state: absent + path: "/home/{{ lookup('ansible.builtin.env', 'TS_USER') }}/tmp/stark_compass_explorer" - - name: Delete tmp repo - file: - state: absent - path: "/home/{{ lookup('ansible.builtin.env', 'TS_USER') }}/tmp/stark_compass_explorer" + - name: Clone repo in tmp dir + ansible.builtin.git: + repo: https://github.com/lambdaclass/stark_compass_explorer.git + version: "{{ lookup('ansible.builtin.env', 'GIT_BRANCH') }}" + dest: "/home/{{ lookup('ansible.builtin.env', 'TS_USER') }}/tmp/stark_compass_explorer" + register: clone_output - - name: Clone repo in tmp dir - ansible.builtin.git: - repo: https://github.com/lambdaclass/stark_compass_explorer.git - version: "{{ lookup('ansible.builtin.env', 'GIT_BRANCH') }}" - dest: "/home/{{ lookup('ansible.builtin.env', 'TS_USER') }}/tmp/stark_compass_explorer" - register: clone_output + - name: Print clone repo output + debug: msg="{{ clone_output }}" - - name: Print clone repo output - debug: msg="{{ clone_output }}" + - name: Build + ansible.builtin.shell: | + set -ex + export PATH=${PATH}:/home/{{ lookup('ansible.builtin.env', 'TS_USER') }}/.cargo/bin + mix local.hex --force + mix local.rebar --force + mix deps.get --only $MIX_ENV + mix deps.compile + mix assets.deploy + mix ecto.setup + mix phx.digest + mix compile + mix release + mix phx.gen.release + environment: + MIX_ENV: prod + RPC_API_HOST: "{{ lookup('ansible.builtin.env', 'RPC_API_HOST') }}" + SEPOLIA_RPC_API_HOST: "{{ lookup('ansible.builtin.env', 'SEPOLIA_RPC_API_HOST') }}" + DB_TYPE: "{{ lookup('ansible.builtin.env', 'DB_TYPE') }}" + DATABASE_URL: "{{ lookup('ansible.builtin.env', 'DATABASE_URL') }}" + NEWRELIC_KEY: + NEWRELIC_APP_NAME: + SECRET_KEY_BASE: "{{ lookup('ansible.builtin.env', 'SECRET_KEY_BASE') }}" + PORT: "4100" + SENTRY_ENV: "{{ lookup('ansible.builtin.env', 'SENTRY_ENV') }}" + SENTRY_DSN: "{{ lookup('ansible.builtin.env', 'SENTRY_DSN') }}" + ENABLE_MAINNET_SYNC: "{{ lookup('ansible.builtin.env', 'ENABLE_MAINNET_SYNC') }}" + ENABLE_SEPOLIA_SYNC: "{{ lookup('ansible.builtin.env', 'ENABLE_SEPOLIA_SYNC') }}" + ENABLE_GATEWAY_DATA: "{{ lookup('ansible.builtin.env', 'ENABLE_GATEWAY_DATA') }}" + args: + chdir: "/home/{{ lookup('ansible.builtin.env', 'TS_USER') }}/tmp/stark_compass_explorer" + register: build_output - - name: Build - ansible.builtin.shell: | - set -ex - export PATH=${PATH}:/home/{{ lookup('ansible.builtin.env', 'TS_USER') }}/.cargo/bin - mix local.hex --force - mix local.rebar --force - mix deps.get --only $MIX_ENV - mix deps.compile - mix assets.deploy - mix ecto.setup - mix phx.digest - mix compile - mix release - mix phx.gen.release - environment: - MIX_ENV: prod - RPC_API_HOST: "{{ lookup('ansible.builtin.env', 'RPC_API_HOST') }}" - TESTNET_RPC_API_HOST: "{{ lookup('ansible.builtin.env', 'TESTNET_RPC_API_HOST') }}" - SEPOLIA_RPC_API_HOST: "{{ lookup('ansible.builtin.env', 'SEPOLIA_RPC_API_HOST') }}" - DB_TYPE: "{{ lookup('ansible.builtin.env', 'DB_TYPE') }}" - DATABASE_URL: "{{ lookup('ansible.builtin.env', 'DATABASE_URL') }}" - NEWRELIC_KEY: - NEWRELIC_APP_NAME: - SECRET_KEY_BASE: "{{ lookup('ansible.builtin.env', 'SECRET_KEY_BASE') }}" - PORT: "4100" - SENTRY_ENV: "{{ lookup('ansible.builtin.env', 'SENTRY_ENV') }}" - SENTRY_DSN: "{{ lookup('ansible.builtin.env', 'SENTRY_DSN') }}" - ENABLE_MAINNET_SYNC: "{{ lookup('ansible.builtin.env', 'ENABLE_MAINNET_SYNC') }}" - ENABLE_TESTNET_SYNC: "{{ lookup('ansible.builtin.env', 'ENABLE_TESTNET_SYNC') }}" - ENABLE_SEPOLIA_SYNC: "{{ lookup('ansible.builtin.env', 'ENABLE_SEPOLIA_SYNC') }}" - ENABLE_GATEWAY_DATA: "{{ lookup('ansible.builtin.env', 'ENABLE_GATEWAY_DATA') }}" - args: - chdir: "/home/{{ lookup('ansible.builtin.env', 'TS_USER') }}/tmp/stark_compass_explorer" - register: build_output + - debug: msg="{{ build_output.stdout_lines + [ build_output.stderr_lines ] }}" - - debug: msg="{{ build_output.stdout_lines + [ build_output.stderr_lines ] }}" + - name: Delete old repo + ansible.builtin.file: + state: absent + path: "/home/{{ lookup('ansible.builtin.env', 'TS_USER') }}/stark_compass_explorer" - - name: Delete old repo - ansible.builtin.file: - state: absent - path: "/home/{{ lookup('ansible.builtin.env', 'TS_USER') }}/stark_compass_explorer" + - name: Copy repo from tmp dir + ansible.builtin.copy: + remote_src: true + src: "/home/{{ lookup('ansible.builtin.env', 'TS_USER') }}/tmp/stark_compass_explorer" + dest: "/home/{{ lookup('ansible.builtin.env', 'TS_USER') }}/" - - name: Copy repo from tmp dir - ansible.builtin.copy: - remote_src: true - src: "/home/{{ lookup('ansible.builtin.env', 'TS_USER') }}/tmp/stark_compass_explorer" - dest: "/home/{{ lookup('ansible.builtin.env', 'TS_USER') }}/" + - name: Create .env file + ansible.builtin.template: + src: .env.j2 + dest: "/home/{{ lookup('ansible.builtin.env', 'TS_USER') }}/.env" + vars: + phx_host: "{{ lookup('ansible.builtin.env', 'PHX_HOST') }}" + secret_key_base: "{{ lookup('ansible.builtin.env', 'SECRET_KEY_BASE') }}" + db_type: "{{ lookup('ansible.builtin.env', 'DB_TYPE') }}" + database_url: "{{ lookup('ansible.builtin.env', 'DATABASE_URL') }}" + rpc_api_host: "{{ lookup('ansible.builtin.env', 'RPC_API_HOST') }}" + sepolia_rpc_api_host: "{{ lookup('ansible.builtin.env', 'SEPOLIA_RPC_API_HOST') }}" + aws_access_key_id: "{{ lookup('ansible.builtin.env', 'AWS_ACCESS_KEY_ID') }}" + aws_secret_access_key: "{{ lookup('ansible.builtin.env', 'AWS_SECRET_ACCESS_KEY') }}" + aws_region: "{{ lookup('ansible.builtin.env', 'AWS_REGION') }}" + prover_storage: "{{ lookup('ansible.builtin.env', 'PROVER_STORAGE') }}" + newrelic_key: "{{ lookup('ansible.builtin.env', 'NEWRELIC_KEY') }}" + newrelic_app_name: "{{ lookup('ansible.builtin.env', 'NEWRELIC_APP_NAME') }}" + sentry_env: "{{ lookup('ansible.builtin.env', 'SENTRY_ENV') }}" + sentry_dsn: "{{ lookup('ansible.builtin.env', 'SENTRY_DSN') }}" + enable_mainnet_sync: "{{ lookup('ansible.builtin.env', 'ENABLE_MAINNET_SYNC') }}" + enable_sepolia_sync: "{{ lookup('ansible.builtin.env', 'ENABLE_SEPOLIA_SYNC') }}" + enable_gateway_data: "{{ lookup('ansible.builtin.env', 'ENABLE_GATEWAY_DATA') }}" - - name: Create .env file - ansible.builtin.template: - src: .env.j2 - dest: "/home/{{ lookup('ansible.builtin.env', 'TS_USER') }}/.env" - vars: - phx_host: "{{ lookup('ansible.builtin.env', 'PHX_HOST') }}" - secret_key_base: "{{ lookup('ansible.builtin.env', 'SECRET_KEY_BASE') }}" - db_type: "{{ lookup('ansible.builtin.env', 'DB_TYPE') }}" - database_url: "{{ lookup('ansible.builtin.env', 'DATABASE_URL') }}" - rpc_api_host: "{{ lookup('ansible.builtin.env', 'RPC_API_HOST') }}" - testnet_rpc_api_host: "{{ lookup('ansible.builtin.env', 'TESTNET_RPC_API_HOST') }}" - sepolia_rpc_api_host: "{{ lookup('ansible.builtin.env', 'SEPOLIA_RPC_API_HOST') }}" - aws_access_key_id: "{{ lookup('ansible.builtin.env', 'AWS_ACCESS_KEY_ID') }}" - aws_secret_access_key: "{{ lookup('ansible.builtin.env', 'AWS_SECRET_ACCESS_KEY') }}" - aws_region: "{{ lookup('ansible.builtin.env', 'AWS_REGION') }}" - prover_storage: "{{ lookup('ansible.builtin.env', 'PROVER_STORAGE') }}" - newrelic_key: "{{ lookup('ansible.builtin.env', 'NEWRELIC_KEY') }}" - newrelic_app_name: "{{ lookup('ansible.builtin.env', 'NEWRELIC_APP_NAME') }}" - sentry_env: "{{ lookup('ansible.builtin.env', 'SENTRY_ENV') }}" - sentry_dsn: "{{ lookup('ansible.builtin.env', 'SENTRY_DSN') }}" - enable_mainnet_sync: "{{ lookup('ansible.builtin.env', 'ENABLE_MAINNET_SYNC') }}" - enable_testnet_sync: "{{ lookup('ansible.builtin.env', 'ENABLE_TESTNET_SYNC') }}" - enable_sepolia_sync: "{{ lookup('ansible.builtin.env', 'ENABLE_SEPOLIA_SYNC') }}" - enable_gateway_data: "{{ lookup('ansible.builtin.env', 'ENABLE_GATEWAY_DATA') }}" + - name: Create user systemd directory + ansible.builtin.file: + state: directory + path: "/home/{{ lookup('ansible.builtin.env', 'TS_USER') }}/.config/systemd/user" - - name: Create user systemd directory - ansible.builtin.file: - state: directory - path: "/home/{{ lookup('ansible.builtin.env', 'TS_USER') }}/.config/systemd/user" + - name: Install systemd service + ansible.builtin.template: + src: starknet_explorer.service.j2 + dest: "/home/{{ lookup('ansible.builtin.env', 'TS_USER') }}/.config/systemd/user/starknet_explorer.service" - - name: Install systemd service - ansible.builtin.template: - src: starknet_explorer.service.j2 - dest: "/home/{{ lookup('ansible.builtin.env', 'TS_USER') }}/.config/systemd/user/starknet_explorer.service" - - - name: Restart starknet_explorer service - ansible.builtin.systemd: - scope: user - state: restarted - daemon_reload: true - enabled: true - name: starknet_explorer + - name: Restart starknet_explorer service + ansible.builtin.systemd: + scope: user + state: restarted + daemon_reload: true + enabled: true + name: starknet_explorer diff --git a/ansible/playbooks/templates/.env.j2 b/ansible/playbooks/templates/.env.j2 index 83566e67..5e1be37b 100644 --- a/ansible/playbooks/templates/.env.j2 +++ b/ansible/playbooks/templates/.env.j2 @@ -4,7 +4,6 @@ SECRET_KEY_BASE={{ secret_key_base }} DB_TYPE={{ db_type }} DATABASE_URL={{ database_url }} RPC_API_HOST={{ rpc_api_host }} -TESTNET_RPC_API_HOST={{ testnet_rpc_api_host }} SEPOLIA_RPC_API_HOST={{ sepolia_rpc_api_host }} AWS_ACCESS_KEY_ID={{ aws_access_key_id }} AWS_SECRET_ACCESS_KEY={{ aws_secret_access_key }} @@ -16,5 +15,4 @@ NEWRELIC_APP_NAME={{ newrelic_app_name }} SENTRY_DSN={{ sentry_dsn }} SENTRY_ENV={{ sentry_env }} ENABLE_MAINNET_SYNC={{ enable_mainnet_sync }} -ENABLE_TESTNET_SYNC={{ enable_testnet_sync }} ENABLE_SEPOLIA_SYNC={{ enable_sepolia_sync }} diff --git a/config/config.exs b/config/config.exs index 3f651376..10d03d83 100644 --- a/config/config.exs +++ b/config/config.exs @@ -62,7 +62,7 @@ config :esbuild, ] config :starknet_explorer, - allowed_networks: [:mainnet, :testnet, :sepolia] + allowed_networks: [:mainnet, :sepolia] # Import environment specific config. This must remain at the bottom # of this file so it overrides the configuration defined above. diff --git a/config/runtime.exs b/config/runtime.exs index 75cf6556..295e49f7 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -26,12 +26,6 @@ rpc_host = environment variable RPC_API_HOST is missing. """ -testnet_rpc_host = - System.get_env("TESTNET_RPC_API_HOST") || - raise """ - environment variable for testnet is missing. - """ - sepolia_rpc_host = System.get_env("SEPOLIA_RPC_API_HOST") || raise """ @@ -40,7 +34,6 @@ sepolia_rpc_host = config :starknet_explorer, rpc_host: rpc_host, - testnet_host: testnet_rpc_host, sepolia_host: sepolia_rpc_host config :starknet_explorer, rpc_host: rpc_host diff --git a/lib/cache_request_warmer.ex b/lib/cache_request_warmer.ex index 2c2a7c63..f1b2ca1f 100644 --- a/lib/cache_request_warmer.ex +++ b/lib/cache_request_warmer.ex @@ -6,7 +6,7 @@ defmodule StarknetExplorer.Cache.BlockWarmer do def interval, do: @interval def execute(%{network: network}) - when network in [:mainnet, :testnet, :sepolia] do + when network in [:mainnet, :sepolia] do Logger.debug("Warming cache for #{network}") # Try/Rescue is not really an elixir/erlang thing to do, but # I think this is the most simple way to do this, since diff --git a/lib/starknet_explorer/application.ex b/lib/starknet_explorer/application.ex index 61527730..b60b8b01 100644 --- a/lib/starknet_explorer/application.ex +++ b/lib/starknet_explorer/application.ex @@ -21,20 +21,6 @@ defmodule StarknetExplorer.Application do ] end - testnet_state_sync = - if System.get_env("DISABLE_TESTNET_SYNC") == "true" do - [] - else - # Start the State Sync System server for testnet. - [ - Supervisor.child_spec( - {StarknetExplorer.Blockchain.StateSyncSystem, - [network: :testnet, name: :testnet_state_sync]}, - id: :testnet_state_sync - ) - ] - end - sepolia_state_sync = if System.get_env("DISABLE_SEPOLIA_SYNC") == "true" do [] @@ -64,7 +50,7 @@ defmodule StarknetExplorer.Application do # Start a worker by calling: StarknetExplorer.Worker.start_link(arg) # {StarknetExplorer.Worker, arg} StarknetExplorer.IndexCache - ] ++ sepolia_state_sync ++ testnet_state_sync ++ mainnet_state_sync + ] ++ sepolia_state_sync ++ mainnet_state_sync # See https://hexdocs.pm/elixir/Supervisor.html # for other strategies and supported options diff --git a/lib/starknet_explorer/block/block.ex b/lib/starknet_explorer/block/block.ex index 5d29d1cd..931fa67c 100644 --- a/lib/starknet_explorer/block/block.ex +++ b/lib/starknet_explorer/block/block.ex @@ -8,7 +8,7 @@ defmodule StarknetExplorer.Block do alias StarknetExplorerWeb.Utils alias StarknetExplorer.TransactionReceipt, as: Receipt require Logger - @networks [:mainnet, :testnet, :sepolia] + @networks [:mainnet, :sepolia] @cast_fields [ :number, :status, diff --git a/lib/starknet_explorer/cache.ex b/lib/starknet_explorer/cache.ex index d9818c49..a504017c 100644 --- a/lib/starknet_explorer/cache.ex +++ b/lib/starknet_explorer/cache.ex @@ -4,14 +4,12 @@ defmodule StarknetExplorer.IndexCache do def start_link(_) do blocks_mainnet = StarknetExplorer.Data.many_blocks_with_txs("mainnet") - blocks_testnet = StarknetExplorer.Data.many_blocks_with_txs("testnet") blocks_sepolia = StarknetExplorer.Data.many_blocks_with_txs("sepolia") Agent.start_link( fn -> %{ "mainnet" => blocks_mainnet, - "testnet" => blocks_testnet, "sepolia" => blocks_sepolia } end, diff --git a/lib/starknet_explorer/class.ex b/lib/starknet_explorer/class.ex index 4843e22c..280967f9 100644 --- a/lib/starknet_explorer/class.ex +++ b/lib/starknet_explorer/class.ex @@ -54,7 +54,7 @@ defmodule StarknetExplorer.Class do ] } - @networks [:mainnet, :testnet, :sepolia] + @networks [:mainnet, :sepolia] @fields [ :declared_by_address, diff --git a/lib/starknet_explorer/contract.ex b/lib/starknet_explorer/contract.ex index 2a3f01bd..42affc96 100644 --- a/lib/starknet_explorer/contract.ex +++ b/lib/starknet_explorer/contract.ex @@ -4,7 +4,7 @@ defmodule StarknetExplorer.Contract do import Ecto.Query alias StarknetExplorer.Repo - @networks [:mainnet, :testnet, :sepolia] + @networks [:mainnet, :sepolia] @fields [ :address, :deployed_by_address, diff --git a/lib/starknet_explorer/events.ex b/lib/starknet_explorer/events.ex index 92398a25..fce705d1 100644 --- a/lib/starknet_explorer/events.ex +++ b/lib/starknet_explorer/events.ex @@ -77,7 +77,7 @@ defmodule StarknetExplorer.Events do field :data, {:array, :string} field :index_in_block, :integer field :transaction_hash, :string - field :network, Ecto.Enum, values: [:mainnet, :testnet, :sepolia] + field :network, Ecto.Enum, values: [:mainnet, :sepolia] timestamps() end diff --git a/lib/starknet_explorer/message.ex b/lib/starknet_explorer/message.ex index 37081246..5668577d 100644 --- a/lib/starknet_explorer/message.ex +++ b/lib/starknet_explorer/message.ex @@ -36,7 +36,7 @@ defmodule StarknetExplorer.Message do :l1_to_l2_cancelled_on_l1 ] - field :network, Ecto.Enum, values: [:mainnet, :testnet, :sepolia] + field :network, Ecto.Enum, values: [:mainnet, :sepolia] # belongs_to :transaction, Transaction, foreign_key: :transaction_hash, references: :hash timestamps() end diff --git a/lib/starknet_explorer/token.ex b/lib/starknet_explorer/token.ex index 3e66c9d8..88de59ff 100644 --- a/lib/starknet_explorer/token.ex +++ b/lib/starknet_explorer/token.ex @@ -40,48 +40,13 @@ defmodule StarknetExplorer.Token do } } - @whitelisted_tokens_testnet %{ - "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7" => %{ - address: "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7", - name: "StarkGate: ETH", - symbol: "ETH" - }, - "0x03e85bfbb8e2a42b7bead9e88e9a1b19dbccf661471061807292120462396ec9" => %{ - address: "0x03e85bfbb8e2a42b7bead9e88e9a1b19dbccf661471061807292120462396ec9", - name: "StarkGate: DAI", - symbol: "DAI" - }, - "0x005a643907b9a4bc6a55e9069c4fd5fd1f5c79a22470690f75556c4736e34426" => %{ - address: "0x005a643907b9a4bc6a55e9069c4fd5fd1f5c79a22470690f75556c4736e34426", - name: "StarkGate: USDC", - symbol: "USDC" - }, - "0x0386e8d061177f19b3b485c20e31137e6f6bc497cc635ccdfcab96fadf5add6a" => %{ - address: "0x0386e8d061177f19b3b485c20e31137e6f6bc497cc635ccdfcab96fadf5add6a", - name: "StarkGate: USDT", - symbol: "USDT" - }, - "0x012d537dc323c439dc65c976fad242d5610d27cfb5f31689a0a319b8be7f3d56" => %{ - address: "0x012d537dc323c439dc65c976fad242d5610d27cfb5f31689a0a319b8be7f3d56", - name: "StarkGate: wBTC", - symbol: "WBTC" - }, - "0x002133188109385fedaac0b1bf9de1134e271b88efcd21e2ea0dac460639fbe2" => %{ - address: "0x002133188109385fedaac0b1bf9de1134e271b88efcd21e2ea0dac460639fbe2", - name: "StarkGate: rETH", - symbol: "rETH" - } - } - + # @networks [:mainnet, :sepolia] # starknet_keccak("balanceOf") @balanceOf_selector "0x2e4263afad30923c891518314c3c95dbe830a16874e8abc5777a9a20b54c76e" def contract_portfolio(address, :mainnet), do: fetch_portfolio(address, :mainnet, @whitelisted_tokens_mainnet) - def contract_portfolio(address, :testnet), - do: fetch_portfolio(address, :testnet, @whitelisted_tokens_testnet) - def contract_portfolio(_, _), do: [] defp fetch_portfolio(address, network, tokens) do diff --git a/lib/starknet_explorer/transaction.ex b/lib/starknet_explorer/transaction.ex index 3a1b04e8..36348e17 100644 --- a/lib/starknet_explorer/transaction.ex +++ b/lib/starknet_explorer/transaction.ex @@ -71,7 +71,7 @@ defmodule StarknetExplorer.Transaction do @deploy_account_tx_fields ++ [:network, :nonce] - @networks [:mainnet, :testnet, :sepolia] + @networks [:mainnet, :sepolia] @primary_key {:hash, :string, []} schema "transactions" do diff --git a/lib/starknet_explorer/transaction_receipt.ex b/lib/starknet_explorer/transaction_receipt.ex index 8292e574..fee11689 100644 --- a/lib/starknet_explorer/transaction_receipt.ex +++ b/lib/starknet_explorer/transaction_receipt.ex @@ -84,7 +84,7 @@ defmodule StarknetExplorer.TransactionReceipt do # :contract_address # ] - @networks [:mainnet, :testnet, :sepolia] + @networks [:mainnet, :sepolia] @fields @invoke_tx_receipt_fields ++ @l1_receipt_handler ++ diff --git a/lib/starknet_explorer_web/components/layouts/root.html.heex b/lib/starknet_explorer_web/components/layouts/root.html.heex index f3df4393..3829dbe5 100644 --- a/lib/starknet_explorer_web/components/layouts/root.html.heex +++ b/lib/starknet_explorer_web/components/layouts/root.html.heex @@ -144,14 +144,6 @@ Mainnet -
diff --git a/lib/starknet_explorer_web/live/common_assigns.ex b/lib/starknet_explorer_web/live/common_assigns.ex index eb154f9c..4656b6a7 100644 --- a/lib/starknet_explorer_web/live/common_assigns.ex +++ b/lib/starknet_explorer_web/live/common_assigns.ex @@ -4,7 +4,7 @@ defmodule StarknetExplorerWeb.Live.CommonAssigns do def on_mount(:network, params, _session, socket) do socket = case Map.get(params, "network") do - network when network in ["testnet", "sepolia"] -> + network when network in ["sepolia"] -> network = network |> String.to_existing_atom() diff --git a/lib/starknet_explorer_web/live/utils.ex b/lib/starknet_explorer_web/live/utils.ex index 1402ac5a..f9ff6d69 100644 --- a/lib/starknet_explorer_web/live/utils.ex +++ b/lib/starknet_explorer_web/live/utils.ex @@ -163,17 +163,12 @@ defmodule StarknetExplorerWeb.Utils do # This case is for mainnet def network_path(:mainnet), do: "/" - def network_path(:testnet), do: "/testnet/" def network_path(:sepolia), do: "/sepolia/" def network_path(:mainnet, remaining_path) do "/#{remaining_path}" end - def network_path(:testnet, remaining_path) do - "/testnet/#{remaining_path}" - end - def network_path(:sepolia, remaining_path) do "/sepolia/#{remaining_path}" end diff --git a/lib/starknet_rpc.ex b/lib/starknet_rpc.ex index 2570b2b3..a9b0089f 100644 --- a/lib/starknet_rpc.ex +++ b/lib/starknet_rpc.ex @@ -81,7 +81,7 @@ defmodule StarknetExplorer.Rpc do network ) - defp send_request(method, args, network) when network in [:mainnet, :testnet, :sepolia] do + defp send_request(method, args, network) when network in [:mainnet, :sepolia] do payload = build_payload(method, args) case cache_lookup(method, args, network) do @@ -107,7 +107,7 @@ defmodule StarknetExplorer.Rpc do end defp send_request_no_cache(method, args, network) - when network in [:mainnet, :testnet, :sepolia] do + when network in [:mainnet, :sepolia] do payload = build_payload(method, args) host = fetch_rpc_host(network) {:ok, rsp} = post(host, payload) @@ -115,7 +115,6 @@ defmodule StarknetExplorer.Rpc do end defp fetch_rpc_host(:mainnet), do: Application.fetch_env!(:starknet_explorer, :rpc_host) - defp fetch_rpc_host(:testnet), do: Application.fetch_env!(:starknet_explorer, :testnet_host) defp fetch_rpc_host(:sepolia), do: Application.fetch_env!(:starknet_explorer, :sepolia_host) defp build_payload(method, params) do @@ -152,7 +151,7 @@ defmodule StarknetExplorer.Rpc do defp do_cache_lookup(cache_type, key, network) when cache_type in [:block_cache, :tx_cache, :request_cache] and - network in [:mainnet, :testnet, :sepolia] do + network in [:mainnet, :sepolia] do cache_name = :"#{network}_#{cache_type}" case Cachex.get(cache_name, key) do