@@ -157,7 +157,7 @@ impl FromStr for SubmissionStrategy {
157157 let percent: u32 = percent. parse ( ) . map_err ( |e| format ! ( "{:?}" , e) ) ?;
158158 Self :: ClaimBetterThan ( Perbill :: from_percent ( percent) )
159159 } else {
160- return Err ( s. into ( ) )
160+ return Err ( s. into ( ) ) ;
161161 } ;
162162 Ok ( res)
163163 }
@@ -424,7 +424,7 @@ where
424424 e,
425425 at. number
426426 ) ;
427- return Err ( e)
427+ return Err ( e) ;
428428 } ,
429429 } ;
430430
@@ -487,7 +487,7 @@ where
487487
488488 if let Some ( submission) = submission {
489489 if & submission. who == us {
490- return Err ( Error :: AlreadySubmitted )
490+ return Err ( Error :: AlreadySubmitted ) ;
491491 }
492492 }
493493 }
@@ -503,7 +503,7 @@ async fn ensure_solution_passes_strategy(
503503) -> Result < ( ) , Error > {
504504 // don't care about current scores.
505505 if matches ! ( strategy, SubmissionStrategy :: Always ) {
506- return Ok ( ( ) )
506+ return Ok ( ( ) ) ;
507507 }
508508
509509 let addr = runtime:: storage ( ) . election_provider_multi_phase ( ) . signed_submission_indices ( ) ;
@@ -533,19 +533,19 @@ async fn submit_and_watch_solution<T: MinerConfig + Send + Sync + 'static>(
533533) -> Result < ( ) , Error > {
534534 let tx = epm:: signed_solution ( RawSolution { solution, score, round } ) ?;
535535
536- // session == epoch
537- let session_len = client
538- . chain_api ( )
539- . constants ( )
540- . at ( & runtime:: constants ( ) . babe ( ) . epoch_duration ( ) ) ?;
541-
536+ // By default we are using the epoch length as the mortality length.
537+ // If that doesn't is available then we just use the default mortality provided by subxt.
538+ //
542539 // TODO: https://github.com/paritytech/polkadot-staking-miner/issues/730
543540 //
544541 // The extrinsic mortality length is static and it doesn't know when the signed phase ends.
545- let xt_cfg = DefaultExtrinsicParamsBuilder :: default ( )
546- . nonce ( nonce)
547- . mortal ( at, session_len)
548- . build ( ) ;
542+ let xt_cfg = if let Ok ( len) =
543+ client. chain_api ( ) . constants ( ) . at ( & runtime:: constants ( ) . babe ( ) . epoch_duration ( ) )
544+ {
545+ DefaultExtrinsicParamsBuilder :: default ( ) . nonce ( nonce) . mortal ( at, len) . build ( )
546+ } else {
547+ DefaultExtrinsicParamsBuilder :: default ( ) . nonce ( nonce) . build ( )
548+ } ;
549549
550550 let xt = client. chain_api ( ) . tx ( ) . create_signed ( & tx, & * signer, xt_cfg) . await ?;
551551
@@ -580,23 +580,25 @@ async fn submit_and_watch_solution<T: MinerConfig + Send + Sync + 'static>(
580580 return Err ( Error :: Other ( format ! (
581581 "No SolutionStored event found at {:?}" ,
582582 in_block. block_hash( )
583- ) ) )
583+ ) ) ) ;
584584 }
585585 } ,
586586 Listen :: Finalized => {
587- let finalized = tx_progress. wait_for_finalized_success ( ) . await ?;
587+ let finalized_block = tx_progress. wait_for_finalized ( ) . await ?;
588+ let block_hash = finalized_block. block_hash ( ) ;
589+ let finalized_success = finalized_block. wait_for_success ( ) . await ?;
588590
589- let solution_stored = finalized
591+ let solution_stored = finalized_success
590592 . find_first :: < runtime:: election_provider_multi_phase:: events:: SolutionStored > (
591593 ) ;
592594
593595 if let Ok ( Some ( _) ) = solution_stored {
594- log:: info!( target: LOG_TARGET , "Finalized at {:?}" , finalized . block_hash( ) ) ;
596+ log:: info!( target: LOG_TARGET , "Finalized at {:?}" , block_hash) ;
595597 } else {
596598 return Err ( Error :: Other ( format ! (
597599 "No SolutionStored event found at {:?}" ,
598- finalized . block_hash( )
599- ) ) )
600+ block_hash,
601+ ) ) ) ;
600602 }
601603 } ,
602604 } ;
@@ -659,7 +661,7 @@ async fn dry_run_works(rpc: &RpcClient) -> Result<(), Error> {
659661 "dry-run requires a RPC endpoint with `--rpc-methods unsafe`; \
660662 either connect to another RPC endpoint or disable dry-run"
661663 . to_string ( ) ,
662- ) )
664+ ) ) ;
663665 }
664666 }
665667 }
0 commit comments