feat: add read-only view fn entry points (V15)#29419
Draft
mohammadfawaz wants to merge 1 commit into
Draft
Conversation
00ccc23 to
b9cbdb0
Compare
mohammadfawaz
pushed a commit
that referenced
this pull request
May 14, 2026
Implements V15 `view fn` block: a top-level program component that reads
finalize-store state off-consensus and returns plaintext to external callers.
Allowed reads cover mappings, vectors, storage, `block.height`, and
`network.id`; writes, `async`, `call`, and `block.timestamp` are rejected.
View fns are leaves (snarkVM rejects `call` inside a view body) but can be
called from `final {}` blocks, `final fn` helpers, and hoisted `Finalize`
bodies. Cross-program views go through `is_cross_program_call_target` to
survive the inliner and monomorphizer. Interface conformance enforces
View↔View and Fn↔(Fn|EntryPoint).
Bumps snarkVM to 088684ed (PR #3253 head): finalize-calls-view plus
`many0` view bodies, so empty views compile to valid Aleo bytecode with
no dummy filler.
closes #29419
b9cbdb0 to
ffebd44
Compare
mohammadfawaz
pushed a commit
that referenced
this pull request
May 14, 2026
Implements V15 `view fn` block: a top-level program component that reads
finalize-store state off-consensus and returns plaintext to external callers.
Allowed reads cover mappings, vectors, storage, `block.height`, and
`network.id`; writes, `async`, `call`, and `block.timestamp` are rejected.
View fns are leaves (snarkVM rejects `call` inside a view body) but can be
called from `final {}` blocks, `final fn` helpers, and hoisted `Finalize`
bodies. Cross-program views go through `is_cross_program_call_target` to
survive the inliner and monomorphizer. Interface conformance enforces
View↔View and Fn↔(Fn|EntryPoint).
Bumps snarkVM to 088684ed (PR #3253 head): finalize-calls-view plus
`many0` view bodies, so empty views compile to valid Aleo bytecode with
no dummy filler.
closes #29419
ffebd44 to
0491006
Compare
mohammadfawaz
pushed a commit
that referenced
this pull request
May 21, 2026
Implements V15 `view fn` block: a top-level program component that reads
finalize-store state off-consensus and returns plaintext to external callers.
Allowed reads cover mappings, vectors, storage, `block.height`, and
`network.id`; writes, `async`, `call`, and `block.timestamp` are rejected.
View fns are leaves (snarkVM rejects `call` inside a view body) but can be
called from `final {}` blocks, `final fn` helpers, and hoisted `Finalize`
bodies. Cross-program views go through `is_cross_program_call_target` to
survive the inliner and monomorphizer. Interface conformance enforces
View↔View and Fn↔(Fn|EntryPoint).
Bumps snarkVM to 088684ed (PR #3253 head): finalize-calls-view plus
`many0` view bodies, so empty views compile to valid Aleo bytecode with
no dummy filler.
closes #29419
0491006 to
aadd361
Compare
689ec55 to
16323d2
Compare
mohammadfawaz
pushed a commit
that referenced
this pull request
May 21, 2026
Implements V15 `view fn` block: a top-level program component that reads
finalize-store state off-consensus and returns plaintext to external callers.
Allowed reads cover mappings, vectors, storage, `block.height`, and
`network.id`; writes, `async`, `call`, and `block.timestamp` are rejected.
View fns are leaves (snarkVM rejects `call` inside a view body) but can be
called from `final {}` blocks, `final fn` helpers, and hoisted `Finalize`
bodies. Cross-program views go through `is_cross_program_call_target` to
survive the inliner and monomorphizer. Interface conformance enforces
View↔View and Fn↔(Fn|EntryPoint).
Bumps snarkVM to 088684ed (PR #3253 head): finalize-calls-view plus
`many0` view bodies, so empty views compile to valid Aleo bytecode with
no dummy filler.
closes #29419
aadd361 to
4e63216
Compare
16323d2 to
783f505
Compare
mohammadfawaz
pushed a commit
that referenced
this pull request
May 21, 2026
Implements V15 `view fn` block: a top-level program component that reads
finalize-store state off-consensus and returns plaintext to external callers.
Allowed reads cover mappings, vectors, storage, `block.height`, and
`network.id`; writes, `async`, `call`, and `block.timestamp` are rejected.
View fns are leaves (snarkVM rejects `call` inside a view body) but can be
called from `final {}` blocks, `final fn` helpers, and hoisted `Finalize`
bodies. Cross-program views go through `is_cross_program_call_target` to
survive the inliner and monomorphizer. Interface conformance enforces
View↔View and Fn↔(Fn|EntryPoint).
Bumps snarkVM to 088684ed (PR #3253 head): finalize-calls-view plus
`many0` view bodies, so empty views compile to valid Aleo bytecode with
no dummy filler.
closes #29419
4e63216 to
2d67342
Compare
783f505 to
0755a20
Compare
mohammadfawaz
pushed a commit
that referenced
this pull request
May 21, 2026
Implements V15 `view fn` block: a top-level program component that reads
finalize-store state off-consensus and returns plaintext to external callers.
Allowed reads cover mappings, vectors, storage, `block.height`, and
`network.id`; writes, `async`, `call`, and `block.timestamp` are rejected.
View fns are leaves (snarkVM rejects `call` inside a view body) but can be
called from `final {}` blocks, `final fn` helpers, and hoisted `Finalize`
bodies. Cross-program views go through `is_cross_program_call_target` to
survive the inliner and monomorphizer. Interface conformance enforces
View↔View and Fn↔(Fn|EntryPoint).
Bumps snarkVM to 088684ed (PR #3253 head): finalize-calls-view plus
`many0` view bodies, so empty views compile to valid Aleo bytecode with
no dummy filler.
closes #29419
2d67342 to
8ae9bbe
Compare
0755a20 to
a302f04
Compare
mohammadfawaz
pushed a commit
that referenced
this pull request
May 22, 2026
Implements V15 `view fn` block: a top-level program component that reads
finalize-store state off-consensus and returns plaintext to external callers.
Allowed reads cover mappings, vectors, storage, `block.height`, and
`network.id`; writes, `async`, `call`, and `block.timestamp` are rejected.
View fns are leaves (snarkVM rejects `call` inside a view body) but can be
called from `final {}` blocks, `final fn` helpers, and hoisted `Finalize`
bodies. Cross-program views go through `is_cross_program_call_target` to
survive the inliner and monomorphizer. Interface conformance enforces
View↔View and Fn↔(Fn|EntryPoint).
Bumps snarkVM to 088684ed (PR #3253 head): finalize-calls-view plus
`many0` view bodies, so empty views compile to valid Aleo bytecode with
no dummy filler.
closes #29419
8ae9bbe to
bd75f21
Compare
mohammadfawaz
added a commit
that referenced
this pull request
May 25, 2026
Implements V15 `view fn` block: a top-level program component that reads
finalize-store state off-consensus and returns plaintext to external
callers. Allowed reads cover mappings, vectors, storage, `block.height`,
and `network.id`; writes, `async`, `call`, and `block.timestamp` are
rejected. View fns are leaves (snarkVM rejects `call` inside a view
body) but can be called from `final {}` blocks, `final fn` helpers, and
hoisted `Finalize` bodies. Cross-program views go through
`is_cross_program_call_target` to survive the inliner and monomorphizer.
Interface conformance enforces View<->View and Fn<->(Fn|EntryPoint).
Also adds a `leo-wasm` crate and playground WASM bindings:
- `crates/leo-wasm/`: WASM entry-point crate exposing the Leo compiler
and view-fn evaluation to the browser playground.
- `crates/parser/src/snarkvm_wasm.rs`, `crates/passes/src/snarkvm_wasm.rs`:
WASM-friendly re-exports for `snarkvm-*` subcrates so the parser and
passes crates compile under `wasm32-unknown-unknown`.
- Workspace `Cargo.toml`: additional `snarkvm-*` subcrate deps (circuit,
ledger-block, ledger-store, synthesizer-process).
- `.cargo/config.toml`, `tree-sitter/package.json` updated for WASM build.
- Parses imports with a shared `NodeBuilder` so NodeIDs in
`Stub::FromLeo` are consistent with the passes' symbol-table scopes,
matching how `leo build` constructs stubs via
`parse_leo_source_directory` and fixing "unreachable" panics and
Unknown variable errors in test compilation.
Pins snarkVM to current staging tip (2cbe677f).
closes #29419
8f3abad to
898fb4a
Compare
Implements V15 `view fn` block: a top-level program component that reads
finalize-store state off-consensus and returns plaintext to external callers.
Allowed reads cover mappings, vectors, storage, `block.height`, and
`network.id`; writes, `async`, `call`, and `block.timestamp` are rejected.
View fns are leaves (snarkVM rejects `call` inside a view body) but can be
called from `final {}` blocks, `final fn` helpers, and hoisted `Finalize`
bodies. Cross-program views go through `is_cross_program_call_target` to
survive the inliner and monomorphizer. Interface conformance enforces
View↔View and Fn↔(Fn|EntryPoint).
Bumps snarkVM to 088684ed (PR #3253 head): finalize-calls-view plus
`many0` view bodies, so empty views compile to valid Aleo bytecode with
no dummy filler.
closes #29419
898fb4a to
b47d646
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds Leo support for V15
view fnblocks (snarkVM #3238 + rename #3257) and lets afinal {}body call those views (snarkVM #3253).Supersedes #29411 (the original branch was force-pushed during the rename and the PR auto-closed).
Variant::View), rowan→AST, type-check restrictions (read-only, plaintext-only, views are leaves;block.timestamprejected, mapping writes /async/callrejected; reads of mappings, vectors, storage,block.height,network.idallowed).view <name>:blocks. Disassembler round-trips them. ABI exposesviews: Vec<Function>.view fn(contextual keyword — preservesviewas a regular identifier in pre-V15 source).viewblocks viaProgram::contains_v15_syntax.Process::evaluate_view_at_height(historyfeature) and adds optionalseed_mappingto populate finalize-store entries before a case runs.Variant::Viewcallees fromfinal {}blocks,final fnhelpers, and hoisted-Variant::Finalizebodies; constructors still forbidcall.is_cross_program_entrygeneralised tois_cross_program_call_target(covers views) so cross-program views survive the inliner and monomorphizer as directcalls. Tightened pre-existing gaps: transition body outsidefinal {}calling a view, andfinal fncalling an entry point, now rejected at type-check with a clear message instead of failing late at snarkVM.snarkVM pinned at
cf6b381b(PR #3253 head);getrandom0.4 enables thewasm_jsbackend onwasm32-unknown-unknown; satellite snarkVM pins promoted to workspace deps; CLI consensus-heights tests carry 15 values (V0–V14).Tests
Compiler-level positive:
basic_view,view_with_branching,view_uses_storage_and_vector,finalize_calls_view,finalize_calls_cross_program_view,final_fn_calls_view.Compiler-level negative:
final_view_fail,view_calls_other_view_fail,view_writes_mapping_fail,view_in_library_fail,entry_body_calls_view_fail,final_fn_calls_entry_point_fail.Execution-level (
Process::execute/evaluate_view_at_height):view_basic,view_storage_and_vector,view_aggregate,view_struct_output,finalize_calls_view.