diff --git a/src/bin_signer/handler.ml b/src/bin_signer/handler.ml index 307b39eec9e49b9de1e0ffa8649bee20a8e150ba..027f72a388a6ca20e15d3aa934534d6b09f38f5f 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