Skip to content

Commit 691d649

Browse files
Scan SSV events (#26)
* Scan SSV events * Update keystores on the fly * Fix tests * Bump version v1.0.0 * Del gnosis/chiado * Fix vulture * Fix vulture 2 * Fix ssv flow * Del SSVOperatorCrud * Use chunkify * Add validate_settings * Review fixes * Review fix
1 parent 65d08d5 commit 691d649

33 files changed

+3385
-527
lines changed

.env.example

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# General section
33
###########################
44

5-
# Network choices: mainnet,hoodi,gnosis,chiado
5+
# Network choices: mainnet,hoodi
66
NETWORK=hoodi
77

88
# LOG_LEVEL=INFO
@@ -63,14 +63,14 @@ OBOL_NODE_INDEX=0
6363
# Path to key file
6464
SSV_OPERATOR_KEY_FILE=encrypted_private_key.json
6565
# Path to password file
66-
SSV_OPERATOR_PASSWORD_FILE=password.txt
66+
SSV_OPERATOR_PASSWORD_FILE=password
6767

6868
# SSV operator key, templated version. Variable 'operator_id' may be used.
6969
# For testing only
7070
# Path to key file, template
7171
# SSV_OPERATOR_KEY_FILE_TEMPLATE=operator-{operator_id}/encrypted_private_key.json
7272
# Path to password file, template
73-
# SSV_OPERATOR_PASSWORD_FILE_TEMPLATE=operator-{operator_id}/password.txt
73+
# SSV_OPERATOR_PASSWORD_FILE_TEMPLATE=operator-{operator_id}/password
7474

7575
# SSV operator id (node id)
7676
SSV_OPERATOR_ID=123
@@ -80,9 +80,6 @@ SSV_OPERATOR_ID=123
8080
# If both SSV_OPERATOR_ID and SSV_OPERATOR_IDS are present then SSV_OPERATOR_IDS has priority
8181
# SSV_OPERATOR_IDS=123,456
8282

83-
# SSV keyshares file path
84-
SSV_KEYSHARES_FILE=keyshares.json
85-
8683
###########################
8784
# Remote signer section
8885
###########################

.github/workflows/ci.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ jobs:
7878
- name: Install dependencies
7979
run: poetry install --no-interaction
8080

81+
- name: Create env-file
82+
run: cp .env.example .env
83+
8184
# Run tests
8285
- name: Run tests
8386
run: poetry run coverage run -m pytest src

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,4 @@ cython_debug/
168168
# Miscellaneous
169169
.DS_Store
170170
*.env
171+
*.db

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ repos:
5757
language: system
5858
types: [ python ]
5959
require_serial: true
60-
exclude: "test_"
60+
exclude: "test|_vulture_whitelist.py"
6161

6262
- repo: local
6363
hooks:
@@ -84,7 +84,7 @@ repos:
8484
always_run: true
8585

8686
- repo: https://github.com/jendrikseipp/vulture
87-
rev: 'v2.13'
87+
rev: 'v2.14'
8888
hooks:
8989
- id: vulture
9090
args: ["src/"]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ docker run \
2020
-u $(id -u):$(id -g) \
2121
--env-file .env \
2222
-v $(pwd)/data:/data \
23-
europe-west4-docker.pkg.dev/stakewiselabs/public/dvt-operator-sidecar:v0.5.0
23+
europe-west4-docker.pkg.dev/stakewiselabs/public/dvt-operator-sidecar:v1.0.0
2424
```
2525

2626
## Development

poetry.lock

Lines changed: 318 additions & 301 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "dvt-operator-sidecar"
3-
version = "v0.5.0"
3+
version = "v1.0.0"
44
description = "StakeWise sidecar for DVT-operator"
55
authors = ["StakeWise Labs <info@stakewise.io>"]
66
package-mode = false
@@ -17,17 +17,18 @@ pyyaml = "==6.0.1"
1717
python-json-logger = "==2.0.7"
1818
staking-deposit = { git = "https://github.com/ethereum/staking-deposit-cli.git", rev = "v2.4.0" }
1919
pycryptodomex = "3.19.1"
20+
aiosqlite = "==0.21.0"
2021

2122
[tool.poetry.group.dev.dependencies]
2223
pylint = "==3.0.1"
2324
mypy = "==1.6.1"
2425
isort = "==5.12.0"
25-
pytest = "==7.4.2"
26-
pytest-asyncio = "==0.21.1"
26+
pytest = "==8.4.1"
27+
pytest-asyncio = "==1.0.0"
2728
pre-commit = "==3.5.0"
2829
Flake8-pyproject = "==1.2.3"
2930
bandit = { version = "==1.7.5", extras = ["toml"] }
30-
black = { version = "==23.10.0", extras = ["d"] }
31+
black = { version = "==25.1.0", extras = ["d"] }
3132
faker = "==19.11.0"
3233
flake8-print = "==5.0.0"
3334
flake8-datetimez = "==20.10.0"
@@ -53,9 +54,10 @@ disable = [
5354
"R0801", # duplicate-code
5455
"R0903", # too-few-public-methods
5556
"W0703", # broad-except
56-
"W0718" # broad-exception-caught
57+
"W0718", # broad-exception-caught
58+
"C0321" # More than one statement on a single line
5759
]
58-
ignore-paths=["src/.*/tests/.*", "src/test_fixtures/.*"]
60+
ignore-paths=["src/.*/tests/.*", "src/test_fixtures/.*", "src/_vulture_whitelist.py"]
5961
ignore=["conftest.py"]
6062

6163
[tool.pylint."BASIC"]
@@ -65,11 +67,13 @@ ignored-modules=["milagro_bls_binding"]
6567
[tool.flake8]
6668
extend-ignore = [
6769
"E203", # Whitespace before ':', conflicts with black
68-
"E501" # line length will be checked by pylint
70+
"E501", # line length will be checked by pylint
71+
"E701", # multiple statements on one line (colon), conflicts with black
6972
]
73+
exclude = ["src/_vulture_whitelist.py"]
7074

7175
[tool.mypy]
72-
exclude = ["test_"]
76+
exclude = ["test", "_vulture_whitelist.py"]
7377
ignore_missing_imports = true
7478
python_version = "3.10"
7579
disallow_untyped_defs = true
@@ -109,4 +113,9 @@ fail_under = 73
109113

110114
[tool.vulture]
111115
exclude = ["*/test*", "conftest.py", "networks.py"]
112-
min_confidence = 80
116+
117+
[tool.pytest.ini_options]
118+
asyncio_mode = "auto"
119+
120+
[tool.migration]
121+
db_version = 1

src/_vulture_whitelist.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# src/validators/keystores/obol_remote.py
2+
previous_version
3+
current_version
4+
fork_info
5+
signing_root
6+
voluntary_exit

src/app.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
import logging
33
from typing import cast
44

5+
from src.common.database import db_client
56
from src.common.setup_logging import ExtendedLogger, setup_logging, setup_sentry
67
from src.common.utils import get_project_version
8+
from src.config.settings import validate_settings
9+
from src.setup_database import setup_database
710

811
setup_logging()
912
setup_sentry()
@@ -17,24 +20,29 @@ async def app() -> None:
1720
from src.startup_checks import startup_checks
1821
from src.validators.tasks import create_tasks
1922

23+
validate_settings()
24+
2025
version = get_project_version()
2126
logger.info('Starting DVT Sidecar service %s', version)
2227

28+
await setup_database()
29+
2330
is_checks_ok = await startup_checks()
2431
if not is_checks_ok:
2532
return
2633

2734
try:
2835
await create_tasks()
36+
logger.info('DVT Sidecar service started')
37+
38+
# Keep tasks running
39+
while True:
40+
await asyncio.sleep(0.1)
2941
except Exception as e:
3042
logger.exception_verbose(e)
31-
return
32-
33-
logger.info('DVT Sidecar service started')
34-
35-
# Keep tasks running
36-
while True:
37-
await asyncio.sleep(0.1)
43+
finally:
44+
# prevent hanging on shutdown
45+
await db_client.close()
3846

3947

4048
if __name__ == '__main__':

src/checkpoints/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)