11mod contract;
2+ mod epoch_block_oracle_subgraph;
23mod ipfs;
34mod manifest;
45mod network_subgraph;
@@ -8,6 +9,7 @@ mod util;
89use common:: prelude:: * ;
910use common:: prometheus;
1011use contract:: * ;
12+ use epoch_block_oracle_subgraph:: { EpochBlockOracleSubgraph , EpochBlockOracleSubgraphImpl } ;
1113use ethers:: abi:: Address ;
1214use ethers:: signers:: LocalWallet ;
1315use ethers:: signers:: Signer ;
@@ -105,14 +107,11 @@ struct Config {
105107 metrics_port : u16 ,
106108
107109 #[ structopt(
108- short,
109110 long,
110- default_value = "mainnet" ,
111- value_delimiter = "," ,
112- env = "SUPPORTED_NETWORKS" ,
113- help = "a comma separated list of the supported network ids"
111+ env = "EPOCH_BLOCK_ORACLE_SUBGRAPH" ,
112+ help = "Graphql endpoint to the epoch block oracle subgraph"
114113 ) ]
115- supported_networks : Vec < String > ,
114+ epoch_block_oracle_subgraph : String ,
116115
117116 // Note: `ethereum/contract` is a valid alias for `ethereum`
118117 #[ structopt(
@@ -157,6 +156,8 @@ async fn main() -> Result<()> {
157156async fn run ( logger : Logger , config : Config ) -> Result < ( ) > {
158157 let ipfs = IpfsImpl :: new ( config. ipfs , config. ipfs_concurrency , config. ipfs_timeout ) ;
159158 let subgraph = NetworkSubgraphImpl :: new ( logger. clone ( ) , config. subgraph ) ;
159+ let epoch_subgraph =
160+ EpochBlockOracleSubgraphImpl :: new ( logger. clone ( ) , config. epoch_block_oracle_subgraph ) ;
160161 let contract: Box < dyn StateManager > = if config. dry_run {
161162 Box :: new ( StateManagerDryRun :: new ( logger. clone ( ) ) )
162163 } else {
@@ -194,7 +195,7 @@ async fn run(logger: Logger, config: Config) -> Result<()> {
194195 subgraph. clone ( ) ,
195196 config. min_signal ,
196197 grace_period,
197- & config . supported_networks ,
198+ epoch_subgraph . clone ( ) ,
198199 & config. supported_data_source_kinds ,
199200 )
200201 . await
@@ -227,7 +228,7 @@ async fn run(logger: Logger, config: Config) -> Result<()> {
227228 subgraph,
228229 config. min_signal ,
229230 grace_period,
230- & config . supported_networks ,
231+ epoch_subgraph . clone ( ) ,
231232 & config. supported_data_source_kinds ,
232233 )
233234 . await
@@ -278,18 +279,33 @@ pub async fn reconcile_deny_list(
278279 subgraph : Arc < impl NetworkSubgraph > ,
279280 min_signal : u64 ,
280281 grace_period : Duration ,
281- supported_network_ids : & [ String ] ,
282+ epoch_subgraph : Arc < impl EpochBlockOracleSubgraph > ,
282283 supported_ds_kinds : & [ String ] ,
283284) -> Result < ( ) , Error > {
284285 let logger = logger. clone ( ) ;
285286
287+ // Fetch supported networks
288+ let mut supported_networks = Vec :: new ( ) ;
289+ let networks_stream = epoch_subgraph. supported_networks ( ) ;
290+ futures:: pin_mut!( networks_stream) ;
291+ while let Some ( network) = networks_stream. next ( ) . await {
292+ match network {
293+ Ok ( network_id) => supported_networks. push ( network_id) ,
294+ Err ( e) => Err ( e) ?,
295+ }
296+ }
297+
298+ info ! ( logger, "Supported networks" ;
299+ "alias" => supported_networks. join( ", " )
300+ ) ;
301+
286302 // Check the availability status of all subgraphs, and gather which should flip the deny flag.
287303 let status_changes: Vec < ( [ u8 ; 32 ] , bool ) > = subgraph
288304 . deployments_over_threshold ( min_signal, grace_period)
289305 . map ( |deployment| async {
290306 let deployment = deployment?;
291307 let id = bytes32_to_cid_v0 ( deployment. id ) ;
292- let validity = match check ( ipfs, id, supported_network_ids , supported_ds_kinds) . await {
308+ let validity = match check ( ipfs, id, & supported_networks , supported_ds_kinds) . await {
293309 Ok ( ( ) ) => Valid :: Yes ,
294310 Err ( CheckError :: Invalid ( e) ) => Valid :: No ( e) ,
295311 Err ( CheckError :: Other ( e) ) => return Err ( e) ,
@@ -419,7 +435,7 @@ impl From<Invalid> for CheckError {
419435async fn check (
420436 ipfs : & impl Ipfs ,
421437 deployment_id : Cid ,
422- supported_network_ids : & [ String ] ,
438+ supported_networks : & [ String ] ,
423439 supported_ds_kinds : & [ String ] ,
424440) -> Result < ( ) , CheckError > {
425441 fn check_link ( file : & manifest:: Link ) -> Result < Cid , Invalid > {
@@ -483,7 +499,7 @@ async fn check(
483499 // - That network is listed in the `supported_networks` list
484500 match ( network, ds_network) {
485501 ( None , Some ( ds_network) ) => {
486- if !supported_network_ids . contains ( ds_network) {
502+ if !supported_networks . contains ( ds_network) {
487503 return Err ( Invalid :: UnsupportedNetwork ( ds_network. clone ( ) ) . into ( ) ) ;
488504 }
489505 network = Some ( ds_network)
0 commit comments