Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
3938c07
Initial scaffolding
maximopalopoli Sep 26, 2025
0dc4391
Merge branch 'main' into circom-test
maximopalopoli Sep 30, 2025
7db4950
Copy the circom generator from web assets
maximopalopoli Sep 30, 2025
6ae5f22
Tidy up the stress test structure, finish proof generation step
maximopalopoli Sep 30, 2025
4aa4375
Change the code to make it work for only one account
maximopalopoli Oct 1, 2025
617abeb
Save the cookies in a CookieJar class and sign the verification data
maximopalopoli Oct 1, 2025
0491d19
Fix: Fetch gas price from an RPC
maximopalopoli Oct 2, 2025
fbae25c
Merge branch 'main' into circom-test
maximopalopoli Oct 3, 2025
b2bc265
Make the account depositing into the batcher payment service
maximopalopoli Oct 3, 2025
22a927d
Add bash script for generating random accounts and fund them
maximopalopoli Oct 3, 2025
8c59d02
Add multiple processes handling
maximopalopoli Oct 3, 2025
cc6e91f
Update random rich accounts
maximopalopoli Oct 3, 2025
f4472fd
Update the rich accounts file reading procedure
maximopalopoli Oct 3, 2025
73729e5
Remove readme file as extra previous steps are not really needed
maximopalopoli Oct 6, 2025
f50a514
Modify generation script to receive the num of acounts
maximopalopoli Oct 6, 2025
27ed5f4
move independent code to separate files
maximopalopoli Oct 6, 2025
3f277fe
Move the literal strings to constants
maximopalopoli Oct 7, 2025
55b7642
Move the repeated constants to a separate file
maximopalopoli Oct 7, 2025
1ce508e
Move all the network constants to the same constant file
maximopalopoli Oct 7, 2025
98c8ab9
Extract the csrf token from getting the main page instead of exposing…
maximopalopoli Oct 7, 2025
c64ac98
Remove the csrf get from the backend
maximopalopoli Oct 7, 2025
49ea0e7
Read the rich accounts from csv file first, fallback to json if not p…
maximopalopoli Oct 7, 2025
92bb6c9
Skip the deposit in aligned step for sepolia network
maximopalopoli Oct 7, 2025
7d10b9a
Remove the status agreement fetching
maximopalopoli Oct 7, 2025
cbbb2fa
Remove the concurrency constraint
maximopalopoli Oct 7, 2025
3c6d115
Restore the agreement status fetching
maximopalopoli Oct 7, 2025
935b0f0
Change constants to match sepolia ones
maximopalopoli Oct 7, 2025
b80d71e
Commit package and lock for test folder
maximopalopoli Oct 7, 2025
81f6b7f
Move the stress test files to a separate folder in test
maximopalopoli Oct 8, 2025
9814d5c
Add a readme for the stress test folder
maximopalopoli Oct 8, 2025
0db13e1
Improve the stress test logs
maximopalopoli Oct 8, 2025
4f6c8f3
fix the circom proof files path
maximopalopoli Oct 8, 2025
312ce6c
Add .env files to the stress test for network config constants
maximopalopoli Oct 8, 2025
f9eb665
Reorganize the stress test struct
maximopalopoli Oct 8, 2025
c9b5627
Fix import in stress test main file
maximopalopoli Oct 8, 2025
d03aab0
Merge branch 'main' into circom-test
maximopalopoli Oct 8, 2025
8194e8a
Default to sepolia in constants
maximopalopoli Oct 8, 2025
60b8b56
Add disclaimer to the game index value
maximopalopoli Oct 9, 2025
9d7e11d
Reestructure the test to make proofs perform all steps simultaneously
maximopalopoli Oct 9, 2025
9214654
Reduce the logs to happen every 100 proofs
maximopalopoli Oct 9, 2025
10a5fbf
Add dotenv to catch the .env variables in stress test
maximopalopoli Oct 9, 2025
32a3eed
introduce a little random jitter on stress test
maximopalopoli Oct 9, 2025
cd7628f
Remove the detailed results, as its overwhelming for more than 100 pr…
maximopalopoli Oct 9, 2025
9d8e611
Add retry with backoff
maximopalopoli Oct 9, 2025
df6288f
Use pool of workers to paralelize computing
maximopalopoli Oct 9, 2025
6bbdcf8
Remove extra file and increase retry timeout
maximopalopoli Oct 9, 2025
c425dc1
Merge branch 'main' into circom-test
JuArce Oct 14, 2025
7ec7a2e
Merge branch 'main' into circom-test
maximopalopoli Oct 15, 2025
c6dafbd
Merge branch 'main' into circom-test
maximopalopoli Oct 30, 2025
349c53a
Merge branch 'main' into circom-test
maximopalopoli Nov 3, 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
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ pkg
/web/deps
/web/priv/static/assets/
node_modules
package-lock.json
package.json

# Generated solution binaries
*.bin
Expand Down
5 changes: 5 additions & 0 deletions test/stress/.env.devnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
RPC_URL='https://localhost:8545'
ZK_ARCADE_URL="https://localhost:4005"
BATCHER_URL="wss://localhost:8080"
BATCHER_PAYMENT_SERVICE_ADDR="0x7bc06c482DEAd17c0e297aFbC32f6e63d3846650"
CHAIN_NAME='anvil'
5 changes: 5 additions & 0 deletions test/stress/.env.sepolia
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
RPC_URL='https://ethereum-sepolia-rpc.publicnode.com'
ZK_ARCADE_URL="https://test.zkarcade.com"
BATCHER_URL="wss://sepolia.batcher.alignedlayer.com"
BATCHER_PAYMENT_SERVICE_ADDR="0x403dE630751e148bD71BFFcE762E5667C0825399"
CHAIN_NAME='sepolia'
101 changes: 101 additions & 0 deletions test/stress/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# ZK Arcade - Stress Testing Suite

This directory contains a set of tools used to perform stress testing on the ZK Arcade backend, which also tests Aligned. The test consists of generating parity proofs for each address and then sending them to the backend via HTTP POST requests.

## Description

The stress test simulates a multi-user load by sending proofs to the backend concurrently. This allows us to validate the system’s scalability and how it reacts under heavy load scenarios.

## Test Architecture

### Main files

#### 1. `src/stress_test.js`

Contains the main logic for each user, which consists of:

1. Obtaining the CSRF token and establishing the session
2. Signing the service agreement by sending a POST request to the backend
3. Making a deposit in Aligned if the testing chain is not the Sepolia network
4. Validating the agreement status (this check also keeps the address stored in the backend session)
5. Generating the Circom proof (a computationally heavy task)
6. Sending the proof to the system

#### 2. `src/circom_proof_generator.js`

Generates the verification data to be sent to the batcher, using Circom and the `snark.js` library to generate the inner proof from the solution.

#### 3. `src/aligned.js`

Handles deposits to the Aligned batcher payment service contract.

#### 4. `src/utils/sign_agreement.js`

Contains the logic to sign the service agreement and send it to the ZK Arcade backend.

#### 5. Other utility files

- **`src/utils/cookie_utils.js`**: Manages cookies between HTTP calls to preserve each session’s data.
- **`src/constants.js`**: Contains configuration specific to the selected network.
- **`src/utils/estimate_max_fee.js`**: Contains logic to estimate the maximum fee sent to the batcher in the proof submission message.
- **`src/utils/batcher.js`**: Retrieves the user’s nonce from the batcher via an RPC call.

## Data Configuration

### Testing addresses

The system supports two file formats for providing funded test accounts:

- The first is a CSV file (`data/sepolia_rich_accounts.csv`) with the private key and address in the header.
- The second is a JSON file (`data/rich_accounts.json`), which consists of an array of objects containing `address` and `privateKey` fields.

### Game solution file

The test requires a solution to generate the Circom proof that certifies users have completed the game.
The solution is read from the `data/solution.json` file, which contains the level boards and user positions for each level in JSON format.

You can copy this data from the browser’s local storage variable `parity-game-data`, which contains the solution played by the user for that specific game configuration.

## Environment Configuration

### Configuration variables (`constants.js`)

As mentioned before, this file contains the network-specific variables for the chain being tested. For example, the Sepolia network configuration looks like this:

```javascript
RPC_URL = 'https://ethereum-sepolia-rpc.publicnode.com'
ZK_ARCADE_URL = "https://test.zkarcade.com"
BATCHER_URL = "wss://sepolia.batcher.alignedlayer.com"
BATCHER_PAYMENT_SERVICE_ADDR = "0x403dE630751e148bD71BFFcE762E5667C0825399"
USED_CHAIN = sepolia
```

TODO: Move these values into a .env file specific to each network (at least Sepolia and Devnet).

### Dependencies

The test requires the following Node.js dependencies:

- `viem`
- `snarkjs`
- `axios/undici`
- `csv-parse`
- `sha3`

## Execution

1. Install the project dependencies:

```bash
npm install
```

2. Add your funded account for the tested network in either `data/sepolia_rich_accounts.csv` or `data/rich_accounts.json`.
- If needed, you can generate test accounts for Devnet using the generate_rich_wallets.sh script: `./generate_rich_wallets.sh <accounts_number>`
3. Make sure that `data/solution.json` contains a valid solution. Note that it does not need to be updated between runs.

4. Run the Test

```bash
node src/stress_test.js
```
Loading