From a05065270ed60c2db849241cc6b7cc21aeb440b5 Mon Sep 17 00:00:00 2001 From: cyc60 Date: Wed, 17 Sep 2025 17:00:53 +0300 Subject: [PATCH 1/4] Update readme --- README.md | 129 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 127 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a725163..cd0e01d 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,7 @@ The Relayer example for Stakewise v3-operator service Relayer-Operator api communication is described in [Operator docs](https://docs.stakewise.io/for-operators/operator-service/running-as-api-service). -In this example keystores and deposit-data file were not created in advance. -Relayer generates validator credentials on the fly. +In this example, keystores are stored in a local folder. ## Running with Docker @@ -34,6 +33,131 @@ europe-west4-docker.pkg.dev/stakewiselabs/public/relayer-example Relayer-example is Python app made with FastAPI. +## API Endpoints + +#### Register New Validators + +**POST** `/validators` +**Request Body**: + +``` +{ + "vault": "0x1234...", + "validators_start_index": int, + "amounts": int[], + "validator_type": "ValidatorType" +} +``` +- `vault` - Address of the vault contract to which the validators will be registered. +- `validators_start_index` - Validator index for the first validator in the batch. +- `amounts` - List of deposit amounts for each validator. Value provided in Gwei. +- `validator_type` - Type of validator to create. Possible values: `V1` or `V2`. + +**Response:** +``` +{ + "validators": [ + { + "public_key": "string", + "deposit_signature": "string", + "amount": int, + "exit_signature": "string" + } + ], + "validators_manager_signature": "string" +} +``` + +--- + +#### Fund Compounding Validators +**POST** `/fund` +**Request Body:** +``` +{ + "vault": "0x1234...", + "public_keys": str[], + "amounts": int[] +} +``` +- `vault` - Address of the vault contract to which the validators will be funded. +- `public_keys` - List of public keys of validators to fund. +- `amounts` - List of amounts to fund into each validator. Value provided in Gwei. + +**Response:** +``` +{ + "validators": [ + { + "public_key": "string", + "deposit_signature": "string", + "amount": int + } + ], + "validators_manager_signature": "string" +} +``` + +--- + +#### Get Signature for Withdraw Funds from Validators Transaction +**POST** `/withdraw` +**Request Body:** +``` +{ + "vault": "0x1234...", + "public_keys": str[], + "amounts": int[] +} +``` +- `vault` - Address of the vault contract to which the validators will be withdrawn. +- `public_keys` - List of public keys of validators to withdraw from. +- `amounts` - List of amounts to withdraw from each validator. Value provided in Gwei. + +**Response:** +``` +{ + "validators_manager_signature": "string" +} +``` + +--- + +#### Get Signature for Consolidate Validators Transaction +**POST** `/consolidate` +**Request Body:** +``` +{ + "vault": "0x1234...", + "source_public_keys": str[], + "target_public_keys": str[] +} +``` +- `vault` - Address of the vault contract to which the validators will be consolidated. +- `source_public_keys` - List of public keys of validators to consolidate from. +- `target_public_keys` - List of public keys of validators to consolidate to. + +**Response:** +``` +{ + "validators_manager_signature": "string" +} +``` + +--- + + +#### Fetch info about relayer +**Get** `/info` + +**Response:** +``` +{ + "network": "string" +} +``` + + ### Folders structure ```text @@ -48,6 +172,7 @@ src/ # sources root |-- validators/ # | |-- credentials.py # Credential and CredentialManager used to generate keystores | |-- endpoints.py # api endpoints +| |-- keystore.py # local keystore storage | |-- schema.py # api request/response schema | |-- typings.py # dataclasses | |-- validators.py # functions for creating validators and exit signatures From b053c5cce36b856824d7465bddee60293d736ba1 Mon Sep 17 00:00:00 2001 From: cyc60 Date: Wed, 17 Sep 2025 17:10:00 +0300 Subject: [PATCH 2/4] Markdown cleanup --- README.md | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index cd0e01d..f94acf6 100644 --- a/README.md +++ b/README.md @@ -35,12 +35,12 @@ Relayer-example is Python app made with FastAPI. ## API Endpoints -#### Register New Validators +### Register New Validators **POST** `/validators` **Request Body**: -``` +```json { "vault": "0x1234...", "validators_start_index": int, @@ -48,13 +48,15 @@ Relayer-example is Python app made with FastAPI. "validator_type": "ValidatorType" } ``` + - `vault` - Address of the vault contract to which the validators will be registered. - `validators_start_index` - Validator index for the first validator in the batch. - `amounts` - List of deposit amounts for each validator. Value provided in Gwei. - `validator_type` - Type of validator to create. Possible values: `V1` or `V2`. **Response:** -``` + +```json { "validators": [ { @@ -70,22 +72,26 @@ Relayer-example is Python app made with FastAPI. --- -#### Fund Compounding Validators +### Fund Compounding Validators + **POST** `/fund` **Request Body:** -``` + +```json { "vault": "0x1234...", "public_keys": str[], "amounts": int[] } ``` + - `vault` - Address of the vault contract to which the validators will be funded. - `public_keys` - List of public keys of validators to fund. - `amounts` - List of amounts to fund into each validator. Value provided in Gwei. **Response:** -``` + +```json { "validators": [ { @@ -100,22 +106,26 @@ Relayer-example is Python app made with FastAPI. --- -#### Get Signature for Withdraw Funds from Validators Transaction +### Get Signature for Withdraw Funds from Validators Transaction + **POST** `/withdraw` **Request Body:** -``` + +```json { "vault": "0x1234...", "public_keys": str[], "amounts": int[] } ``` + - `vault` - Address of the vault contract to which the validators will be withdrawn. - `public_keys` - List of public keys of validators to withdraw from. - `amounts` - List of amounts to withdraw from each validator. Value provided in Gwei. **Response:** -``` + +```json { "validators_manager_signature": "string" } @@ -123,22 +133,26 @@ Relayer-example is Python app made with FastAPI. --- -#### Get Signature for Consolidate Validators Transaction +### Get Signature for Consolidate Validators Transaction + **POST** `/consolidate` **Request Body:** -``` + +```json { "vault": "0x1234...", "source_public_keys": str[], "target_public_keys": str[] } ``` + - `vault` - Address of the vault contract to which the validators will be consolidated. - `source_public_keys` - List of public keys of validators to consolidate from. - `target_public_keys` - List of public keys of validators to consolidate to. **Response:** -``` + +```json { "validators_manager_signature": "string" } @@ -146,18 +160,18 @@ Relayer-example is Python app made with FastAPI. --- +### Fetch info about relayer -#### Fetch info about relayer **Get** `/info` **Response:** -``` + +```json { "network": "string" } ``` - ### Folders structure ```text From 46da88aaa4d8c3bdefd886409bc37b334d7551f3 Mon Sep 17 00:00:00 2001 From: cyc60 Date: Fri, 19 Sep 2025 10:11:59 +0300 Subject: [PATCH 3/4] Unify api examples --- README.md | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index f94acf6..3ec43a6 100644 --- a/README.md +++ b/README.md @@ -43,9 +43,9 @@ Relayer-example is Python app made with FastAPI. ```json { "vault": "0x1234...", - "validators_start_index": int, - "amounts": int[], - "validator_type": "ValidatorType" + "validators_start_index": 20551, + "amounts": [32000000000], + "validator_type": "0x02" } ``` @@ -60,13 +60,13 @@ Relayer-example is Python app made with FastAPI. { "validators": [ { - "public_key": "string", - "deposit_signature": "string", - "amount": int, - "exit_signature": "string" + "public_key": "0xPubKey1", + "deposit_signature": "0xDepositSig1", + "amount": 32000000000, + "exit_signature": "0xExitSig1" } ], - "validators_manager_signature": "string" + "validators_manager_signature": "0xManagerSig" } ``` @@ -80,8 +80,8 @@ Relayer-example is Python app made with FastAPI. ```json { "vault": "0x1234...", - "public_keys": str[], - "amounts": int[] + "public_keys": ["0xPubKey1"], + "amounts": [2000000000] } ``` @@ -95,12 +95,12 @@ Relayer-example is Python app made with FastAPI. { "validators": [ { - "public_key": "string", - "deposit_signature": "string", - "amount": int + "public_key": "0xPubKey1", + "deposit_signature": "0xDepositSig1", + "amount": 2000000000 } ], - "validators_manager_signature": "string" + "validators_manager_signature": "0xManagerSig" } ``` @@ -114,8 +114,8 @@ Relayer-example is Python app made with FastAPI. ```json { "vault": "0x1234...", - "public_keys": str[], - "amounts": int[] + "public_keys": ["0xPubKey1", "0xPubKey2"], + "amounts": [55000000000, 0] } ``` @@ -127,7 +127,7 @@ Relayer-example is Python app made with FastAPI. ```json { - "validators_manager_signature": "string" + "validators_manager_signature": "0xManagerSig" } ``` @@ -141,8 +141,8 @@ Relayer-example is Python app made with FastAPI. ```json { "vault": "0x1234...", - "source_public_keys": str[], - "target_public_keys": str[] + "source_public_keys": ["0xPubKey1", "0xPubKey2"], + "target_public_keys": ["0xPubKey3", "0xPubKey3"] } ``` @@ -154,7 +154,7 @@ Relayer-example is Python app made with FastAPI. ```json { - "validators_manager_signature": "string" + "validators_manager_signature": "0xManagerSig" } ``` @@ -178,8 +178,13 @@ Relayer-example is Python app made with FastAPI. src/ # sources root |-- common/ # | |-- abi/ # contracts ABI +| |-- app_state/ # store app state | |-- clients.py # execution client | |-- contracts.py # validators registry contract +| |-- endpoints.py # info api endpoint +| |-- schema.py # api request/response schema +| |-- setup_logging.py # logging scheme setup +| |-- typings.py # comon types |-- config/ | |-- networks.py # network configs | |-- settings.py # app settings From efb3314e1ac97b62a518a65c91117d72dab5f745 Mon Sep 17 00:00:00 2001 From: cyc60 Date: Fri, 19 Sep 2025 10:13:28 +0300 Subject: [PATCH 4/4] Unify api examples --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3ec43a6..5c38a8f 100644 --- a/README.md +++ b/README.md @@ -168,7 +168,7 @@ Relayer-example is Python app made with FastAPI. ```json { - "network": "string" + "network": "mainnet" } ```