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

Add VRF monitoring #8

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions aleph_scoring/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import sentry_sdk
import typer
from aleph.sdk.chains.ethereum import ETHAccount
from aleph.sdk.client import AuthenticatedAlephClient
from aleph.sdk.client import AuthenticatedAlephHttpClient
from aleph.sdk.types import Account
from hexbytes import HexBytes

Expand Down Expand Up @@ -49,7 +49,7 @@ async def publish_metrics_on_aleph(account: Account, node_metrics: NodeMetrics):
aleph_api_server = settings.NODE_DATA_HOST

metrics_post_data = MetricsPost(tags=["mainnet"], metrics=node_metrics)
async with AuthenticatedAlephClient(
async with AuthenticatedAlephHttpClient(
account=account, api_server=aleph_api_server
) as client:
metrics_post, status = await client.create_post(
Expand Down Expand Up @@ -78,7 +78,7 @@ async def publish_scores_on_aleph(
# Force datetime conversion to string
post_content["period"] = json.loads(period.json())

async with AuthenticatedAlephClient(
async with AuthenticatedAlephHttpClient(
account=account, api_server=aleph_api_server
) as client:
scores_post, status = await client.create_post(
Expand Down
19 changes: 16 additions & 3 deletions aleph_scoring/metrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import aiohttp
import async_timeout
import pyasn
from aleph.sdk import AlephClient
from aleph.sdk import AlephHttpClient
from pydantic import BaseModel, validator
from urllib3.util import Url, parse_url

Expand Down Expand Up @@ -56,7 +56,12 @@
"67705389842a0a1b95eaa408b009741027964edc805997475e95c505d642edd8"
)

VRF_VM_HASH = (
"f6a734dbc98659f030e1cd9c12d8ffb769deac55d42d5db5285fba099755c779"
)

CRN_DIAGNOSTIC_VM_PATH = "{url}vm/" + CRN_DIAGNOSTIC_VM_HASH
VRF_VM_PATH = "{url}vm/" + VRF_VM_HASH
IP4_SERVICE_URL = "https://v4.ident.me/"


Expand Down Expand Up @@ -469,6 +474,14 @@ async def get_crn_metrics(
)
)[0]

vrf_vm_latency = (
await measure_http_latency(
session,
"".join(VRF_VM_PATH).format(url=url),
timeout_seconds=10,
)
)[0]

async with aiohttp.ClientSession(
timeout=timeout_generator(),
connector=aiohttp.TCPConnector(
Expand Down Expand Up @@ -502,6 +515,7 @@ async def get_crn_metrics(
diagnostic_vm_latency=diagnostic_vm_latency,
full_check_latency=full_check_latency,
vm_ping_latency=vm_ping_latency,
vrf_latency=vrf_vm_latency,
)


Expand Down Expand Up @@ -538,11 +552,10 @@ async def collect_all_crn_metrics(node_data: Dict[str, Any]) -> Sequence[CrnMetr


async def get_aleph_nodes() -> Dict:
async with AlephClient(api_server=settings.NODE_DATA_HOST) as client:
async with AlephHttpClient(api_server=settings.NODE_DATA_HOST) as client:
return await client.fetch_aggregate(
address=settings.NODE_DATA_ADDR,
key="corechannel",
limit=50,
)


Expand Down
1 change: 1 addition & 0 deletions aleph_scoring/metrics/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class CrnMetrics(AlephNodeMetrics):
diagnostic_vm_latency: Optional[float]
full_check_latency: Optional[float]
vm_ping_latency: Optional[float] = None
vrf_latency: Optional[float] = None


class NodeMetrics(BaseModel):
Expand Down