From 92f92bd985baf8fdb6f322963b74360be08286fc Mon Sep 17 00:00:00 2001 From: "s. rannou" Date: Mon, 13 Nov 2023 14:26:40 +0100 Subject: [PATCH 01/17] feat: remove slot/epoch labels as it's consuming with cardinality --- eth_validator_watcher/entrypoint.py | 1 + eth_validator_watcher/missed_blocks.py | 17 ----------------- .../test_process_missed_blocks_head.py | 15 --------------- 3 files changed, 1 insertion(+), 32 deletions(-) diff --git a/eth_validator_watcher/entrypoint.py b/eth_validator_watcher/entrypoint.py index cc04f6a..8496e39 100644 --- a/eth_validator_watcher/entrypoint.py +++ b/eth_validator_watcher/entrypoint.py @@ -1,3 +1,4 @@ + """Entrypoint for the eth-validator-watcher CLI.""" import functools diff --git a/eth_validator_watcher/missed_blocks.py b/eth_validator_watcher/missed_blocks.py index 7c5aec6..bc8d490 100644 --- a/eth_validator_watcher/missed_blocks.py +++ b/eth_validator_watcher/missed_blocks.py @@ -15,23 +15,11 @@ "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( "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, @@ -100,7 +88,6 @@ def process_missed_blocks_head( if is_our_validator and missed: missed_block_proposals_head_count.inc() - missed_block_proposals_head_count_details.labels(slot=slot, epoch=epoch).inc() return is_our_validator @@ -180,8 +167,4 @@ def process_missed_blocks_finalized( missed_block_proposals_finalized_count.inc() - missed_block_proposals_finalized_count_details.labels( - slot=slot_, epoch=epoch - ).inc() - return last_finalized_slot diff --git a/tests/missed_blocks_head/test_process_missed_blocks_head.py b/tests/missed_blocks_head/test_process_missed_blocks_head.py index aedce28..bdc03df 100644 --- a/tests/missed_blocks_head/test_process_missed_blocks_head.py +++ b/tests/missed_blocks_head/test_process_missed_blocks_head.py @@ -1,6 +1,5 @@ from eth_validator_watcher.missed_blocks import ( missed_block_proposals_head_count, - missed_block_proposals_head_count_details, process_missed_blocks_head, ) from eth_validator_watcher.models import ProposerDuties @@ -35,16 +34,9 @@ def send_message(self, _: str) -> None: assert process_missed_blocks_head(Beacon(), None, 3, {"0xaaa", "0xddd"}, slack) # type: ignore counter_after = missed_block_proposals_head_count.collect()[0].samples[0].value # type: ignore - # Has sample for slot - has_slot_metric = False - for sample in missed_block_proposals_head_count_details.collect()[0].samples: # type: ignore - if sample.labels["slot"] == "3": - has_slot_metric = True - delta = counter_after - counter_before assert delta == 1 assert slack.counter == 1 - assert has_slot_metric def test_process_missed_blocks_head_habemus_blockam() -> None: @@ -76,13 +68,6 @@ def send_message(self, _: str) -> None: assert not process_missed_blocks_head(Beacon(), "A BLOCK", 2, {"0xaaa", "0xddd"}, slack) # type: ignore counter_after = missed_block_proposals_head_count.collect()[0].samples[0].value # type: ignore - # Has sample for slot - has_slot_metric = False - for sample in missed_block_proposals_head_count_details.collect()[0].samples: # type: ignore - if sample.labels["slot"] == "2": - has_slot_metric = True - delta = counter_after - counter_before assert delta == 0 assert slack.counter == 0 - assert not (has_slot_metric) From a8af3451945c1407030b212bcf284b0dfcc0871e Mon Sep 17 00:00:00 2001 From: "s. rannou" Date: Mon, 13 Nov 2023 14:27:30 +0100 Subject: [PATCH 02/17] feat: update documentation according to slot/epoch label removal --- README.md | 2 -- eth_validator_watcher/entrypoint.py | 1 - 2 files changed, 3 deletions(-) diff --git a/README.md b/README.md index 556ff6d..d27a475 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/eth_validator_watcher/entrypoint.py b/eth_validator_watcher/entrypoint.py index 8496e39..cc04f6a 100644 --- a/eth_validator_watcher/entrypoint.py +++ b/eth_validator_watcher/entrypoint.py @@ -1,4 +1,3 @@ - """Entrypoint for the eth-validator-watcher CLI.""" import functools From 991ca2e74b85c6942c1ab0d8b645a0b3678ad690 Mon Sep 17 00:00:00 2001 From: "s. rannou" Date: Mon, 20 Nov 2023 10:59:13 +0100 Subject: [PATCH 03/17] feat: prefix coinbase metrics with metric_ --- eth_validator_watcher/coinbase.py | 4 ++-- tests/coinbase/test_emit_eth_usd_conversion_rate.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/eth_validator_watcher/coinbase.py b/eth_validator_watcher/coinbase.py index 562f1bc..9fde9e9 100644 --- a/eth_validator_watcher/coinbase.py +++ b/eth_validator_watcher/coinbase.py @@ -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: @@ -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 diff --git a/tests/coinbase/test_emit_eth_usd_conversion_rate.py b/tests/coinbase/test_emit_eth_usd_conversion_rate.py index 28e31ab..2aefc0d 100644 --- a/tests/coinbase/test_emit_eth_usd_conversion_rate.py +++ b/tests/coinbase/test_emit_eth_usd_conversion_rate.py @@ -1,6 +1,6 @@ from requests_mock import Mocker -from eth_validator_watcher.coinbase import Coinbase, eth_usd_gauge +from eth_validator_watcher.coinbase import Coinbase, metric_eth_usd_gauge def test_emit_eth_usd_conversion_rate_success() -> None: @@ -21,7 +21,7 @@ def test_emit_eth_usd_conversion_rate_success() -> None: ) coinbase.emit_eth_usd_conversion_rate() - assert eth_usd_gauge.collect()[0].samples[0].value == 1791.86 # type: ignore + assert metric_eth_usd_gauge.collect()[0].samples[0].value == 1791.86 # type: ignore def test_emit_eth_usd_conversion_rate_error() -> None: From 45910389632987af9888da82392d0179b15cace5 Mon Sep 17 00:00:00 2001 From: "s. rannou" Date: Mon, 20 Nov 2023 10:59:27 +0100 Subject: [PATCH 04/17] feat: add dummy Makefile to run tests --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a40c4b6 --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +all: + +test: + poetry run pytest From 57ad1a8f37c9a19ccffbac359b5069bde6968924 Mon Sep 17 00:00:00 2001 From: "s. rannou" Date: Mon, 20 Nov 2023 10:59:41 +0100 Subject: [PATCH 05/17] feat: add coverage.xml to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 2ed77d4..50f21df 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ __pycache__ .mypy_cache .coverage .idea +coverage.xml \ No newline at end of file From 9efb1c7fffd480a9af5c6abe7e430b4fd761a3d6 Mon Sep 17 00:00:00 2001 From: "s. rannou" Date: Mon, 20 Nov 2023 11:06:06 +0100 Subject: [PATCH 06/17] feat: prefix gauge/slot metrics --- eth_validator_watcher/entrypoint.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/eth_validator_watcher/entrypoint.py b/eth_validator_watcher/entrypoint.py index cc04f6a..50b932f 100644 --- a/eth_validator_watcher/entrypoint.py +++ b/eth_validator_watcher/entrypoint.py @@ -50,8 +50,8 @@ 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( "our_pending_queued_validators_count", @@ -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 From e66c2873b20fc98902f00381184b736544b06f7c Mon Sep 17 00:00:00 2001 From: "s. rannou" Date: Mon, 20 Nov 2023 11:12:33 +0100 Subject: [PATCH 07/17] feat: prefix queue and active validator metrics --- eth_validator_watcher/entrypoint.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/eth_validator_watcher/entrypoint.py b/eth_validator_watcher/entrypoint.py index 50b932f..a79c7bc 100644 --- a/eth_validator_watcher/entrypoint.py +++ b/eth_validator_watcher/entrypoint.py @@ -53,22 +53,22 @@ 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", ) @@ -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, {}) @@ -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, {}) @@ -316,7 +316,7 @@ 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, {}) @@ -324,7 +324,7 @@ def _handler( 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, {}) From baf5179e745225a27066fbe9f2380f41d99fb070 Mon Sep 17 00:00:00 2001 From: "s. rannou" Date: Mon, 20 Nov 2023 11:14:22 +0100 Subject: [PATCH 08/17] feat: prefix queue time duration metric --- eth_validator_watcher/entry_queue.py | 4 ++-- tests/entry_queue/test_export_duration_sec.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/eth_validator_watcher/entry_queue.py b/eth_validator_watcher/entry_queue.py index 6ff6d72..b2a391b 100644 --- a/eth_validator_watcher/entry_queue.py +++ b/eth_validator_watcher/entry_queue.py @@ -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", ) @@ -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) diff --git a/tests/entry_queue/test_export_duration_sec.py b/tests/entry_queue/test_export_duration_sec.py index 310973a..cb903b1 100644 --- a/tests/entry_queue/test_export_duration_sec.py +++ b/tests/entry_queue/test_export_duration_sec.py @@ -1,9 +1,9 @@ from eth_validator_watcher.entry_queue import ( - entry_queue_duration_sec, + metric_entry_queue_duration_sec, export_duration_sec, ) def test_export_duration_sec() -> None: export_duration_sec(0, 8) - assert entry_queue_duration_sec.collect()[0].samples[0].value == 768 # type: ignore + assert metric_entry_queue_duration_sec.collect()[0].samples[0].value == 768 # type: ignore From 3a7daddeba0239c25a16d7997925007fcbcf38ed Mon Sep 17 00:00:00 2001 From: "s. rannou" Date: Mon, 20 Nov 2023 11:21:56 +0100 Subject: [PATCH 09/17] feat: prefix exited validators metric --- eth_validator_watcher/exited_validators.py | 4 ++-- tests/exited_validators/test_process_exited_validators.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/eth_validator_watcher/exited_validators.py b/eth_validator_watcher/exited_validators.py index f568034..57de772 100644 --- a/eth_validator_watcher/exited_validators.py +++ b/eth_validator_watcher/exited_validators.py @@ -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", ) @@ -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 diff --git a/tests/exited_validators/test_process_exited_validators.py b/tests/exited_validators/test_process_exited_validators.py index 2865ef7..3a2e33a 100644 --- a/tests/exited_validators/test_process_exited_validators.py +++ b/tests/exited_validators/test_process_exited_validators.py @@ -1,6 +1,6 @@ from eth_validator_watcher.exited_validators import ( ExitedValidators, - our_exited_validators_count, + metric_our_exited_validators_count, ) from eth_validator_watcher.models import Validators @@ -33,7 +33,7 @@ def send_message(self, _: str) -> None: our_exited_unslashed_index_to_validator, our_withdrawal_index_to_validator ) - assert our_exited_validators_count.collect()[0].samples[0].value == 3 # type: ignore + assert metric_our_exited_validators_count.collect()[0].samples[0].value == 3 # type: ignore assert slack.counter == 0 assert ( @@ -50,7 +50,7 @@ def send_message(self, _: str) -> None: our_exited_unslashed_index_to_validator, our_withdrawal_index_to_validator ) - assert our_exited_validators_count.collect()[0].samples[0].value == 4 # type: ignore + assert metric_our_exited_validators_count.collect()[0].samples[0].value == 4 # type: ignore assert slack.counter == 1 assert ( From da5331a7acf1db059ada1b8b0c6ab68163a398cc Mon Sep 17 00:00:00 2001 From: "s. rannou" Date: Mon, 20 Nov 2023 11:28:34 +0100 Subject: [PATCH 10/17] feat: prefix wrong fee recipient count --- eth_validator_watcher/fee_recipient.py | 4 +-- .../test_process_fee_recipient.py | 28 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/eth_validator_watcher/fee_recipient.py b/eth_validator_watcher/fee_recipient.py index d3b3b40..d459a5a 100644 --- a/eth_validator_watcher/fee_recipient.py +++ b/eth_validator_watcher/fee_recipient.py @@ -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", ) @@ -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() diff --git a/tests/fee_recipient/test_process_fee_recipient.py b/tests/fee_recipient/test_process_fee_recipient.py index 485b151..f0d0f45 100644 --- a/tests/fee_recipient/test_process_fee_recipient.py +++ b/tests/fee_recipient/test_process_fee_recipient.py @@ -5,7 +5,7 @@ from eth_validator_watcher.fee_recipient import ( process_fee_recipient, - wrong_fee_recipient_proposed_block_count, + metric_wrong_fee_recipient_proposed_block_count, ) from eth_validator_watcher.models import Block, ExecutionBlock, Validators from tests.fee_recipient import assets @@ -56,7 +56,7 @@ def block() -> Block: def test_execution_is_none(): slack = Slack() - counter_before = wrong_fee_recipient_proposed_block_count.collect()[0].samples[0].value # type: ignore + counter_before = metric_wrong_fee_recipient_proposed_block_count.collect()[0].samples[0].value # type: ignore process_fee_recipient( block="A block", # type: ignore @@ -66,7 +66,7 @@ def test_execution_is_none(): slack=slack, # type: ignore ) - counter_after = wrong_fee_recipient_proposed_block_count.collect()[0].samples[0].value # type: ignore + counter_after = metric_wrong_fee_recipient_proposed_block_count.collect()[0].samples[0].value # type: ignore assert counter_after == counter_before assert slack.counter == 0 @@ -74,7 +74,7 @@ def test_execution_is_none(): def test_fee_recipient_is_none(): slack = Slack() - counter_before = wrong_fee_recipient_proposed_block_count.collect()[0].samples[0].value # type: ignore + counter_before = metric_wrong_fee_recipient_proposed_block_count.collect()[0].samples[0].value # type: ignore process_fee_recipient( block="A block", # type: ignore @@ -89,7 +89,7 @@ def test_fee_recipient_is_none(): def test_not_our_validator(block: Block): slack = Slack() - counter_before = wrong_fee_recipient_proposed_block_count.collect()[0].samples[0].value # type: ignore + counter_before = metric_wrong_fee_recipient_proposed_block_count.collect()[0].samples[0].value # type: ignore process_fee_recipient( block=block, @@ -99,7 +99,7 @@ def test_not_our_validator(block: Block): slack=slack, # type: ignore ) - counter_after = wrong_fee_recipient_proposed_block_count.collect()[0].samples[0].value # type: ignore + counter_after = metric_wrong_fee_recipient_proposed_block_count.collect()[0].samples[0].value # type: ignore assert counter_after == counter_before assert slack.counter == 0 @@ -107,7 +107,7 @@ def test_not_our_validator(block: Block): def test_our_validator_allright(block: Block): slack = Slack() - counter_before = wrong_fee_recipient_proposed_block_count.collect()[0].samples[0].value # type: ignore + counter_before = metric_wrong_fee_recipient_proposed_block_count.collect()[0].samples[0].value # type: ignore process_fee_recipient( block=block, @@ -121,7 +121,7 @@ def test_our_validator_allright(block: Block): slack=slack, # type: ignore ) - counter_after = wrong_fee_recipient_proposed_block_count.collect()[0].samples[0].value # type: ignore + counter_after = metric_wrong_fee_recipient_proposed_block_count.collect()[0].samples[0].value # type: ignore assert counter_after == counter_before assert slack.counter == 0 @@ -129,7 +129,7 @@ def test_our_validator_allright(block: Block): def test_our_validator_ok_in_last_tx(block: Block): slack = Slack() - counter_before = wrong_fee_recipient_proposed_block_count.collect()[0].samples[0].value # type: ignore + counter_before = metric_wrong_fee_recipient_proposed_block_count.collect()[0].samples[0].value # type: ignore process_fee_recipient( block=block, @@ -143,7 +143,7 @@ def test_our_validator_ok_in_last_tx(block: Block): slack=slack, # type: ignore ) - counter_after = wrong_fee_recipient_proposed_block_count.collect()[0].samples[0].value # type: ignore + counter_after = metric_wrong_fee_recipient_proposed_block_count.collect()[0].samples[0].value # type: ignore assert counter_after == counter_before assert slack.counter == 0 @@ -151,7 +151,7 @@ def test_our_validator_ok_in_last_tx(block: Block): def test_our_validator_not_ok_empty_block(block: Block): slack = Slack() - counter_before = wrong_fee_recipient_proposed_block_count.collect()[0].samples[0].value # type: ignore + counter_before = metric_wrong_fee_recipient_proposed_block_count.collect()[0].samples[0].value # type: ignore process_fee_recipient( block=block, @@ -165,7 +165,7 @@ def test_our_validator_not_ok_empty_block(block: Block): slack=slack, # type: ignore ) - counter_after = wrong_fee_recipient_proposed_block_count.collect()[0].samples[0].value # type: ignore + counter_after = metric_wrong_fee_recipient_proposed_block_count.collect()[0].samples[0].value # type: ignore assert counter_after == counter_before + 1 assert slack.counter == 1 @@ -173,7 +173,7 @@ def test_our_validator_not_ok_empty_block(block: Block): def test_our_validator_not_ok(block: Block): slack = Slack() - counter_before = wrong_fee_recipient_proposed_block_count.collect()[0].samples[0].value # type: ignore + counter_before = metric_wrong_fee_recipient_proposed_block_count.collect()[0].samples[0].value # type: ignore process_fee_recipient( block=block, @@ -187,7 +187,7 @@ def test_our_validator_not_ok(block: Block): slack=slack, # type: ignore ) - counter_after = wrong_fee_recipient_proposed_block_count.collect()[0].samples[0].value # type: ignore + counter_after = metric_wrong_fee_recipient_proposed_block_count.collect()[0].samples[0].value # type: ignore assert counter_after == counter_before + 1 assert slack.counter == 1 From 54fa8cf3073537d04f3304dae58ad9d2f9e94189 Mon Sep 17 00:00:00 2001 From: "s. rannou" Date: Mon, 20 Nov 2023 11:37:01 +0100 Subject: [PATCH 11/17] feat: prefix missed blocks metrics --- eth_validator_watcher/missed_attestations.py | 8 ++++---- eth_validator_watcher/missed_blocks.py | 8 ++++---- .../test_process_missed_blocks_finalized.py | 6 +++--- .../test_process_missed_blocks_head.py | 10 +++++----- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/eth_validator_watcher/missed_attestations.py b/eth_validator_watcher/missed_attestations.py index 5df6b34..896eafd 100644 --- a/eth_validator_watcher/missed_attestations.py +++ b/eth_validator_watcher/missed_attestations.py @@ -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", ) @@ -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() @@ -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() diff --git a/eth_validator_watcher/missed_blocks.py b/eth_validator_watcher/missed_blocks.py index bc8d490..5bfebd5 100644 --- a/eth_validator_watcher/missed_blocks.py +++ b/eth_validator_watcher/missed_blocks.py @@ -10,12 +10,12 @@ 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_finalized_count = Counter( +metric_missed_block_proposals_finalized_count = Counter( "missed_block_proposals_finalized_count", "Missed block proposals finalized count", ) @@ -87,7 +87,7 @@ def process_missed_blocks_head( slack.send_message(message_slack) if is_our_validator and missed: - missed_block_proposals_head_count.inc() + metric_missed_block_proposals_head_count.inc() return is_our_validator @@ -165,6 +165,6 @@ def process_missed_blocks_finalized( slack.send_message(message_slack) - missed_block_proposals_finalized_count.inc() + metric_missed_block_proposals_finalized_count.inc() return last_finalized_slot diff --git a/tests/missed_blocks_finalized/test_process_missed_blocks_finalized.py b/tests/missed_blocks_finalized/test_process_missed_blocks_finalized.py index a034fa7..c206d77 100644 --- a/tests/missed_blocks_finalized/test_process_missed_blocks_finalized.py +++ b/tests/missed_blocks_finalized/test_process_missed_blocks_finalized.py @@ -5,7 +5,7 @@ from eth_validator_watcher.beacon import NoBlockError from eth_validator_watcher.missed_blocks import ( - missed_block_proposals_finalized_count, + metric_missed_block_proposals_finalized_count, process_missed_blocks_finalized, ) from eth_validator_watcher.models import BlockIdentierType, Header, ProposerDuties @@ -174,7 +174,7 @@ def get_proposer_duties(epoch: int) -> ProposerDuties: beacon = Beacon() slack = Slack() - counter_before = missed_block_proposals_finalized_count.collect()[0].samples[0].value # type: ignore + counter_before = metric_missed_block_proposals_finalized_count.collect()[0].samples[0].value # type: ignore assert ( process_missed_blocks_finalized( @@ -198,7 +198,7 @@ def get_proposer_duties(epoch: int) -> ProposerDuties: == 100 ) - counter_after = missed_block_proposals_finalized_count.collect()[0].samples[0].value # type: ignore + counter_after = metric_missed_block_proposals_finalized_count.collect()[0].samples[0].value # type: ignore delta = counter_after - counter_before assert delta == 2 assert slack.counter == 2 diff --git a/tests/missed_blocks_head/test_process_missed_blocks_head.py b/tests/missed_blocks_head/test_process_missed_blocks_head.py index bdc03df..2768715 100644 --- a/tests/missed_blocks_head/test_process_missed_blocks_head.py +++ b/tests/missed_blocks_head/test_process_missed_blocks_head.py @@ -1,5 +1,5 @@ from eth_validator_watcher.missed_blocks import ( - missed_block_proposals_head_count, + metric_missed_block_proposals_head_count, process_missed_blocks_head, ) from eth_validator_watcher.models import ProposerDuties @@ -30,9 +30,9 @@ def send_message(self, _: str) -> None: slack = Slack() - counter_before = missed_block_proposals_head_count.collect()[0].samples[0].value # type: ignore + counter_before = metric_missed_block_proposals_head_count.collect()[0].samples[0].value # type: ignore assert process_missed_blocks_head(Beacon(), None, 3, {"0xaaa", "0xddd"}, slack) # type: ignore - counter_after = missed_block_proposals_head_count.collect()[0].samples[0].value # type: ignore + counter_after = metric_missed_block_proposals_head_count.collect()[0].samples[0].value # type: ignore delta = counter_after - counter_before assert delta == 1 @@ -64,9 +64,9 @@ def send_message(self, _: str) -> None: slack = Slack() - counter_before = missed_block_proposals_head_count.collect()[0].samples[0].value # type: ignore + counter_before = metric_missed_block_proposals_head_count.collect()[0].samples[0].value # type: ignore assert not process_missed_blocks_head(Beacon(), "A BLOCK", 2, {"0xaaa", "0xddd"}, slack) # type: ignore - counter_after = missed_block_proposals_head_count.collect()[0].samples[0].value # type: ignore + counter_after = metric_missed_block_proposals_head_count.collect()[0].samples[0].value # type: ignore delta = counter_after - counter_before assert delta == 0 From 7f22722a4a116feda6f197cb0d088c2fab7a0732 Mon Sep 17 00:00:00 2001 From: "s. rannou" Date: Mon, 20 Nov 2023 11:37:40 +0100 Subject: [PATCH 12/17] feat: prefix future block proposal --- eth_validator_watcher/next_blocks_proposal.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eth_validator_watcher/next_blocks_proposal.py b/eth_validator_watcher/next_blocks_proposal.py index 7234b95..3a06fe5 100644 --- a/eth_validator_watcher/next_blocks_proposal.py +++ b/eth_validator_watcher/next_blocks_proposal.py @@ -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", ) @@ -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: From f9817232713689fcf1b30c44620ca8f80ad234c7 Mon Sep 17 00:00:00 2001 From: "s. rannou" Date: Mon, 20 Nov 2023 11:38:30 +0100 Subject: [PATCH 13/17] feat: prefix bad relay count --- eth_validator_watcher/relays.py | 4 ++-- tests/relays/test_process.py | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/eth_validator_watcher/relays.py b/eth_validator_watcher/relays.py index 09ca987..d92678b 100644 --- a/eth_validator_watcher/relays.py +++ b/eth_validator_watcher/relays.py @@ -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", ) @@ -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)" ) diff --git a/tests/relays/test_process.py b/tests/relays/test_process.py index 2bfe2b5..84abeba 100644 --- a/tests/relays/test_process.py +++ b/tests/relays/test_process.py @@ -2,14 +2,14 @@ from requests.exceptions import ConnectionError from requests_mock import Mocker -from eth_validator_watcher.relays import Relays, bad_relay_count +from eth_validator_watcher.relays import Relays, metric_bad_relay_count def test_process_no_relay() -> None: - counter_before = bad_relay_count.collect()[0].samples[0].value # type: ignore + counter_before = metric_bad_relay_count.collect()[0].samples[0].value # type: ignore relays = Relays(urls=[]) relays.process(slot=42) - counter_after = bad_relay_count.collect()[0].samples[0].value # type: ignore + counter_after = metric_bad_relay_count.collect()[0].samples[0].value # type: ignore delta = counter_after - counter_before assert delta == 0 @@ -18,7 +18,7 @@ def test_process_no_relay() -> None: def test_process_bad_relay() -> None: relays = Relays(urls=["http://relay-1.com", "http://relay-2.com"]) - counter_before = bad_relay_count.collect()[0].samples[0].value # type: ignore + counter_before = metric_bad_relay_count.collect()[0].samples[0].value # type: ignore with Mocker() as mock: mock.get( @@ -33,7 +33,7 @@ def test_process_bad_relay() -> None: relays.process(slot=42) - counter_after = bad_relay_count.collect()[0].samples[0].value # type: ignore + counter_after = metric_bad_relay_count.collect()[0].samples[0].value # type: ignore delta = counter_after - counter_before assert delta == 1 @@ -41,7 +41,7 @@ def test_process_bad_relay() -> None: def test_process_good_relay() -> None: relays = Relays(urls=["http://relay-1.com", "http://relay-2.com"]) - counter_before = bad_relay_count.collect()[0].samples[0].value # type: ignore + counter_before = metric_bad_relay_count.collect()[0].samples[0].value # type: ignore with Mocker() as mock: mock.get( @@ -56,7 +56,7 @@ def test_process_good_relay() -> None: relays.process(slot=42) - counter_after = bad_relay_count.collect()[0].samples[0].value # type: ignore + counter_after = metric_bad_relay_count.collect()[0].samples[0].value # type: ignore delta = counter_after - counter_before assert delta == 0 From 6eec93f6fb4a9a68b194f3e05c49bba17a2e3b6c Mon Sep 17 00:00:00 2001 From: "s. rannou" Date: Mon, 20 Nov 2023 11:50:38 +0100 Subject: [PATCH 14/17] feat: prefix rewards metrics --- eth_validator_watcher/rewards.py | 88 +++++++------- tests/rewards/test_process_rewards_net.py | 136 +++++++++++----------- tests/rewards/test_process_rewards_our.py | 136 +++++++++++----------- 3 files changed, 180 insertions(+), 180 deletions(-) diff --git a/eth_validator_watcher/rewards.py b/eth_validator_watcher/rewards.py index f130963..6ddf400 100644 --- a/eth_validator_watcher/rewards.py +++ b/eth_validator_watcher/rewards.py @@ -17,9 +17,9 @@ # Network validators # ------------------ ( - net_suboptimal_sources_rate_gauge, - net_suboptimal_targets_rate_gauge, - net_suboptimal_heads_rate_gauge, + metric_net_suboptimal_sources_rate_gauge, + metric_net_suboptimal_targets_rate_gauge, + metric_net_suboptimal_heads_rate_gauge, ) = ( Gauge("net_suboptimal_sources_rate", "Network suboptimal sources rate"), Gauge("net_suboptimal_targets_rate", "Network suboptimal targets rate"), @@ -27,9 +27,9 @@ ) ( - net_ideal_sources_count, - net_ideal_targets_count, - net_ideal_heads_count, + metric_net_ideal_sources_count, + metric_net_ideal_targets_count, + metric_net_ideal_heads_count, ) = ( Counter("net_ideal_sources_count", "Network ideal sources count"), Counter("net_ideal_targets_count", "Network ideal targets count"), @@ -37,11 +37,11 @@ ) ( - net_actual_pos_sources_count, - net_actual_neg_sources_count, - net_actual_pos_targets_count, - net_actual_neg_targets_count, - net_actual_heads_count, + metric_net_actual_pos_sources_count, + metric_net_actual_neg_sources_count, + metric_net_actual_pos_targets_count, + metric_net_actual_neg_targets_count, + metric_net_actual_heads_count, ) = ( Counter("net_actual_pos_sources_count", "Network actual positive sources count"), Counter("net_actual_neg_sources_count", "Network actual negative sources count"), @@ -53,9 +53,9 @@ # Our validators # -------------- ( - our_suboptimal_sources_rate_gauge, - our_suboptimal_targets_rate_gauge, - our_suboptimal_heads_rate_gauge, + metric_our_suboptimal_sources_rate_gauge, + metric_our_suboptimal_targets_rate_gauge, + metric_our_suboptimal_heads_rate_gauge, ) = ( Gauge("our_suboptimal_sources_rate", "Our suboptimal sources rate"), Gauge("our_suboptimal_targets_rate", "Our suboptimal targets rate"), @@ -63,9 +63,9 @@ ) ( - our_ideal_sources_count, - our_ideal_targets_count, - our_ideal_heads_count, + metric_our_ideal_sources_count, + metric_our_ideal_targets_count, + metric_our_ideal_heads_count, ) = ( Counter("our_ideal_sources_count", "Our ideal sources count"), Counter("our_ideal_targets_count", "Our ideal targets count"), @@ -73,11 +73,11 @@ ) ( - our_actual_pos_sources_count, - our_actual_neg_sources_count, - our_actual_pos_targets_count, - our_actual_neg_targets_count, - our_actual_heads_count, + metric_our_actual_pos_sources_count, + metric_our_actual_neg_sources_count, + metric_our_actual_pos_targets_count, + metric_our_actual_neg_targets_count, + metric_our_actual_heads_count, ) = ( Counter("our_actual_pos_sources_count", "Our actual positive sources count"), Counter("our_actual_neg_sources_count", "Our actual negative sources count"), @@ -198,35 +198,35 @@ def process_rewards( total_ideal_targets = sum(ideal_targets) total_ideal_heads = sum(ideal_heads) - net_ideal_sources_count.inc(total_ideal_sources) - net_ideal_targets_count.inc(total_ideal_targets) - net_ideal_heads_count.inc(total_ideal_heads) + metric_net_ideal_sources_count.inc(total_ideal_sources) + metric_net_ideal_targets_count.inc(total_ideal_targets) + metric_net_ideal_heads_count.inc(total_ideal_heads) total_actual_sources = sum(actual_sources) total_actual_targets = sum(actual_targets) total_actual_heads = sum(actual_heads) ( - net_actual_pos_sources_count + metric_net_actual_pos_sources_count if total_actual_sources >= 0 - else net_actual_neg_sources_count + else metric_net_actual_neg_sources_count ).inc(abs(total_actual_sources)) ( - net_actual_pos_targets_count + metric_net_actual_pos_targets_count if total_actual_targets >= 0 - else net_actual_neg_targets_count + else metric_net_actual_neg_targets_count ).inc(abs(total_actual_targets)) - net_actual_heads_count.inc(total_actual_heads) + metric_net_actual_heads_count.inc(total_actual_heads) suboptimal_sources_rate = 1 - sum(are_sources_ideal) / len(are_sources_ideal) suboptimal_targets_rate = 1 - sum(are_targets_ideal) / len(are_targets_ideal) suboptimal_heads_rate = 1 - sum(are_heads_ideal) / len(are_heads_ideal) - net_suboptimal_sources_rate_gauge.set(suboptimal_sources_rate) - net_suboptimal_targets_rate_gauge.set(suboptimal_targets_rate) - net_suboptimal_heads_rate_gauge.set(suboptimal_heads_rate) + metric_net_suboptimal_sources_rate_gauge.set(suboptimal_sources_rate) + metric_net_suboptimal_targets_rate_gauge.set(suboptimal_targets_rate) + metric_net_suboptimal_heads_rate_gauge.set(suboptimal_heads_rate) # Our validators # -------------- @@ -278,35 +278,35 @@ def process_rewards( total_ideal_targets = sum(ideal_targets) total_ideal_heads = sum(ideal_heads) - our_ideal_sources_count.inc(total_ideal_sources) - our_ideal_targets_count.inc(total_ideal_targets) - our_ideal_heads_count.inc(total_ideal_heads) + metric_our_ideal_sources_count.inc(total_ideal_sources) + metric_our_ideal_targets_count.inc(total_ideal_targets) + metric_our_ideal_heads_count.inc(total_ideal_heads) total_actual_sources = sum(actual_sources) total_actual_targets = sum(actual_targets) total_actual_heads = sum(actual_heads) ( - our_actual_pos_sources_count + metric_our_actual_pos_sources_count if total_actual_sources >= 0 - else our_actual_neg_sources_count + else metric_our_actual_neg_sources_count ).inc(abs(total_actual_sources)) ( - our_actual_pos_targets_count + metric_our_actual_pos_targets_count if total_actual_targets >= 0 - else our_actual_neg_targets_count + else metric_our_actual_neg_targets_count ).inc(abs(total_actual_targets)) - our_actual_heads_count.inc(total_actual_heads) + metric_our_actual_heads_count.inc(total_actual_heads) suboptimal_sources_rate = 1 - sum(are_sources_ideal) / len(are_sources_ideal) suboptimal_targets_rate = 1 - sum(are_targets_ideal) / len(are_targets_ideal) suboptimal_heads_rate = 1 - sum(are_heads_ideal) / len(are_heads_ideal) - our_suboptimal_sources_rate_gauge.set(suboptimal_sources_rate) - our_suboptimal_targets_rate_gauge.set(suboptimal_targets_rate) - our_suboptimal_heads_rate_gauge.set(suboptimal_heads_rate) + metric_our_suboptimal_sources_rate_gauge.set(suboptimal_sources_rate) + metric_our_suboptimal_targets_rate_gauge.set(suboptimal_targets_rate) + metric_our_suboptimal_heads_rate_gauge.set(suboptimal_heads_rate) _log(pubkeys, are_sources_ideal, suboptimal_sources_rate, epoch, "🚰", "source") _log(pubkeys, are_targets_ideal, suboptimal_targets_rate, epoch, "🎯", "target") diff --git a/tests/rewards/test_process_rewards_net.py b/tests/rewards/test_process_rewards_net.py index bf823cb..2ef8cf3 100644 --- a/tests/rewards/test_process_rewards_net.py +++ b/tests/rewards/test_process_rewards_net.py @@ -2,17 +2,17 @@ from eth_validator_watcher.models import BeaconType, Rewards, Validators from eth_validator_watcher.rewards import ( - net_actual_heads_count, - net_actual_neg_sources_count, - net_actual_neg_targets_count, - net_actual_pos_sources_count, - net_actual_pos_targets_count, - net_ideal_heads_count, - net_ideal_sources_count, - net_ideal_targets_count, - net_suboptimal_heads_rate_gauge, - net_suboptimal_sources_rate_gauge, - net_suboptimal_targets_rate_gauge, + metric_net_actual_heads_count, + metric_net_actual_neg_sources_count, + metric_net_actual_neg_targets_count, + metric_net_actual_pos_sources_count, + metric_net_actual_pos_targets_count, + metric_net_ideal_heads_count, + metric_net_ideal_sources_count, + metric_net_ideal_targets_count, + metric_net_suboptimal_heads_rate_gauge, + metric_net_suboptimal_sources_rate_gauge, + metric_net_suboptimal_targets_rate_gauge, process_rewards, ) from eth_validator_watcher.utils import LimitedDict @@ -90,15 +90,15 @@ def get_rewards( beacon = Beacon() - ideal_sources_count_before = net_ideal_sources_count.collect()[0].samples[0].value # type: ignore - ideal_targets_count_before = net_ideal_targets_count.collect()[0].samples[0].value # type: ignore - ideal_heads_count_before = net_ideal_heads_count.collect()[0].samples[0].value # type: ignore + ideal_sources_count_before = metric_net_ideal_sources_count.collect()[0].samples[0].value # type: ignore + ideal_targets_count_before = metric_net_ideal_targets_count.collect()[0].samples[0].value # type: ignore + ideal_heads_count_before = metric_net_ideal_heads_count.collect()[0].samples[0].value # type: ignore - actual_positive_sources_count_before = net_actual_pos_sources_count.collect()[0].samples[0].value # type: ignore - actual_negative_sources_count_before = net_actual_neg_sources_count.collect()[0].samples[0].value # type: ignore - actual_positive_targets_count_before = net_actual_pos_targets_count.collect()[0].samples[0].value # type: ignore - actual_negative_targets_count_before = net_actual_neg_targets_count.collect()[0].samples[0].value # type: ignore - actual_heads_count_before = net_actual_heads_count.collect()[0].samples[0].value # type: ignore + actual_positive_sources_count_before = metric_net_actual_pos_sources_count.collect()[0].samples[0].value # type: ignore + actual_negative_sources_count_before = metric_net_actual_neg_sources_count.collect()[0].samples[0].value # type: ignore + actual_positive_targets_count_before = metric_net_actual_pos_targets_count.collect()[0].samples[0].value # type: ignore + actual_negative_targets_count_before = metric_net_actual_neg_targets_count.collect()[0].samples[0].value # type: ignore + actual_heads_count_before = metric_net_actual_heads_count.collect()[0].samples[0].value # type: ignore net_epoch_to_index_to_validator = LimitedDict(2) net_epoch_to_index_to_validator[42] = { @@ -130,16 +130,16 @@ def get_rewards( our_epoch_to_index_to_validator, ) - ideal_sources_count_after = net_ideal_sources_count.collect()[0].samples[0].value # type: ignore - ideal_targets_count_after = net_ideal_targets_count.collect()[0].samples[0].value # type: ignore - ideal_heads_count_after = net_ideal_heads_count.collect()[0].samples[0].value # type: ignore + ideal_sources_count_after = metric_net_ideal_sources_count.collect()[0].samples[0].value # type: ignore + ideal_targets_count_after = metric_net_ideal_targets_count.collect()[0].samples[0].value # type: ignore + ideal_heads_count_after = metric_net_ideal_heads_count.collect()[0].samples[0].value # type: ignore - actual_positive_sources_count_after = net_actual_pos_sources_count.collect()[0].samples[0].value # type: ignore - actual_negative_sources_count_after = net_actual_neg_sources_count.collect()[0].samples[0].value # type: ignore - actual_positive_targets_count_after = net_actual_pos_targets_count.collect()[0].samples[0].value # type: ignore - actual_negative_targets_count_after = net_actual_neg_targets_count.collect()[0].samples[0].value # type: ignore + actual_positive_sources_count_after = metric_net_actual_pos_sources_count.collect()[0].samples[0].value # type: ignore + actual_negative_sources_count_after = metric_net_actual_neg_sources_count.collect()[0].samples[0].value # type: ignore + actual_positive_targets_count_after = metric_net_actual_pos_targets_count.collect()[0].samples[0].value # type: ignore + actual_negative_targets_count_after = metric_net_actual_neg_targets_count.collect()[0].samples[0].value # type: ignore - actual_heads_count_after = net_actual_heads_count.collect()[0].samples[0].value # type: ignore + actual_heads_count_after = metric_net_actual_heads_count.collect()[0].samples[0].value # type: ignore assert ideal_sources_count_after - ideal_sources_count_before == 9_090 assert ideal_targets_count_after - ideal_targets_count_before == 16_889 @@ -165,9 +165,9 @@ def get_rewards( assert actual_heads_count_after - actual_heads_count_before == 8_752 - assert isclose(net_suboptimal_sources_rate_gauge.collect()[0].samples[0].value, 0.0) # type: ignore - assert isclose(net_suboptimal_targets_rate_gauge.collect()[0].samples[0].value, 0.0) # type: ignore - assert isclose(net_suboptimal_heads_rate_gauge.collect()[0].samples[0].value, 0.0) # type: ignore + assert isclose(metric_net_suboptimal_sources_rate_gauge.collect()[0].samples[0].value, 0.0) # type: ignore + assert isclose(metric_net_suboptimal_targets_rate_gauge.collect()[0].samples[0].value, 0.0) # type: ignore + assert isclose(metric_net_suboptimal_heads_rate_gauge.collect()[0].samples[0].value, 0.0) # type: ignore def test_process_rewards_some_net_validators_are_ideal() -> None: @@ -242,15 +242,15 @@ def get_rewards( beacon = Beacon() - ideal_sources_count_before = net_ideal_sources_count.collect()[0].samples[0].value # type: ignore - ideal_targets_count_before = net_ideal_targets_count.collect()[0].samples[0].value # type: ignore - ideal_heads_count_before = net_ideal_heads_count.collect()[0].samples[0].value # type: ignore + ideal_sources_count_before = metric_net_ideal_sources_count.collect()[0].samples[0].value # type: ignore + ideal_targets_count_before = metric_net_ideal_targets_count.collect()[0].samples[0].value # type: ignore + ideal_heads_count_before = metric_net_ideal_heads_count.collect()[0].samples[0].value # type: ignore - actual_positive_sources_count_before = net_actual_pos_sources_count.collect()[0].samples[0].value # type: ignore - actual_negative_sources_count_before = net_actual_neg_sources_count.collect()[0].samples[0].value # type: ignore - actual_positive_targets_count_before = net_actual_pos_targets_count.collect()[0].samples[0].value # type: ignore - actual_negative_targets_count_before = net_actual_neg_targets_count.collect()[0].samples[0].value # type: ignore - actual_heads_count_before = net_actual_heads_count.collect()[0].samples[0].value # type: ignore + actual_positive_sources_count_before = metric_net_actual_pos_sources_count.collect()[0].samples[0].value # type: ignore + actual_negative_sources_count_before = metric_net_actual_neg_sources_count.collect()[0].samples[0].value # type: ignore + actual_positive_targets_count_before = metric_net_actual_pos_targets_count.collect()[0].samples[0].value # type: ignore + actual_negative_targets_count_before = metric_net_actual_neg_targets_count.collect()[0].samples[0].value # type: ignore + actual_heads_count_before = metric_net_actual_heads_count.collect()[0].samples[0].value # type: ignore net_epoch_to_index_to_validator = LimitedDict(2) net_epoch_to_index_to_validator[42] = { @@ -317,16 +317,16 @@ def get_rewards( our_epoch_to_index_to_validator, ) - ideal_sources_count_after = net_ideal_sources_count.collect()[0].samples[0].value # type: ignore - ideal_targets_count_after = net_ideal_targets_count.collect()[0].samples[0].value # type: ignore - ideal_heads_count_after = net_ideal_heads_count.collect()[0].samples[0].value # type: ignore + ideal_sources_count_after = metric_net_ideal_sources_count.collect()[0].samples[0].value # type: ignore + ideal_targets_count_after = metric_net_ideal_targets_count.collect()[0].samples[0].value # type: ignore + ideal_heads_count_after = metric_net_ideal_heads_count.collect()[0].samples[0].value # type: ignore - actual_positive_sources_count_after = net_actual_pos_sources_count.collect()[0].samples[0].value # type: ignore - actual_negative_sources_count_after = net_actual_neg_sources_count.collect()[0].samples[0].value # type: ignore - actual_positive_targets_count_after = net_actual_pos_targets_count.collect()[0].samples[0].value # type: ignore - actual_negative_targets_count_after = net_actual_neg_targets_count.collect()[0].samples[0].value # type: ignore + actual_positive_sources_count_after = metric_net_actual_pos_sources_count.collect()[0].samples[0].value # type: ignore + actual_negative_sources_count_after = metric_net_actual_neg_sources_count.collect()[0].samples[0].value # type: ignore + actual_positive_targets_count_after = metric_net_actual_pos_targets_count.collect()[0].samples[0].value # type: ignore + actual_negative_targets_count_after = metric_net_actual_neg_targets_count.collect()[0].samples[0].value # type: ignore - actual_heads_count_after = net_actual_heads_count.collect()[0].samples[0].value # type: ignore + actual_heads_count_after = metric_net_actual_heads_count.collect()[0].samples[0].value # type: ignore assert ideal_sources_count_after - ideal_sources_count_before == 30_524 assert ideal_targets_count_after - ideal_targets_count_before == 56_712 @@ -353,17 +353,17 @@ def get_rewards( assert actual_heads_count_after - actual_heads_count_before == 14_740 assert isclose( - net_suboptimal_sources_rate_gauge.collect()[0].samples[0].value, # type: ignore + metric_net_suboptimal_sources_rate_gauge.collect()[0].samples[0].value, # type: ignore 0.1, ) assert isclose( - net_suboptimal_targets_rate_gauge.collect()[0].samples[0].value, # type: ignore + metric_net_suboptimal_targets_rate_gauge.collect()[0].samples[0].value, # type: ignore 0.3, ) assert isclose( - net_suboptimal_heads_rate_gauge.collect()[0].samples[0].value, # type: ignore + metric_net_suboptimal_heads_rate_gauge.collect()[0].samples[0].value, # type: ignore 0.5, ) @@ -412,15 +412,15 @@ def get_rewards( beacon = Beacon() - ideal_sources_count_before = net_ideal_sources_count.collect()[0].samples[0].value # type: ignore - ideal_targets_count_before = net_ideal_targets_count.collect()[0].samples[0].value # type: ignore - ideal_heads_count_before = net_ideal_heads_count.collect()[0].samples[0].value # type: ignore + ideal_sources_count_before = metric_net_ideal_sources_count.collect()[0].samples[0].value # type: ignore + ideal_targets_count_before = metric_net_ideal_targets_count.collect()[0].samples[0].value # type: ignore + ideal_heads_count_before = metric_net_ideal_heads_count.collect()[0].samples[0].value # type: ignore - actual_positive_sources_count_before = net_actual_pos_sources_count.collect()[0].samples[0].value # type: ignore - actual_negative_sources_count_before = net_actual_neg_sources_count.collect()[0].samples[0].value # type: ignore - actual_positive_targets_count_before = net_actual_pos_targets_count.collect()[0].samples[0].value # type: ignore - actual_negative_targets_count_before = net_actual_neg_targets_count.collect()[0].samples[0].value # type: ignore - actual_heads_count_before = net_actual_heads_count.collect()[0].samples[0].value # type: ignore + actual_positive_sources_count_before = metric_net_actual_pos_sources_count.collect()[0].samples[0].value # type: ignore + actual_negative_sources_count_before = metric_net_actual_neg_sources_count.collect()[0].samples[0].value # type: ignore + actual_positive_targets_count_before = metric_net_actual_pos_targets_count.collect()[0].samples[0].value # type: ignore + actual_negative_targets_count_before = metric_net_actual_neg_targets_count.collect()[0].samples[0].value # type: ignore + actual_heads_count_before = metric_net_actual_heads_count.collect()[0].samples[0].value # type: ignore net_epoch_to_index_to_validator = LimitedDict(2) net_epoch_to_index_to_validator[42] = { @@ -452,16 +452,16 @@ def get_rewards( our_epoch_to_index_to_validator, ) - ideal_sources_count_after = net_ideal_sources_count.collect()[0].samples[0].value # type: ignore - ideal_targets_count_after = net_ideal_targets_count.collect()[0].samples[0].value # type: ignore - ideal_heads_count_after = net_ideal_heads_count.collect()[0].samples[0].value # type: ignore + ideal_sources_count_after = metric_net_ideal_sources_count.collect()[0].samples[0].value # type: ignore + ideal_targets_count_after = metric_net_ideal_targets_count.collect()[0].samples[0].value # type: ignore + ideal_heads_count_after = metric_net_ideal_heads_count.collect()[0].samples[0].value # type: ignore - actual_positive_sources_count_after = net_actual_pos_sources_count.collect()[0].samples[0].value # type: ignore - actual_negative_sources_count_after = net_actual_neg_sources_count.collect()[0].samples[0].value # type: ignore - actual_positive_targets_count_after = net_actual_pos_targets_count.collect()[0].samples[0].value # type: ignore - actual_negative_targets_count_after = net_actual_neg_targets_count.collect()[0].samples[0].value # type: ignore + actual_positive_sources_count_after = metric_net_actual_pos_sources_count.collect()[0].samples[0].value # type: ignore + actual_negative_sources_count_after = metric_net_actual_neg_sources_count.collect()[0].samples[0].value # type: ignore + actual_positive_targets_count_after = metric_net_actual_pos_targets_count.collect()[0].samples[0].value # type: ignore + actual_negative_targets_count_after = metric_net_actual_neg_targets_count.collect()[0].samples[0].value # type: ignore - actual_heads_count_after = net_actual_heads_count.collect()[0].samples[0].value # type: ignore + actual_heads_count_after = metric_net_actual_heads_count.collect()[0].samples[0].value # type: ignore assert ideal_sources_count_after - ideal_sources_count_before == 9_090 assert ideal_targets_count_after - ideal_targets_count_before == 16_889 @@ -487,6 +487,6 @@ def get_rewards( assert actual_heads_count_after - actual_heads_count_before == 0 - assert isclose(net_suboptimal_sources_rate_gauge.collect()[0].samples[0].value, 1.0) # type: ignore - assert isclose(net_suboptimal_targets_rate_gauge.collect()[0].samples[0].value, 1.0) # type: ignore - assert isclose(net_suboptimal_heads_rate_gauge.collect()[0].samples[0].value, 1.0) # type: ignore + assert isclose(metric_net_suboptimal_sources_rate_gauge.collect()[0].samples[0].value, 1.0) # type: ignore + assert isclose(metric_net_suboptimal_targets_rate_gauge.collect()[0].samples[0].value, 1.0) # type: ignore + assert isclose(metric_net_suboptimal_heads_rate_gauge.collect()[0].samples[0].value, 1.0) # type: ignore diff --git a/tests/rewards/test_process_rewards_our.py b/tests/rewards/test_process_rewards_our.py index 0af2e26..6217bba 100644 --- a/tests/rewards/test_process_rewards_our.py +++ b/tests/rewards/test_process_rewards_our.py @@ -2,17 +2,17 @@ from eth_validator_watcher.models import BeaconType, Rewards, Validators from eth_validator_watcher.rewards import ( - our_actual_heads_count, - our_actual_neg_sources_count, - our_actual_neg_targets_count, - our_actual_pos_sources_count, - our_actual_pos_targets_count, - our_ideal_heads_count, - our_ideal_sources_count, - our_ideal_targets_count, - our_suboptimal_heads_rate_gauge, - our_suboptimal_sources_rate_gauge, - our_suboptimal_targets_rate_gauge, + metric_our_actual_heads_count, + metric_our_actual_neg_sources_count, + metric_our_actual_neg_targets_count, + metric_our_actual_pos_sources_count, + metric_our_actual_pos_targets_count, + metric_our_ideal_heads_count, + metric_our_ideal_sources_count, + metric_our_ideal_targets_count, + metric_our_suboptimal_heads_rate_gauge, + metric_our_suboptimal_sources_rate_gauge, + metric_our_suboptimal_targets_rate_gauge, process_rewards, ) from eth_validator_watcher.utils import LimitedDict @@ -64,15 +64,15 @@ def get_rewards( beacon = Beacon() - ideal_sources_count_before = our_ideal_sources_count.collect()[0].samples[0].value # type: ignore - ideal_targets_count_before = our_ideal_targets_count.collect()[0].samples[0].value # type: ignore - ideal_heads_count_before = our_ideal_heads_count.collect()[0].samples[0].value # type: ignore + ideal_sources_count_before = metric_our_ideal_sources_count.collect()[0].samples[0].value # type: ignore + ideal_targets_count_before = metric_our_ideal_targets_count.collect()[0].samples[0].value # type: ignore + ideal_heads_count_before = metric_our_ideal_heads_count.collect()[0].samples[0].value # type: ignore - actual_positive_sources_count_before = our_actual_pos_sources_count.collect()[0].samples[0].value # type: ignore - actual_negative_sources_count_before = our_actual_neg_sources_count.collect()[0].samples[0].value # type: ignore - actual_positive_targets_count_before = our_actual_pos_targets_count.collect()[0].samples[0].value # type: ignore - actual_negative_targets_count_before = our_actual_neg_targets_count.collect()[0].samples[0].value # type: ignore - actual_heads_count_before = our_actual_heads_count.collect()[0].samples[0].value # type: ignore + actual_positive_sources_count_before = metric_our_actual_pos_sources_count.collect()[0].samples[0].value # type: ignore + actual_negative_sources_count_before = metric_our_actual_neg_sources_count.collect()[0].samples[0].value # type: ignore + actual_positive_targets_count_before = metric_our_actual_pos_targets_count.collect()[0].samples[0].value # type: ignore + actual_negative_targets_count_before = metric_our_actual_neg_targets_count.collect()[0].samples[0].value # type: ignore + actual_heads_count_before = metric_our_actual_heads_count.collect()[0].samples[0].value # type: ignore net_epoch_to_index_to_validator = LimitedDict(2) net_epoch_to_index_to_validator[42] = { @@ -104,16 +104,16 @@ def get_rewards( our_epoch_to_index_to_validator, ) - ideal_sources_count_after = our_ideal_sources_count.collect()[0].samples[0].value # type: ignore - ideal_targets_count_after = our_ideal_targets_count.collect()[0].samples[0].value # type: ignore - ideal_heads_count_after = our_ideal_heads_count.collect()[0].samples[0].value # type: ignore + ideal_sources_count_after = metric_our_ideal_sources_count.collect()[0].samples[0].value # type: ignore + ideal_targets_count_after = metric_our_ideal_targets_count.collect()[0].samples[0].value # type: ignore + ideal_heads_count_after = metric_our_ideal_heads_count.collect()[0].samples[0].value # type: ignore - actual_positive_sources_count_after = our_actual_pos_sources_count.collect()[0].samples[0].value # type: ignore - actual_negative_sources_count_after = our_actual_neg_sources_count.collect()[0].samples[0].value # type: ignore - actual_positive_targets_count_after = our_actual_pos_targets_count.collect()[0].samples[0].value # type: ignore - actual_negative_targets_count_after = our_actual_neg_targets_count.collect()[0].samples[0].value # type: ignore + actual_positive_sources_count_after = metric_our_actual_pos_sources_count.collect()[0].samples[0].value # type: ignore + actual_negative_sources_count_after = metric_our_actual_neg_sources_count.collect()[0].samples[0].value # type: ignore + actual_positive_targets_count_after = metric_our_actual_pos_targets_count.collect()[0].samples[0].value # type: ignore + actual_negative_targets_count_after = metric_our_actual_neg_targets_count.collect()[0].samples[0].value # type: ignore - actual_heads_count_after = our_actual_heads_count.collect()[0].samples[0].value # type: ignore + actual_heads_count_after = metric_our_actual_heads_count.collect()[0].samples[0].value # type: ignore assert ideal_sources_count_after - ideal_sources_count_before == 9_090 assert ideal_targets_count_after - ideal_targets_count_before == 16_889 @@ -139,9 +139,9 @@ def get_rewards( assert actual_heads_count_after - actual_heads_count_before == 8_752 - assert isclose(our_suboptimal_sources_rate_gauge.collect()[0].samples[0].value, 0.0) # type: ignore - assert isclose(our_suboptimal_targets_rate_gauge.collect()[0].samples[0].value, 0.0) # type: ignore - assert isclose(our_suboptimal_heads_rate_gauge.collect()[0].samples[0].value, 0.0) # type: ignore + assert isclose(metric_our_suboptimal_sources_rate_gauge.collect()[0].samples[0].value, 0.0) # type: ignore + assert isclose(metric_our_suboptimal_targets_rate_gauge.collect()[0].samples[0].value, 0.0) # type: ignore + assert isclose(metric_our_suboptimal_heads_rate_gauge.collect()[0].samples[0].value, 0.0) # type: ignore def test_process_rewards_some_our_validators_are_ideal() -> None: @@ -216,15 +216,15 @@ def get_rewards( beacon = Beacon() - ideal_sources_count_before = our_ideal_sources_count.collect()[0].samples[0].value # type: ignore - ideal_targets_count_before = our_ideal_targets_count.collect()[0].samples[0].value # type: ignore - ideal_heads_count_before = our_ideal_heads_count.collect()[0].samples[0].value # type: ignore + ideal_sources_count_before = metric_our_ideal_sources_count.collect()[0].samples[0].value # type: ignore + ideal_targets_count_before = metric_our_ideal_targets_count.collect()[0].samples[0].value # type: ignore + ideal_heads_count_before = metric_our_ideal_heads_count.collect()[0].samples[0].value # type: ignore - actual_positive_sources_count_before = our_actual_pos_sources_count.collect()[0].samples[0].value # type: ignore - actual_negative_sources_count_before = our_actual_neg_sources_count.collect()[0].samples[0].value # type: ignore - actual_positive_targets_count_before = our_actual_pos_targets_count.collect()[0].samples[0].value # type: ignore - actual_negative_targets_count_before = our_actual_neg_targets_count.collect()[0].samples[0].value # type: ignore - actual_heads_count_before = our_actual_heads_count.collect()[0].samples[0].value # type: ignore + actual_positive_sources_count_before = metric_our_actual_pos_sources_count.collect()[0].samples[0].value # type: ignore + actual_negative_sources_count_before = metric_our_actual_neg_sources_count.collect()[0].samples[0].value # type: ignore + actual_positive_targets_count_before = metric_our_actual_pos_targets_count.collect()[0].samples[0].value # type: ignore + actual_negative_targets_count_before = metric_our_actual_neg_targets_count.collect()[0].samples[0].value # type: ignore + actual_heads_count_before = metric_our_actual_heads_count.collect()[0].samples[0].value # type: ignore net_epoch_to_index_to_validator = LimitedDict(2) net_epoch_to_index_to_validator[42] = { @@ -291,16 +291,16 @@ def get_rewards( our_epoch_to_index_to_validator, ) - ideal_sources_count_after = our_ideal_sources_count.collect()[0].samples[0].value # type: ignore - ideal_targets_count_after = our_ideal_targets_count.collect()[0].samples[0].value # type: ignore - ideal_heads_count_after = our_ideal_heads_count.collect()[0].samples[0].value # type: ignore + ideal_sources_count_after = metric_our_ideal_sources_count.collect()[0].samples[0].value # type: ignore + ideal_targets_count_after = metric_our_ideal_targets_count.collect()[0].samples[0].value # type: ignore + ideal_heads_count_after = metric_our_ideal_heads_count.collect()[0].samples[0].value # type: ignore - actual_positive_sources_count_after = our_actual_pos_sources_count.collect()[0].samples[0].value # type: ignore - actual_negative_sources_count_after = our_actual_neg_sources_count.collect()[0].samples[0].value # type: ignore - actual_positive_targets_count_after = our_actual_pos_targets_count.collect()[0].samples[0].value # type: ignore - actual_negative_targets_count_after = our_actual_neg_targets_count.collect()[0].samples[0].value # type: ignore + actual_positive_sources_count_after = metric_our_actual_pos_sources_count.collect()[0].samples[0].value # type: ignore + actual_negative_sources_count_after = metric_our_actual_neg_sources_count.collect()[0].samples[0].value # type: ignore + actual_positive_targets_count_after = metric_our_actual_pos_targets_count.collect()[0].samples[0].value # type: ignore + actual_negative_targets_count_after = metric_our_actual_neg_targets_count.collect()[0].samples[0].value # type: ignore - actual_heads_count_after = our_actual_heads_count.collect()[0].samples[0].value # type: ignore + actual_heads_count_after = metric_our_actual_heads_count.collect()[0].samples[0].value # type: ignore assert ideal_sources_count_after - ideal_sources_count_before == 30_524 assert ideal_targets_count_after - ideal_targets_count_before == 56_712 @@ -327,17 +327,17 @@ def get_rewards( assert actual_heads_count_after - actual_heads_count_before == 14_740 assert isclose( - our_suboptimal_sources_rate_gauge.collect()[0].samples[0].value, # type: ignore + metric_our_suboptimal_sources_rate_gauge.collect()[0].samples[0].value, # type: ignore 0.1, ) assert isclose( - our_suboptimal_targets_rate_gauge.collect()[0].samples[0].value, # type: ignore + metric_our_suboptimal_targets_rate_gauge.collect()[0].samples[0].value, # type: ignore 0.3, ) assert isclose( - our_suboptimal_heads_rate_gauge.collect()[0].samples[0].value, # type: ignore + metric_our_suboptimal_heads_rate_gauge.collect()[0].samples[0].value, # type: ignore 0.5, ) @@ -386,15 +386,15 @@ def get_rewards( beacon = Beacon() - ideal_sources_count_before = our_ideal_sources_count.collect()[0].samples[0].value # type: ignore - ideal_targets_count_before = our_ideal_targets_count.collect()[0].samples[0].value # type: ignore - ideal_heads_count_before = our_ideal_heads_count.collect()[0].samples[0].value # type: ignore + ideal_sources_count_before = metric_our_ideal_sources_count.collect()[0].samples[0].value # type: ignore + ideal_targets_count_before = metric_our_ideal_targets_count.collect()[0].samples[0].value # type: ignore + ideal_heads_count_before = metric_our_ideal_heads_count.collect()[0].samples[0].value # type: ignore - actual_positive_sources_count_before = our_actual_pos_sources_count.collect()[0].samples[0].value # type: ignore - actual_negative_sources_count_before = our_actual_neg_sources_count.collect()[0].samples[0].value # type: ignore - actual_positive_targets_count_before = our_actual_pos_targets_count.collect()[0].samples[0].value # type: ignore - actual_negative_targets_count_before = our_actual_neg_targets_count.collect()[0].samples[0].value # type: ignore - actual_heads_count_before = our_actual_heads_count.collect()[0].samples[0].value # type: ignore + actual_positive_sources_count_before = metric_our_actual_pos_sources_count.collect()[0].samples[0].value # type: ignore + actual_negative_sources_count_before = metric_our_actual_neg_sources_count.collect()[0].samples[0].value # type: ignore + actual_positive_targets_count_before = metric_our_actual_pos_targets_count.collect()[0].samples[0].value # type: ignore + actual_negative_targets_count_before = metric_our_actual_neg_targets_count.collect()[0].samples[0].value # type: ignore + actual_heads_count_before = metric_our_actual_heads_count.collect()[0].samples[0].value # type: ignore net_epoch_to_index_to_validator = LimitedDict(2) net_epoch_to_index_to_validator[42] = { @@ -426,16 +426,16 @@ def get_rewards( our_epoch_to_index_to_validator, ) - ideal_sources_count_after = our_ideal_sources_count.collect()[0].samples[0].value # type: ignore - ideal_targets_count_after = our_ideal_targets_count.collect()[0].samples[0].value # type: ignore - ideal_heads_count_after = our_ideal_heads_count.collect()[0].samples[0].value # type: ignore + ideal_sources_count_after = metric_our_ideal_sources_count.collect()[0].samples[0].value # type: ignore + ideal_targets_count_after = metric_our_ideal_targets_count.collect()[0].samples[0].value # type: ignore + ideal_heads_count_after = metric_our_ideal_heads_count.collect()[0].samples[0].value # type: ignore - actual_positive_sources_count_after = our_actual_pos_sources_count.collect()[0].samples[0].value # type: ignore - actual_negative_sources_count_after = our_actual_neg_sources_count.collect()[0].samples[0].value # type: ignore - actual_positive_targets_count_after = our_actual_pos_targets_count.collect()[0].samples[0].value # type: ignore - actual_negative_targets_count_after = our_actual_neg_targets_count.collect()[0].samples[0].value # type: ignore + actual_positive_sources_count_after = metric_our_actual_pos_sources_count.collect()[0].samples[0].value # type: ignore + actual_negative_sources_count_after = metric_our_actual_neg_sources_count.collect()[0].samples[0].value # type: ignore + actual_positive_targets_count_after = metric_our_actual_pos_targets_count.collect()[0].samples[0].value # type: ignore + actual_negative_targets_count_after = metric_our_actual_neg_targets_count.collect()[0].samples[0].value # type: ignore - actual_heads_count_after = our_actual_heads_count.collect()[0].samples[0].value # type: ignore + actual_heads_count_after = metric_our_actual_heads_count.collect()[0].samples[0].value # type: ignore assert ideal_sources_count_after - ideal_sources_count_before == 9_090 assert ideal_targets_count_after - ideal_targets_count_before == 16_889 @@ -461,6 +461,6 @@ def get_rewards( assert actual_heads_count_after - actual_heads_count_before == 0 - assert isclose(our_suboptimal_sources_rate_gauge.collect()[0].samples[0].value, 1.0) # type: ignore - assert isclose(our_suboptimal_targets_rate_gauge.collect()[0].samples[0].value, 1.0) # type: ignore - assert isclose(our_suboptimal_heads_rate_gauge.collect()[0].samples[0].value, 1.0) # type: ignore + assert isclose(metric_our_suboptimal_sources_rate_gauge.collect()[0].samples[0].value, 1.0) # type: ignore + assert isclose(metric_our_suboptimal_targets_rate_gauge.collect()[0].samples[0].value, 1.0) # type: ignore + assert isclose(metric_our_suboptimal_heads_rate_gauge.collect()[0].samples[0].value, 1.0) # type: ignore From 4e486f0c586cdb64864d18e5a9c8c7ea68883054 Mon Sep 17 00:00:00 2001 From: "s. rannou" Date: Mon, 20 Nov 2023 11:53:32 +0100 Subject: [PATCH 15/17] feat: prefix slashes metric --- eth_validator_watcher/slashed_validators.py | 8 ++++---- .../test_process_slashed_validators.py | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/eth_validator_watcher/slashed_validators.py b/eth_validator_watcher/slashed_validators.py index b2c1cbe..a682c90 100644 --- a/eth_validator_watcher/slashed_validators.py +++ b/eth_validator_watcher/slashed_validators.py @@ -5,12 +5,12 @@ from .models import Validators from .utils import Slack -our_slashed_validators_count = Gauge( +metric_our_slashed_validators_count = Gauge( "our_slashed_validators_count", "Our slashed validators count", ) -total_slashed_validators_count = Gauge( +metric_total_slashed_validators_count = Gauge( "total_slashed_validators_count", "Total slashed validators count", ) @@ -74,8 +74,8 @@ def process( our_slashed_withdrawal_index_to_validator ) - total_slashed_validators_count.set(len(total_slashed_indexes)) - our_slashed_validators_count.set(len(our_slashed_indexes)) + metric_total_slashed_validators_count.set(len(total_slashed_indexes)) + metric_our_slashed_validators_count.set(len(our_slashed_indexes)) total_exited_slashed_indexes = set(total_exited_slashed_index_to_validator) our_exited_slashed_indexes = set(our_exited_slashed_index_to_validator) diff --git a/tests/slashed_validators/test_process_slashed_validators.py b/tests/slashed_validators/test_process_slashed_validators.py index 547adf1..7e154c0 100644 --- a/tests/slashed_validators/test_process_slashed_validators.py +++ b/tests/slashed_validators/test_process_slashed_validators.py @@ -1,8 +1,8 @@ from eth_validator_watcher.models import Validators from eth_validator_watcher.slashed_validators import ( SlashedValidators, - our_slashed_validators_count, - total_slashed_validators_count, + metric_our_slashed_validators_count, + metric_total_slashed_validators_count, ) Validator = Validators.DataItem.Validator @@ -52,8 +52,8 @@ def send_message(self, _: str) -> None: our_withdrawal_index_to_validator, ) - assert total_slashed_validators_count.collect()[0].samples[0].value == 7 # type: ignore - assert our_slashed_validators_count.collect()[0].samples[0].value == 3 # type: ignore + assert metric_total_slashed_validators_count.collect()[0].samples[0].value == 7 # type: ignore + assert metric_our_slashed_validators_count.collect()[0].samples[0].value == 3 # type: ignore assert slack.counter == 0 assert ( @@ -88,8 +88,8 @@ def send_message(self, _: str) -> None: our_withdrawal_index_to_validator, ) - assert total_slashed_validators_count.collect()[0].samples[0].value == 8 # type: ignore - assert our_slashed_validators_count.collect()[0].samples[0].value == 4 # type: ignore + assert metric_total_slashed_validators_count.collect()[0].samples[0].value == 8 # type: ignore + assert metric_our_slashed_validators_count.collect()[0].samples[0].value == 4 # type: ignore assert slack.counter == 1 assert ( From f66ccf900b9faf4166deb572380ec85932048213 Mon Sep 17 00:00:00 2001 From: "s. rannou" Date: Mon, 20 Nov 2023 11:54:34 +0100 Subject: [PATCH 16/17] feat: prefix suboptimal attestations --- eth_validator_watcher/suboptimal_attestations.py | 4 ++-- tests/suboptimal_attestations/test_suboptimal_attestations.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/eth_validator_watcher/suboptimal_attestations.py b/eth_validator_watcher/suboptimal_attestations.py index f779b55..cc528de 100644 --- a/eth_validator_watcher/suboptimal_attestations.py +++ b/eth_validator_watcher/suboptimal_attestations.py @@ -18,7 +18,7 @@ print = functools.partial(print, flush=True) -suboptimal_attestations_rate_gauge = Gauge( +metric_suboptimal_attestations_rate_gauge = Gauge( "suboptimal_attestations_rate", "Suboptimal attestations rate", ) @@ -133,7 +133,7 @@ def process_suboptimal_attestations( ) if suboptimal_attestations_rate is not None: - suboptimal_attestations_rate_gauge.set(100 * suboptimal_attestations_rate) + metric_suboptimal_attestations_rate_gauge.set(100 * suboptimal_attestations_rate) if len(our_validators_index_that_did_not_attest_optimally_during_previous_slot) > 0: assert suboptimal_attestations_rate is not None diff --git a/tests/suboptimal_attestations/test_suboptimal_attestations.py b/tests/suboptimal_attestations/test_suboptimal_attestations.py index f4f8657..10a4564 100644 --- a/tests/suboptimal_attestations/test_suboptimal_attestations.py +++ b/tests/suboptimal_attestations/test_suboptimal_attestations.py @@ -1,7 +1,7 @@ from eth_validator_watcher import models, suboptimal_attestations from eth_validator_watcher.suboptimal_attestations import ( process_suboptimal_attestations, - suboptimal_attestations_rate_gauge, + metric_suboptimal_attestations_rate_gauge, ) Validator = models.Validators.DataItem.Validator @@ -149,4 +149,4 @@ def get_duty_slot_to_committee_index_to_validators_index( ) assert expected == actual - assert suboptimal_attestations_rate_gauge.collect()[0].samples[0].value == 50.0 # type: ignore + assert metric_suboptimal_attestations_rate_gauge.collect()[0].samples[0].value == 50.0 # type: ignore From b9a3ae80e5eeabad441d8dd7b63b59c53e11c33c Mon Sep 17 00:00:00 2001 From: "s. rannou" Date: Mon, 20 Nov 2023 11:55:17 +0100 Subject: [PATCH 17/17] feat: prefix key count metric --- eth_validator_watcher/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eth_validator_watcher/utils.py b/eth_validator_watcher/utils.py index f1ecff5..074a3ad 100644 --- a/eth_validator_watcher/utils.py +++ b/eth_validator_watcher/utils.py @@ -40,7 +40,7 @@ '"Infinite."', ] -keys_count = Gauge( +metric_keys_count = Gauge( "keys_count", "Keys count", ) @@ -210,7 +210,7 @@ def get_our_pubkeys( ) our_pubkeys = pubkeys_from_file | pubkeys_from_web3signer - keys_count.set(len(our_pubkeys)) + metric_keys_count.set(len(our_pubkeys)) return our_pubkeys