@@ -396,7 +396,10 @@ async def observer_loop(config: Configuration) -> None:
396396 contracts = cm .get_contracts_list ()
397397 event_signatures = cm .get_events ()
398398
399- fum = FastUpdatesManager ()
399+ entity = signing_policy .entity_mapper .by_identity_address [tia ]
400+ fum = FastUpdatesManager (
401+ block_number , FastUpdate (reward_epoch .id , entity .signing_policy_address , [])
402+ )
400403 spm = SigningPolicyManager (signing_policy , signing_policy )
401404 rm = RewardManager ()
402405
@@ -418,6 +421,7 @@ async def observer_loop(config: Configuration) -> None:
418421 )
419422 last_minimal_conditions_check = int (time .time ())
420423 last_ping = time .time ()
424+ last_registration_check = time .time ()
421425
422426 node_connections = defaultdict (deque )
423427 uptime_validations = 0
@@ -431,10 +435,6 @@ async def observer_loop(config: Configuration) -> None:
431435 voter_registration_started_ts : int = 0
432436 registered : bool = False
433437
434- preregistration_started : bool = False
435- preregistration_started_ts : int = 0
436- preregistered : bool = False
437-
438438 nr_of_feeds : int = 0
439439 fast_update_re : int = 0
440440
@@ -528,6 +528,8 @@ async def observer_loop(config: Configuration) -> None:
528528 case "VoterRegistered" :
529529 e = VoterRegistered .from_dict (data ["args" ])
530530 spb .add (e )
531+ if registered :
532+ continue
531533 entity = signing_policy .entity_mapper .by_identity_address [
532534 tia
533535 ]
@@ -543,73 +545,51 @@ async def observer_loop(config: Configuration) -> None:
543545 e = VoterRegistrationInfo .from_dict (data ["args" ])
544546 spb .add (e )
545547 case "VotePowerBlockSelected" :
546- preregistration_started = False
547- preregistered = False
548548 e = VotePowerBlockSelected .from_dict (data ["args" ])
549549 spb .add (e )
550+ if registered :
551+ continue
550552 voter_registration_started = True
551553 voter_registration_started_ts = int (time .time ())
552554 case "RandomAcquisitionStarted" :
553555 e = RandomAcquisitionStarted .from_dict (data ["args" ])
554556 spb .add (e )
555- preregistration_started = True
556- preregistration_started_ts = int (time .time ())
557557 case "FastUpdateFeedsSubmitted" :
558- e = FastUpdateFeedsSubmitted .from_dict (
559- data ["args" ],
560- data ["address" ],
561- data ["transactionHash" ],
562- )
558+ e = FastUpdateFeedsSubmitted .from_dict (data )
563559 tx = await w .eth .get_transaction (e .transaction_hash )
564560 spa , address , update_array = calculate_update_from_tx (
565561 config , w , tx
566562 )
567563 entity = signing_policy .entity_mapper .by_identity_address [
568564 tia
569565 ]
570- fum . fast_updates . append (
571- FastUpdate (
566+ if un_prefix_0x ( entity . signing_policy_address ) == spa :
567+ fum . last_update = FastUpdate (
572568 signing_policy .reward_epoch .id ,
573569 address ,
574570 update_array ,
575571 )
576- )
577- # with expected sample size 1 and average block time of
578- # 1s, this should be an ok approximation
579- if (
580- len (fum .fast_updates )
581- > minimal_conditions .time_period .value
582- ):
583- fum .fast_updates .popleft ()
584- if un_prefix_0x (entity .signing_policy_address ) == spa :
572+ fum .last_update_block = int (data ["blockNumber" ])
585573 # We check update array when we receive a new one
586574 event_messages .extend (
587575 fum .check_update_length (nr_of_feeds , fast_update_re )
588576 )
589577 fum .address_list .add (address )
590578 case "FastUpdateFeeds" :
591- e = FastUpdateFeeds .from_dict (
592- data ["args" ],
593- data ["address" ],
594- data ["transactionHash" ],
595- )
579+ e = FastUpdateFeeds .from_dict (data )
596580 nr_of_feeds , fast_update_re = (
597581 len (e .feeds ),
598582 ref .from_voting_epoch (
599583 vef .make_epoch (e .voting_round_id )
600584 ).id ,
601585 )
602586 case "VoterPreRegistered" :
603- e = VoterPreRegistered .from_dict (
604- data ["args" ],
605- data ["address" ],
606- data ["transactionHash" ],
607- )
587+ e = VoterPreRegistered .from_dict (data )
608588 entity = signing_policy .entity_mapper .by_identity_address [
609589 tia
610590 ]
611591 if tia == e .voter :
612- preregistered = True
592+ registered = True
613593
614594 for tx in block_data ["transactions" ]:
615595 assert not isinstance (tx , bytes )
@@ -692,7 +672,7 @@ async def observer_loop(config: Configuration) -> None:
692672
693673 min_cond_messages .extend (
694674 minimal_conditions .calculate_ftso_block_latency_feeds (
695- entity , spm , fum
675+ entity , signing_policy , fum . last_update_block , block
696676 )
697677 )
698678 min_cond_messages .extend (
@@ -784,23 +764,16 @@ async def observer_loop(config: Configuration) -> None:
784764 while len (signatures ) > minimal_conditions .time_period .value // 90 :
785765 signatures .popleft ()
786766
787- # reporting on registration and preregistration
788- if preregistration_started and not preregistered :
789- mb = Message .builder ()
790- if int (time .time () - preregistration_started_ts ) > 60 :
791- level = MessageLevel .CRITICAL
792- message = mb .build (
793- level ,
794- (
795- "Voter not preregistered after "
796- f"{ int (time .time () - preregistration_started_ts ) // 60 } "
797- " minutes"
798- ),
799- )
800- messages .append (message )
801-
802- if voter_registration_started and not registered :
803- mb = Message .builder ()
767+ # reporting on registration and preregistration once per minute
768+ interval = 60
769+ if int (time .time () - voter_registration_started_ts ) > 15 * 60 :
770+ interval = 10
771+ if (
772+ int (time .time () - last_registration_check ) > interval
773+ and voter_registration_started
774+ and not registered
775+ ):
776+ mb = Message .builder ().add (network = config .chain_id )
804777 if int (time .time () - voter_registration_started_ts ) > 60 :
805778 level = MessageLevel .CRITICAL
806779 message = mb .build (
0 commit comments