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

Better error reporting for when memory accesses break the range check #833

Closed
hackaugusto opened this issue Apr 6, 2023 · 5 comments
Closed
Assignees
Milestone

Comments

@hackaugusto
Copy link
Contributor

hackaugusto commented Apr 6, 2023

The following program works:

begin push.1099511627776 mem_load push.1103806595071 mem_load end

the following fails:

begin push.1099511627776 mem_load push.1103806595072 mem_load end

As explained to me by @bobbinth , this happens because at the end of the program execution, the gap between used memory addresses must be at most 2**32 (order is not important). The issue is that testing the above gives simply not a 32-bit value, and when runing or proveing with the release binary there is no reporting, which makes debugging this issue harder. The issue is to improve the error reporting so if someone encounters the issue, it is easy to tell what happened.

@bobbinth
Copy link
Contributor

bobbinth commented Apr 11, 2023

One way to fix this is to just set a hard limit on memory address - i.e., valid memory addresses can be in the range between [0, 2^32). We can impose this first in the processor, and then later figure out if we can impose the same constraints via AIR.

@hackaugusto
Copy link
Contributor Author

valid memory addresses can be in the range between [0, 2^32).

If we do this, then we know that a memory pointer can not be a u64, and we can start using u32 operations for everything. This would open some other optimizations, for example, the mmr::unpack could be implemented with the fixed 32 peaks https://github.com/0xPolygonMiden/miden-vm/pull/834/files#r1162724881 , since it would not be possible to represent the extra leaves in the VM.

@bobbinth
Copy link
Contributor

for example, the mmr::unpack could be implemented with the fixed 32 peaks https://github.com/0xPolygonMiden/miden-vm/pull/834/files#r1162724881 , since it would not be possible to represent the extra leaves in the VM.

I do think this will enable some optimizations, but I'm not sure the above case applies. Since absolute position is not a memory address, we can use a full field element to represent it, and since we describe the whole MMR with just its roots, we'll actually never have to use more than a few dozen memory addresses to describe an MMR.

@hackaugusto
Copy link
Contributor Author

Since absolute position is not a memory address, we can use a full field element to represent it

Makes sense, that basically means there will never be some sort of memory mapping going on, and values would be lazily loaded.

@Fumuran
Copy link
Contributor

Fumuran commented Aug 29, 2023

Closed by #1049

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

3 participants