@@ -176,19 +176,18 @@ impl ExecutionPhase {
176
176
pub fn decode_execution_result < Header : HeaderT > (
177
177
& self ,
178
178
execution_result : Vec < u8 > ,
179
- ) -> Header :: Hash {
179
+ ) -> Result < Header :: Hash , VerificationError > {
180
180
match self {
181
181
ExecutionPhase :: InitializeBlock { .. } | ExecutionPhase :: ApplyExtrinsic { .. } => {
182
182
let encoded_storage_root = Vec :: < u8 > :: decode ( & mut execution_result. as_slice ( ) )
183
- . expect ( "The return value of verifying `initialize_block` and `apply_extrinsic` must be an encoded storage root; qed" ) ;
183
+ . map_err ( VerificationError :: InitializeBlockOrApplyExtrinsicDecode ) ? ;
184
184
Header :: Hash :: decode ( & mut encoded_storage_root. as_slice ( ) )
185
- . expect ( "storage root must use the same Header Hash type; qed" )
185
+ . map_err ( VerificationError :: StorageRootDecode )
186
186
}
187
187
ExecutionPhase :: FinalizeBlock => {
188
- let new_header = Header :: decode ( & mut execution_result. as_slice ( ) ) . expect (
189
- "The return value of `BlockBuilder_finalize_block` must be a Header; qed" ,
190
- ) ;
191
- * new_header. state_root ( )
188
+ let new_header = Header :: decode ( & mut execution_result. as_slice ( ) )
189
+ . map_err ( VerificationError :: HeaderDecode ) ?;
190
+ Ok ( * new_header. state_root ( ) )
192
191
}
193
192
}
194
193
}
@@ -205,6 +204,12 @@ pub enum VerificationError {
205
204
BadProof ( sp_std:: boxed:: Box < dyn sp_state_machine:: Error > ) ,
206
205
/// The `post_state_root` calculated by farmer does not match the one declared in [`FraudProof`].
207
206
BadPostStateRoot { expected : H256 , got : H256 } ,
207
+ /// Failed to decode the return value of `initialize_block` and `apply_extrinsic`.
208
+ InitializeBlockOrApplyExtrinsicDecode ( parity_scale_codec:: Error ) ,
209
+ /// Failed to decode the storage root produced by verifying `initialize_block` or `apply_extrinsic`.
210
+ StorageRootDecode ( parity_scale_codec:: Error ) ,
211
+ /// Failed to decode the header produced by `finalize_block`.
212
+ HeaderDecode ( parity_scale_codec:: Error ) ,
208
213
}
209
214
210
215
/// Fraud proof for the state computation.
0 commit comments