feat(rest): expose view function evaluation endpoints#4310
Merged
Conversation
…lock height
Add `POST /{network}/program/{id}/view/{functionName}/{height}` endpoint,
gated behind `#[cfg(feature = "history")]`.
The request body is a JSON array of string-encoded inputs, e.g.:
["aleo1...", "10u64"]
The handler calls `VM::evaluate_view_at_height` and returns a JSON array
of string-encoded output values.
Copilot
AI
changed the title
[WIP] Expose new API endpoint to read view function data
feat(rest): expose view function evaluation endpoint
Jun 9, 2026
Collaborator
|
@copilot update the snarkVM rev in the top-level Cargo.toml, add a new endpoint which evaluates a view at the latest height, and extend |
…evnet test
- Update snarkVM rev from c457b6b9e to e4a7a945 (historic program edition support)
- Add POST /{network}/program/{id}/view/{function} endpoint for latest height
- Register new route in lib.rs alongside the height-specific route
- Add `view get_value` to test_program.aleo in test_devnet.sh
- Test both view endpoints (latest + specific height) in test_devnet.sh
- Move height capture inside spawn_blocking to minimize race window - Rename test view function from get_value to compute_sum for clarity
Contributor
Author
Done in commits
|
Copilot
AI
changed the title
feat(rest): expose view function evaluation endpoint
feat(rest): expose view function evaluation endpoints
Jun 10, 2026
raychu86
reviewed
Jun 10, 2026
Copilot stopped work on behalf of
vicsn due to an error
June 12, 2026 12:38
vicsn
reviewed
Jun 12, 2026
a5b5f08 to
8ad736d
Compare
ljedrz
previously approved these changes
Jun 15, 2026
ljedrz
left a comment
Collaborator
There was a problem hiding this comment.
I'm not familiar with the new snarkVM-side feature, but the snarkOS impl looks good to me.
ljedrz
approved these changes
Jun 15, 2026
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.
Adds REST endpoints to evaluate Aleo view functions against ledger state, as exposed by
VM::evaluate_view_at_heightin snarkVM. Both a historic (specific block height) and a latest-height variant are provided.New endpoints
Both require the
historyfeature.POST /{network}/program/{id}/view/{functionName}/{height}— evaluate at a specific block heightPOST /{network}/program/{id}/view/{functionName}— evaluate at the latest block heightChanges
Cargo.tomle4a7a945— adds program-edition–aware view evaluation soevaluate_view_at_heightresolves the program edition live at the queried heightnode/rest/src/routes.rs#[cfg(feature = "history")] use snarkvm::prelude::ValueViewFunctionRoute<N>path extractor type aliasparse_view_inputs<N>helper (mirrors existingparse_historical_mapping_keyspattern)evaluate_viewhandler: parses inputs, callsvm.evaluate_view_at_heightinspawn_blocking, returns outputs as JSON stringsevaluate_view_latesthandler: same asevaluate_viewbut captureslatest_height()insidespawn_blockingto minimize the sampling-to-evaluation windownode/rest/src/lib.rs#[cfg(feature = "history")]block.ci/test_devnet.shview compute_sumfunction totest_program.aleo(computes1u32 + 2u32)"3u32"