diff --git a/aleph_scoring/__main__.py b/aleph_scoring/__main__.py index d361bd8..003a941 100644 --- a/aleph_scoring/__main__.py +++ b/aleph_scoring/__main__.py @@ -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 @@ -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( @@ -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( diff --git a/aleph_scoring/metrics/__init__.py b/aleph_scoring/metrics/__init__.py index 0898927..632a14c 100644 --- a/aleph_scoring/metrics/__init__.py +++ b/aleph_scoring/metrics/__init__.py @@ -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 @@ -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/" @@ -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( @@ -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, ) @@ -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, ) diff --git a/aleph_scoring/metrics/models.py b/aleph_scoring/metrics/models.py index c408358..fbe1700 100644 --- a/aleph_scoring/metrics/models.py +++ b/aleph_scoring/metrics/models.py @@ -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):