Add initialization-block to tycho runner, fix docker and improve docs
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
SUBSTREAMS_API_TOKEN="changeme"
|
||||
DOMAIN_OWNER="AWSAccountId"
|
||||
@@ -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"]
|
||||
CMD ["python", "testing/src/runner/cli.py", "--package", "my_substream", "--with_binary_logs", "--db_url", "postgres://postgres:mypassword@db:5432"]
|
||||
@@ -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
|
||||
```
|
||||
@@ -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:
|
||||
26
testing/pre_build.sh
Executable file
26
testing/pre_build.sh
Executable file
@@ -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
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user