@@ -81,6 +81,7 @@ impl EscalationPolicy {
8181 }
8282}
8383
84+ /// Send a transaction and wait for the receipt to ensure that it was confirmed on chain.
8485pub async fn send_and_confirm < A : Middleware > ( contract_call : ContractCall < A , ( ) > ) -> Result < ( ) > {
8586 let call_name = contract_call. function . name . as_str ( ) ;
8687 let pending_tx = contract_call
@@ -141,6 +142,13 @@ pub async fn estimate_tx_cost<T: Middleware + 'static>(
141142 Ok ( gas_price * gas_used)
142143}
143144
145+ /// Submit a transaction, retrying on failure according to a configurable backoff policy.
146+ /// The transaction is retried with exponentially increasing delay between retries, and
147+ /// similarly escalating gas and fee multipliers.
148+ /// The gas_limit parameter is the maximum gas that we expect the transaction to use -- if the gas estimate for
149+ /// the transaction exceeds this limit, the transaction is not submitted.
150+ /// Note however that any gas_escalation policy is applied to the estimate, so the actual gas used may exceed the limit.
151+ /// The transaction is retried until it is confirmed on chain or the maximum number of retries is reached.
144152pub async fn submit_tx_with_backoff < T : Middleware + NonceManaged + ' static > (
145153 middleware : Arc < T > ,
146154 call : ContractCall < T , ( ) > ,
@@ -198,8 +206,8 @@ pub async fn submit_tx_with_backoff<T: Middleware + NonceManaged + 'static>(
198206 } )
199207}
200208
201- /// Process a callback on a chain . It estimates the gas for the reveal with callback and
202- /// submits the transaction if the gas estimate is below the gas limit .
209+ /// Submit a transaction to the blockchain . It estimates the gas for the transaction,
210+ /// pads both the gas and fee estimates using the provided multipliers, and submits the transaction .
203211/// It will return a permanent or transient error depending on the error type and whether
204212/// retry is possible or not.
205213pub async fn submit_tx < T : Middleware + NonceManaged + ' static > (
@@ -219,7 +227,7 @@ pub async fn submit_tx<T: Middleware + NonceManaged + 'static>(
219227 backoff:: Error :: transient ( anyhow ! ( "Error estimating gas for reveal: {:?}" , e) )
220228 } ) ?;
221229
222- // The gas limit on the simulated transaction is the configured gas limit on the chain ,
230+ // The gas limit on the simulated transaction is the maximum expected tx gas estimate ,
223231 // but we are willing to pad the gas a bit to ensure reliable submission.
224232 if gas_estimate > gas_limit {
225233 return Err ( backoff:: Error :: permanent ( anyhow ! (
@@ -229,12 +237,10 @@ pub async fn submit_tx<T: Middleware + NonceManaged + 'static>(
229237 ) ) ) ;
230238 }
231239
232- // Pad the gas estimate after checking it against the simulation gas limit, ensuring that
233- // the padded gas estimate doesn't exceed the maximum amount of gas we are willing to use.
240+ // Pad the gas estimate after checking it against the simulation gas limit.
234241 let gas_estimate = gas_estimate. saturating_mul ( gas_estimate_multiplier_pct. into ( ) ) / 100 ;
235242
236243 let call = call. clone ( ) . gas ( gas_estimate) ;
237-
238244 let mut transaction = call. tx . clone ( ) ;
239245
240246 // manually fill the tx with the gas info, so we can log the details in case of error
0 commit comments