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 } ,
8- } ,
9- anyhow:: { anyhow, Result } ,
10- ethers:: {
8+ } , anyhow:: { anyhow, Result } , ethers:: {
119 abi:: Bytes as AbiBytes ,
1210 signers:: { LocalWallet , Signer } ,
1311 types:: { Address , Bytes } ,
14- } ,
15- futures:: future:: join_all,
16- std:: sync:: Arc ,
17- tokio:: spawn,
18- tracing:: Instrument ,
12+ } , futures:: future:: join_all, std:: sync:: Arc , tokio:: spawn, tracing:: Instrument
1913} ;
2014
2115/// Setup provider for all the chains.
@@ -76,7 +70,7 @@ async fn setup_chain_provider(
7670 let contract = Arc :: new ( SignablePythContract :: from_config ( chain_config, & private_key) . await ?) ;
7771
7872 tracing:: info!( "Fetching provider info" ) ;
79- let provider_info = contract. get_provider_info ( provider_address) . call ( ) . await ?;
73+ let provider_info = contract. get_provider_info_v2 ( provider_address) . call ( ) . await ?;
8074 tracing:: info!( "Provider info: {:?}" , provider_info) ;
8175
8276 let mut register = false ;
@@ -146,7 +140,7 @@ async fn setup_chain_provider(
146140 tracing:: info!( "Registered" ) ;
147141 }
148142
149- let provider_info = contract. get_provider_info ( provider_address) . call ( ) . await ?;
143+ let provider_info = contract. get_provider_info_v2 ( provider_address) . call ( ) . await ?;
150144
151145 sync_fee ( & contract, & provider_info, chain_config. fee )
152146 . in_current_span ( )
@@ -173,12 +167,20 @@ async fn setup_chain_provider(
173167 . in_current_span ( )
174168 . await ?;
175169
170+ sync_default_gas_limit (
171+ & contract,
172+ & provider_info,
173+ chain_config. gas_limit ,
174+ )
175+ . in_current_span ( )
176+ . await ?;
177+
176178 Ok ( ( ) )
177179}
178180
179181async fn sync_uri (
180182 contract : & Arc < SignablePythContract > ,
181- provider_info : & EntropyStructsProviderInfo ,
183+ provider_info : & EntropyStructsV2ProviderInfo ,
182184 uri : String ,
183185) -> Result < ( ) > {
184186 let uri_as_bytes: Bytes = AbiBytes :: from ( uri. as_str ( ) ) . into ( ) ;
@@ -198,7 +200,7 @@ async fn sync_uri(
198200
199201async fn sync_fee (
200202 contract : & Arc < SignablePythContract > ,
201- provider_info : & EntropyStructsProviderInfo ,
203+ provider_info : & EntropyStructsV2ProviderInfo ,
202204 provider_fee : u128 ,
203205) -> Result < ( ) > {
204206 if provider_info. fee_in_wei != provider_fee {
@@ -217,7 +219,7 @@ async fn sync_fee(
217219
218220async fn sync_fee_manager (
219221 contract : & Arc < SignablePythContract > ,
220- provider_info : & EntropyStructsProviderInfo ,
222+ provider_info : & EntropyStructsV2ProviderInfo ,
221223 fee_manager : Address ,
222224) -> Result < ( ) > {
223225 if provider_info. fee_manager != fee_manager {
@@ -231,7 +233,7 @@ async fn sync_fee_manager(
231233
232234async fn sync_max_num_hashes (
233235 contract : & Arc < SignablePythContract > ,
234- provider_info : & EntropyStructsProviderInfo ,
236+ provider_info : & EntropyStructsV2ProviderInfo ,
235237 max_num_hashes : u32 ,
236238) -> Result < ( ) > {
237239 if provider_info. max_num_hashes != max_num_hashes {
@@ -247,3 +249,22 @@ async fn sync_max_num_hashes(
247249 }
248250 Ok ( ( ) )
249251}
252+
253+ async fn sync_default_gas_limit (
254+ contract : & Arc < SignablePythContract > ,
255+ provider_info : & EntropyStructsV2ProviderInfo ,
256+ default_gas_limit : u32 ,
257+ ) -> Result < ( ) > {
258+ if provider_info. default_gas_limit != default_gas_limit {
259+ tracing:: info!( "Updating provider default gas limit to {:?}" , default_gas_limit) ;
260+ if let Some ( receipt) = contract
261+ . set_default_gas_limit ( default_gas_limit)
262+ . send ( )
263+ . await ?
264+ . await ?
265+ {
266+ tracing:: info!( "Updated provider default gas limit to : {:?}" , receipt) ;
267+ }
268+ }
269+ Ok ( ( ) )
270+ }
0 commit comments