11use {
22 crate :: {
33 api:: { get_register_uri, ChainId } ,
4- chain:: ethereum:: { EntropyStructsProviderInfo , SignablePythContract } ,
4+ chain:: ethereum:: { EntropyStructsV2ProviderInfo , SignablePythContract } ,
55 command:: register_provider:: { register_provider_from_config, CommitmentMetadata } ,
66 config:: { Config , EthereumConfig , SetupProviderOptions } ,
77 state:: { HashChainState , PebbleHashChain } ,
@@ -76,7 +76,10 @@ async fn setup_chain_provider(
7676 let contract = Arc :: new ( SignablePythContract :: from_config ( chain_config, & private_key) . await ?) ;
7777
7878 tracing:: info!( "Fetching provider info" ) ;
79- let provider_info = contract. get_provider_info ( provider_address) . call ( ) . await ?;
79+ let provider_info = contract
80+ . get_provider_info_v2 ( provider_address)
81+ . call ( )
82+ . await ?;
8083 tracing:: info!( "Provider info: {:?}" , provider_info) ;
8184
8285 let mut register = false ;
@@ -147,7 +150,10 @@ async fn setup_chain_provider(
147150 tracing:: info!( "Registered" ) ;
148151 }
149152
150- let provider_info = contract. get_provider_info ( provider_address) . call ( ) . await ?;
153+ let provider_info = contract
154+ . get_provider_info_v2 ( provider_address)
155+ . call ( )
156+ . await ?;
151157
152158 if register || !chain_config. sync_fee_only_on_register {
153159 sync_fee ( & contract, & provider_info, chain_config. fee )
@@ -176,12 +182,16 @@ async fn setup_chain_provider(
176182 . in_current_span ( )
177183 . await ?;
178184
185+ sync_default_gas_limit ( & contract, & provider_info, chain_config. gas_limit )
186+ . in_current_span ( )
187+ . await ?;
188+
179189 Ok ( ( ) )
180190}
181191
182192async fn sync_uri (
183193 contract : & Arc < SignablePythContract > ,
184- provider_info : & EntropyStructsProviderInfo ,
194+ provider_info : & EntropyStructsV2ProviderInfo ,
185195 uri : String ,
186196) -> Result < ( ) > {
187197 let uri_as_bytes: Bytes = AbiBytes :: from ( uri. as_str ( ) ) . into ( ) ;
@@ -201,7 +211,7 @@ async fn sync_uri(
201211
202212async fn sync_fee (
203213 contract : & Arc < SignablePythContract > ,
204- provider_info : & EntropyStructsProviderInfo ,
214+ provider_info : & EntropyStructsV2ProviderInfo ,
205215 provider_fee : u128 ,
206216) -> Result < ( ) > {
207217 if provider_info. fee_in_wei != provider_fee {
@@ -220,7 +230,7 @@ async fn sync_fee(
220230
221231async fn sync_fee_manager (
222232 contract : & Arc < SignablePythContract > ,
223- provider_info : & EntropyStructsProviderInfo ,
233+ provider_info : & EntropyStructsV2ProviderInfo ,
224234 fee_manager : Address ,
225235) -> Result < ( ) > {
226236 if provider_info. fee_manager != fee_manager {
@@ -234,7 +244,7 @@ async fn sync_fee_manager(
234244
235245async fn sync_max_num_hashes (
236246 contract : & Arc < SignablePythContract > ,
237- provider_info : & EntropyStructsProviderInfo ,
247+ provider_info : & EntropyStructsV2ProviderInfo ,
238248 max_num_hashes : u32 ,
239249) -> Result < ( ) > {
240250 if provider_info. max_num_hashes != max_num_hashes {
@@ -250,3 +260,25 @@ async fn sync_max_num_hashes(
250260 }
251261 Ok ( ( ) )
252262}
263+
264+ async fn sync_default_gas_limit (
265+ contract : & Arc < SignablePythContract > ,
266+ provider_info : & EntropyStructsV2ProviderInfo ,
267+ default_gas_limit : u32 ,
268+ ) -> Result < ( ) > {
269+ if provider_info. default_gas_limit != default_gas_limit {
270+ tracing:: info!(
271+ "Updating provider default gas limit to {:?}" ,
272+ default_gas_limit
273+ ) ;
274+ if let Some ( receipt) = contract
275+ . set_default_gas_limit ( default_gas_limit)
276+ . send ( )
277+ . await ?
278+ . await ?
279+ {
280+ tracing:: info!( "Updated provider default gas limit to : {:?}" , receipt) ;
281+ }
282+ }
283+ Ok ( ( ) )
284+ }
0 commit comments