diff --git a/substreams/ethereum-balancer/test_assets.yaml b/substreams/ethereum-balancer/test_assets.yaml index 3087fa1..76711b7 100644 --- a/substreams/ethereum-balancer/test_assets.yaml +++ b/substreams/ethereum-balancer/test_assets.yaml @@ -2,6 +2,8 @@ substreams_yaml_path: ./substreams.yaml protocol_type_names: - "balancer_pool" adapter_contract: "BalancerV2SwapAdapter" +adapter_build_signature: "constructor(address)" +adapter_build_args: "0xBA12222222228d8Ba445958a75a0704d566BF2C8" skip_balance_check: true initialized_accounts: - "0xba12222222228d8ba445958a75a0704d566bf2c8" diff --git a/substreams/ethereum-template/test_assets.yaml b/substreams/ethereum-template/test_assets.yaml index c8600bf..93711a1 100644 --- a/substreams/ethereum-template/test_assets.yaml +++ b/substreams/ethereum-template/test_assets.yaml @@ -1,5 +1,7 @@ substreams_yaml_path: ./substreams.yaml adapter_contract: "SwapAdapter.evm.runtime" +adapter_build_signature: "constructor(address)" +adapter_build_args: "0x0000000000000000000000000000000000000000" skip_balance_check: false protocol_type_names: - "type_name_1" diff --git a/testing/.env.default b/testing/.env.default index 21eb434..91db7db 100644 --- a/testing/.env.default +++ b/testing/.env.default @@ -1,4 +1,5 @@ SUBSTREAMS_PATH=../substreams/ethereum-curve RPC_URL=https://mainnet.infura.io/v3/your-infura-key DATABASE_URL: "postgres://postgres:mypassword@db:5432/tycho_indexer_0" -SUBSTREAMS_API_TOKEN="changeme" \ No newline at end of file +SUBSTREAMS_API_TOKEN="changeme" +DOMAIN_OWNER="AWSAccountId" \ No newline at end of file diff --git a/testing/Dockerfile b/testing/Dockerfile index e71f4c1..66f1c57 100644 --- a/testing/Dockerfile +++ b/testing/Dockerfile @@ -7,7 +7,7 @@ WORKDIR /app # Add current directory code to /app in container ADD . /app/testing -RUN chmod +x /app/testing/tycho-indexer-linux-x64 +RUN chmod +x /app/testing/tycho-indexer # Create a new conda environment and install pip RUN conda create -n myenv pip python=3.9 @@ -21,7 +21,8 @@ RUN apt-get update \ && pip install psycopg2 \ && apt-get clean -RUN /bin/bash -c "source activate myenv && cd testing && pip install --no-cache-dir -r requirements.txt && cd -" +ARG PIP_INDEX_URL +RUN /bin/bash -c "source activate myenv && cd testing && pip install --no-cache-dir -r src/requirements.txt && cd -" # Make port 80 available to the world outside this container EXPOSE 80 @@ -31,4 +32,4 @@ RUN wget -c https://github.com/streamingfast/substreams/releases/download/v1.8.0 RUN mv substreams /usr/local/bin/substreams && chmod +x /usr/local/bin/substreams # Run the command to start your application -CMD ["python", "testing/cli.py", "--test_yaml_path", "/app/substreams/my_substream/test_assets.yaml", "--with_binary_logs", "--db_url", "postgres://postgres:mypassword@db:5432"] \ No newline at end of file +CMD ["python", "testing/src/runner/cli.py", "--package", "my_substream", "--with_binary_logs", "--db_url", "postgres://postgres:mypassword@db:5432"] \ No newline at end of file diff --git a/testing/README.md b/testing/README.md index eb011e3..8796f45 100644 --- a/testing/README.md +++ b/testing/README.md @@ -9,6 +9,7 @@ The testing suite builds the `.spkg` for your Substreams module, indexes a speci ## Prerequisites - Latest version of our indexer, Tycho. Please contact us to obtain the latest version. Once acquired, place it in the `/testing/` directory. +- Access to PropellerHeads' private PyPI repository. Please contact us to obtain access. - Docker installed on your machine. ## Test Configuration @@ -38,7 +39,9 @@ Example: `SUBSTREAMS_PATH=../substreams/ethereum-curve` ### Step 2: Build and the Testing Script -Run the testing script using Docker Compose: +To build the testing script, run the following commands: ```bash +source pre_build.sh +docker compose build docker compose run app ``` \ No newline at end of file diff --git a/testing/docker-compose.yaml b/testing/docker-compose.yaml index 652261b..2e787f1 100644 --- a/testing/docker-compose.yaml +++ b/testing/docker-compose.yaml @@ -17,17 +17,29 @@ services: build: context: . dockerfile: Dockerfile + args: + PIP_INDEX_URL: ${PIP_INDEX_URL} volumes: - - ${SUBSTREAMS_PATH}:/app/substreams/my_substream +# - ${SUBSTREAMS_PATH}:/app/substreams/my_substream - ../substreams:/app/substreams - ../proto:/app/proto - - ./tycho-indexer:/app/testing/tycho-indexer + - ./tycho-indexer:/bin/tycho-indexer - ./src/runner/runner.py:/app/testing/src.py + - ../evm:/app/evm + - ./src/runner:/app/testing/src/runner ports: - "80:80" depends_on: - db env_file: - ".env" + command: + - "python" + - "testing/src/runner/cli.py" + - "--package" + - "ethereum-balancer" + - "--with_binary_logs" + - "--db_url" + - "postgres://postgres:mypassword@db:5432/tycho_indexer_0" volumes: postgres_data: \ No newline at end of file diff --git a/testing/pre_build.sh b/testing/pre_build.sh new file mode 100755 index 0000000..06fd22b --- /dev/null +++ b/testing/pre_build.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# Enable automatic export of all defined variables +set -a + +# Source the .env file +source .env + +# Disable automatic export (optional, if you want to stop exporting variables) +set +a + +# Check if DOMAIN_OWNER is set +if [ -z "$DOMAIN_OWNER" ]; then + echo "DOMAIN_OWNER environment variable is not set." + exit 1 +fi + +# Fetch the CODEARTIFACT_AUTH_TOKEN +CODEARTIFACT_AUTH_TOKEN=$(aws --region eu-central-1 codeartifact get-authorization-token --domain propeller --domain-owner $DOMAIN_OWNER --query authorizationToken --output text --duration 1800) + +# Set the PIP_INDEX_URL +PIP_INDEX_URL="https://aws:${CODEARTIFACT_AUTH_TOKEN}@propeller-${DOMAIN_OWNER}.d.codeartifact.eu-central-1.amazonaws.com/pypi/protosim/simple/" + +# Export the variables +export CODEARTIFACT_AUTH_TOKEN +export PIP_INDEX_URL \ No newline at end of file diff --git a/testing/src/runner/tycho.py b/testing/src/runner/tycho.py index ec5331e..1918291 100644 --- a/testing/src/runner/tycho.py +++ b/testing/src/runner/tycho.py @@ -109,7 +109,9 @@ class TychoRunner: str(start_block), "--stop-block", # +2 is to make up for the cache in the index side. - str(end_block + 2) + str(end_block + 2), + "--initialization-block", + str(start_block), ] + (["--initialized-accounts", ",".join(all_accounts)] if all_accounts else []), stdout=subprocess.PIPE, stderr=subprocess.PIPE, diff --git a/testing/tycho-client/README.md b/testing/tycho-client/README.md index 2000d45..3679b42 100644 --- a/testing/tycho-client/README.md +++ b/testing/tycho-client/README.md @@ -7,10 +7,13 @@ This repository contains the Tycho Adapter, a tool that allows you to interact w ### Prerequisites - Python 3.9 +- Access to PropellerHead's private PyPi repository (CodeArtifact) ### Install with pip ```shell +# Access to PropellerHead's private PyPi repository (CodeArtifact) +aws codeartifact login --tool pip --repository protosim --domain propeller # Create conda environment conda create -n tycho pip python=3.9 # Activate environment