@@ -22,7 +22,7 @@ defmodule Explorer.Periodically do
2222 :timer . send_interval ( one_second * 12 , :batches )
2323 # every 1 hour
2424 :timer . send_interval ( one_second * seconds_in_an_hour , :restakings )
25- :timer . send_interval ( one_second * seconds_in_an_hour , :aggregated_proofs )
25+ :timer . send_interval ( one_second * 12 , :aggregated_proofs )
2626 end
2727
2828 # Reads and process last blocks for operators and restaking changes
@@ -74,7 +74,7 @@ defmodule Explorer.Periodically do
7474 end
7575
7676 def handle_info ( :aggregated_proofs , state ) do
77- read_block_qty = 310
77+ read_block_qty = 50000
7878 latest_block_number = AlignedLayerServiceManager . get_latest_block_number ( )
7979 read_from_block = max ( 0 , latest_block_number - read_block_qty )
8080
@@ -105,13 +105,18 @@ defmodule Explorer.Periodically do
105105 end )
106106
107107 # Store aggregated proofs to db
108- proofs
109- |> Enum . zip ( proof_hashes )
110- |> Enum . each ( fn { agg_proof , hashes } ->
111- agg_proof
112- |> Map . merge ( % { number_of_proofs: length ( hashes ) } )
113- |> AggregatedProofs . insert_or_update ( )
114- end )
108+ proofs =
109+ proofs
110+ |> Enum . zip ( proof_hashes )
111+ |> Enum . map ( fn { agg_proof , hashes } ->
112+ agg_proof =
113+ agg_proof
114+ |> Map . merge ( % { number_of_proofs: length ( hashes ) } )
115+
116+ { :ok , % { id: id } } = AggregatedProofs . insert_or_update ( agg_proof )
117+
118+ Map . merge ( agg_proof , % { id: id } )
119+ end )
115120
116121 # Store each individual proof
117122 proofs
@@ -121,7 +126,7 @@ defmodule Explorer.Periodically do
121126 |> Enum . with_index ( )
122127 |> Enum . each ( fn { hash , index } ->
123128 AggregationModeProof . insert_or_update ( % {
124- merkle_root : agg_proof . merkle_root ,
129+ agg_proof_id : agg_proof . id ,
125130 proof_hash: "0x" <> List . to_string ( hash ) ,
126131 index: index
127132 } )
0 commit comments