Skip to content

dev: make Memory::get pub #2039

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

Merged
merged 5 commits into from
Apr 15, 2025
Merged

Conversation

enitrat
Copy link
Contributor

@enitrat enitrat commented Apr 1, 2025

Make Memory::get pub

Description

get becomes public, as now that memory itself is public, I want to be able to call get and get a MaybeRelocatable, without going through get_integer or get_relocatable.

Checklist

  • Linked to Github Issue
  • Unit tests added
  • Integration tests added.
  • This change requires new documentation.
    • Documentation has been added/updated.
    • CHANGELOG has been updated.

Copy link
Contributor

@JulianGCalderon JulianGCalderon left a comment

Choose a reason for hiding this comment

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

Hi @enitrat, we prefer not to expose the get function, as the signature is a bit too complex and the Cow is there for legacy reasons.

Could you create a new function get_maybe_relocatable with the following signature, that internally calls get, and expose that one?

pub fn get_maybe_relocatable(&self, key: Relocatable)
    -> Result<MaybeRelocatable, MemoryError>;

@enitrat
Copy link
Contributor Author

enitrat commented Apr 14, 2025

Could you create a new function get_maybe_relocatable with the following signature, that internally calls get, and expose that one?

pub fn get_maybe_relocatable(&self, key: Relocatable)
-> Result<MaybeRelocatable, MemoryError>;

This is what I had done locally while waiting for this to get merged. Would you want me implement this in this PR?

@enitrat enitrat force-pushed the dev/memory-get-public branch from 61513d5 to 3b4066c Compare April 14, 2025 21:45
@enitrat enitrat force-pushed the dev/memory-get-public branch from 3b4066c to 70d85da Compare April 14, 2025 21:45
@JulianGCalderon
Copy link
Contributor

Hey @enitrat. Could you add some unit tests? The coverage workflow would probably fail if not.

@enitrat
Copy link
Contributor Author

enitrat commented Apr 15, 2025

Not sure how to run them locally:

$ make test

cairo1/bin/starknet-compile --allowed-libfuncs-list-name experimental_v0.1.0 cairo_programs/cairo-1-contracts/alloc_constant_size.cairo cairo_programs/cairo-1-contracts/alloc_constant_size.sierra
cairo1/bin/starknet-compile: cairo1/bin/starknet-compile: cannot execute binary file
make: *** [cairo_programs/cairo-1-contracts/alloc_constant_size.sierra] Error 126

@FrancoGiachetta
Copy link
Contributor

FrancoGiachetta commented Apr 15, 2025

Try running make deps (or deps-macos depending on you OS), and then run make test again.

Copy link
Contributor

@JulianGCalderon JulianGCalderon left a comment

Choose a reason for hiding this comment

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

LGTM

@gabrielbosio gabrielbosio added this pull request to the merge queue Apr 15, 2025
Merged via the queue into lambdaclass:main with commit 7ba282c Apr 15, 2025
179 of 184 checks passed
enitrat added a commit to kkrt-labs/cairo-vm that referenced this pull request May 6, 2025
* dev: make Memory::get `pub`

* edit changelog

* dev: expose get_maybe_relocatable instead

* add comment on borrowed variant

* add tests
gabrielbosio pushed a commit that referenced this pull request May 21, 2025
* dev: make Memory::get `pub`

* edit changelog

* dev: expose get_maybe_relocatable instead

* add comment on borrowed variant

* add tests
gabrielbosio added a commit that referenced this pull request Jun 4, 2025
* Remove duplicated `get_val` (#2065)

* avoid installing gmp if it is already installed

* revert part of the last commit

* changelog

* remove unwanted file

* CI: Make cache keys depend on Cairo version (#2056)

* Add Makefile and requirements.txt to cache key

* Don't fetch cairo stwo exclusive programs

* Remove empty file

* Restrict caching Cairo programs

Revert how the Rust workflow uses the Cairo program paths to
calculate the cache keys.
This change would imply the branch only adds Makefile and
requirements.txt to the cache key computation.

---------

Co-authored-by: gabrielbosio <[email protected]>
Co-authored-by: Gabriel Bosio <[email protected]>

* dev: make Memory::get `pub` (#2039)

* dev: make Memory::get `pub`

* edit changelog

* dev: expose get_maybe_relocatable instead

* add comment on borrowed variant

* add tests

* feat(breaking): add support for hint accessible scopes (#2042)

* feat: add support for hint accessible scopes

update changelog

* Update vm/src/hint_processor/hint_processor_definition.rs

Co-authored-by: Julian Gonzalez Calderon <[email protected]>

---------

Co-authored-by: Julian Gonzalez Calderon <[email protected]>

* feat: add support for alias identifiers destination in program serde (#2071)

* feat: add support for aliases destination in program serde

* add changelog

---------

Co-authored-by: Julián González Calderón <[email protected]>

* fix: Add boundary tests for SecpSplitOutOfRange in secp_utils (#2062)

* fix: Add boundary tests for SecpSplitOutOfRange in secp_utils

* Update secp_utils.rs

* Update CHANGELOG.md

* Update secp_utils.rs

* remove optimizations

* Update CHANGELOG.md

* Update CHANGELOG.md

* Update CHANGELOG.md

* empty commit to fix CI

---------

Co-authored-by: Julian Gonzalez Calderon <[email protected]>

* docs: add --run_from_cairo_pie documentation for Cairo 0 and Cairo 1 (#2077)

* docs: add --run_from_cairo_pie flag usage documentation for Cairo 0

* docs: add --run_from_cairo_pie flag usage documentation for Cairo 1

* Update README.md

Co-authored-by: Julian Gonzalez Calderon <[email protected]>

* Update README.md

* Update README.md

* Update README.md

Co-authored-by: Julian Gonzalez Calderon <[email protected]>

* Update README.md

Co-authored-by: Gabriel Bosio <[email protected]>

* Update README.md

Co-authored-by: Julian Gonzalez Calderon <[email protected]>

---------

Co-authored-by: Julian Gonzalez Calderon <[email protected]>
Co-authored-by: Gabriel Bosio <[email protected]>

* Fix WRITE_DIVMOD_SEGMENT hint (#2078)

* Minor fixes - use CAIRO_PRIME

* Add error handling

* Update CHANGELOG.md

* Bump cairo-lang to 0.13.5 (#1959)

* Update cairo-lang versin

* Update changelog

* Add new hints

* Specify prime in new hints

* Only apply mod floor if prime is not CAIRO_PRIME

* Properly implement pack for a different prime

* Fix pack in compute_doubling_slope

* Add negative_points.cairo test

* Add try_get_point_from_x for negative points

* Add double_x test for negative points

* Allow to many arguments

* Add codecov to cairo-0-secp-hints feature

* Prepare for Release v3.0.0-rc.1 (#2092)

* Update version

* Update lock

* Update toolchain

* Update changelog

* Fix clippy

* Update toolchain in CI

* fix: correct cache keys for no-std test coverage in CI (#2093)

* Update rust.yml

* Update rust.yml

* Update rust toolchain to 1.87.0 (#2100)

* update rust toolchain to 1.87.0

* remove uneeded file

* update rust in workflows

* update changelog

* clippy

* clippy

* remove unneeded clippy allow

* fix Changelog link (#2104)

* Improve memory_segments coverage (#2110)

* Add tests for .gen_arg() and .write_arg()

* Add test for .is_valid_memory_value()

* Assert contents of memory segments

---------

Co-authored-by: Franco Giachetta <[email protected]>
Co-authored-by: Julian Gonzalez Calderon <[email protected]>
Co-authored-by: Mathieu <[email protected]>
Co-authored-by: VolodymyrBg <[email protected]>
Co-authored-by: GarmashAlex <[email protected]>
Co-authored-by: crStiv <[email protected]>
Co-authored-by: DiegoC <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants