Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #292

Merged
merged 32 commits into from
Mar 19, 2024
Merged

Dev #292

Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c25aa0b
Add oracles cache (#238)
evgeny-stakewise Nov 29, 2023
3e0f207
Merge branch 'master' into dev
cyc60 Dec 1, 2023
dacfaa9
Use separate tasks for main functions (#230)
cyc60 Dec 1, 2023
d269426
Merge master into dev
cyc60 Dec 11, 2023
a7acb0b
Move ipfs retries to client (#252)
evgeny-stakewise Dec 11, 2023
1a5bc88
Merge master into dev
cyc60 Dec 14, 2023
42e4c77
Refactored keystores (#249)
cyc60 Dec 27, 2023
da3b4e2
Log format (#260)
cyc60 Jan 8, 2024
e437145
Add log envs to example (#262)
cyc60 Jan 9, 2024
fcd671d
Merge remote-tracking branch 'origin/master' into dev
evgeny-stakewise Jan 18, 2024
d345eda
Fixes after merge
evgeny-stakewise Jan 18, 2024
35b7bfc
Rework signature rotation parallel (#273)
evgeny-stakewise Jan 19, 2024
cd8d0be
Add flake8-datetimez plugin (#274)
evgeny-stakewise Jan 22, 2024
f4943d1
Update execution.py (#284)
tsudmi Feb 2, 2024
95ba429
Add setup_logging (#285)
evgeny-stakewise Feb 2, 2024
9689fe1
Merge master into dev
cyc60 Feb 6, 2024
d6b8839
Rework remote signer (#288)
evgeny-stakewise Feb 7, 2024
5a0139d
Merge remote-tracking branch 'origin/master' into dev
evgeny-stakewise Feb 8, 2024
32b5ac5
Add interruptible sleep (#290)
evgeny-stakewise Feb 9, 2024
1fdcf26
Add --pool-size arg to start command (#291)
evgeny-stakewise Feb 9, 2024
0e72967
Del pip-audit ignore (#294)
evgeny-stakewise Feb 14, 2024
dfff5c6
Rework remote db (#293)
evgeny-stakewise Feb 15, 2024
1cbf436
Add web3_log_level setting (#295)
evgeny-stakewise Feb 15, 2024
7754244
Add api for obol (#280)
evgeny-stakewise Feb 21, 2024
5ed5454
goerli to holesky rename (#297)
execute237 Feb 21, 2024
e8f111c
Fix tx confirm (#300)
evgeny-stakewise Mar 5, 2024
fa55bf2
Fix _fetch_outdated_indexes (#302)
evgeny-stakewise Mar 5, 2024
ba7a2ce
Fix pip-audit (#303)
evgeny-stakewise Mar 6, 2024
859ebc7
Fix validators check (#304)
evgeny-stakewise Mar 13, 2024
2173706
Add priority fee (#301)
evgeny-stakewise Mar 18, 2024
18d9111
Bump version v1.1.0 (#305)
evgeny-stakewise Mar 18, 2024
52d2a52
Docker Hub (#296) (#306)
evgeny-stakewise Mar 18, 2024
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
7 changes: 6 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ CONSENSUS_ENDPOINTS=http://localhost:3500
# METRICS_HOST=127.0.0.1
# METRICS_PORT=9100

# The network of the Vault. Choices are: mainnet, gnosis, goerli
# The network of the Vault. Choices are: mainnet, gnosis, holesky
# Default value will be taken from vault config
# NETWORK=mainnet

Expand Down Expand Up @@ -68,3 +68,8 @@ CONSENSUS_ENDPOINTS=http://localhost:3500
# HOT_WALLET_FILE=/home/user/.stakewise/${VAULT_CONTRACT_ADDRESS}/wallet/wallet.json
# Default is ${DATA_DIR}/${VAULT_CONTRACT_ADDRESS}/wallet/password.txt
# HOT_WALLET_PASSWORD_FILE=/home/user/.stakewise/${VAULT_CONTRACT_ADDRESS}/wallet/password.txt

# Log level
# LOG_LEVEL=INFO
# Log record format. Can be "plain" or "json". Default is "plain"
# LOG_FORMAT=plain
1 change: 0 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,3 @@ jobs:
- uses: pypa/[email protected]
with:
inputs: audit_requirements.txt
ignore-vulns: PYSEC-2022-43059
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# StakeWise V3 Operator

1. [What is V3 Operator?](#what-is-v3-operator)
Expand Down Expand Up @@ -42,12 +43,13 @@ The validator registration process consists of the following steps:
1. Check whether Vault has accumulated enough assets to register a validator (e.g., 32 ETH for Ethereum)
2. Get the next free validator public key from the deposit data file attached to the operator. The validators are
registered in the same order as specified in the deposit data file.
3. Share the exit signature of the validator with StakeWise Oracles:
1. Using [Shamir's secret sharing](https://en.wikipedia.org/wiki/Shamir%27s_secret_sharing), generate shares for the
validator's BLS private key. The number of shares is equal to the number of oracles.
2. Sign the exit message with every private key share and encrypt exit signatures with oracles' public keys.
3. Obtain BLS signature for exit message using local keystores or remote signer.
4. Share the exit signature of the validator with StakeWise Oracles:
1. Using [Shamir's secret sharing](https://en.wikipedia.org/wiki/Shamir%27s_secret_sharing), split
validator's BLS signature. The number of shares is equal to the number of oracles.
2. Encrypt exit signatures with oracles' public keys.
3. Send encrypted exit signatures to all the oracles and receive registration signatures from them.
4. Send transaction to Vault contract to register the validator.
5. Send transaction to Vault contract to register the validator.

### Exit signatures rotation

Expand Down Expand Up @@ -147,22 +149,22 @@ Head to [Usage](#usage) to launch your operator service.
Pull the latest docker operator docker image:

```bash
docker pull europe-west4-docker.pkg.dev/stakewiselabs/public/v3-operator:v1.0.8
docker pull europe-west4-docker.pkg.dev/stakewiselabs/public/v3-operator:v1.1.0
```

You can also build the docker image from source by cloning this repo and executing the following command from within
the `v3-operator` folder:

```bash
docker build --pull -t europe-west4-docker.pkg.dev/stakewiselabs/public/v3-operator:v1.0.8 .
docker build --pull -t europe-west4-docker.pkg.dev/stakewiselabs/public/v3-operator:v1.1.0 .
```

You will execute Operator Service commands using the format below (note the use of flags are optional):

```bash
docker run --rm -ti \
-v ~/.stakewise/:/data \
europe-west4-docker.pkg.dev/stakewiselabs/public/v3-operator:v1.0.8 \
europe-west4-docker.pkg.dev/stakewiselabs/public/v3-operator:v1.1.0 \
src/main.py COMMAND \
--flagA=123 \
--flagB=xyz
Expand Down Expand Up @@ -384,7 +386,7 @@ below:
```bash
docker run --restart on-failure:10 \
-v ~/.stakewise/:/data \
europe-west4-docker.pkg.dev/stakewiselabs/public/v3-operator:v1.0.8 \
europe-west4-docker.pkg.dev/stakewiselabs/public/v3-operator:v1.1.0 \
src/main.py start \
--vault=0x3320ad928c20187602a2b2c04eeaa813fa899468 \
--data-dir=/data \
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
operator:
build:
context: .
dockerfile: europe-west4-docker.pkg.dev/stakewiselabs/public/v3-operator:v1.0.8
dockerfile: europe-west4-docker.pkg.dev/stakewiselabs/public/v3-operator:v1.1.0
image: v3-operator
container_name: v3-operator
command: ["src/main.py", "start"]
Expand Down
634 changes: 428 additions & 206 deletions poetry.lock

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "v3-operator"
version = "v1.0.8"
version = "v1.1.0"
description = "StakeWise operator service for registering vault validators"
authors = ["StakeWise Labs <[email protected]>"]

Expand All @@ -9,8 +9,8 @@ python = ">=3.10,<3.11"
python-decouple = "==3.8"
sentry-sdk = "==1.32.0"
py-ecc = "==6.0.0"
multiproof = { git = "https://github.com/stakewise/multiproof.git", rev = "v0.1.6" }
sw-utils = { git = "https://github.com/stakewise/sw-utils.git", rev = "v0.3.31" }
multiproof = { git = "https://github.com/stakewise/multiproof.git", rev = "v0.1.7" }
sw-utils = { git = "https://github.com/stakewise/sw-utils.git", rev = "v0.6.1" }
staking-deposit = { git = "https://github.com/ethereum/staking-deposit-cli.git", rev = "v2.4.0" }
pycryptodomex = "3.19.1"
milagro-bls-binding = "==1.9.0"
Expand All @@ -21,6 +21,10 @@ prometheus-client = "==0.17.1"
psycopg2 = "==2.9.9"
pyyaml = "==6.0.1"
aiohttp = "==3.9.3"
python-json-logger = "==2.0.7"
starlette = "==0.36.2"
uvicorn = "==0.27.0"
pydantic = "==2.5.3"

[tool.poetry.group.dev.dependencies]
pylint = "==3.0.1"
Expand All @@ -34,8 +38,8 @@ bandit = { version = "==1.7.5", extras = ["toml"] }
black = { version = "==23.10.0", extras = ["d"] }
pyinstaller = "==5.13.2"
faker = "==19.11.0"
flake8-datetime-utcnow-plugin = "==0.1.2"
flake8-print = "==5.0.0"
flake8-datetimez = "==20.10.0"
types-pyyaml = "==6.0.12.12"
coverage = "==7.3.2"
aioresponses = "^0.7.4"
Expand Down
2 changes: 1 addition & 1 deletion scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ http_copy() {
github_release() {
owner_repo=$1
version=$2
test -z "$version" && version="v1.0.8"
test -z "$version" && version="v1.1.0"
giturl="https://github.com/${owner_repo}/releases/${version}"
json=$(http_copy "$giturl" "Accept:application/json")
test -z "$json" && return 1
Expand Down
11 changes: 11 additions & 0 deletions src/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from starlette.applications import Starlette
from starlette.routing import Route

from src.validators.api.endpoints import get_validators, submit_validators

app = Starlette(
routes=[
Route('/validators', get_validators, methods=['GET']),
Route('/validators', submit_validators, methods=['POST']),
]
)
2 changes: 1 addition & 1 deletion src/commands/create_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
@click.option(
'--pool-size',
help='Number of processes in a pool.',
# do not prompt
envvar='POOL_SIZE',
type=int,
)
@click.command(help='Creates the validator keys from the mnemonic.')
Expand Down
14 changes: 13 additions & 1 deletion src/commands/recover.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from src.common.contracts import v2_pool_contract, vault_contract
from src.common.credentials import CredentialManager
from src.common.execution import SECONDS_PER_MONTH
from src.common.logging import setup_logging
from src.common.logging import LOG_LEVELS, setup_logging
from src.common.password import generate_password, get_or_create_password_file
from src.common.utils import greenify, log_verbose
from src.common.validators import validate_eth_address, validate_mnemonic
Expand Down Expand Up @@ -76,6 +76,16 @@
case_sensitive=False,
),
)
@click.option(
'--log-level',
type=click.Choice(
LOG_LEVELS,
case_sensitive=False,
),
default='INFO',
envvar='LOG_LEVEL',
help='The log level.',
)
# pylint: disable-next=too-many-arguments
def recover(
data_dir: str,
Expand All @@ -86,6 +96,7 @@ def recover(
execution_endpoints: str,
per_keystore_password: bool,
no_confirm: bool,
log_level: str,
) -> None:
# pylint: disable=duplicate-code
config = VaultConfig(
Expand All @@ -106,6 +117,7 @@ def recover(
vault=vault,
network=network,
vault_dir=config.vault_dir,
log_level=log_level,
)

try:
Expand Down
Loading
Loading