Skip to content

Conversation

@glyh
Copy link
Member

@glyh glyh commented Sep 18, 2025

This PR added migration for non-nullable zkapp state table.

TODO:

  • fix issue that failed commands lead to succeeded result

previous: #17826

@glyh glyh requested a review from a team as a code owner September 18, 2025 08:26
@glyh glyh moved this to In Progress in OCaml Node Team Board Sep 18, 2025
RAISE DEBUG 'Adding column % for zkapp_states', col_name;

EXECUTE format(
'ALTER TABLE zkapp_states ADD COLUMN IF NOT EXISTS %I INT DEFAULT 0 NOT NULL REFERENCES zkapp_field(id)',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you reason why 0 not null?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MIP explicitly specify we should use 0 as polyfill.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing that zkapp_states_nullable seems to be used for is constructing account updates:

let%bind state =
let%bind elements =
query_db ~f:(fun db ->
Processor.Zkapp_states_nullable.load db state_id )
in
let elements = Pickles_types.Vector.to_list elements in
let%map fields =
Deferred.List.map elements ~f:(fun id_opt ->
Option.value_map id_opt ~default:(return None) ~f:(fun id ->
let%map field_str =
query_db ~f:(fun db -> Processor.Zkapp_field.load db id)
in
Some (Zkapp_basic.F.of_string field_str) ) )
in
List.map fields ~f:Or_ignore.of_option |> Zkapp_state.V.of_list_exn
in

That state contains a vector of F.t Or_ignore.t - the field elements are allowed to be absent, I think because the update might only affect the state at certain indices.

Should we be adding 0 as a value to the update in that case? If this is only used for updates then null seems more correct.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ I assume this comment is for PR #17826

@glyh glyh force-pushed the lyh/archive-mesa-migrate-non-nullable-zkapp-state branch from e1ad22b to b747663 Compare September 19, 2025 13:44
@glyh glyh force-pushed the lyh/redesign-mesa-archive-migration branch from 3964e50 to ea19fa6 Compare September 30, 2025 05:15
@glyh glyh force-pushed the lyh/redesign-mesa-archive-migration branch from ea19fa6 to e655d54 Compare September 30, 2025 05:17
@glyh glyh force-pushed the lyh/archive-mesa-migrate-non-nullable-zkapp-state branch from b747663 to d243526 Compare October 14, 2025 07:41
@glyh glyh force-pushed the lyh/redesign-mesa-archive-migration branch from 94d0061 to a7988ad Compare October 15, 2025 10:41
@glyh glyh requested a review from a team as a code owner October 15, 2025 10:41
@glyh glyh closed this Oct 15, 2025
@github-project-automation github-project-automation bot moved this from In Progress to Done in OCaml Node Team Board Oct 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants