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

Synchronous contract calls: Node support #236

Closed
7 tasks done
abizjak opened this issue Jan 8, 2022 · 1 comment · Fixed by #227
Closed
7 tasks done

Synchronous contract calls: Node support #236

abizjak opened this issue Jan 8, 2022 · 1 comment · Fixed by #227
Assignees
Labels
[Prio] High An urgent problem that blocks the system use until the issue is resolved. [Type] Task An additional feature or improvement.

Comments

@abizjak
Copy link
Contributor

abizjak commented Jan 8, 2022

Task description

Implement V1 contracts that use synchronous function calls instead of actions for inter-contract communication, as well as for other operations, such as transfers from a contract to account.

The high-level requirements are

  • smart contracts can invoke other smart contracts in the middle of their execution, in a synchronous way, and inspect the return value.
  • the node API must be extended so that smart contracts may be invoked locally without transactions to obtain parts of contract state, or to dry run a contract call.
  • existing contracts must continue to function as they did in current protocol versions.
  • As usual, all changes must be fully backwards compatible. The node must be able to process all existing blocks, and either migrate existing database, or use it as is.

NB: V1 contracts will also have the new state. However we will implement this in steps, first sync calls and then add the new state, so that changes are more manageable.

Sub-tasks

  • Introduce V1 contract modules and contract instances. Contract modules will need to have a different version since they need to be validated differently, due to the different host functions available. The type of the contract is determined by the module which contains its functions.
    • Introduce support for V1 and V0 modules and contract instances in global state.
    • Introduce support for handling V1 modules and contract updates in the Scheduler. It must be possible to send messages from V0 contracts to V1 contracts, and invoke V0 contracts from V1 contracts. Existing transactions will be used to initialize and update both V0 and V1 contracts.
    • Add unit tests with example contracts.
  • Add a new API endpoint "InvokeContract" that invokes a contract and returns the response. The invocation should take any parameters necessary. In particular it should take a block as an argument and it should execute the contract in the state at the end of the given block. In the future we can make this more fine-grained and execute it in the state in the middle of a block, however this should not be in the first version.
  • Add documentation of the new API endpoint.
  • Add documentation of the contract calling semantics, and the API the smart contracts expect.

This requires a new protocol version. Some of the changes are therefore going to be dependent, or conflict with, work being done on the #212 issue. We'll have to resolve those when they arrive.

@abizjak abizjak added [Prio] High An urgent problem that blocks the system use until the issue is resolved. [Type] Task An additional feature or improvement. labels Jan 8, 2022
@abizjak abizjak self-assigned this Jan 8, 2022
@abizjak abizjak changed the title Synchronous function calls: Node support Synchronous contract calls: Node support Jan 8, 2022
@abizjak abizjak linked a pull request Feb 19, 2022 that will close this issue
5 tasks
@abizjak
Copy link
Contributor Author

abizjak commented Apr 27, 2022

Addressed in #243

@abizjak abizjak closed this as completed Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Prio] High An urgent problem that blocks the system use until the issue is resolved. [Type] Task An additional feature or improvement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant