Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hashdict_finalize #403

Open
8 tasks
Tracked by #288
Eikix opened this issue Jan 13, 2025 · 0 comments · May be fixed by #496
Open
8 tasks
Tracked by #288

hashdict_finalize #403

Eikix opened this issue Jan 13, 2025 · 0 comments · May be fixed by #496
Assignees

Comments

@Eikix
Copy link
Member

Eikix commented Jan 13, 2025

Why

We need two behaviors

  • rollback to a previous state of the dict with soundness (not only memcpy a portion of a segment)
  • integrate values otherwise with soundness

The original dict_squash method only verifies that a DictAccess segment is sound.

What

Add a function hashdict_finalize in dict.cairo to handle these two behaviors.

How

  • take a merge: felt argument to define the target behavior
  • if merge=FALSE, then dict_squash and create a new dict segment of k, p, p created from the squashed dict
  • if merge=TRUE, then do nothing
  • if original_mapping exists, append the above mentioned segment (newly or existing) to the original segment
  • if not, then return the above mentioned segment
  • remove the previous test_dict.cairo file
  • returns dict_start, dict
  • for the test, use a hint in test_dict.cairo to load the initial data into a DictAccess*
@given(...)
def test_hashdict_finalize(original_mapping: Dict[int, int], merge: bool):
    cairo_run_py("test_hashdict_finalize", ...)

in cairo

  • dict_copy
  • in cairo hint, append in current_mapping values to simulate writes
  • call function and return a dict so that it's serde automatically
  • assert in python values = values + int(merge)
@github-project-automation github-project-automation bot moved this to Backlog in Keth Jan 13, 2025
@Eikix Eikix moved this from Backlog to Todo in Keth Jan 13, 2025
@ClementWalter ClementWalter added this to the EELS migration milestone Jan 16, 2025
@ClementWalter ClementWalter changed the title hashdict_squash hashdict_finalize Jan 20, 2025
@enitrat enitrat self-assigned this Jan 20, 2025
@enitrat enitrat linked a pull request Jan 20, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

Successfully merging a pull request may close this issue.

3 participants