Skip to content

Latest commit

 

History

History
80 lines (56 loc) · 3.34 KB

processor.md

File metadata and controls

80 lines (56 loc) · 3.34 KB

Processor

A stateless execution engine for smart contract methods, in an isolated environment (multiple languages supported). The processor retains no knowledge of the system around it. Every API it provides to smart contract developers is routed to the VirtualMachine controlling the execution process.

Multiple processors exist in various languages and runtimes like Ethereum Solidity, Go, Python and JavaScript. Every smart contract execution is always running in the memory context of a deployed service.

Currently, a single instance per virtual chain per node.

Interacts with services

  • VirtualMachine - Uses it to perform smart contract SDK calls.

 

Processors

Native

  • Smart contracts that are hard coded in the code base and updated through node version updates.
  • Implemented in the native language of the node for efficiency and performance.
  • Namespace code is stored in a registry that is loaded on initialization and cached by the processor.

Ethereum Solidity (EVM)

  • Coming soon.

 

Permissions

Per contract

  • Is it a system service:
    • Service - Standard permissions. For example, it can only read and write state variables in its own address space.
    • System - A system contracts that run under special permissions that give it more abilities.

Per method

  • Who can call this method:
    • Internal - Caller must be the same service.
    • External - Caller can be anyone.
  • Does it change state:
    • ReadWrite - Potentially changes state (thus needs to run under consensus).
    • ReadOnly - Does not change state (thus can run not under consensus).

 

Smart Contract SDK

  • Every processor provides an SDK for smart contract developers.
  • API that integrates with the system (like state access) is routed through VirtualMachine.
  • The processor implements API that doesn't integrate with the system (like a standard crypto operation).
  • See API specification.

 

ProcessCall (method)

Executes a method call under the context of a service, and generates output or side effects (like transient state).

  • Identify whether we're running under a system contract (original contract permission is Service or System).
  • Identify the smart contract (service or library) whose method we need to call.
  • Retrieve the method code and permissions, fail if not found.
  • Verify that the method has appropriate permissions for execution:
    • Internal method can only be called within the same smart contract unless System permissions.
    • ReadWrite method can only be called with an appropriate write context.
    • Fail if found a permission problem.
  • Execute the code on the processor.
    • External SDK calls are performed by blocking execution and calling the registered virtual machine service by calling its HandleSdkCall.

 

GetContractInfo (method)

Provides information (like contract permission) about a specific contract on a processor.

Native smart contracts

  • Make sure a native smart contract exists with the service name.
  • Retrieve the contract permission (Service or System) from the repository and return it.