Skip to content

Commit

Permalink
Feature/MGX-1223/deposit transactions tracing (#230)
Browse files Browse the repository at this point in the history
* add new variables for tracing

* feat: add and upgrade dependencies

* feat: add encrypted values for tracing

* feat: add contract json for viem clients

* feat: MGX-1223: add logic for tracing deposits

* feat: add documentation for tracing deposits

* feat: add tests for tracing of deposits

* chore: update documentation and add postman collection

* feat: small changes
  • Loading branch information
olgakonsta authored Sep 12, 2024
1 parent b8eb18c commit bd4c37f
Show file tree
Hide file tree
Showing 25 changed files with 4,424 additions and 277 deletions.
82 changes: 79 additions & 3 deletions stash/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,84 @@
# stash service
# Stash

## 1. Prerequisites
Stash is a service that serves some configurations and also caches some blockchain node information.

1. Install and configure SOPS to access secrets
## API


### Hosts
| Environment | URL |
|---------------------------------------------------------------------------------------|-----------------------------------------------------------------------|
| [ROLLUP-DEV](https://mangata-stash-rollup-dev-dot-direct-pixel-353917.oa.r.appspot.com) | `https://mangata-stash-rollup-dev-dot-direct-pixel-353917.oa.r.appspot.com` |
| [ROLLUP-TESTNET](https://mangata-stash-rollup-testnet-dot-direct-pixel-353917.oa.r.appspot.com) | `https://mangata-stash-rollup-testnet-dot-direct-pixel-353917.oa.r.appspot.com` |

### API documentation
To access the public API, refer to the ```[HOST]/doc``` endpoint, where you'll find comprehensive documentation for our services.
This resource provides detailed information about our available API functionalities and how to interact with them.


### Postman collections
The `api/` can be imported into Postman to use the API cals.
Setup the `$host` env to rollup-dev & rollup-testnet, or replace it with actual URL in the API address bar.
Collection contains scripts to visualize the response data in a graph.
Script is defined in the `Tests` tab of the request section, and graph is in the `Body -> Visualize` tab in the response section.

Each API has a limit of 50K entries to return.

## Local quick start

1. Rename `.env.local` to `.env` and add missing envs (if any)
2. Install all the dependencies `yarn`
3. Start local Redis `docker run --name stash-redis-stack -p 6379:6379 -d redis/redis-stack-server`
4. Make a copy of `.env.local` and name it `.env`. This file will be ignored from git and you can set your own values.
5. Run the app in debug mode with watch option `yarn start-local`

## Documentation

### Used tech

- `Node.js` & `Typescript`
- `Express` - Node.js web framework.

### Tests

Tests have their own runtime docker container. Currently, most of the use cases are covered using integration tests in `integration.test.ts`

We use a combination of `supertests` & `testcontainers` libraries to achieve smooth and unified integration tests running either on local or CI environment.

## Storage
Google Memorystore (Redis with RDB)

## XCM Metadata Network Service
Data in this service are managed by

### Modification of XCM values

1. Setup `gcloud` CLI tool (make sure you setup correct project ID - `gcloud config set project direct-pixel-353917` )
2. Install Redis client that suits you
3. Port forward into our cloud instance `gcloud compute ssh port-forward-vm --zone=europe-west6-a -- -N -L 6379:10.96.14.131:6379` (dev Redis)
4. You can test your connection with `redis-cli ping`
5. You should be able to connect to the Redis instance of your choice thru localhost setup: `127.0.0.1` and NO password
6. You can now modify the values of XCM network configurations.

## Configurations

### Port forwards instance

`port-forward-vm europe-west6-a f1-micro 10.172.0.2 34.65.196.67`

### Port forward command

`gcloud compute ssh port-forward-vm --zone=europe-west6-a -- -N -L 6379:REPLACE_WITH_REDIS_INERNAL_IP:6379`

### ROLLUP-DEV

`10.15.245.67`

### ROLLUP-TESTNET

`10.37.94.163`

### Access secrets via SOPS

```bash
# 1. Install sops from here https://github.com/getsops/sops
Expand Down
140 changes: 140 additions & 0 deletions stash/api/Tracing collection.postman_collection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
{
"info": {
"_postman_id": "d5a365ed-8d28-4b31-ae8e-03607c61bfb3",
"name": "Tracing collection",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "36395820",
"_collection_link": "https://gasp77.postman.co/workspace/GASP-Workspace~0284ceb5-a521-4b91-b1b5-aeb16ce16070/collection/36395820-d5a365ed-8d28-4b31-ae8e-03607c61bfb3?action=share&source=collection_link&creator=36395820"
},
"item": [
{
"name": "Start tracing",
"event": [
{
"listen": "test",
"script": {
"exec": [
"var jsonData = pm.response.json();",
"pm.environment.set(\"entityId\", jsonData.transaction.entityId);",
"pm.environment.set(\"address\", jsonData.transaction.address);",
"pm.environment.set(\"txHash\", jsonData.transaction.txHash);"
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"txHash\": \"0x101\",\n \"address\": \"0x102\",\n \"type\": \"deposit\", //deposit or withdrawal\n \"chain\": \"Arbitrum\", //send Ethereum or Arbitrum\n \"amount\": \"400000000000000000\",\n \"asset_chainId\": \"0x106\",\n \"asset_address\": \"0x107\"\n\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "localhost:8080/tracing/tx/start",
"host": [
"localhost"
],
"port": "8080",
"path": [
"tracing",
"tx",
"start"
]
},
"description": "Tracing collection"
},
"response": []
},
{
"name": "Get status by hash or entityId",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "localhost:8080/tracing/tx/{{entityId}}",
"host": [
"localhost"
],
"port": "8080",
"path": [
"tracing",
"tx",
"{{entityId}}"
]
}
},
"response": []
},
{
"name": "Get all for address",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "localhost:8080/tracing/tx/listByAddress/{{address}}",
"host": [
"localhost"
],
"port": "8080",
"path": [
"tracing",
"tx",
"listByAddress",
"{{address}}"
]
}
},
"response": []
},
{
"name": "Get transactions by address and status",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "localhost:8080/tracing/tx/listByAddress/{{address}}/{{status}}",
"host": [
"localhost"
],
"port": "8080",
"path": [
"tracing",
"tx",
"listByAddress",
"{{address}}",
"{{status}}"
]
}
},
"response": []
},
{
"name": "Get transaction by entityId",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "localhost:8080/tracing/tx/findByEntityId/{{entityId}}",
"host": [
"localhost"
],
"port": "8080",
"path": [
"tracing",
"tx",
"findByEntityId",
"{{entityId}}"
]
}
},
"response": []
}
]
}
33 changes: 33 additions & 0 deletions stash/api/Tracing environment.postman_environment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"id": "72cf64a3-457b-4759-a7de-6da057518569",
"name": "Tracing environment",
"values": [
{
"key": "entityId",
"value": "",
"type": "default",
"enabled": true
},
{
"key": "txHash",
"value": "",
"type": "default",
"enabled": true
},
{
"key": "address",
"value": "",
"type": "default",
"enabled": true
},
{
"key": "status",
"value": "L1_INITIATED",
"type": "default",
"enabled": true
}
],
"_postman_variable_scope": "environment",
"_postman_exported_at": "2024-09-09T12:32:49.761Z",
"_postman_exported_using": "Postman/11.11.1"
}
Loading

0 comments on commit bd4c37f

Please sign in to comment.