Skip to content

Commit

Permalink
Added e2e testing with docker compose.
Browse files Browse the repository at this point in the history
  • Loading branch information
piohei committed Jun 12, 2024
1 parent 3c40f15 commit 84b3375
Show file tree
Hide file tree
Showing 15 changed files with 1,257 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ commitments.json
!.editorconfig
!.dockerignore
!.cargo

e2e_tests/docker-compose/keys/*
!e2e_tests/docker-compose/keys/.keep
27 changes: 27 additions & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ license-file = "LICENSE.md"
build = "build.rs"

[workspace]
members = ["crates/*"]
members = ["crates/*", "e2e_tests/scenarios"]

[features]
default = []
Expand Down
147 changes: 147 additions & 0 deletions e2e_tests/docker-compose/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
services:
chain:
image: ghcr.io/foundry-rs/foundry
hostname: chain
platform: linux/amd64
ports:
- ${CHAIN_PORT:-8545}:8545
command: [ "anvil --host 0.0.0.0 --chain-id 31337 --block-time 30 --base-fee 0 --gas-limit 0 --gas-price 0 --fork-url https://eth-sepolia.g.alchemy.com/v2/${ALCHEMY_API_KEY}@5091094" ]
tx-sitter-db:
image: postgres:latest
hostname: tx-sitter-db
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=tx-sitter
ports:
- ${TX_SITTER_DB_PORT:-5460}:5432
volumes:
- tx_sitter_db_data:/var/lib/postgresql/data
sequencer-db:
image: postgres:latest
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=sequencer
ports:
- ${SEQUENCER_DB_PORT:-5461}:5432
volumes:
- sequencer_db_data:/var/lib/postgresql/data
tx-sitter:
image: ghcr.io/worldcoin/tx-sitter-monolith:latest
hostname: tx-sitter
depends_on:
- tx-sitter-db
- chain
restart: always
ports:
- ${TX_SITTER_PORT:-3000}:3000
environment:
- RUST_LOG=info
- TX_SITTER__SERVICE__ESCALATION_INTERVAL=3s
- TX_SITTER__DATABASE__KIND=connection_string
- TX_SITTER__DATABASE__CONNECTION_STRING=postgres://postgres:postgres@tx-sitter-db:5432/tx-sitter?sslmode=disable
- TX_SITTER__KEYS__KIND=local
- TX_SITTER__SERVICE__PREDEFINED__NETWORK__CHAIN_ID=31337
- TX_SITTER__SERVICE__PREDEFINED__NETWORK__NAME=Anvil
- TX_SITTER__SERVICE__PREDEFINED__NETWORK__HTTP_RPC=http://chain:8545
- TX_SITTER__SERVICE__PREDEFINED__NETWORK__WS_RPC=ws://chain:8545
- TX_SITTER__SERVICE__PREDEFINED__RELAYER__ID=1b908a34-5dc1-4d2d-a146-5eb46e975830
- TX_SITTER__SERVICE__PREDEFINED__RELAYER__NAME=Relayer
- TX_SITTER__SERVICE__PREDEFINED__RELAYER__CHAIN_ID=31337
- TX_SITTER__SERVICE__PREDEFINED__RELAYER__KEY_ID=d10607662a85424f02a33fb1e6d095bd0ac7154396ff09762e41f82ff2233aaa
- TX_SITTER__SERVICE__PREDEFINED__RELAYER__API_KEY=G5CKNF3BTS2hRl60bpdYMNPqXvXsP-QZd2lrtmgctsnllwU9D3Z4D8gOt04M0QNH
- TX_SITTER__SERVER__HOST=0.0.0.0:3000
- TX_SITTER__SERVER__DISABLE_AUTH=true
semaphore-keys-init-insertion:
image: curlimages/curl:latest
user: "0:0"
volumes:
- ./keys:/keys
entrypoint: /bin/sh
command: [ "-c", "if [ ! -f \"/keys/insertion_b10t30.ps\" ]; then curl \"https://semaphore-mtb-trusted-setup-ceremony.s3.amazonaws.com/insertion_b10/insertion_b10t30.ps\" -o /keys/insertion_b10t30.ps && chown -f $(stat -c \"%u:%g\" /keys/.keep) /keys/insertion_b10t30.ps; fi" ]
semaphore-keys-init-deletion:
image: curlimages/curl:latest
user: "0:0"
volumes:
- ./keys:/keys
entrypoint: /bin/sh
command: [ "-c", "if [ ! -f \"/keys/deletion_b10t30.ps\" ]; then curl \"https://semaphore-mtb-trusted-setup-ceremony.s3.amazonaws.com/deletion_b10/deletion_b10t30.ps\" -o /keys/deletion_b10t30.ps && chown -f $(stat -c \"%u:%g\" /keys/.keep) /keys/deletion_b10t30.ps; fi" ]
semaphore-insertion:
image: semaphore-mtb
hostname: semaphore-insertion
restart: always
ports:
- ${SEMAPHORE_INSERTION_PORT:-3001}:3001
command: [ "start", "--keys-file", "/mtb/keys", "--prover-address", "0.0.0.0:3001", "--mode", "insertion" ]
volumes:
- ./keys/insertion_b10t30.ps:/mtb/keys
environment:
BATCH_TIMEOUT_SECONDS: 1
depends_on:
semaphore-keys-init-insertion:
condition: service_completed_successfully
semaphore-deletion:
image: semaphore-mtb
hostname: semaphore-deletion
restart: always
ports:
- ${SEMAPHORE_DELETION_PORT:-3002}:3001
command: [ "start", "--keys-file", "/mtb/keys", "--prover-address", "0.0.0.0:3001", "--mode", "deletion" ]
volumes:
- ./keys/deletion_b10t30.ps:/mtb/keys
environment:
BATCH_DELETION_TIMEOUT_SECONDS: 1
depends_on:
semaphore-keys-init-deletion:
condition: service_completed_successfully
signup-sequencer-balancer:
image: haproxy:3.0.0
hostname: signup-sequencer-balancer
restart: always
ports:
- ${SIGNUP_SEQUENCER_BALANCER_PORT:-8080}:8080
volumes:
- ./haproxy:/usr/local/etc/haproxy
depends_on:
- signup-sequencer-0
signup-sequencer-0: &signup-sequencer-def
image: signup-sequencer
hostname: signup-sequencer-0
profiles: [ e2e-ha ]
build:
context: ./../../
depends_on:
- sequencer-db
- chain
- semaphore-insertion
- semaphore-deletion
- tx-sitter
restart: always
ports:
- ${SIGNUP_SEQUENCER_0_PORT:-9080}:8080
volumes:
- ./signup_sequencer/config.toml:/config.toml
command: [ "/config.toml" ]
environment:
- RUST_LOG=debug
# signup-sequencer-1:
# <<: *signup-sequencer-def
# hostname: signup-sequencer-1
# ports:
# - ${SIGNUP_SEQUENCER_0_PORT:-9081}:8080
# signup-sequencer-2:
# <<: *signup-sequencer-def
# hostname: signup-sequencer-2
# ports:
# - ${SIGNUP_SEQUENCER_0_PORT:-9082}:8080
# signup-sequencer-3:
# <<: *signup-sequencer-def
# hostname: signup-sequencer-3
# ports:
# - ${SIGNUP_SEQUENCER_0_PORT:-9083}:8080
volumes:
tx_sitter_db_data:
driver: local
sequencer_db_data:
driver: local
137 changes: 137 additions & 0 deletions e2e_tests/docker-compose/compose.yml.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
version: "3"
services:
chain:
container_name: chain
image: ghcr.io/foundry-rs/foundry
hostname: chain
platform: linux/amd64
ports:
- "8545:8545"
command: [ "anvil --host 0.0.0.0 --chain-id 31337 --block-time 10 --base-fee 0 --gas-limit 0 --gas-price 0 --fork-url https://eth-sepolia.g.alchemy.com/v2/Hkj3vTy6ee49NbI4Imhe6r5mRM1vkR10@5091094" ]
tx-sitter-db:
container_name: tx-sitter-db
image: postgres:latest
hostname: tx-sitter-db
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=tx-sitter
ports:
- "5460:5432"
volumes:
- tx_sitter_db_data:/var/lib/postgresql/data
sequencer-db:
container_name: sequencer-db
image: postgres:latest
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=sequencer
ports:
- "5461:5432"
volumes:
- sequencer_db_data:/var/lib/postgresql/data
- /home/piotr/Downloads/dump.sql:/tmp2/dump.sql
tx-sitter:
container_name: tx-sitter
image: tx-sitter-monolith
hostname: tx-sitter
depends_on:
- tx-sitter-db
- chain
restart: always
ports:
- "3000:3000"
environment:
- RUST_LOG=info
- TX_SITTER__SERVICE__ESCALATION_INTERVAL=3s
- TX_SITTER__DATABASE__KIND=connection_string
- TX_SITTER__DATABASE__CONNECTION_STRING=postgres://postgres:postgres@tx-sitter-db:5432/tx-sitter?sslmode=disable
- TX_SITTER__KEYS__KIND=local
- TX_SITTER__SERVICE__PREDEFINED__NETWORK__CHAIN_ID=31337
- TX_SITTER__SERVICE__PREDEFINED__NETWORK__NAME=Anvil
- TX_SITTER__SERVICE__PREDEFINED__NETWORK__HTTP_RPC=http://chain:8545
- TX_SITTER__SERVICE__PREDEFINED__NETWORK__WS_RPC=ws://chain:8545
- TX_SITTER__SERVICE__PREDEFINED__RELAYER__ID=1b908a34-5dc1-4d2d-a146-5eb46e975830
- TX_SITTER__SERVICE__PREDEFINED__RELAYER__NAME=Relayer
- TX_SITTER__SERVICE__PREDEFINED__RELAYER__CHAIN_ID=31337
- TX_SITTER__SERVICE__PREDEFINED__RELAYER__KEY_ID=d10607662a85424f02a33fb1e6d095bd0ac7154396ff09762e41f82ff2233aaa
- TX_SITTER__SERVICE__PREDEFINED__RELAYER__API_KEY=G5CKNF3BTS2hRl60bpdYMNPqXvXsP-QZd2lrtmgctsnllwU9D3Z4D8gOt04M0QNH
- TX_SITTER__SERVER__HOST=0.0.0.0:3000
- TX_SITTER__SERVER__DISABLE_AUTH=true
semaphore-insertion:
container_name: semaphore-insertion
image: semaphore-mtb
hostname: semaphore-insertion
restart: always
ports:
- "3001:3001"
command: [ "start", "--keys-file", "/mtb/keys", "--prover-address", "0.0.0.0:3001", "--mode", "insertion" ]
volumes:
- ./keys/insertion_b10t30.ps:/mtb/keys
environment:
BATCH_TIMEOUT_SECONDS: 1
semaphore-deletion:
container_name: semaphore-deletion
image: semaphore-mtb
hostname: semaphore-deletion
restart: always
ports:
- "3002:3001"
command: [ "start", "--keys-file", "/mtb/keys", "--prover-address", "0.0.0.0:3001", "--mode", "deletion" ]
volumes:
- ./keys/deletion_b10t30.ps:/mtb/keys
environment:
BATCH_DELETION_TIMEOUT_SECONDS: 1
signup-sequencer-0: &signup-sequencer-def
container_name: signup-sequencer-0
image: signup-sequencer
profiles: [ e2e-ha ]
build:
context: ./../../
depends_on:
- sequencer-db
- chain
- semaphore-insertion
- semaphore-deletion
- tx-sitter
restart: always
ports:
- "9080:8080"
environment:
- RUST_LOG=debug
- SEQ__TREE__TREE_DEPTH=30
- SEQ__TREE__DENSE_TREE_PREFIX_DEPTH=10
- SEQ__TREE__TREE_GC_THRESHOLD=10000000
- SEQ__TREE__CACHE_FILE=./cache_file
- SEQ__SERVER__ADDRESS=0.0.0.0:8080
- SEQ__NETWORK__IDENTITY_MANAGER_ADDRESS=0x48483748eb0446A16cAE79141D0688e3F624Cb73
- SEQ__RELAYER__KIND=tx_sitter
- SEQ__RELAYER__TX_SITTER_URL=http://tx-sitter:3000/1/api/G5CKNF3BTS2hRl60bpdYMNPqXvXsP-QZd2lrtmgctsnllwU9D3Z4D8gOt04M0QNH
- SEQ__RELAYER__TX_SITTER_ADDRESS=0x1d7ffed610cc4cdC097ecDc835Ae5FEE93C9e3Da
- SEQ__RELAYER__TX_SITTER_GAS_LIMIT=2000000
- SEQ__PROVIDERS__PRIMARY_NETWORK_PROVIDER=http://chain:8545
- 'SEQ__APP__PROVERS_URLS=[{"url": "http://semaphore-insertion:3001", "prover_type": "insertion", "batch_size": 10,"timeout_s": 30}, {"url": "http://semaphore-deletion:3001", "prover_type": "deletion", "batch_size": 10,"timeout_s": 30}]'
- SEQ__DATABASE__DATABASE=postgres://postgres:postgres@sequencer-db:5432/sequencer?sslmode=disable
- SEQ__APP__BATCH_INSERTION_TIMEOUT=30s
- SEQ__APP__BATCH_DELETION_TIMEOUT=1s
# signup-sequencer-1:
# <<: *signup-sequencer-def
# container_name: signup-sequencer-1
# ports:
# - "9081:8080"
# signup-sequencer-2:
# <<: *signup-sequencer-def
# container_name: signup-sequencer-2
# ports:
# - "9082:8080"
# signup-sequencer-3:
# <<: *signup-sequencer-def
# container_name: signup-sequencer-3
# ports:
# - "9083:8080"
volumes:
tx_sitter_db_data:
driver: local
sequencer_db_data:
driver: local
10 changes: 10 additions & 0 deletions e2e_tests/docker-compose/haproxy/haproxy.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
frontend http-in
bind *:8080
default_backend http_back

backend http_back
balance roundrobin
server signup-sequencer-0 signup-sequencer-0:8080 check
# server signup-sequencer-1 signup-sequencer-1:8080 check
# server signup-sequencer-2 signup-sequencer-2:8080 check
# server signup-sequencer-3 signup-sequencer-3:8080 check
Empty file.
28 changes: 28 additions & 0 deletions e2e_tests/docker-compose/signup_sequencer/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[tree]
tree_depth = 30
dense_tree_prefix_depth = 10
tree_gc_threshold = 10000000
cache_file = "./cache_file"

[server]
address = "0.0.0.0:8080"

[network]
identity_manager_address = "0x48483748eb0446A16cAE79141D0688e3F624Cb73"

[relayer]
kind = "tx_sitter"
tx_sitter_url = "http://tx-sitter:3000/1/api/G5CKNF3BTS2hRl60bpdYMNPqXvXsP-QZd2lrtmgctsnllwU9D3Z4D8gOt04M0QNH"
tx_sitter_address = "0x1d7ffed610cc4cdC097ecDc835Ae5FEE93C9e3Da"
tx_sitter_gas_limit = 2000000

[providers]
primary_network_provider = "http://chain:8545"

[app]
provers_urls = '[{"url": "http://semaphore-insertion:3001", "prover_type": "insertion", "batch_size": 10,"timeout_s": 30}, {"url": "http://semaphore-deletion:3001", "prover_type": "deletion", "batch_size": 10,"timeout_s": 30}]'
batch_insertion_timeout = "30s"
batch_deletion_timeout = "1s"

[database]
database = "postgres://postgres:postgres@sequencer-db:5432/sequencer?sslmode=disable"
Loading

0 comments on commit 84b3375

Please sign in to comment.