Skip to content

Commit

Permalink
Updating for the new approach to staking
Browse files Browse the repository at this point in the history
	modified:   README.md
	modified:   commands.json
	modified:   docker-compose.yml
	modified:   package-lock.json
	modified:   package.json
	modified:   query-gateway/config/gateway-config.yml
	modified:   src/processor.ts
	modified:   src/testConfig.ts
	new file:   src/utils.ts
  • Loading branch information
abernatskiy committed Jan 31, 2024
1 parent a1b17e9 commit 3685a6c
Show file tree
Hide file tree
Showing 9 changed files with 1,872 additions and 158 deletions.
41 changes: 27 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

The network is ready for its first stress test! Help with it by running this squid.

Note: you'll need to have at least 100 tSQD to complete this quest. Obtain them by doing other quests first.
Note: you'll need to have at least **update the exact amount** tSQD to complete this quest. Obtain them by doing other quests first.

### I. Install dependencies: Node.js, Docker, Git.

Expand Down Expand Up @@ -109,24 +109,33 @@ A healthy response should look similar to

2. Press "Get Key" button in the quest card to obtain the `networkTestTwoHighTrafficLogs.key` key file. Save it to the `./query-gateway/keys` subfolder of the squid folder. The file will be used to identify your local query gateway when staking tSQD to allocate bandwidth and as it operates.

3. Stake some tSQD on the ID of your future gateway by running
3. Get the peer ID that your future gateway will have by running:
```bash
sqd stake
sqd get-peer-id
```
The command will prompt you for the private key of the wallet where you have your tSQDs. The key will be used to sign the staking transaction. [Here's an instruction on how to get your private key on Metamask](https://support.metamask.io/hc/en-us/articles/360015289632-How-to-export-an-account-s-private-key).

4. Start the query gateway with
4. Stake **enter the exact amount here** tSQD on the ID of your future gateway by filling the form on the [staking page](https://app.subsquid.io/profile/gateways/add) ([dev version](https://app.devsquid.net/profile/gateways/add)). Tips:
- Gateway registration and staking are two separate actions. Do not forget to do both.
- Make sure that you stake your tSQD for at least five hours. On Arbitrum Sepolia that's roughly 10000 blocks.

5. Wait for about 15 minutes. This is the time it takes for Subsquid Network to enter a new epoch, at the beginning of which computation units (CUs) will be allocated towards your gateway based on your tSQD stake.

6. Start the query gateway with
```bash
WALLET_PRIVATE_KEY=XXXX... sqd up
sqd up
```
If you'd like to check if the staking was successful, you can inspect the logs of the query gateway container with `docker logs <query_gateway_container_name>`. After one-two minutes required for the node startup it should contain some lines like this one:
```
The key will be used for signing the CU allocation transactions.
[2024-01-31T14:55:06Z INFO query_gateway::chain_updates] allocated CU: 24759 spent CU: 0
```
**update the exact CU amount**

5. Build the squid code
7. Build the squid code
```bash
sqd build
```

6. Start your squid with
8. Start your squid with
```bash
sqd run .
```
Expand Down Expand Up @@ -157,11 +166,15 @@ A healthy response should look similar to
[eth-processor] 03:07:18 INFO sqd:processor:mapping Got 0 ERC20 transfers
```

The squid should download enough data in 3-4 hours. When it's done, stop it with Ctrl-C, then stop and remove the query gateway containers with
```bash
sqd down
```
You will get a warning about the missing `WALLET_PRIVATE_KEY` variable. That's normal.
The squid should download enough data in 3-4 hours.

> [!TIP]
> Do not worry if the squid fails: any progress it made is saved. Simply restart it if it happens.
When done, stop the squid processor with Ctrl-C, then stop and remove the query gateway container with
```bash
sqd down
```

# Quest Info

Expand Down
8 changes: 4 additions & 4 deletions commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
"cmd": ["tsc"]
},
"check-key": {
"cmd": ["node", "scripts/checkKey.js", "query-gateway/keys/networkTestTwoHighTrafficLogs.key"],
"cmd": ["node", "scripts/checkKey.js", "query-gateway/keys/query-gateway/keys/networkTestTwoHighTrafficLogs.key"],
"hidden": true
},
"stake": {
"get-peer-id": {
"deps": ["check-key"],
"description": "Runs a script that interactively walks you through staking tSQD for a Subsquid network gateway",
"cmd": ["node", "scripts/stake.js"]
"description": "Get a peer ID given the public key",
"cmd": ["node", "scripts/getPeerIdFromGatewayKey.js", "query-gateway/keys/query-gateway/keys/networkTestTwoHighTrafficLogs.key"]
},
"up": {
"deps": ["check-key"],
Expand Down
9 changes: 4 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3"

services:
query_gateway:
image: subsquid/query-gateway:0.2.2
image: subsquid/query-gateway:0.2.5
environment:
HTTP_LISTEN_ADDR: 0.0.0.0:8000
BOOT_NODES: >
Expand All @@ -11,13 +11,12 @@ services:
12D3KooWQER7HEpwsvqSzqzaiV36d3Bn6DZrnwEunnzS76pgZkMU /dns4/testnet.subsquid.io/tcp/32345
RPC_URL: https://sepolia-rollup.arbitrum.io/rpc
CONFIG_PATH: /app/data/config/gateway-config.yml
KEY_PATH: /app/data/keys/networkTestTwoHighTrafficLogs.key
KEY_PATH: /app/data/keys/networkTestOneUniformLoad.key
ALLOCATIONS_DB_PATH: /app/data/allocations.db
WALLET_KEY: "${WALLET_PRIVATE_KEY}"
MULTICALL_CONTRACT_ADDR: 0xcA11bde05977b3631167028862bE2a173976CA11
WORKER_REGISTRATION_CONTRACT_ADDR: 0x7Bf0B1ee9767eAc70A857cEbb24b83115093477F
GATEWAY_REGISTRY_CONTRACT_ADDR: 0xC168fD9298141E3a19c624DF5692ABeeb480Fb94
GATEWAY_CONTRACT_CREATION_BLOCK: 6010034
NETWORK_CONTROLLER_CONTRACT_ADDR: 0x938026fefC5F2b6d7c1bCC7098A3Fd1A81C2AECF
GATEWAY_REGISTRY_CONTRACT_ADDR: 0x70FCB652F81436d8f1AFDc9F15085Fb2274281E8
volumes:
- ./query-gateway:/app/data
ports:
Expand Down
Loading

0 comments on commit 3685a6c

Please sign in to comment.