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

Improvements #92

Merged
merged 17 commits into from
Nov 20, 2023
Merged
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ __pycache__
.mypy_cache
.coverage
.idea
coverage.xml
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
all:

test:
poetry run pytest
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,7 @@ name | description
`missed_attestations_count` | Missed attestations count
`double_missed_attestations_count` | Double missed attestations count
`missed_block_proposals_head_count` | Missed block proposals on head count
`missed_block_proposals_head_count_details` | Missed block proposals on head count with slot and epoch labels
`missed_block_proposals_finalized_count` | Missed block proposals on finalized count
`missed_block_proposals_finalized_count_details` | Missed block proposals on finalized count with slot and epoch labels
`future_block_proposals_count` | Future block proposals count
`our_slashed_validators_count` | Our slashed validators count
`total_slashed_validators_count` | Total slashed validators count
Expand Down
4 changes: 2 additions & 2 deletions eth_validator_watcher/coinbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from .models import CoinbaseTrade

URL = "https://api.pro.coinbase.com/products/ETH-USD/trades"
eth_usd_gauge = Gauge("eth_usd", "ETH/USD conversion rate")
metric_eth_usd_gauge = Gauge("eth_usd", "ETH/USD conversion rate")


class Coinbase:
Expand All @@ -27,7 +27,7 @@ def emit_eth_usd_conversion_rate(self) -> None:
trades_dict = response.json()
trades = parse_obj_as(list[CoinbaseTrade], trades_dict)
trade, *_ = trades
eth_usd_gauge.set(trade.price)
metric_eth_usd_gauge.set(trade.price)
except:
# This feature is totally optional, so if it fails, we just return 0
pass
4 changes: 2 additions & 2 deletions eth_validator_watcher/entry_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
(2_621_440, 40),
]

entry_queue_duration_sec = Gauge(
metric_entry_queue_duration_sec = Gauge(
"entry_queue_duration_sec",
"Entry queue duration in seconds",
)
Expand Down Expand Up @@ -141,4 +141,4 @@ def export_duration_sec(
"""

duration_sec = compute_duration_sec(nb_active_validators, position_in_entry_queue)
entry_queue_duration_sec.set(duration_sec)
metric_entry_queue_duration_sec.set(duration_sec)
24 changes: 12 additions & 12 deletions eth_validator_watcher/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,25 @@

app = typer.Typer(add_completion=False)

slot_gauge = Gauge("slot", "Slot")
epoch_gauge = Gauge("epoch", "Epoch")
metric_slot_gauge = Gauge("slot", "Slot")
metric_epoch_gauge = Gauge("epoch", "Epoch")

our_queued_vals_gauge = Gauge(
metric_our_queued_vals_gauge = Gauge(
"our_pending_queued_validators_count",
"Our pending queued validators count",
)

net_pending_q_vals_gauge = Gauge(
metric_net_pending_q_vals_gauge = Gauge(
"total_pending_queued_validators_count",
"Total pending queued validators count",
)

our_active_validators_gauge = Gauge(
metric_our_active_validators_gauge = Gauge(
"our_active_validators_count",
"Our active validators count",
)

net_active_validators_gauge = Gauge(
metric_net_active_validators_gauge = Gauge(
"total_active_validators_count",
"Total active validators count",
)
Expand Down Expand Up @@ -267,8 +267,8 @@ def _handler(
epoch = slot // NB_SLOT_PER_EPOCH
slot_in_epoch = slot % NB_SLOT_PER_EPOCH

slot_gauge.set(slot)
epoch_gauge.set(epoch)
metric_slot_gauge.set(slot)
metric_epoch_gauge.set(epoch)

is_new_epoch = previous_epoch is None or previous_epoch != epoch

Expand All @@ -287,7 +287,7 @@ def _handler(

net_pending_q_idx2val = net_status2idx2val.get(Status.pendingQueued, {})
nb_total_pending_q_vals = len(net_pending_q_idx2val)
net_pending_q_vals_gauge.set(nb_total_pending_q_vals)
metric_net_pending_q_vals_gauge.set(nb_total_pending_q_vals)

active_ongoing = net_status2idx2val.get(Status.activeOngoing, {})
active_exiting = net_status2idx2val.get(Status.activeExiting, {})
Expand All @@ -296,7 +296,7 @@ def _handler(
net_epoch2active_idx2val[epoch] = net_active_idx2val

net_active_vals_count = len(net_active_idx2val)
net_active_validators_gauge.set(net_active_vals_count)
metric_net_active_validators_gauge.set(net_active_vals_count)

net_exited_s_idx2val = net_status2idx2val.get(Status.exitedSlashed, {})

Expand All @@ -316,15 +316,15 @@ def _handler(
}

our_queued_idx2val = our_status2idx2val.get(Status.pendingQueued, {})
our_queued_vals_gauge.set(len(our_queued_idx2val))
metric_our_queued_vals_gauge.set(len(our_queued_idx2val))

ongoing = our_status2idx2val.get(Status.activeOngoing, {})
active_exiting = our_status2idx2val.get(Status.activeExiting, {})
active_slashed = our_status2idx2val.get(Status.activeSlashed, {})
our_active_idx2val = ongoing | active_exiting | active_slashed
our_epoch2active_idx2val[epoch] = our_active_idx2val

our_active_validators_gauge.set(len(our_active_idx2val))
metric_our_active_validators_gauge.set(len(our_active_idx2val))
our_exited_u_idx2val = our_status2idx2val.get(Status.exitedUnslashed, {})
our_exited_s_idx2val = our_status2idx2val.get(Status.exitedSlashed, {})

Expand Down
4 changes: 2 additions & 2 deletions eth_validator_watcher/exited_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from .models import Validators
from .utils import Slack

our_exited_validators_count = Gauge(
metric_our_exited_validators_count = Gauge(
"our_exited_validators_count",
"Our exited validators count",
)
Expand Down Expand Up @@ -52,7 +52,7 @@ def process(
our_unslashed_withdrawal_index_to_validator
)

our_exited_validators_count.set(len(our_exited_indexes))
metric_our_exited_validators_count.set(len(our_exited_indexes))

if self.__our_exited_unslashed_indexes is None:
self.__our_exited_unslashed_indexes = our_exited_unslashed_indexes
Expand Down
4 changes: 2 additions & 2 deletions eth_validator_watcher/fee_recipient.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from .models import Block, Validators
from .utils import NB_SLOT_PER_EPOCH, Slack

wrong_fee_recipient_proposed_block_count = Counter(
metric_wrong_fee_recipient_proposed_block_count = Counter(
"wrong_fee_recipient_proposed_block_count",
"Wrong fee recipient proposed block count",
)
Expand Down Expand Up @@ -93,4 +93,4 @@ def process_fee_recipient(
if slack is not None:
slack.send_message(message)

wrong_fee_recipient_proposed_block_count.inc()
metric_wrong_fee_recipient_proposed_block_count.inc()
8 changes: 4 additions & 4 deletions eth_validator_watcher/missed_attestations.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@

print = functools.partial(print, flush=True)

missed_attestations_count = Gauge(
metric_missed_attestations_count = Gauge(
"missed_attestations_count",
"Missed attestations count",
)

double_missed_attestations_count = Gauge(
metric_double_missed_attestations_count = Gauge(
"double_missed_attestations_count",
"Double missed attestations count",
)
Expand Down Expand Up @@ -58,7 +58,7 @@ def process_missed_attestations(
index for index, liveness in validators_liveness.items() if not liveness
}

missed_attestations_count.set(len(dead_indexes))
metric_missed_attestations_count.set(len(dead_indexes))

if len(dead_indexes) == 0:
return set()
Expand Down Expand Up @@ -108,7 +108,7 @@ def process_double_missed_attestations(
return set()

double_dead_indexes = dead_indexes & previous_dead_indexes
double_missed_attestations_count.set(len(double_dead_indexes))
metric_double_missed_attestations_count.set(len(double_dead_indexes))

if len(double_dead_indexes) == 0:
return set()
Expand Down
25 changes: 4 additions & 21 deletions eth_validator_watcher/missed_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,16 @@

print = functools.partial(print, flush=True)

missed_block_proposals_head_count = Counter(
metric_missed_block_proposals_head_count = Counter(
"missed_block_proposals_head_count",
"Missed block proposals head count",
)

missed_block_proposals_head_count_details = Counter(
"missed_block_proposals_head_count_details",
"Missed block proposals head count details",
["slot", "epoch"],
)

missed_block_proposals_finalized_count = Counter(
metric_missed_block_proposals_finalized_count = Counter(
"missed_block_proposals_finalized_count",
"Missed block proposals finalized count",
)

missed_block_proposals_finalized_count_details = Counter(
"missed_block_proposals_finalized_count_details",
"Missed block proposals finalized count details",
["slot", "epoch"],
)


def process_missed_blocks_head(
beacon: Beacon,
Expand Down Expand Up @@ -99,8 +87,7 @@ def process_missed_blocks_head(
slack.send_message(message_slack)

if is_our_validator and missed:
missed_block_proposals_head_count.inc()
missed_block_proposals_head_count_details.labels(slot=slot, epoch=epoch).inc()
metric_missed_block_proposals_head_count.inc()

return is_our_validator

Expand Down Expand Up @@ -178,10 +165,6 @@ def process_missed_blocks_finalized(

slack.send_message(message_slack)

missed_block_proposals_finalized_count.inc()

missed_block_proposals_finalized_count_details.labels(
slot=slot_, epoch=epoch
).inc()
metric_missed_block_proposals_finalized_count.inc()

return last_finalized_slot
4 changes: 2 additions & 2 deletions eth_validator_watcher/next_blocks_proposal.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

print = functools.partial(print, flush=True)

future_block_proposals_count = Gauge(
metric_future_block_proposals_count = Gauge(
"future_block_proposals_count",
"Future block proposals count",
)
Expand Down Expand Up @@ -43,7 +43,7 @@ def process_future_blocks_proposal(
if item.pubkey in our_pubkeys and item.slot >= slot
]

future_block_proposals_count.set(len(filtered))
metric_future_block_proposals_count.set(len(filtered))

if is_new_epoch:
for item in filtered:
Expand Down
4 changes: 2 additions & 2 deletions eth_validator_watcher/relays.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
MAX_TRIALS = 5
WAIT_SEC = 0.5

bad_relay_count = Counter(
metric_bad_relay_count = Counter(
"bad_relay_count",
"Bad relay count",
)
Expand Down Expand Up @@ -54,7 +54,7 @@ def process(self, slot: int) -> None:
for relay_url in self.__urls
)
):
bad_relay_count.inc()
metric_bad_relay_count.inc()
print(
"🟧 Block proposed with unknown builder (may be a locally built block)"
)
Expand Down
Loading