13 Synced Subgraphs

Next, our goal is to figure out which subgraphs we want to open new allocations for. To start, we want to get to a list of synced subgraphs as potential candidates for new allocations.

You can and should do this using the status endpoint of the indexer. Ricky wanted full access to all the data, so the example below connects to the graph node database directly.

## [1] "Connecting to database..."
## [1] "Executing query..."
## [1] "Processed sync state data:"
## # A tibble: 370 × 6
##    deployment             network shard synced current_block synced_at          
##    <chr>                  <chr>   <chr> <chr>          <dbl> <dttm>             
##  1 QmTyyrcaTduZN1ySRwtVM… gnosis  subg… true        39765332 2025-03-02 03:21:57
##  2 QmWXhLkz6fRJwLyFmgBKV… mainnet subg… true        22356157 2025-02-28 19:30:35
##  3 QmVUcp8WqE47payYxMJUL… mainnet subg… true        22356157 2025-02-28 19:25:20
##  4 QmdKXcBUHR3UyURqVRQHu… arbitr… subg… true       330548614 2025-02-28 02:00:28
##  5 QmW26TG5s9myd1gzio9fk… arbitr… subg… true       330548614 2025-02-27 08:34:51
##  6 QmYSxAAWeXDJ8DbWTy3ov… mainnet subg… true        22356157 2024-12-31 16:14:58
##  7 QmYV4MbMHuE98rWL5HRJb… base    subg… true        29458320 2024-12-20 17:37:28
##  8 QmddvgpoNsfxXyQ972Khp… mainnet subg… true        22356157 2024-12-20 14:52:23
##  9 QmSK5hvEsM5mw6658SE1B… arbitr… subg… true       330548614 2024-12-20 10:57:03
## 10 QmQuCY9bwTF13ZkPdpgy7… arbitr… subg… true       330548614 2024-12-19 15:48:56
## # ℹ 360 more rows
## [1] "Closing database connection..."
## # A tibble: 370 × 6
##    deployment             network shard synced current_block synced_at          
##    <chr>                  <chr>   <chr> <chr>          <dbl> <dttm>             
##  1 QmTyyrcaTduZN1ySRwtVM… gnosis  subg… true        39765332 2025-03-02 03:21:57
##  2 QmWXhLkz6fRJwLyFmgBKV… mainnet subg… true        22356157 2025-02-28 19:30:35
##  3 QmVUcp8WqE47payYxMJUL… mainnet subg… true        22356157 2025-02-28 19:25:20
##  4 QmdKXcBUHR3UyURqVRQHu… arbitr… subg… true       330548614 2025-02-28 02:00:28
##  5 QmW26TG5s9myd1gzio9fk… arbitr… subg… true       330548614 2025-02-27 08:34:51
##  6 QmYSxAAWeXDJ8DbWTy3ov… mainnet subg… true        22356157 2024-12-31 16:14:58
##  7 QmYV4MbMHuE98rWL5HRJb… base    subg… true        29458320 2024-12-20 17:37:28
##  8 QmddvgpoNsfxXyQ972Khp… mainnet subg… true        22356157 2024-12-20 14:52:23
##  9 QmSK5hvEsM5mw6658SE1B… arbitr… subg… true       330548614 2024-12-20 10:57:03
## 10 QmQuCY9bwTF13ZkPdpgy7… arbitr… subg… true       330548614 2024-12-19 15:48:56
## # ℹ 360 more rows

Add whether they are synced:

# Look at block numbers by network to determine what's synced
synced_subgraphs = sync_state %>%
  group_by(network) %>%
  mutate(
    max_block = max(current_block),
    blocks_behind = max_block - current_block
  ) %>%
  filter(
    synced == 'true',
    blocks_behind < 500  # Within 500 blocks of the highest known block for that network
  ) %>%
  ungroup()

# View results
print("Synced subgraphs by network:")
## [1] "Synced subgraphs by network:"
print(synced_subgraphs %>% 
  group_by(network) %>%
  summarise(
    count = n(),
    latest_block = max(current_block),
    most_recent_sync = max(synced_at)
  ))
## # A tibble: 4 × 4
##   network      count latest_block most_recent_sync   
##   <chr>        <int>        <dbl> <dttm>             
## 1 arbitrum-one    75    330548614 2025-02-28 02:00:28
## 2 base            39     29458320 2024-12-20 17:37:28
## 3 gnosis          15     39765332 2025-03-02 03:21:57
## 4 mainnet        129     22356157 2025-02-28 19:30:35
# View the actual synced subgraphs
print("\nDetailed synced subgraphs:")
## [1] "\nDetailed synced subgraphs:"
print(synced_subgraphs)
## # A tibble: 258 × 8
##    deployment   network shard synced current_block synced_at           max_block
##    <chr>        <chr>   <chr> <chr>          <dbl> <dttm>                  <dbl>
##  1 QmTyyrcaTdu… gnosis  subg… true        39765332 2025-03-02 03:21:57  39765332
##  2 QmWXhLkz6fR… mainnet subg… true        22356157 2025-02-28 19:30:35  22356157
##  3 QmVUcp8WqE4… mainnet subg… true        22356157 2025-02-28 19:25:20  22356157
##  4 QmdKXcBUHR3… arbitr… subg… true       330548614 2025-02-28 02:00:28 330548614
##  5 QmW26TG5s9m… arbitr… subg… true       330548614 2025-02-27 08:34:51 330548614
##  6 QmYSxAAWeXD… mainnet subg… true        22356157 2024-12-31 16:14:58  22356157
##  7 QmYV4MbMHuE… base    subg… true        29458320 2024-12-20 17:37:28  29458320
##  8 QmddvgpoNsf… mainnet subg… true        22356157 2024-12-20 14:52:23  22356157
##  9 QmSK5hvEsM5… arbitr… subg… true       330548614 2024-12-20 10:57:03 330548614
## 10 QmQuCY9bwTF… arbitr… subg… true       330548614 2024-12-19 15:48:56 330548614
## # ℹ 248 more rows
## # ℹ 1 more variable: blocks_behind <dbl>
## # A tibble: 258 × 8
##    deployment   network shard synced current_block synced_at           max_block
##    <chr>        <chr>   <chr> <chr>          <dbl> <dttm>                  <dbl>
##  1 QmTyyrcaTdu… gnosis  subg… true        39765332 2025-03-02 03:21:57  39765332
##  2 QmWXhLkz6fR… mainnet subg… true        22356157 2025-02-28 19:30:35  22356157
##  3 QmVUcp8WqE4… mainnet subg… true        22356157 2025-02-28 19:25:20  22356157
##  4 QmdKXcBUHR3… arbitr… subg… true       330548614 2025-02-28 02:00:28 330548614
##  5 QmW26TG5s9m… arbitr… subg… true       330548614 2025-02-27 08:34:51 330548614
##  6 QmYSxAAWeXD… mainnet subg… true        22356157 2024-12-31 16:14:58  22356157
##  7 QmYV4MbMHuE… base    subg… true        29458320 2024-12-20 17:37:28  29458320
##  8 QmddvgpoNsf… mainnet subg… true        22356157 2024-12-20 14:52:23  22356157
##  9 QmSK5hvEsM5… arbitr… subg… true       330548614 2024-12-20 10:57:03 330548614
## 10 QmQuCY9bwTF… arbitr… subg… true       330548614 2024-12-19 15:48:56 330548614
## # ℹ 248 more rows
## # ℹ 1 more variable: blocks_behind <dbl>

Great! Next, we will figure out the synced subgraphs that offer the best indexing rewards. Next section

save.image('/root/github/indexer_analytics_tutorial/data/chapters_snapshots/05-synced_subgraphs.RData')