@@ -151,6 +151,26 @@ def calculate_update_from_tx(config: Configuration, w: AsyncWeb3, tx: TxData):
151151 return signing_policy_address , address , signed_array
152152
153153
154+ async def get_block_production (w : AsyncWeb3 ) -> float :
155+ latest_block = await w .eth .get_block ("latest" )
156+ assert "timestamp" in latest_block
157+ assert "number" in latest_block
158+ to_compare = min (1_000_000 , int (latest_block ["number" ]) - 1 )
159+ comparison_block = await w .eth .get_block (int (latest_block ["number" ]) - to_compare )
160+ assert "timestamp" in comparison_block
161+ time_delta = latest_block ["timestamp" ] - comparison_block ["timestamp" ]
162+ block_production = time_delta / to_compare
163+ return block_production
164+
165+
166+ def calculate_maximum_exponent (block_production : float , config : Configuration ) -> int :
167+ blocks_in_epoch = int (
168+ config .epoch .reward_epoch_factory .duration () / block_production
169+ )
170+ max_exponent = blocks_in_epoch // 100
171+ return max_exponent
172+
173+
154174async def find_voter_registration_blocks (
155175 w : AsyncWeb3 ,
156176 current_block_id : int ,
@@ -340,6 +360,9 @@ async def observer_loop(config: Configuration) -> None:
340360 )
341361 spb = SigningPolicy .builder ().for_epoch (reward_epoch .next )
342362
363+ block_production = await get_block_production (w )
364+ maximum_exponent = calculate_maximum_exponent (block_production , config )
365+
343366 # print("Signing policy created for reward epoch", current_rid)
344367 # print("Reward Epoch object created", reward_epoch_info)
345368 # print("Current Reward Epoch status", reward_epoch_info.status(config))
@@ -666,13 +689,17 @@ async def observer_loop(config: Configuration) -> None:
666689 messages .extend (event_messages )
667690 entity = signing_policy .entity_mapper .by_identity_address [tia ]
668691
669- # perform all minimal condition checks here and reset node connections
692+ # perform all minimal condition checks here
670693 if int (time .time () - last_minimal_conditions_check ) > 60 :
671694 min_cond_messages : list [Message ] = []
672695
673696 min_cond_messages .extend (
674697 minimal_conditions .calculate_ftso_block_latency_feeds (
675- entity , signing_policy , fum .last_update_block , block
698+ maximum_exponent ,
699+ entity ,
700+ signing_policy ,
701+ fum .last_update_block ,
702+ block ,
676703 )
677704 )
678705 min_cond_messages .extend (
0 commit comments