---
# System prepended metadata

title: I. List of files in Hangzhou views implemenation
tags: [views]

---

---
title: I. List of files in Hangzhou views implemenation
tags: views
---

# I. List of files in views implementation in Hangzhou

This work presents at a review party of Marigold-protocol on the 9-Sept-2022.

## Design

Original [TZIP](https://gitlab.com/tezos/tzip/-/blob/fe0d72eaae9e68ce1767ab2cf8ff3cda7991f62f/drafts/current/draft_views.md). This Tzip is merged in the Michelson doc: [operations on views](https://tezos.gitlab.io/active/michelson.html#operations-on-views). The announcement of [on-chain views](https://tezos.gitlab.io/protocols/011_hangzhou.html#michelson-on-chain-views) on Hangzhou. [Tips](https://www.marigold.dev/post/tips-for-using-views) on using view.


## Implementation
- [MR 2359](https://gitlab.com/tezos/tezos/-/merge_requests/2359/): original implementation and tests of views.
- [MR 3431](https://gitlab.com/tezos/tezos/-/merge_requests/3431): fix bug, views are not originated when using `CREATE_CONTRACT`
- [MR 3654](https://gitlab.com/tezos/tezos/-/merge_requests/3654): [fix bug](https://www.marigold.dev/post/communicating-about-the-view-issue-in-hangzhou), `self_content` isn't restored after view's execution is returned.

### MR 2359

- Docs: alpha/michelson.rst; protocols/alpha.rst
- Implementations:
    - lib_benchmarks_proto
        - interpreter_benchmarks.ml
        - interpreter_model.ml
        - interpreter_workload.ml
    - lib_client
        - michelson_v1_error_reporter.ml
    - lib_plugin
        - plugin.ml
    - lib_protocol
        - test
            - test_typechecking.ml
        - alpha_context.mli
        - apply.ml
        - contract_services.ml
        - michelson_v1_gas.ml(i)
        - michelson_v1_primitives.ml(i)
        - script_interpreter.ml
        - script_interpreter_defs.ml
        - script_ir_annot.ml(i)
        - script_ir_translator.ml(i)
        - script_tc_errors.ml
        - script_tc_errors_registration.ml
        - script_typed_ir.ml
- Tests: tests_python
    - contracts_alpha
        - ill_typed
            - view_op_bad_name_invalid_char_set.tz
            - view_op_bad_name_invalid_type.tz
            - view_op_bad_name_non_printable_char
            - view_op_bad_name_too_long
            - view_op_bad_return_type
            - view_op_dupable_type
            - view_op_invalid_arity
            - view_op_lazy_arity
            - view_op_lazy_storage
            - view_op_lazay_storage_type
            - view_toplevel_bad_input_type
            - view_toplevel_bad_name_invalid_char_set
            - view_toplevel_bad_name_invalid_type
            - view_toplevel_bad_name_non_printable_char
            - view_toplevel_bad_name_too_long
            - view_toplevel_bad_return_type
            - view_toplevel_bad_type
            - view_toplevel_dupable_type_input
            - view_toplevel_dupable_type_output
            - view_toplevel_duplicated_name
            - view_toplevel_invalid_arity
            - view_toplevel_lazy_storage_input
            - view_toplevel_lazy_storage_output
        - opcodes
            - view_fib.tz
            - view_mutual_recursion
            - view_op_add
            - view_op_id
            - view_op_nonexistent_addr
            - view_op_nonexistent_func
            - view_op_test_step_contants
            - view_op_toplevel_inconsistent_input_type
            - view_op_toplevel_inconsistent_output_type
            - view_rec
            - view_toplevel_lib
    - tests_alpha
        - _regtest_output
        - test_contract.py
- Tests parsing
    - lib_protocol/test
        - test_typechecking.ml: `test_unparse_view` function

### MR 3431
- Implementation
    - lib_benchmarks_proto
        - interpreter_benchmarks.ml
    - lib_protocol
        - script_interpreter.ml
        - script_interpreter_defs.ml
        - script_ir_translator.ml
        - script_type_ir.ml(i)
- Tests
    - tests python
        - contracts 
            - alpha/opcodes:
                - create_contract_with_view.tz
                - view_op_constant.tz
    - tests alpha
        - test_contract.py

### MR 3654

- Implementation
    - lib_benchmarks_proto
        - interpreter_benchmarks.ml
        - interpreter_model.ml
        - interpreter_workload.ml
    - lib_protocol
        - michelson_v1_gas.ml(i)
        - script_interpreter.ml(i)
        - script_interpreter_defs.ml
        - script_typed_ir.ml(i)
- Tests
    - tests_python
        - contract_alpha/opcodes
            - amount_after_fib_view.tz
            - amount_after_nonexistent_view.tz
            - amount_after_view
            - balance_after_fib_view
            - balance_after_nonexistent_view
            - balance_after_view
            - self_address_after_fib_view
            - self_address_after_nonexistent_view
            - self_address_after_view
            - self_after_fib_view
            - self_after_nonexistent_view
            - self_after_view
            - sender_after_fib_view
            - sender_after_nonexistent_view
            - sender_after_view
    - tests_alpha
        - _regtest_outputs
        - test_contract.py

## Tests
- Examples contracts:
It is all the files ended or started with "_view.tz": contracts_alpha/opcodes

- Python tests:
Tests on views are written in python: tests_python/tests_alpha/test_contract.py

- Test of the implementation:
Test type checking views in lib_protocol/test_typechecking.ml, `test_unparse_view` function.

# Views on protocol Jakarta

[Announcement](https://tezos.gitlab.io/protocols/013_jakarta.html#michelson) of changing on views on Jakarta.

Implementation of that change at [MR 3737](https://gitlab.com/tezos/tezos/-/merge_requests/3737).

Major changes are forbidden some operations in views:
- Forbidden: `CREATE_CONTRACT`, `SET_DELEGATE`, `TRANSFER_TOKENS`, these instructions cannot be used at top-level of a view because they are stateful. `SELF` because the entry-point does not make sense in view
- But `CREATE_CONTRACT`, `SET_DELEGATE`, `TRANSFER_TOKENS` remain available in lambdas defined in a view.

# Detail notes about views

[Note](https://www.notion.so/Views-patch-a282c3a243c04d38a3968908261d489b)