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