Added metric for tracking last scanned block by ritual tracker scanner task.

Added test.
pull/3405/head
derekpierre 2024-01-22 15:39:24 -05:00 committed by KPrasch
parent 931cdde08e
commit 8535e628c7
2 changed files with 19 additions and 4 deletions

View File

@ -4,6 +4,7 @@ import time
from typing import Callable, List, Optional, Tuple
import maya
from prometheus_client import REGISTRY, Gauge
from twisted.internet import threads
from web3.datastructures import AttributeDict
@ -66,6 +67,13 @@ class EventScannerTask(SimpleTask):
self.start(now=False) # take a breather
LAST_SCANNED_BLOCK_METRIC = Gauge(
"ritual_events_last_scanned_block_number",
"Last scanned block number for ritual events",
registry=REGISTRY,
)
class ActiveRitualTracker:
MAX_CHUNK_SIZE = 10000
@ -417,14 +425,16 @@ class ActiveRitualTracker:
Because there might have been a minor Ethereum chain reorganisations since the last scan ended,
we need to discard the last few blocks from the previous scan results.
"""
self.scanner.delete_potentially_forked_block_data(
self.state.get_last_scanned_block() - self.scanner.chain_reorg_rescan_window
)
last_scanned_block = self.scanner.get_last_scanned_block()
LAST_SCANNED_BLOCK_METRIC.set(last_scanned_block)
if self.scanner.get_last_scanned_block() == 0:
if last_scanned_block == 0:
# first run so calculate starting block number based on dkg timeout
suggested_start_block = self._get_first_scan_start_block_number()
else:
self.scanner.delete_potentially_forked_block_data(
last_scanned_block - self.scanner.chain_reorg_rescan_window
)
suggested_start_block = self.scanner.get_suggested_scan_start_block()
end_block = self.scanner.get_suggested_scan_end_block()

View File

@ -197,6 +197,11 @@ def test_ursula_ritualist(
for ursula in cohort:
assert ursula.dkg_storage.get_transcript(RITUAL_ID) is not None
last_scanned_block = REGISTRY.get_sample_value(
"ritual_events_last_scanned_block_number"
)
assert last_scanned_block > 0
def test_encrypt(_):
"""Encrypts a message and returns the ciphertext and conditions"""
print("==================== DKG ENCRYPTION ====================")