diff --git a/full-node/sov-stf-runner/src/prover_service/parallel/prover.rs b/full-node/sov-stf-runner/src/prover_service/parallel/prover.rs index dbf3870a8..4e62a4916 100644 --- a/full-node/sov-stf-runner/src/prover_service/parallel/prover.rs +++ b/full-node/sov-stf-runner/src/prover_service/parallel/prover.rs @@ -69,7 +69,7 @@ where let prover_manager_clone = self.prover_manager.clone(); let mut prover_manager = self.prover_manager.write().expect("Lock was poisoned"); - let (prover_status, state_transition_data) = prover_manager + let prover_status = prover_manager .remove(&block_header_hash) .ok_or_else(|| anyhow::anyhow!("Missing witness for block: {:?}", block_header_hash))?; @@ -77,6 +77,12 @@ where ProverStatus::WitnessSubmitted => { let start_prover = prover_manager.inc_task_count_if_not_busy(self.num_threads); + let state_transition_data = prover_manager + .get_witness(&block_header_hash) + .ok_or_else(|| { + anyhow::anyhow!("Missing witness for block: {:?}", block_header_hash) + })?; + // Initiate a new proving job only if the prover is not busy. if start_prover { vm.add_hint(state_transition_data); diff --git a/full-node/sov-stf-runner/src/prover_service/parallel/prover_manager.rs b/full-node/sov-stf-runner/src/prover_service/parallel/prover_manager.rs index 62c7f04ca..ad16ae9ac 100644 --- a/full-node/sov-stf-runner/src/prover_service/parallel/prover_manager.rs +++ b/full-node/sov-stf-runner/src/prover_service/parallel/prover_manager.rs @@ -29,6 +29,13 @@ impl ProverState { self.witness.remove(hash) } + fn get_witness( + &mut self, + hash: &Da::SlotHash, + ) -> Option<&StateTransitionData> { + self.witness.get(hash) + } + fn set_to_proving(&mut self, hash: Da::SlotHash) -> Option { self.prover_status .insert(hash, ProverStatus::ProvingInProgress) @@ -117,8 +124,8 @@ impl ProverManager { pub(crate) fn get_witness( &mut self, hash: &Da::SlotHash, - ) -> &StateTransitionData { - self.prover_state.witness.get(hash).unwrap() + ) -> Option<&StateTransitionData> { + self.prover_state.witness.get(hash) } pub(crate) fn submit_witness( @@ -149,13 +156,8 @@ impl ProverManager { } // TODO change name - pub(crate) fn remove( - &mut self, - hash: &Da::SlotHash, - ) -> Option<(ProverStatus, StateTransitionData)> { - let status = self.prover_state.remove(hash)?; - let witness = self.prover_state.remove_witness(hash)?; - Some((status, witness)) + pub(crate) fn remove(&mut self, hash: &Da::SlotHash) -> Option { + self.prover_state.remove(hash) } pub(crate) fn get_prover_status(&mut self, hash: &Da::SlotHash) -> Option<&ProverStatus> {