11// Copyright 2023-, Edge & Node, GraphOps, and Semiotic Labs.
22// SPDX-License-Identifier: Apache-2.0
33
4- use bigdecimal:: { BigDecimal , FromPrimitive , ToPrimitive } ;
5- use figment:: {
6- providers:: { Env , Format , Toml } ,
7- Figment ,
8- } ;
9- use serde_repr:: Deserialize_repr ;
10- use serde_with:: DurationSecondsWithFrac ;
114use std:: {
125 collections:: HashMap ,
6+ env,
137 net:: { Ipv4Addr , SocketAddr , SocketAddrV4 } ,
148 path:: PathBuf ,
159 str:: FromStr ,
1610 time:: Duration ,
1711} ;
18- use tracing:: warn;
1912
20- use alloy :: primitives :: Address ;
13+ use bigdecimal :: { BigDecimal , FromPrimitive , ToPrimitive } ;
2114use bip39:: Mnemonic ;
15+ use figment:: {
16+ providers:: { Env , Format , Toml } ,
17+ Figment ,
18+ } ;
2219use regex:: Regex ;
2320use serde:: Deserialize ;
24- use serde_with :: serde_as ;
25- use std :: env ;
26- use thegraph_core:: DeploymentId ;
21+ use serde_repr :: Deserialize_repr ;
22+ use serde_with :: { serde_as , DurationSecondsWithFrac } ;
23+ use thegraph_core:: { alloy :: primitives :: Address , DeploymentId } ;
2724use url:: Url ;
2825
2926use crate :: NonZeroGRT ;
@@ -57,7 +54,7 @@ impl<'de> Deserialize<'de> for ConfigWrapper {
5754 D : serde:: Deserializer < ' de > ,
5855 {
5956 let config: Config = serde_ignored:: deserialize ( deserializer, |path| {
60- warn ! ( "Ignoring unknown configuration field: {}" , path) ;
57+ tracing :: warn!( "Ignoring unknown configuration field: {}" , path) ;
6158 } ) ?;
6259
6360 Ok ( ConfigWrapper ( config) )
@@ -158,7 +155,7 @@ impl Config {
158155 x if * x <= 1 . into ( ) => {
159156 return Err ( "trigger_value_divisor must be greater than 1" . to_string ( ) )
160157 }
161- x if * x > 1 . into ( ) && * x < 10 . into ( ) => warn ! (
158+ x if * x > 1 . into ( ) && * x < 10 . into ( ) => tracing :: warn!(
162159 "It's recommended that trigger_value_divisor \
163160 be a value greater than 10."
164161 ) ,
@@ -176,7 +173,7 @@ impl Config {
176173 . to_u128 ( )
177174 . unwrap ( )
178175 {
179- warn ! (
176+ tracing :: warn!(
180177 "Trigger value is too low, currently below 0.1 GRT. \
181178 Please modify `max_amount_willing_to_lose_grt` or `trigger_value_divisor`. \
182179 It is best to have a higher trigger value, ideally above 1 GRT. \
@@ -190,7 +187,7 @@ impl Config {
190187 let usual_grt_price = BigDecimal :: from_str ( "0.0001" ) . unwrap ( ) * ten;
191188 if self . tap . max_amount_willing_to_lose_grt . get_value ( ) < usual_grt_price. to_u128 ( ) . unwrap ( )
192189 {
193- warn ! (
190+ tracing :: warn!(
194191 "Your `max_amount_willing_to_lose_grt` value is too close to zero. \
195192 This may deny the sender too often or even break the whole system. \
196193 It's recommended it to be a value greater than 100x an usual query price."
@@ -200,7 +197,7 @@ impl Config {
200197 if self . subgraphs . escrow . config . syncing_interval_secs < Duration :: from_secs ( 10 )
201198 || self . subgraphs . network . config . syncing_interval_secs < Duration :: from_secs ( 10 )
202199 {
203- warn ! (
200+ tracing :: warn!(
204201 "Your `syncing_interval_secs` value it too low. \
205202 This may overload your graph-node instance, \
206203 a recommended value is about 60 seconds."
@@ -210,15 +207,15 @@ impl Config {
210207 if self . subgraphs . escrow . config . syncing_interval_secs > Duration :: from_secs ( 600 )
211208 || self . subgraphs . network . config . syncing_interval_secs > Duration :: from_secs ( 600 )
212209 {
213- warn ! (
210+ tracing :: warn!(
214211 "Your `syncing_interval_secs` value it too high. \
215212 This may cause issues while reacting to updates in the blockchain. \
216213 a recommended value is about 60 seconds."
217214 ) ;
218215 }
219216
220217 if self . tap . rav_request . timestamp_buffer_secs < Duration :: from_secs ( 10 ) {
221- warn ! (
218+ tracing :: warn!(
222219 "Your `tap.rav_request.timestamp_buffer_secs` value it too low. \
223220 You may discart receipts in case of any synchronization issues, \
224221 a recommended value is about 30 seconds."
@@ -423,15 +420,15 @@ pub struct RavRequestConfig {
423420
424421#[ cfg( test) ]
425422mod tests {
426- use alloy:: primitives:: FixedBytes ;
423+ use std:: { env, fs, path:: PathBuf } ;
424+
427425 use figment:: value:: Uncased ;
428426 use sealed_test:: prelude:: * ;
429- use std :: { env , fs , path :: PathBuf , str :: FromStr } ;
427+ use thegraph_core :: alloy :: primitives :: address ;
430428 use tracing_test:: traced_test;
431429
432- use crate :: { Config , ConfigPrefix } ;
433-
434430 use super :: { DatabaseConfig , SHARED_PREFIX } ;
431+ use crate :: { Config , ConfigPrefix } ;
435432
436433 #[ test]
437434 fn test_minimal_config ( ) {
@@ -451,9 +448,7 @@ mod tests {
451448 )
452449 . unwrap ( ) ;
453450 max_config. dips = Some ( crate :: DipsConfig {
454- allowed_payers : vec ! [ thegraph_core:: Address (
455- FixedBytes :: <20 >:: from_str( "0x3333333333333333333333333333333333333333" ) . unwrap( ) ,
456- ) ] ,
451+ allowed_payers : vec ! [ address!( "3333333333333333333333333333333333333333" ) ] ,
457452 cancellation_time_tolerance : None ,
458453 } ) ;
459454
0 commit comments