Skip to content

proto/soru: Add protocol migration to first block of protocol

Sylvain R. requested to merge sribaroud@soru@add_ipl_in_mig_level into master

Context

fix #4529 (closed)

The last block of a protocol runs the migration code of the next protocol. The smart rollup inbox was wrongfully partly updated during the migration code.

The MR fixes it by removing the inbox update in the migration code, as the inbox is fully updated during the construction of the block. And the first block of the new protocol adds the migration message.

Manually testing the MR

This is a bit tedious, this is how I've done:

write a test to print the inbox witness :

let test_missing_ipl () =
  let open Lwt_result_syntax in
  let history = Sc_rollup.Inbox.History.empty ~capacity:10000L in
  let inbox =
    Sc_rollup.Inbox.genesis
      ~predecessor_timestamp:Time.Protocol.epoch
      ~predecessor:Block_hash.zero
      Raw_level.root
  in
  let*? _payloads_history, _history, inbox_with, _payloads, _messages =
    Environment.wrap_tzresult
    @@ Sc_rollup.Inbox.add_all_messages
         ~first_block:true
         ~predecessor_timestamp:
           (Time.Protocol.of_notation_exn "2023-03-31T12:53:11Z")
         ~predecessor:
           (Block_hash.of_b58check_exn
              "BKmeVXfMUVCxg3iaTSqdGwP2a9gydMo7fEXbU5nV9KSXEZzik6m")
         history
         inbox
         []
  in
  let*? _payloads_history, _history, inbox_without, _payloads, _messages =
    Environment.wrap_tzresult
    @@ Sc_rollup.Inbox.add_all_messages
         ~first_block:false
         ~predecessor_timestamp:
           (Time.Protocol.of_notation_exn "2023-03-31T12:53:11Z")
         ~predecessor:
           (Block_hash.of_b58check_exn
              "BKmeVXfMUVCxg3iaTSqdGwP2a9gydMo7fEXbU5nV9KSXEZzik6m")
         history
         inbox
         []
  in
  let witness_hash_with = Sc_rollup.Inbox.current_witness inbox_with in
  let witness_hash_without = Sc_rollup.Inbox.current_witness inbox_without in
  failwith
    "with mig: %a\nwithout: %a"
    Sc_rollup.Inbox_merkelized_payload_hashes.Hash.pp
    witness_hash_with
    Sc_rollup.Inbox_merkelized_payload_hashes.Hash.pp
    witness_hash_without

then do a manual migration in a sandbox (use ./script/prepare_migration_test.sh manual 10) and follow the script instruction. Please bear in mind, this script need on small fix for src/bin_client/octez-init-sandboxed-client.sh:

-        parameters_file="$bin_dir/../../_build/default/src/proto_alpha/lib_parameters/sandbox-parameters.json"
+        parameters_file="$bin_dir/../../_build/default/src/proto_016_PtMumbai/lib_parameters/sandbox-parameters.json"

then bake until the migration happens and replace in the previous test the predecessor and predecessor_timestamp with the one of the migration block and finally run the script to compare the value with the value of the rpc

octez-client rpc get /chains/main/blocks/head/context/smart_rollups/all/inbox

Checklist

  • Document the interface of any function added or modified (see the coding guidelines)
  • Document any change to the user interface, including configuration parameters (see node configuration)
  • Provide automatic testing (see the testing guide).
  • For new features and bug fixes, add an item in the appropriate changelog (docs/protocols/alpha.rst for the protocol and the environment, CHANGES.rst at the root of the repository for everything else).
  • Select suitable reviewers using the Reviewers field below.
  • Select as Assignee the next person who should take action on that MR
Edited by Sylvain R.

Merge request reports

Loading