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
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
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.