From 2a178659c7df9fd9922610ef8ae2c39477e43c6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Thir=C3=A9?= Date: Tue, 6 Feb 2024 16:04:28 +0100 Subject: [PATCH 1/2] Protocol/DAL: Tag slot heaer encoding to facilitate migration --- .../files/alpha__smart_rollup__game.ksy | 20 ++++++++++++++----- src/proto_alpha/lib_protocol/dal_slot_repr.ml | 16 ++++++++++++++- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/contrib/kaitai-struct-files/files/alpha__smart_rollup__game.ksy b/contrib/kaitai-struct-files/files/alpha__smart_rollup__game.ksy index b45db8af9902..1ebedfc81d37 100644 --- a/contrib/kaitai-struct-files/files/alpha__smart_rollup__game.ksy +++ b/contrib/kaitai-struct-files/files/alpha__smart_rollup__game.ksy @@ -15,12 +15,12 @@ types: type: n attested: seq: - - id: level - type: s4 - - id: index + - id: attested_tag type: u1 - - id: commitment - size: 48 + enum: attested_tag + - id: v0 + type: v0 + if: (attested_tag == attested_tag::v0) back_pointers: seq: - id: back_pointers_entries @@ -176,7 +176,17 @@ types: type: s4 - id: index type: u1 + v0: + seq: + - id: level + type: s4 + - id: index + type: u1 + - id: commitment + size: 48 enums: + attested_tag: + 0: v0 bool: 0: false 255: true diff --git a/src/proto_alpha/lib_protocol/dal_slot_repr.ml b/src/proto_alpha/lib_protocol/dal_slot_repr.ml index adc528fa144a..21b383c08b7b 100644 --- a/src/proto_alpha/lib_protocol/dal_slot_repr.ml +++ b/src/proto_alpha/lib_protocol/dal_slot_repr.ml @@ -84,7 +84,21 @@ module Header = struct conv (fun {id; commitment} -> (id, commitment)) (fun (id, commitment) -> {id; commitment}) - (merge_objs id_encoding (obj1 (req "commitment" Commitment.encoding))) + (* A tag is added to ensure we can migrate from this encoding to + different version if we decide to change the encoding. *) + (union + [ + case + ~title:"v0" + (Tag 0) + (merge_objs + (obj1 (req "version" (constant "0"))) + (merge_objs + id_encoding + (obj1 (req "commitment" Commitment.encoding)))) + (fun x -> Some ((), x)) + (fun ((), x) -> x); + ]) let pp_id fmt {published_level; index} = Format.fprintf -- GitLab From a11426b90ca36ebcd17f31586f610b612a47b684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Thir=C3=A9?= Date: Fri, 16 Feb 2024 10:53:11 +0100 Subject: [PATCH 2/2] Tezt/DAL: Fix regression tests --- ... rollup and node with L1 (rollup_node_applies_dal_pages).out | 2 +- ...AL rollup and node with L1 (rollup_node_downloads_slots).out | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tezt/tests/expected/dal.ml/Alpha- Testing DAL rollup and node with L1 (rollup_node_applies_dal_pages).out b/tezt/tests/expected/dal.ml/Alpha- Testing DAL rollup and node with L1 (rollup_node_applies_dal_pages).out index 25e3bf89329f..fb1cdb8f63a4 100644 --- a/tezt/tests/expected/dal.ml/Alpha- Testing DAL rollup and node with L1 (rollup_node_applies_dal_pages).out +++ b/tezt/tests/expected/dal.ml/Alpha- Testing DAL rollup and node with L1 (rollup_node_applies_dal_pages).out @@ -64,7 +64,7 @@ This sequence of operations was run: GET http://[HOST]:[PORT]/global/block/head/dal/slot_headers 200 OK -[{"level":4,"index":0,"commitment":"[DAL_SLOT_HEADER]"},{"level":4,"index":1,"commitment":"[DAL_SLOT_HEADER]"},{"level":4,"index":2,"commitment":"[DAL_SLOT_HEADER]"}] +[{"version":"0","level":4,"index":0,"commitment":"[DAL_SLOT_HEADER]"},{"version":"0","level":4,"index":1,"commitment":"[DAL_SLOT_HEADER]"},{"version":"0","level":4,"index":2,"commitment":"[DAL_SLOT_HEADER]"}] GET http://[HOST]:[PORT]/global/block/head/dal/processed_slots 200 OK diff --git a/tezt/tests/expected/dal.ml/Alpha- Testing DAL rollup and node with L1 (rollup_node_downloads_slots).out b/tezt/tests/expected/dal.ml/Alpha- Testing DAL rollup and node with L1 (rollup_node_downloads_slots).out index 88eb1e74003e..fb3f446ffc2b 100644 --- a/tezt/tests/expected/dal.ml/Alpha- Testing DAL rollup and node with L1 (rollup_node_downloads_slots).out +++ b/tezt/tests/expected/dal.ml/Alpha- Testing DAL rollup and node with L1 (rollup_node_downloads_slots).out @@ -64,7 +64,7 @@ This sequence of operations was run: GET http://[HOST]:[PORT]/global/block/head/dal/slot_headers 200 OK -[{"level":4,"index":0,"commitment":"[DAL_SLOT_HEADER]"},{"level":4,"index":1,"commitment":"[DAL_SLOT_HEADER]"},{"level":4,"index":2,"commitment":"[DAL_SLOT_HEADER]"}] +[{"version":"0","level":4,"index":0,"commitment":"[DAL_SLOT_HEADER]"},{"version":"0","level":4,"index":1,"commitment":"[DAL_SLOT_HEADER]"},{"version":"0","level":4,"index":2,"commitment":"[DAL_SLOT_HEADER]"}] GET http://[HOST]:[PORT]/global/block/head/dal/processed_slots 200 OK -- GitLab