NethermindEth / cairo-vm-go

A virtual machine for Cairo written in Go
MIT License
73 stars 43 forks source link

Implement DictSquashUpdatePtr #420

Closed har777 closed 4 weeks ago

har777 commented 1 month ago

Fixes #293

sweep-ai[bot] commented 1 month ago

Sweep: PR Review

pkg/hintrunner/hinter/zero_dict.go

New methods SetFreeOffset were added to both ZeroDictionary and ZeroDictionaryManager to allow direct setting of the freeOffset field.


pkg/hintrunner/zero/hintcode.go

A new constant string dictSquashUpdatePtrCode was added to update the current_ptr of the DictTracker to the end address of the squashed dictionary.

Sweep Found These Issues

  • The new code does not handle the case where __dict_manager.get_tracker(ids.squashed_dict_start) returns None, which could lead to a NoneType attribute error.
  • https://github.com/NethermindEth/cairo-vm-go/blob/ce52a881e4ac6b5edd2ad837e46fb63e95bebb6f/pkg%2Fhintrunner%2Fzero%2Fhintcode.go#L120 [View Diff](https://github.com/NethermindEth/cairo-vm-go/pull/420/files#diff-380d0c8d26bef53465d34c871daf8e8fca56a48f7442a200cd32aeef3b7f528bR120)

pkg/hintrunner/zero/zerohint.go

The changes add support for the dictSquashUpdatePtrCode hint type in the GetHintFromCode function by introducing a new case and its corresponding hinter creation function call.


pkg/hintrunner/zero/zerohint_dictionaries.go

Added functions to create and handle a new hint "DictSquashUpdatePtrCode" for updating the current_ptr of a DictTracker.

Sweep Found These Issues

  • If __dict_manager is not in scope, the function returns an error without providing a mechanism to initialize or handle this case.
  • https://github.com/NethermindEth/cairo-vm-go/blob/ce52a881e4ac6b5edd2ad837e46fb63e95bebb6f/pkg%2Fhintrunner%2Fzero%2Fzerohint_dictionaries.go#L422-L424 [View Diff](https://github.com/NethermindEth/cairo-vm-go/pull/420/files#diff-15fa9623cd83e47339eaeccd336d741551849902b2f765413b7eef5b63240ac7R422-R424)

TAdev0 commented 1 month ago

@har777 you have a conflict, can you resolve it?

har777 commented 1 month ago

@har777 you have a conflict, can you resolve it?

Done!