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

Fix poa chains #22

Merged
merged 1 commit into from
Sep 28, 2022
Merged
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
13 changes: 10 additions & 3 deletions src/collectors/evm.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from settings import cfg, logger
from web3 import Web3
from web3.exceptions import ExtraDataLengthError
import asyncio
from helpers import strip_url, check_protocol, generate_labels_from_metadata
from collectors.ws import websocket_collector
Expand All @@ -23,22 +24,28 @@ def __init__(self, rpc_metadata):
})
self.ws_collector.setDaemon(True)
self.ws_collector.start()
self.record_difficulty = True

else:
logger.error("Please provide wss/ws endpoint for {}".format(strip_url(self.url)))
exit(1)

def probe(self) -> results:
results.register(self.url, self.labels_values)
try:
if self.client.isConnected():
results.register(self.url, self.labels_values)
results.record_health(self.url, True)
results.record_head_count(self.url, self.ws_collector.message_counter)
results.record_disconnects(self.url, self.ws_collector.disconnects_counter)
results.record_latency(self.url, self.ws_collector.get_latency())
results.record_block_height(self.url, self.client.eth.block_number)
results.record_total_difficulty(self.url, self.client.eth.get_block('latest')['totalDifficulty'])
results.record_difficulty(self.url, self.client.eth.get_block('latest')['difficulty'])
try:
if self.record_difficulty:
results.record_total_difficulty(self.url, self.client.eth.get_block('latest')['totalDifficulty'])
results.record_difficulty(self.url, self.client.eth.get_block('latest')['difficulty'])
except ExtraDataLengthError:
logger.info("It looks like this is a POA chain, and does not use difficulty anymore. Collector will ignore difficulty metric from this point on")
self.record_difficulty = False
results.record_gas_price(self.url, self.client.eth.gas_price)
results.record_max_priority_fee(self.url, self.client.eth.max_priority_fee)
results.record_client_version(self.url, self.client.clientVersion)
Expand Down