Comments (3)
I think given the current specs, this behavior is correct - but I see how this can be very confusing. The issue is that script context does not have any locals and for procedures fmp
always starts at 0
- so, they overlap. There are a couple of ways to address this:
- We can allow locals in the script context as well - e.g., via
begin.4
or something like that. - We can set the initial value of
fmp
to something other than 0.
If we go with the second option (which I think might be a better approach), the next question would be: what should the initial offset be? One option is: 2^32 - 1.
This would mean that the segment of "global memory" which doesn't overlap with local memory of procedures is roughly 2^32 - 1 words, which should be more than sufficient for any program. The reason why we don't want to make it even bigger is that we have a constraint against memory addresses which says that memory addresses accessed during program execution must be at most 2^32 - 1 values apart. Thus, if we make the offset bigger, and the program doesn't do anything with the global memory, the offset could cause a fault.
In fact, it may be safer to set the offset to something like 2^30. This still provides enough "global memory" and would also safeguard against cases when procedures declare locals but don't end up using them.
An alternative approach is to always output the first operation of a program to be something that pushes zeros to memory address 2^32 - 1. And then we can make the offset 2^32 or even greater (and we won't run into faults) - but I'm not sure this is worth it.
from miden-vm.
I think given the current specs, this behavior is correct
Yeah, I've been thinking about it more & I agree, but I think it's very unexpected behaviour from a user perspective & should probably be adjusted.
We can set the initial value of fmp to something other than 0.
This would be my preference. It seems more flexible and easier to work with than requiring locals to be declared in the script context.
In fact, it may be safer to set the offset to something like 2^30. This still provides enough "global memory" and would also safeguard against cases when procedures declare locals but don't end up using them.
Yeah, I think we should plan for that case. Using offset 2^30 seems like the best option to me.
An alternative approach is to always output the first operation of a program to be something that pushes zeros to memory address 2^32 - 1. And then we can make the offset 2^32 or even greater (and we won't run into faults) - but I'm not sure this is worth it.
This doesn't seem worth it, since it seems unlikely that the option above will be problematic. If we really run into cases where so much memory is being used that we need a bigger offset, we could make this adjustment.
from miden-vm.
Closed by #124
from miden-vm.
Related Issues (20)
- Persist max trace length in `ExecutionTrace` HOT 3
- Transaction Prover Bug HOT 4
- Faster modular reduction for Falcon prime HOT 4
- `StackOutputs.stack_top()` fails when `stack < STACK_TOP_SIZE` HOT 5
- Migrate CLI from StructOpt to Clap HOT 1
- Decorator to get position of the first/last non-empty element of a merkle tree. HOT 4
- stdlib: procedure to check if a given merkle path corresponds to the first/last element of a tree HOT 3
- Remove duplicated computation of z^trace_len among AirScript Masm backend and stark stdlib
- Replace [ZERO; 4] with a constant EMPTY_WORD HOT 3
- Support for basic arithmetic on constant values HOT 3
- Add support for constants on MASM control flow
- Tracking issue: Finalize STARK recursive verifier
- Range checking the parameters of recursive verifier
- Update range-checker to use log derivative-based multiset checks HOT 1
- Support nested modules in Miden assembly HOT 1
- Execution options for processor and prover HOT 1
- Assertions with user-defined error codes HOT 12
- Auxiliary trace column builder simplification
- Implement source location tracking in MAST HOT 2
- Change AdviceMap key in JSON inputs to use [u64; 4] HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from miden-vm.