1
1
mod contract;
2
+ mod epoch_block_oracle_subgraph;
2
3
mod ipfs;
3
4
mod manifest;
4
5
mod network_subgraph;
@@ -8,6 +9,7 @@ mod util;
8
9
use common:: prelude:: * ;
9
10
use common:: prometheus;
10
11
use contract:: * ;
12
+ use epoch_block_oracle_subgraph:: { EpochBlockOracleSubgraph , EpochBlockOracleSubgraphImpl } ;
11
13
use ethers:: abi:: Address ;
12
14
use ethers:: signers:: LocalWallet ;
13
15
use ethers:: signers:: Signer ;
@@ -105,14 +107,11 @@ struct Config {
105
107
metrics_port : u16 ,
106
108
107
109
#[ structopt(
108
- short,
109
110
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"
114
113
) ]
115
- supported_networks : Vec < String > ,
114
+ epoch_block_oracle_subgraph : String ,
116
115
117
116
// Note: `ethereum/contract` is a valid alias for `ethereum`
118
117
#[ structopt(
@@ -157,6 +156,8 @@ async fn main() -> Result<()> {
157
156
async fn run ( logger : Logger , config : Config ) -> Result < ( ) > {
158
157
let ipfs = IpfsImpl :: new ( config. ipfs , config. ipfs_concurrency , config. ipfs_timeout ) ;
159
158
let subgraph = NetworkSubgraphImpl :: new ( logger. clone ( ) , config. subgraph ) ;
159
+ let epoch_subgraph =
160
+ EpochBlockOracleSubgraphImpl :: new ( logger. clone ( ) , config. epoch_block_oracle_subgraph ) ;
160
161
let contract: Box < dyn StateManager > = if config. dry_run {
161
162
Box :: new ( StateManagerDryRun :: new ( logger. clone ( ) ) )
162
163
} else {
@@ -194,7 +195,7 @@ async fn run(logger: Logger, config: Config) -> Result<()> {
194
195
subgraph. clone ( ) ,
195
196
config. min_signal ,
196
197
grace_period,
197
- & config . supported_networks ,
198
+ epoch_subgraph . clone ( ) ,
198
199
& config. supported_data_source_kinds ,
199
200
)
200
201
. await
@@ -227,7 +228,7 @@ async fn run(logger: Logger, config: Config) -> Result<()> {
227
228
subgraph,
228
229
config. min_signal ,
229
230
grace_period,
230
- & config . supported_networks ,
231
+ epoch_subgraph . clone ( ) ,
231
232
& config. supported_data_source_kinds ,
232
233
)
233
234
. await
@@ -278,18 +279,33 @@ pub async fn reconcile_deny_list(
278
279
subgraph : Arc < impl NetworkSubgraph > ,
279
280
min_signal : u64 ,
280
281
grace_period : Duration ,
281
- supported_network_ids : & [ String ] ,
282
+ epoch_subgraph : Arc < impl EpochBlockOracleSubgraph > ,
282
283
supported_ds_kinds : & [ String ] ,
283
284
) -> Result < ( ) , Error > {
284
285
let logger = logger. clone ( ) ;
285
286
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
+
286
302
// Check the availability status of all subgraphs, and gather which should flip the deny flag.
287
303
let status_changes: Vec < ( [ u8 ; 32 ] , bool ) > = subgraph
288
304
. deployments_over_threshold ( min_signal, grace_period)
289
305
. map ( |deployment| async {
290
306
let deployment = deployment?;
291
307
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 {
293
309
Ok ( ( ) ) => Valid :: Yes ,
294
310
Err ( CheckError :: Invalid ( e) ) => Valid :: No ( e) ,
295
311
Err ( CheckError :: Other ( e) ) => return Err ( e) ,
@@ -419,7 +435,7 @@ impl From<Invalid> for CheckError {
419
435
async fn check (
420
436
ipfs : & impl Ipfs ,
421
437
deployment_id : Cid ,
422
- supported_network_ids : & [ String ] ,
438
+ supported_networks : & [ String ] ,
423
439
supported_ds_kinds : & [ String ] ,
424
440
) -> Result < ( ) , CheckError > {
425
441
fn check_link ( file : & manifest:: Link ) -> Result < Cid , Invalid > {
@@ -483,7 +499,7 @@ async fn check(
483
499
// - That network is listed in the `supported_networks` list
484
500
match ( network, ds_network) {
485
501
( None , Some ( ds_network) ) => {
486
- if !supported_network_ids . contains ( ds_network) {
502
+ if !supported_networks . contains ( ds_network) {
487
503
return Err ( Invalid :: UnsupportedNetwork ( ds_network. clone ( ) ) . into ( ) ) ;
488
504
}
489
505
network = Some ( ds_network)
0 commit comments