@@ -1859,11 +1859,10 @@ func ElectraGetEpochProcessedHashes(epoch uint64) ([][]byte, error) {
18591859 `, (utils.Config.ClConfig.SlotsPerEpoch*epoch)-1))
18601860 */
18611861 // use goqu
1862- q := goqu .Dialect ("postgres" ).Select ("block_root " ).
1863- From ("consensus_layer_events " ).
1862+ q := goqu .Dialect ("postgres" ).Select ("transition_block_hash " ).
1863+ From ("consensus_layer_events_indexer_metadata " ).
18641864 Where (
1865- goqu .I ("event_name" ).Eq ("EpochProcessedEvent" ),
1866- goqu .I ("slot" ).Eq ((utils .Config .ClConfig .SlotsPerEpoch * epoch )- 1 ),
1865+ goqu .I ("epoch" ).Eq (epoch - 1 ), // it is what it is
18671866 )
18681867 sql , args , err := q .Prepared (true ).ToSQL ()
18691868 if err != nil {
@@ -1881,18 +1880,17 @@ func ElectraGetProcessedDeposits(epoch uint64) ([]constypes.ElectraDeposit, erro
18811880 endSlot := (epoch + 1 )* utils .Config .ClConfig .SlotsPerEpoch - 1
18821881 var result []constypes.ElectraDeposit
18831882 q := goqu .Dialect ("postgres" ).Select (
1884- goqu .L ("data->>'amount'" ).As ("amount" ),
1885- goqu .L ("data->>'pubkey'" ).As ("pubkey" ),
1886- // SignatureValid field, assume true if not present
1887- goqu .COALESCE (goqu .L ("data->>'signature_valid'" ), goqu .L ("'true'" )).As ("signature_valid" ),
1883+ goqu .L ("amount" ).As ("amount" ),
1884+ goqu .L ("pubkey" ).As ("pubkey" ),
1885+ goqu .L ("true" ).As ("signature_valid" ),
18881886 ).
1889- From ("consensus_layer_events " ).
1887+ From ("blocks_deposit_requests_v2 " ).
18901888 Where (
1891- goqu .I ("event_name " ).Eq ("DepositProcessedEvent " ),
1892- goqu .I ("slot " ).Gte (startSlot ),
1893- goqu .I ("slot " ).Lt (endSlot ),
1889+ goqu .I ("status " ).Eq ("completed " ),
1890+ goqu .I ("slot_processed " ).Gte (startSlot ),
1891+ goqu .I ("slot_processed " ).Lt (endSlot ),
18941892 ).
1895- Order (goqu .I ("slot " ).Asc (), goqu .I ("event_index " ).Asc ())
1893+ Order (goqu .I ("slot_processed " ).Asc (), goqu .I ("index_processed " ).Asc ())
18961894 sql , args , err := q .Prepared (true ).ToSQL ()
18971895 if err != nil {
18981896 return nil , fmt .Errorf ("error fetching electra deposits for epoch %v: %w" , epoch , err )
@@ -1910,16 +1908,17 @@ func ElectraGetProcessedConsolidations(epoch uint64) ([]constypes.ElectraConsoli
19101908 endSlot := (epoch + 1 )* utils .Config .ClConfig .SlotsPerEpoch - 1
19111909 var consolidations []constypes.ElectraConsolidation
19121910 q := goqu .Dialect ("postgres" ).Select (
1913- goqu .L ("data->>'amount' " ).As ("amount" ),
1914- goqu .L ("data->>'source_index' " ).As ("source_index " ),
1915- goqu .L ("data->>'target_index' " ).As ("target_index " ),
1911+ goqu .L ("amount_consolidated " ).As ("amount" ),
1912+ goqu .L ("source_pubkey " ).As ("source_pubkey " ),
1913+ goqu .L ("target_pubkey " ).As ("target_pubkey " ),
19161914 ).
1917- From ("consensus_layer_events " ).
1915+ From ("blocks_consolidation_requests_v2 " ).
19181916 Where (
1919- goqu .I ("event_name" ).Eq ("ConsolidationProcessedEvent" ),
1920- goqu .I ("slot" ).Gte (startSlot ),
1921- goqu .I ("slot" ).Lt (endSlot ),
1922- )
1917+ goqu .I ("status" ).Eq ("completed" ),
1918+ goqu .I ("slot_processed" ).Gte (startSlot ),
1919+ goqu .I ("slot_processed" ).Lt (endSlot ),
1920+ ).
1921+ Order (goqu .I ("slot_processed" ).Asc (), goqu .I ("index_processed" ).Asc ())
19231922 sql , args , err := q .Prepared (true ).ToSQL ()
19241923 if err != nil {
19251924 return nil , fmt .Errorf ("error fetching electra consolidations for epoch %v: %w" , epoch , err )
@@ -1936,15 +1935,16 @@ func ElectraGetRemovedExcessBalanceEvents(epoch uint64) ([]constypes.ElectraExce
19361935 endSlot := (epoch + 1 )* utils .Config .ClConfig .SlotsPerEpoch - 1
19371936 var excessBalanceEvents []constypes.ElectraExcessBalance
19381937 q := goqu .Dialect ("postgres" ).Select (
1939- goqu .L ("data->>'validator_index' " ).As ("validator_index " ),
1940- goqu .L ("data->>' amount' " ).As ("amount" ),
1938+ goqu .L ("validator_pubkey " ).As ("validator_pubkey " ),
1939+ goqu .L ("amount" ).As ("amount" ),
19411940 ).
1942- From ("consensus_layer_events " ).
1941+ From ("blocks_removed_excess_balance_events " ).
19431942 Where (
1944- goqu .I ("event_name" ).Eq ("RemovedExcessBalanceEvent" ),
1945- goqu .I ("slot" ).Gte (startSlot ),
1946- goqu .I ("slot" ).Lt (endSlot ),
1947- )
1943+ goqu .I ("status" ).Eq ("completed" ),
1944+ goqu .I ("slot_processed" ).Gte (startSlot ),
1945+ goqu .I ("slot_processed" ).Lt (endSlot ),
1946+ ).
1947+ Order (goqu .I ("slot_processed" ).Asc (), goqu .I ("index_processed" ).Asc ())
19481948 sql , args , err := q .Prepared (true ).ToSQL ()
19491949 if err != nil {
19501950 return nil , fmt .Errorf ("error fetching electra excess balance events for epoch %v: %w" , epoch , err )
0 commit comments