From 82e483d2686f2bca9626597cb1cca46fbc95a78e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Kr=C3=BCger?= Date: Mon, 17 Apr 2023 18:44:23 +0100 Subject: [PATCH] SCORU: Node: Improve error reporting for bad reveal hashes --- .../lib_sc_rollup_node/fueled_pvm.ml | 20 ++++++++++++------- .../lib_sc_rollup_node/fueled_pvm.ml | 20 ++++++++++++------- .../lib_sc_rollup_node/fueled_pvm.ml | 20 ++++++++++++------- 3 files changed, 39 insertions(+), 21 deletions(-) diff --git a/src/proto_016_PtMumbai/lib_sc_rollup_node/fueled_pvm.ml b/src/proto_016_PtMumbai/lib_sc_rollup_node/fueled_pvm.ml index e294a44c5760..3f2d28080991 100644 --- a/src/proto_016_PtMumbai/lib_sc_rollup_node/fueled_pvm.ml +++ b/src/proto_016_PtMumbai/lib_sc_rollup_node/fueled_pvm.ml @@ -141,14 +141,20 @@ module Make (PVM : Pvm.S) = struct { reveal_preimage = (fun hash -> - let hash = - (* The payload represents the encoded [Sc_rollup_reveal_hash.t]. We must - decode it properly, instead of converting it byte-for-byte. *) - Data_encoding.Binary.of_string_exn - Sc_rollup_reveal_hash.encoding - hash - in let*! data = + let*? hash = + (* The payload represents the encoded [Sc_rollup_reveal_hash.t]. We must + decode it properly, instead of converting it byte-for-byte. *) + Result.bind_error + (Data_encoding.Binary.of_string + Sc_rollup_reveal_hash.encoding + hash) + (error_with + "Bad reveal hash '%a': %a" + Hex.pp + (Hex.of_string hash) + Data_encoding.Binary.pp_read_error) + in get_reveal ~data_dir:node_ctxt.data_dir reveal_map hash in match data with diff --git a/src/proto_017_PtNairob/lib_sc_rollup_node/fueled_pvm.ml b/src/proto_017_PtNairob/lib_sc_rollup_node/fueled_pvm.ml index e7d904662e68..adbb02216313 100644 --- a/src/proto_017_PtNairob/lib_sc_rollup_node/fueled_pvm.ml +++ b/src/proto_017_PtNairob/lib_sc_rollup_node/fueled_pvm.ml @@ -141,14 +141,20 @@ module Make (PVM : Pvm.S) = struct { reveal_preimage = (fun hash -> - let hash = - (* The payload represents the encoded [Sc_rollup_reveal_hash.t]. We must - decode it properly, instead of converting it byte-for-byte. *) - Data_encoding.Binary.of_string_exn - Sc_rollup_reveal_hash.encoding - hash - in let*! data = + let*? hash = + (* The payload represents the encoded [Sc_rollup_reveal_hash.t]. We must + decode it properly, instead of converting it byte-for-byte. *) + Result.bind_error + (Data_encoding.Binary.of_string + Sc_rollup_reveal_hash.encoding + hash) + (error_with + "Bad reveal hash '%a': %a" + Hex.pp + (Hex.of_string hash) + Data_encoding.Binary.pp_read_error) + in get_reveal ~data_dir:node_ctxt.data_dir reveal_map hash in match data with diff --git a/src/proto_alpha/lib_sc_rollup_node/fueled_pvm.ml b/src/proto_alpha/lib_sc_rollup_node/fueled_pvm.ml index 84ed1c098573..325df99539fe 100644 --- a/src/proto_alpha/lib_sc_rollup_node/fueled_pvm.ml +++ b/src/proto_alpha/lib_sc_rollup_node/fueled_pvm.ml @@ -141,14 +141,20 @@ module Make (PVM : Pvm.S) = struct { reveal_preimage = (fun hash -> - let hash = - (* The payload represents the encoded [Sc_rollup_reveal_hash.t]. We must - decode it properly, instead of converting it byte-for-byte. *) - Data_encoding.Binary.of_string_exn - Sc_rollup_reveal_hash.encoding - hash - in let*! data = + let*? hash = + (* The payload represents the encoded [Sc_rollup_reveal_hash.t]. We must + decode it properly, instead of converting it byte-for-byte. *) + Result.bind_error + (Data_encoding.Binary.of_string + Sc_rollup_reveal_hash.encoding + hash) + (error_with + "Bad reveal hash '%a': %a" + Hex.pp + (Hex.of_string hash) + Data_encoding.Binary.pp_read_error) + in get_reveal ?dac_client:node_ctxt.dac_client ~data_dir:node_ctxt.data_dir -- GitLab