Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for views #149

Open
annenkov opened this issue Mar 21, 2022 · 0 comments
Open

Add support for views #149

annenkov opened this issue Mar 21, 2022 · 0 comments
Labels
part: execution Issues and PRs related to the execution layer type: feature New feature request/implementation

Comments

@annenkov
Copy link
Collaborator

The view functionality allows for querying contracts in a synchronous way. This functionality makes it easier to implement contracts that require using some data from other contracts, for example, getting data from oracles. With only message passing, it could be implemented with callbacks. This is, however, awkward and error-prone.

The view mechanism guarantees that the state will not be changed, that's why it should be relatively unproblematic to add to ConCert: the execution model stays the same, we just need to add some additional data available to contracts during the receive function call.

We can extend ConCert to handle views:

  • Add view function(s) to the Contract; it could be done by using a single function that dispatches on a special "view message" (however, the return type still might be different for different views).

  • Pass around the extended state. Currently, the blockchain state available to the contracts (part of the contract's signature):

Record Chain :=
 build_chain {
   chain_height : nat;
   current_slot : nat;
   finalized_height : nat;
 }.

It could be extended with a field containing the whole Environment, or some restriction of it. In this case, one could access the contract's view functions (and, maybe, state?). Possibly, some of the infrastructure from the implementations of the execution layer can be used [LocalBlockchain](https://github.com/AU-COBRA/ConCert/blob/0399316dbc882e228e5e0c0daf98b51460dc760a/execution/theories/LocalBlockchain.v#L39]

  • Introduce a view_call function that will fetch a view and, if it was successfully fetched, call it.
@annenkov annenkov added the type: enhancement Enhancement to an existing feature label Mar 21, 2022
@annenkov annenkov changed the title Add support for views [execution] Add support for views Mar 21, 2022
@4ever2 4ever2 added type: feature New feature request/implementation part: execution Issues and PRs related to the execution layer and removed type: enhancement Enhancement to an existing feature labels May 21, 2022
@4ever2 4ever2 changed the title [execution] Add support for views Add support for views May 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
part: execution Issues and PRs related to the execution layer type: feature New feature request/implementation
Projects
None yet
Development

No branches or pull requests

2 participants