Comments (10)
That would be awesome! I do want to say that this might be a fairly involved task. So, maybe worth splitting it into a couple of PRs. For example, the first (simpler) PR could be to add u32assert2
instruction to Miden assembly, and only after that add it to the VM's instruction set.
from miden-vm.
If no one else is looking into it, then I'd like to pick this up?
from miden-vm.
Actually, that's the plan! I will start working on adding u32assert2
instruction to Miden assembly and submit a PR. Just wanted to know your thoughts on how are we planning to reduce the overall VM cycles. For ex: adding two u32 value unsafely will require 1 VM cycle and likewise doing it safely would costs us 7 VM cycles (1 for addition and 3 each for asserting u32). How can we do this in 2 VM cycles("we'd be able to do must safe operations at just 2x the cost of the unsafe ones.")? Are we planning to do the operation unsafely first and then check of the output is u32 or not? Again this method will cost 4 VM cycles. Apologies if I'm missing something. Thanks.
from miden-vm.
Actually, that's the plan! I will start working on adding
u32assert2
instruction to Miden assembly and submit a PR.
Great!
For ex: adding two u32 value unsafely will require 1 VM cycle and likewise doing it safely would costs us 7 VM cycles
Once u32assert2
is implemented as a native VM operation (i.e., an operation which takes 1 cycle) the cost of safe operations will be reduced significantly. But you are right, for operations where we need to check that output is in the right range, it will still take more than 2 cycles. To take a u32add
operation as an example.
Plain u32add
would take 4 cycles and would look like this:
u32assert2
u32add.unsafe
eq.0
assert
But u32add.full
would take only 2 cycles and would look like this:
u32assert2
u32add.unsafe
PS: There is a typo in "we'd be able to do must safe operations at just 2x the cost of the unsafe ones" - "must" should be "most" :)
from miden-vm.
Thanks for the explanation. Makes sense now. What opcode shall I use for U32assert2?
from miden-vm.
For the assembly instruction let's call it u32assert.2
.
As discussed above, as a part of the first PR there is no need to change the actual opcodes of the VM. But once we get there, the opcode could be just u32assert2
.
from miden-vm.
I'll start working on adding u32assert2 to the core VM instruction set, given it's already been added to the assembly. @bobbinth What binary literal shall I use for u32assert2?
from miden-vm.
@0xkanekiken - yep, u32assert2
sounds good.
from miden-vm.
@bobbinth - I've introduced u32assert2
opcode to the VM instruction. Let me know your thought on the pull request.
from miden-vm.
Closed by #202
from miden-vm.
Related Issues (20)
- Implement`adv.push_smtset` and `adv.push_smtget`
- Allow the removal of entries from advice map
- Handle extra memory requests made by new `RCombBase` op HOT 1
- `debug.stack` decorator is broken HOT 1
- Implement extensible subsystem for on-demand storage/provisioning of MAST objects HOT 7
- Test to ensure that `RCOMBBASE` instruction can be executed and proven HOT 1
- Introduce a newtype for to represent a row in a trace
- Update `StackOutputs` fields HOT 1
- Update `usize` serialization and deserialization HOT 1
- Encryption in the VM
- Kernel procedure table
- Reproducible (ish) builds HOT 6
- Change errors to use thiserror HOT 5
- mtree_verify should also accept err HOT 3
- Compilation failure due to missing name should report the user readable name HOT 4
- Rename miden crate so that it matches the package name. HOT 1
- Separate error codes from kernel to user code HOT 11
- Write tool to format `Cargo.toml` HOT 2
- `miden-stdlib` docs failing to build for docs.rs
- Syntax to refer to a procedure's MAST root inside the VM HOT 2
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.