Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
77db48b
feat(testing): Implement local testing environment for indexer services
neithanmo Mar 17, 2025
f53c3d1
fix(testing): Organize containers and configurations into its owne co…
neithanmo Mar 21, 2025
968ecdf
fix(testing): add reload script and container builder script to setup…
neithanmo Mar 21, 2025
adf2908
fix(testing): Remove unnecessary tests and files
neithanmo Mar 21, 2025
06cfef5
fix(testing): Update justfile and add a Makefile(for future CI)
neithanmo Mar 21, 2025
519e2e1
feat(testing): Add a minimal workflow for integration testing using l…
neithanmo Mar 21, 2025
0afaa14
fix(service): tap-agent start script to use settings from .env variab…
neithanmo Mar 21, 2025
740a947
fix(testing): Fix docker command in makefile
neithanmo Mar 21, 2025
cad130e
chore(testnet): Add more logs and double check for contracts to be de…
neithanmo Mar 25, 2025
92170b5
fix(testing_setup): Update local network and enable missing services
neithanmo Mar 28, 2025
5480a80
feat(local_network): Enable the gateway service
neithanmo Mar 31, 2025
059b2f6
fix(indexer-testing): Use same auth token as gateway
neithanmo Apr 1, 2025
d6ebb30
fix(testing): Use reasonable values to configure RAV request in tap-a…
neithanmo Apr 3, 2025
3e449a5
chore(testing): Remove old testing script
neithanmo Apr 3, 2025
62bfb87
feat(testing): Add end to end testing for RAV generation
neithanmo Apr 3, 2025
663c73d
fix(git): Add new items to gitignore
neithanmo Apr 3, 2025
4790efb
fix(makefile): Avoid triggering errors if no container is active
neithanmo Apr 3, 2025
74ce3fe
fix(ci): Enable test execution on push
neithanmo Apr 3, 2025
fe2af78
fix(rav_test): Increase number of receipts to ensure we hit rav gener…
neithanmo Apr 3, 2025
51bbc4d
fix(ci): Disable local testnet testing for now
neithanmo Apr 3, 2025
7def4a3
fix(Makefile): Update help and ensure funding script is executed befo…
neithanmo Apr 3, 2025
6ae72c0
fix(testing_plan): Remove code example and improve description of tes…
neithanmo Apr 3, 2025
73f00e4
chore(local_testnet): Update README and Fix down action in justfile
neithanmo Apr 3, 2025
41a22f2
fix(license): Add license headers
neithanmo Apr 3, 2025
7275a17
fix(ci): Ignore Dockerfile, docker compose, bash scripts and configur…
neithanmo Apr 3, 2025
0015b69
fix(ci): Restore original Dockerfiles for indexer and tap-agent services
neithanmo Apr 3, 2025
2c62eca
fix(ci): Ignore bash scripts in rav_e2e testing
neithanmo Apr 3, 2025
b11e926
fix(ci): Fix syntax error
neithanmo Apr 3, 2025
0bfaa0a
chore(test): Reduce timestamp_buffer_secs window
neithanmo Apr 4, 2025
2eb4d31
chore(testing): Improve test by checking for metrics after sending re…
neithanmo Apr 4, 2025
3035ec9
feat(rav_test): Organize better testing code
neithanmo Apr 4, 2025
c1312ee
fix(gateway_service): Add health check after deploying gateway to ens…
neithanmo Apr 4, 2025
6205c5f
fix(justfile): Update test command
neithanmo Apr 4, 2025
6ac450c
fix(make): Remove Makefile and used Justfile instead
neithanmo Apr 4, 2025
6123ed2
fix(setup): Fix setup script docker storage report and ensure we mine…
neithanmo Apr 4, 2025
f91ba7b
fix(docs): Update README instruction to setting up local network and …
neithanmo Apr 4, 2025
e74d2d3
fix(test): Ensure contracts are mined before verification
neithanmo Apr 4, 2025
43fc827
fix(test): Sent only 3 receipts per batch otherwise they could be dis…
neithanmo Apr 4, 2025
e610328
fix(test): Remove premature block mining
neithanmo Apr 5, 2025
d3ea08d
chore(test): Change crate name and made it part of the workspace
neithanmo Apr 7, 2025
e32bb79
fix(license): Update path to exclude bash script for testing
neithanmo Apr 7, 2025
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
9 changes: 8 additions & 1 deletion .github/workflows/license_headers_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: License headers check

on:
push:
branches: [ main, dev ]
branches: [main, dev]
pull_request:
workflow_dispatch:

Expand Down Expand Up @@ -31,4 +31,11 @@ jobs:
-ignore 'migrations/*.sql' \
-ignore 'crates/dips/src/proto/*' \
-ignore 'crates/dips/proto/*' \
-ignore 'contrib/**/*' \
-ignore '*.sh' \
-ignore 'Dockerfile' \
-ignore '*.toml' \
-ignore '*.yml' \
-ignore '*.yaml' \
-ignore 'integration-tests/*.sh' \
.
31 changes: 31 additions & 0 deletions .github/workflows/tap_integration_test.yml.disable
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Test GraphTally Protocol
on:
push:
# branches: [main]
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Docker
uses: docker/setup-buildx-action@v2

- name: Set up Docker cache
uses: docker/setup-buildx-action@v2
with:
install: true

- name: Run make setup
run: make setup

- name: Run tests
run: make rav_tests

- name: Tear down containers
if: always()
run: make down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ indexer.toml
crates/dips/node_modules/
crates/dips/generated/
crates/dips/npm-debug.log*
contrib/local-network
node_modules
target/
*.code-workspace
17 changes: 17 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ members = [
"crates/tap-agent",
"crates/test-assets",
"crates/watcher",
"integration-tests",
]
resolver = "2"

Expand Down
96 changes: 96 additions & 0 deletions contrib/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Developer Setup Guide

This guide provides the step to set up a development workflow for the indexer-service project testing.
Including how to build and deploy the required containers, and how to use hot-reload for faster dev iterations.

### Note

The current implementation leverages local-network for the common services and uses its testing configuration.

## Available Commands

We provide the following Make/Just commands to streamline your development workflow:

- `just setup` - Full setup of all services, dependencies and binary compilation
- `just reload` - Rebuild Rust binaries and restart services after code changes
- `just logs` - Watch log output from all services
- `just down` - Stop all services
- `just test-local` - Run integration tests against local services

## Initial Setup

To get started with development:

1. Clone the repository
2. Run the full setup to initialize all services:

```bash
just setup
```

This will:

- Clone the local-network repo if needed
- Start core infrastructure services
- Deploy contracts and required services
- Set up and start the indexer and tap-agent services

## Development Workflow

After the initial setup, you can use the fast development workflow:

1. Make changes to the Rust code in `crates/`
2. Run the reload command to rebuild and restart indexer and tap-agent services:

```bash
just reload
```

This workflow is much faster because:

- It only recompiles the Rust code
- It doesn't rebuild Docker containers
- It restarts only the necessary services

The `reload` command will automatically show the logs after restarting, so you can see if your changes are working properly.

## How It Works

The development workflow uses volume mounts to avoid rebuilding containers:

1. A base Docker image with all dependencies is created once
2. Your code is compiled locally on your machine
3. The compiled binaries are mounted into the containers
4. Services are restarted with the new binaries

This approach avoids the time-consuming container rebuild process while still maintaining a consistent containerized environment.

## Viewing Logs

To monitor the services during development:

```bash
just logs
```

This will show a live stream of logs from all services, which is useful for debugging.

## Running Tests

To run integration tests against your local environment:

```bash
just local-test
```

This is currently a work in progress, and additional testing strategies are still being defined and implemented.

## Stopping Services

When you're done working:

```bash
just down
```

This will stop and remove all the containers defined in the docker-compose file.
6 changes: 6 additions & 0 deletions contrib/base/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM debian:bookworm-slim

RUN apt-get update && apt-get install -y --no-install-recommends \
openssl ca-certificates protobuf-compiler postgresql-client curl \
jq \
&& rm -rf /var/lib/apt/lists/*
57 changes: 57 additions & 0 deletions contrib/docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
services:
indexer-service:
image: indexer-base:latest
container_name: indexer-service
volumes:
- ../target/release/indexer-service-rs:/usr/local/bin/indexer-service-rs
- ./indexer-service/start.sh:/usr/local/bin/start.sh
- ./indexer-service/config.toml:/opt/config/config.toml
- ../local-network/contracts.json:/opt/contracts.json:ro
- ../local-network/.env:/opt/.env:ro
- ../migrations:/opt/migrations:ro
entrypoint: ["/usr/local/bin/start.sh"]
environment:
- RUST_BACKTRACE=1
- RUST_LOG=debug
ports:
- "7601:7601"
networks:
- local-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:7601/"]
interval: 5s
timeout: 3s
retries: 10
start_period: 10s

tap-agent:
image: indexer-base:latest # Pre-built base image with dependencies
container_name: tap-agent
depends_on:
indexer-service:
condition: service_healthy
volumes:
- ../target/release/indexer-tap-agent:/usr/local/bin/indexer-tap-agent
- ./tap-agent/start.sh:/usr/local/bin/start.sh
- ./tap-agent:/opt/config:ro
- ./local-network/.env:/opt/.env:ro
- ./local-network/contracts.json:/opt/contracts.json:ro
- ../migrations:/opt/migrations:ro
entrypoint: ["/bin/bash", "-c", "/opt/config/start.sh"]
environment:
- RUST_BACKTRACE=1
- RUST_LOG=debug
ports:
# to expose the metrics port
- "7300:7300"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:7300/metrics"]
interval: 5s
timeout: 3s
retries: 10
start_period: 10s

networks:
local-network:
external: true
name: local-network_default
57 changes: 57 additions & 0 deletions contrib/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
services:
indexer-service:
build:
context: .. # Go up one level to the root directory
dockerfile: ./contrib/indexer-service/Dockerfile
container_name: indexer-service
volumes:
- ./indexer-service:/opt/config:ro # From contrib dir to indexer-service dir
- ./local-network/contracts.json:/opt/contracts.json:ro
- ./local-network/.env:/opt/.env:ro
- ../migrations:/opt/migrations:ro
entrypoint: ["/bin/bash", "-c", "/opt/config/start.sh"]
environment:
- RUST_BACKTRACE=1
- RUST_LOG=debug
ports:
- "7601:7601"
networks:
- local-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:7601/"]
interval: 5s
timeout: 3s
retries: 10
start_period: 10s

tap-agent:
build:
context: ..
dockerfile: ./contrib/tap-agent/Dockerfile
container_name: tap-agent
depends_on:
indexer-service:
condition: service_healthy
volumes:
- ./tap-agent:/opt/config:ro # From contrib dir to tap-agent dir
- ./local-network/.env:/opt/.env:ro
- ./local-network/contracts.json:/opt/contracts.json:ro
- ../migrations:/opt/migrations:ro
entrypoint: ["/bin/bash", "-c", "/opt/config/start.sh"]
environment:
- RUST_BACKTRACE=1
- RUST_LOG=debug
ports:
# to expose the metrics port
- "7300:7300"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:7300/metrics"]
interval: 5s
timeout: 3s
retries: 10
start_period: 10s

networks:
local-network:
external: true
name: local-network_default
32 changes: 32 additions & 0 deletions contrib/indexer-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM rust:1.81-bookworm as build
WORKDIR /root
# Copy from the root project directory (two levels up)
COPY ../../ .
# Force SQLx to use the offline mode to statically check the database queries against
# the prepared files in the `.sqlx` directory.
#
ENV SQLX_OFFLINE=true

RUN apt-get update && apt-get install -y --no-install-recommends \
protobuf-compiler && rm -rf /var/lib/apt/lists/*

RUN cargo build --release --bin indexer-service-rs

########################################################################################

FROM debian:bookworm-slim

RUN apt-get update && apt-get install -y --no-install-recommends \
openssl ca-certificates protobuf-compiler postgresql-client curl \
jq \
&& rm -rf /var/lib/apt/lists/*

COPY --from=build /root/target/release/indexer-service-rs /usr/local/bin/indexer-service-rs

# Copy our start script into the image
COPY contrib/indexer-service/start.sh /usr/local/bin/start.sh
COPY contrib/indexer-service/config.toml /opt/config/config.toml

RUN chmod +x /usr/local/bin/start.sh

ENTRYPOINT [ "/usr/local/bin/start.sh" ]
46 changes: 46 additions & 0 deletions contrib/indexer-service/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[indexer]
indexer_address = "INDEXER_ADDRESS_PLACEHOLDER"
operator_mnemonic = "INDEXER_MNEMONIC_PLACEHOLDER"

[database]
postgres_url = "postgres://postgres@postgres:POSTGRES_PORT_PLACEHOLDER/indexer_components_1"

[graph_node]
query_url = "http://graph-node:8000"
status_url = "http://graph-node:8030/graphql"

[subgraphs.network]
query_url = "http://graph-node:8000/subgraphs/name/graph-network"
deployment_id = "NETWORK_DEPLOYMENT_PLACEHOLDER"

[subgraphs.escrow]
query_url = "http://graph-node:8000/subgraphs/name/semiotic/tap"
deployment_id = "ESCROW_DEPLOYMENT_PLACEHOLDER"

[blockchain]
chain_id = 1337
receipts_verifier_address = "VERIFIER_ADDRESS_PLACEHOLDER"

[service]
host_and_port = "0.0.0.0:7601"
free_query_auth_token = "freestuff"

[service.tap]
max_receipt_value_grt = "0.001"

[tap]
max_amount_willing_to_lose_grt = 1000

[tap.rav_request]
# Set a lower timestamp buffer threshold
timestamp_buffer_secs = 30
# The trigger value divisor is used to calculate the trigger value for the RAV request.
# using the formula:
# trigger_value = max_amount_willing_to_lose_grt / trigger_value_divisor
# where the default value for max_amount_willing_to_lose_grt is 1000
# the idea to set this for trigger_value to be 0.002
# requiring the sender to send at least 20 receipts of 0.0001 grt
trigger_value_divisor = 500_000

[tap.sender_aggregator_endpoints]
"ACCOUNT0_ADDRESS_PLACEHOLDER" = "http://tap-aggregator:7610"
Loading
Loading