From 8099158b1dc946f403532f565bd0c1b014844249 Mon Sep 17 00:00:00 2001 From: Diane Gallois-Wong Date: Wed, 23 Apr 2025 17:58:38 +0200 Subject: [PATCH 1/3] Proto/operation_repr: properly decode attestations aggregate with DAL --- .../lib_protocol/operation_repr.ml | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/proto_alpha/lib_protocol/operation_repr.ml b/src/proto_alpha/lib_protocol/operation_repr.ml index ca9d76c3e877..6a9e3cfea6ac 100644 --- a/src/proto_alpha/lib_protocol/operation_repr.ml +++ b/src/proto_alpha/lib_protocol/operation_repr.ml @@ -1159,10 +1159,15 @@ module Encoding = struct (varopt "signature" Signature.encoding))) let dal_content_encoding = - obj1 (req "dal_attestation" Dal_attestation_repr.encoding) + conv + (fun {attestation} -> attestation) + (fun attestation -> {attestation}) + Dal_attestation_repr.encoding let consensus_content_with_dal_encoding = - merge_objs consensus_content_encoding dal_content_encoding + merge_objs + consensus_content_encoding + (obj1 (req "dal_attestation" dal_content_encoding)) (* Precondition: [dal_content = None]. *) let attestation_encoding_proj @@ -1177,10 +1182,10 @@ module Encoding = struct (Attestation {consensus_content; dal_content}) = match dal_content with | None -> assert false - | Some dal_content -> (consensus_content, dal_content.attestation) + | Some dal_content -> (consensus_content, dal_content) - let attestation_with_dal_encoding_inj (consensus_content, attestation) = - Attestation {consensus_content; dal_content = Some {attestation}} + let attestation_with_dal_encoding_inj (consensus_content, dal_content) = + Attestation {consensus_content; dal_content = Some dal_content} let attestation_case = Case @@ -1251,7 +1256,12 @@ module Encoding = struct let attestations_aggregate_encoding = obj2 (req "consensus_content" consensus_aggregate_content_encoding) - (req "committee" (list Slot_repr.encoding)) + (req + "committee" + (list + (obj2 + (req "slot" Slot_repr.encoding) + (opt "dal_attestation" dal_content_encoding)))) let attestations_aggregate_case = Case @@ -1264,13 +1274,9 @@ module Encoding = struct | Contents (Attestations_aggregate _ as op) -> Some op | _ -> None); proj = (fun (Attestations_aggregate {consensus_content; committee}) -> - (* TODO: https://gitlab.com/tezos/tezos/-/issues/7935 - Take dal_content into account. *) - let committee = tmp_to_old_committee committee in (consensus_content, committee)); inj = (fun (consensus_content, committee) -> - let committee = tmp_of_old_committee committee in Attestations_aggregate {consensus_content; committee}); } -- GitLab From 6e07de6f74ec14d13f8777db2119b172c4e0d645 Mon Sep 17 00:00:00 2001 From: Diane Gallois-Wong Date: Tue, 15 Apr 2025 15:26:18 +0200 Subject: [PATCH 2/3] kaitai: update committee encoding Generated with: dune exec -- client-libs/bin_codec_kaitai/codec.exe dump kaitai specs in client-libs/kaitai-struct-files/files --- .../files/alpha__operation.ksy | 26 ++++++++++++++++++- .../alpha__operation__bls_mode_unsigned.ksy | 26 ++++++++++++++++++- .../files/alpha__operation__contents.ksy | 26 ++++++++++++++++++- .../files/alpha__operation__contents_list.ksy | 26 ++++++++++++++++++- .../files/alpha__operation__protocol_data.ksy | 26 ++++++++++++++++++- .../files/alpha__operation__unsigned.ksy | 26 ++++++++++++++++++- 6 files changed, 150 insertions(+), 6 deletions(-) diff --git a/client-libs/kaitai-struct-files/files/alpha__operation.ksy b/client-libs/kaitai-struct-files/files/alpha__operation.ksy index 9f6640648209..11f17279097f 100644 --- a/client-libs/kaitai-struct-files/files/alpha__operation.ksy +++ b/client-libs/kaitai-struct-files/files/alpha__operation.ksy @@ -419,7 +419,31 @@ types: - id: committee type: committee size: len_committee + committee_1: + seq: + - id: committee_entries + type: committee_entries_0 + repeat: eos + committee_2: + seq: + - id: len_committee + type: u4be + valid: + max: 1073741823 + - id: committee + type: committee_1 + size: len_committee committee_entries: + seq: + - id: slot + type: u2be + - id: dal_attestation_tag + type: u1 + enum: bool + - id: dal_attestation + type: z + if: (dal_attestation_tag == bool::true) + committee_entries_0: seq: - id: committee_elt type: u2be @@ -907,7 +931,7 @@ types: - id: consensus_content type: consensus_content - id: committee - type: committee_0 + type: committee_2 price: seq: - id: id diff --git a/client-libs/kaitai-struct-files/files/alpha__operation__bls_mode_unsigned.ksy b/client-libs/kaitai-struct-files/files/alpha__operation__bls_mode_unsigned.ksy index 454865ebe155..35f9c4982714 100644 --- a/client-libs/kaitai-struct-files/files/alpha__operation__bls_mode_unsigned.ksy +++ b/client-libs/kaitai-struct-files/files/alpha__operation__bls_mode_unsigned.ksy @@ -420,7 +420,31 @@ types: - id: committee type: committee size: len_committee + committee_1: + seq: + - id: committee_entries + type: committee_entries_0 + repeat: eos + committee_2: + seq: + - id: len_committee + type: u4be + valid: + max: 1073741823 + - id: committee + type: committee_1 + size: len_committee committee_entries: + seq: + - id: slot + type: u2be + - id: dal_attestation_tag + type: u1 + enum: bool + - id: dal_attestation + type: z + if: (dal_attestation_tag == bool::true) + committee_entries_0: seq: - id: committee_elt type: u2be @@ -908,7 +932,7 @@ types: - id: consensus_content type: consensus_content - id: committee - type: committee_0 + type: committee_2 price: seq: - id: id diff --git a/client-libs/kaitai-struct-files/files/alpha__operation__contents.ksy b/client-libs/kaitai-struct-files/files/alpha__operation__contents.ksy index 28bc8c0b027c..9f60bce9852e 100644 --- a/client-libs/kaitai-struct-files/files/alpha__operation__contents.ksy +++ b/client-libs/kaitai-struct-files/files/alpha__operation__contents.ksy @@ -400,7 +400,31 @@ types: - id: committee type: committee size: len_committee + committee_1: + seq: + - id: committee_entries + type: committee_entries_0 + repeat: eos + committee_2: + seq: + - id: len_committee + type: u4be + valid: + max: 1073741823 + - id: committee + type: committee_1 + size: len_committee committee_entries: + seq: + - id: slot + type: u2be + - id: dal_attestation_tag + type: u1 + enum: bool + - id: dal_attestation + type: z + if: (dal_attestation_tag == bool::true) + committee_entries_0: seq: - id: committee_elt type: u2be @@ -884,7 +908,7 @@ types: - id: consensus_content type: consensus_content - id: committee - type: committee_0 + type: committee_2 price: seq: - id: id diff --git a/client-libs/kaitai-struct-files/files/alpha__operation__contents_list.ksy b/client-libs/kaitai-struct-files/files/alpha__operation__contents_list.ksy index 66d84ed954f3..9d4cda5bb787 100644 --- a/client-libs/kaitai-struct-files/files/alpha__operation__contents_list.ksy +++ b/client-libs/kaitai-struct-files/files/alpha__operation__contents_list.ksy @@ -404,7 +404,31 @@ types: - id: committee type: committee size: len_committee + committee_1: + seq: + - id: committee_entries + type: committee_entries_0 + repeat: eos + committee_2: + seq: + - id: len_committee + type: u4be + valid: + max: 1073741823 + - id: committee + type: committee_1 + size: len_committee committee_entries: + seq: + - id: slot + type: u2be + - id: dal_attestation_tag + type: u1 + enum: bool + - id: dal_attestation + type: z + if: (dal_attestation_tag == bool::true) + committee_entries_0: seq: - id: committee_elt type: u2be @@ -888,7 +912,7 @@ types: - id: consensus_content type: consensus_content - id: committee - type: committee_0 + type: committee_2 price: seq: - id: id diff --git a/client-libs/kaitai-struct-files/files/alpha__operation__protocol_data.ksy b/client-libs/kaitai-struct-files/files/alpha__operation__protocol_data.ksy index 63c7638002ba..317c0144f339 100644 --- a/client-libs/kaitai-struct-files/files/alpha__operation__protocol_data.ksy +++ b/client-libs/kaitai-struct-files/files/alpha__operation__protocol_data.ksy @@ -419,7 +419,31 @@ types: - id: committee type: committee size: len_committee + committee_1: + seq: + - id: committee_entries + type: committee_entries_0 + repeat: eos + committee_2: + seq: + - id: len_committee + type: u4be + valid: + max: 1073741823 + - id: committee + type: committee_1 + size: len_committee committee_entries: + seq: + - id: slot + type: u2be + - id: dal_attestation_tag + type: u1 + enum: bool + - id: dal_attestation + type: z + if: (dal_attestation_tag == bool::true) + committee_entries_0: seq: - id: committee_elt type: u2be @@ -907,7 +931,7 @@ types: - id: consensus_content type: consensus_content - id: committee - type: committee_0 + type: committee_2 price: seq: - id: id diff --git a/client-libs/kaitai-struct-files/files/alpha__operation__unsigned.ksy b/client-libs/kaitai-struct-files/files/alpha__operation__unsigned.ksy index f6125dbda13a..94fc086df82e 100644 --- a/client-libs/kaitai-struct-files/files/alpha__operation__unsigned.ksy +++ b/client-libs/kaitai-struct-files/files/alpha__operation__unsigned.ksy @@ -407,7 +407,31 @@ types: - id: committee type: committee size: len_committee + committee_1: + seq: + - id: committee_entries + type: committee_entries_0 + repeat: eos + committee_2: + seq: + - id: len_committee + type: u4be + valid: + max: 1073741823 + - id: committee + type: committee_1 + size: len_committee committee_entries: + seq: + - id: slot + type: u2be + - id: dal_attestation_tag + type: u1 + enum: bool + - id: dal_attestation + type: z + if: (dal_attestation_tag == bool::true) + committee_entries_0: seq: - id: committee_elt type: u2be @@ -895,7 +919,7 @@ types: - id: consensus_content type: consensus_content - id: committee - type: committee_0 + type: committee_2 price: seq: - id: id -- GitLab From a28b06124c8efb18972b733a1c65da4a27f2ecad Mon Sep 17 00:00:00 2001 From: Diane Gallois-Wong Date: Tue, 15 Apr 2025 15:23:31 +0200 Subject: [PATCH 3/3] Tezt: update attestations-aggregate encoding Updated tezt/tests/encoding_samples/ files manually then ran: dune exec tezt/tests/main.exe -- -f tezt/tests/encoding.ml alpha -m operation --reset-regressions --- ...nsigned-attestations-aggregate.sample.json | 18 +++++++++++- ...eration-attestations_aggregate.sample.json | 18 +++++++++++- ...ol encoding regression test- operation.out | 28 ++++++++++++++----- ...ng regression test- operation.unsigned.out | 28 ++++++++++++++----- 4 files changed, 76 insertions(+), 16 deletions(-) diff --git a/tezt/tests/encoding_samples/alpha/operation.unsigned/operation.unsigned-attestations-aggregate.sample.json b/tezt/tests/encoding_samples/alpha/operation.unsigned/operation.unsigned-attestations-aggregate.sample.json index 4c1dfeb71fc6..aac83e147fae 100644 --- a/tezt/tests/encoding_samples/alpha/operation.unsigned/operation.unsigned-attestations-aggregate.sample.json +++ b/tezt/tests/encoding_samples/alpha/operation.unsigned/operation.unsigned-attestations-aggregate.sample.json @@ -8,7 +8,23 @@ "round": 0, "block_payload_hash": "vh1g87ZG6scSYxKhspAUzprQVuLAyoa5qMBKcUfjgnQGnFb3dJcG" }, - "committee": [ 0, 23, 51, 893 ] + "committee": [ + { + "slot": 0 + }, + { + "slot": 23, + "dal_attestation": "2048" + }, + { + "slot": 51, + "dal_attestation": "0" + }, + { + "slot": 893, + "dal_attestation": "1" + } + ] } ] } diff --git a/tezt/tests/encoding_samples/alpha/operation/operation-attestations_aggregate.sample.json b/tezt/tests/encoding_samples/alpha/operation/operation-attestations_aggregate.sample.json index f6889bd9f2f8..859824ef0952 100644 --- a/tezt/tests/encoding_samples/alpha/operation/operation-attestations_aggregate.sample.json +++ b/tezt/tests/encoding_samples/alpha/operation/operation-attestations_aggregate.sample.json @@ -8,7 +8,23 @@ "round": 0, "block_payload_hash": "vh1g87ZG6scSYxKhspAUzprQVuLAyoa5qMBKcUfjgnQGnFb3dJcG" }, - "committee": [ 0, 23, 51, 893 ] + "committee": [ + { + "slot": 0 + }, + { + "slot": 23, + "dal_attestation": "2048" + }, + { + "slot": 51, + "dal_attestation": "0" + }, + { + "slot": 893, + "dal_attestation": "1" + } + ] } ], "signature": "BLsigBANTUiNcB2UB7VMj1yTn4SgX9NZabdSY3cHBZgDvFoDcJWrtYZZZshA8LEjY46wqxoWM7PvDTatLiDoiCTmc4p2LVdsXLC9CPtDmZYe7mr33uPgLyVutVSqMmrxRF1ej9Ce7p7nRH" diff --git a/tezt/tests/expected/encoding.ml/Alpha- protocol encoding regression test- operation.out b/tezt/tests/expected/encoding.ml/Alpha- protocol encoding regression test- operation.out index 8eff237d57a6..2f33acacf984 100644 --- a/tezt/tests/expected/encoding.ml/Alpha- protocol encoding regression test- operation.out +++ b/tezt/tests/expected/encoding.ml/Alpha- protocol encoding regression test- operation.out @@ -82,18 +82,29 @@ "block_payload_hash": "vh1g87ZG6scSYxKhspAUzprQVuLAyoa5qMBKcUfjgnQGnFb3dJcG" }, "committee": [ - 0, - 23, - 51, - 893 + { + "slot": 0 + }, + { + "slot": 23, + "dal_attestation": "2048" + }, + { + "slot": 51, + "dal_attestation": "0" + }, + { + "slot": 893, + "dal_attestation": "1" + } ] } ], "signature": "BLsigBANTUiNcB2UB7VMj1yTn4SgX9NZabdSY3cHBZgDvFoDcJWrtYZZZshA8LEjY46wqxoWM7PvDTatLiDoiCTmc4p2LVdsXLC9CPtDmZYe7mr33uPgLyVutVSqMmrxRF1ej9Ce7p7nRH" }' -0e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a81f0000053300000000000000000000000000000000000000000000000000000000000000000000000000000008000000170033037dff03aa9d7b7d96832a1d687a1be9a330ed89ba3fcb293de1dbbede4d9f69a22555f2e2c661f68ed427c4cafc7568554207ce0e2d6daa5abb0a07031ed7e5ee3d5c9c17cf827b1824a4b03afd7f13cdde07e37d8c38b053fd928815e462bdf9eb062d +0e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a81f00000533000000000000000000000000000000000000000000000000000000000000000000000000000000100000000017ff80200033ff00037dff01ff03aa9d7b7d96832a1d687a1be9a330ed89ba3fcb293de1dbbede4d9f69a22555f2e2c661f68ed427c4cafc7568554207ce0e2d6daa5abb0a07031ed7e5ee3d5c9c17cf827b1824a4b03afd7f13cdde07e37d8c38b053fd928815e462bdf9eb062d -./octez-codec decode alpha.operation from 0e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a81f0000053300000000000000000000000000000000000000000000000000000000000000000000000000000008000000170033037dff03aa9d7b7d96832a1d687a1be9a330ed89ba3fcb293de1dbbede4d9f69a22555f2e2c661f68ed427c4cafc7568554207ce0e2d6daa5abb0a07031ed7e5ee3d5c9c17cf827b1824a4b03afd7f13cdde07e37d8c38b053fd928815e462bdf9eb062d +./octez-codec decode alpha.operation from 0e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a81f00000533000000000000000000000000000000000000000000000000000000000000000000000000000000100000000017ff80200033ff00037dff01ff03aa9d7b7d96832a1d687a1be9a330ed89ba3fcb293de1dbbede4d9f69a22555f2e2c661f68ed427c4cafc7568554207ce0e2d6daa5abb0a07031ed7e5ee3d5c9c17cf827b1824a4b03afd7f13cdde07e37d8c38b053fd928815e462bdf9eb062d { "branch": "BKpbfCvh777DQHnXjU2sqHvVUNZ7dBAdqEfKkdw8EGSkD9LSYXb", "contents": [ { "kind": "attestations_aggregate", @@ -101,7 +112,10 @@ { "level": 1331, "round": 0, "block_payload_hash": "vh1g87ZG6scSYxKhspAUzprQVuLAyoa5qMBKcUfjgnQGnFb3dJcG" }, - "committee": [ 0, 23, 51, 893 ] } ], + "committee": + [ { "slot": 0 }, { "slot": 23, "dal_attestation": "2048" }, + { "slot": 51, "dal_attestation": "0" }, + { "slot": 893, "dal_attestation": "1" } ] } ], "signature": "BLsigBANTUiNcB2UB7VMj1yTn4SgX9NZabdSY3cHBZgDvFoDcJWrtYZZZshA8LEjY46wqxoWM7PvDTatLiDoiCTmc4p2LVdsXLC9CPtDmZYe7mr33uPgLyVutVSqMmrxRF1ej9Ce7p7nRH" } diff --git a/tezt/tests/expected/encoding.ml/Alpha- protocol encoding regression test- operation.unsigned.out b/tezt/tests/expected/encoding.ml/Alpha- protocol encoding regression test- operation.unsigned.out index 416b19714b55..69a7b869fb0c 100644 --- a/tezt/tests/expected/encoding.ml/Alpha- protocol encoding regression test- operation.unsigned.out +++ b/tezt/tests/expected/encoding.ml/Alpha- protocol encoding regression test- operation.unsigned.out @@ -73,17 +73,28 @@ "block_payload_hash": "vh1g87ZG6scSYxKhspAUzprQVuLAyoa5qMBKcUfjgnQGnFb3dJcG" }, "committee": [ - 0, - 23, - 51, - 893 + { + "slot": 0 + }, + { + "slot": 23, + "dal_attestation": "2048" + }, + { + "slot": 51, + "dal_attestation": "0" + }, + { + "slot": 893, + "dal_attestation": "1" + } ] } ] }' -0e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a81f0000053300000000000000000000000000000000000000000000000000000000000000000000000000000008000000170033037d +0e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a81f00000533000000000000000000000000000000000000000000000000000000000000000000000000000000100000000017ff80200033ff00037dff01 -./octez-codec decode alpha.operation.unsigned from 0e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a81f0000053300000000000000000000000000000000000000000000000000000000000000000000000000000008000000170033037d +./octez-codec decode alpha.operation.unsigned from 0e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a81f00000533000000000000000000000000000000000000000000000000000000000000000000000000000000100000000017ff80200033ff00037dff01 { "branch": "BKpbfCvh777DQHnXjU2sqHvVUNZ7dBAdqEfKkdw8EGSkD9LSYXb", "contents": [ { "kind": "attestations_aggregate", @@ -91,7 +102,10 @@ { "level": 1331, "round": 0, "block_payload_hash": "vh1g87ZG6scSYxKhspAUzprQVuLAyoa5qMBKcUfjgnQGnFb3dJcG" }, - "committee": [ 0, 23, 51, 893 ] } ] } + "committee": + [ { "slot": 0 }, { "slot": 23, "dal_attestation": "2048" }, + { "slot": 51, "dal_attestation": "0" }, + { "slot": 893, "dal_attestation": "1" } ] } ] } ./octez-codec encode alpha.operation.unsigned from '{ "branch": "BKpbfCvh777DQHnXjU2sqHvVUNZ7dBAdqEfKkdw8EGSkD9LSYXb", -- GitLab