From 77d483addb992793dbc069e1cb9891b5d392043a Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Fri, 18 Jul 2025 10:01:31 +0200 Subject: [PATCH] Signer: fix tz4 highwatermark --- src/bin_signer/handler.ml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/bin_signer/handler.ml b/src/bin_signer/handler.ml index 307b39eec9e4..027f72a388a6 100644 --- a/src/bin_signer/handler.ml +++ b/src/bin_signer/handler.ml @@ -67,11 +67,19 @@ module High_watermark = struct "Failed to retrieve level and round of a Tenderbake block: %s" (Printexc.to_string exn) - let get_level_and_round_for_tenderbake_attestation bytes = + let get_level_and_round_for_tenderbake_attestation + (pkh : Signature.public_key_hash) bytes = (* ... *) let open Lwt_result_syntax in try - let level_offset = 1 + 4 + 32 + 1 + 2 in + let level_offset = + match pkh with + | Bls _ -> + (* Slot is not part of the signed payload when + signing with a tz4 address *) + 1 + 4 + 32 + 1 + | Ed25519 _ | Secp256k1 _ | P256 _ -> 1 + 4 + 32 + 1 + 2 + in let level = Bytes.get_int32_be bytes level_offset in let round = Bytes.get_int32_be bytes (level_offset + 4) in return (level, Some round) @@ -215,11 +223,11 @@ module High_watermark = struct | 0x12 -> (* tenderbake preattestation *) mark "a" "preattestation" (fun () -> - get_level_and_round_for_tenderbake_attestation bytes) + get_level_and_round_for_tenderbake_attestation pkh bytes) | 0x13 -> (* tenderbake attestation *) mark "an" "attestation" (fun () -> - get_level_and_round_for_tenderbake_attestation bytes) + get_level_and_round_for_tenderbake_attestation pkh bytes) | _ -> sign bytes end -- GitLab