v.4 by Alexander Myodov
2018-11-02 21:11

Node-side smart contract

unfinished work in progress

Node should execute some types of smart contracts on the network. For example the storage contract is being executed on each node. Develop a basic environment for it. Such a contract could be distinguished by analysing its definition.extended_type, which, if present, must contain the valid (approved by the node) smart-contract type, otherwise it must be declined.

The valid server-side smart contract implementation implements the NodeSmartContract.java interface.

The node executes such smart contracts in the following way:

If extends the local check:

  • before the check, if the definition.extended_type presents and not known, fail.

  • perform the usual contract check as with a regular contract

  • call the interface beforeCreate(), beforeUpdate() or beforeRevoke() respectively, It it returns false, fail.

If the network approve the change or revoke the contract, call onCreate(), onUpdate() or onRevoke() respectively. First two return optional Binder with extra data to return to the client as ItemResult#extra#.

The interface implement a query: readonly method calls to get some information from a single node. This is readonly, immutable method that must not change nothing in such smart contract state and associated data and could be called separately on each node.