Skip to content

Commit

Permalink
Merge branch 'master' of github.com:airalab/aira
Browse files Browse the repository at this point in the history
  • Loading branch information
akru committed Dec 30, 2018
2 parents 562c0b8 + 48fcb79 commit e0dbf52
Show file tree
Hide file tree
Showing 13 changed files with 393 additions and 441 deletions.
74 changes: 37 additions & 37 deletions docs/aira_in_depth/Message_spec.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Robonomics Messages

.. note::

This is Robonomics network ``Generation 3`` message specification.
This is Robonomics network ``Generation 4`` message specification.

* Currently for message delivery is used IPFS PubSub_ broadcaster.
* IPFS PubSub **topic** is set according to *Lighthouse* ENS_ name.
Expand All @@ -18,47 +18,47 @@ Specification

**Demand**

=============== ========= ================================================
Field Type Description
=============== ========= ================================================
model string CPS behavioral model Identifier
objective string CPS behavioral model parameters in rosbag file
token string Operational token address
cost ineger CPS behavioral model implementation cost
lighthouse string Lighthouse address
validator string Observing network address
validatorFee integer Observing network commission
deadline integer Deadline block number
nonce array Random uniq data
signature array Sender's digital signature
=============== ========= ================================================
================ ============================================================== ================================================
Field Type Description
================ ============================================================== ================================================
model :ref:`ipfs_common/Multihash <IPFS-Common-Multihash.msg>` CPS behavioral model Identifier
objective :ref:`ipfs_common/Multihash <IPFS-Common-Multihash.msg>` CPS behavioral model parameters in rosbag file
token :ref:`ethereum_common/Address <Ethereum-common-Address.msg>` Operational token address
cost :ref:`ethereum_common/UInt256 <Ethereum-common-UInt256.msg>` CPS behavioral model implementation cost
lighthouse :ref:`ethereum_common/Address <Ethereum-common-Address.msg>` Lighthouse address
validator :ref:`ethereum_common/Address <Ethereum-common-Address.msg>` Observing network address
validatorFee :ref:`ethereum_common/UInt256 <Ethereum-common-UInt256.msg>` Observing network commission
deadline :ref:`ethereum_common/UInt256 <Ethereum-common-UInt256.msg>` Deadline block number
nonce std_msgs/UInt8[] Random unique data
signature std_msgs/UInt8[] Sender's digital signature
================ ============================================================== ================================================

**Offer**

=============== ========= ================================================
Field Type Description
=============== ========= ================================================
model string CPS behavioral model Identifier
objective string CPS behavioral model parameters in rosbag file
token string Operational token address
cost ineger CPS behavioral model implementation cost
validator string Observing network address
lighthouse string Lighthouse address
lighthouseFee integer Liability creation commission
deadline integer Deadline block number
nonce array Random uniq data
signature array Sender's digital signature
=============== ========= ================================================
=============== ============================================================== ================================================
Field Type Description
=============== ============================================================== ================================================
model :ref:`ipfs_common/Multihash <IPFS-Common-Multihash.msg>` CPS behavioral model Identifier
objective :ref:`ipfs_common/Multihash <IPFS-Common-Multihash.msg>` CPS behavioral model parameters in rosbag file
token :ref:`ethereum_common/Address <Ethereum-common-Address.msg>` Operational token address
cost :ref:`ethereum_common/UInt256 <Ethereum-common-UInt256.msg>` CPS behavioral model implementation cost
validator :ref:`ethereum_common/Address <Ethereum-common-Address.msg>` Observing network address
lighthouse :ref:`ethereum_common/Address <Ethereum-common-Address.msg>` Lighthouse address
lighthouseFee :ref:`ethereum_common/UInt256 <Ethereum-common-UInt256.msg>` Liability creation commission
deadline :ref:`ethereum_common/UInt256 <Ethereum-common-UInt256.msg>` Deadline block number
nonce std_msgs/UInt8[] Random unique data
signature std_msgs/UInt8[] Sender's digital signature
=============== ============================================================== ================================================

**Result**

============ ========== ================================================
Field Type Description
============ ========== ================================================
liability string Liability contract address
result string Liability result hash encoded as Base58
success boolean Is liability executed successful
signature array Sender's digital signature
============ ========== ================================================
=========== ============================================================== =========================================
Field Type Description
=========== ============================================================== =========================================
liability :ref:`ethereum_common/Address <Ethereum-common-Address.msg>` Liability contract address
result :ref:`ipfs_common/Multihash <IPFS-Common-Multihash.msg>` Liability result hash encoded as Base58
success std_msgs/Bool Is liability executed successful
signature std_msgs/UInt8[] Sender's digital signature
=========== ============================================================== =========================================

.. _Type: JSON type
49 changes: 20 additions & 29 deletions docs/aira_in_depth/Robonomics_How_It_Works.rst
Original file line number Diff line number Diff line change
@@ -1,35 +1,26 @@
Robonomics Network: How It Works
================================

In this section we will discuss the Robonomics Network scenario.
In this section we will discuss the Robonomics Network scenario.

Robonomics Network uses IPFS PubSub channels for messaging. There are three types of messages: Demand, Offer, Result.

**Below there is the specification for a Demand message:**

+--------------+---------+-------------------------------------------------------+------------------------------------------------+
| Field | Type | Description | Example |
+==============+=========+=======================================================+================================================+
| model | string | CPS behavioral model Identifier | QmfXHZ2YkNC5vRjp1oAaRoDHD8H3zZznfhBPasTu348eWC |
+--------------+---------+-------------------------------------------------------+------------------------------------------------+
| objective | string | CPS behavioral model parameters in rosbag file | QmUo3vvSXZPQaQWjb3cH3qQo1hc8vAUqNnqbdVABbSLb6r |
+--------------+---------+-------------------------------------------------------+------------------------------------------------+
| token | string | Operational token address | 0xbD949595eE52346c225a19724084cE517B2cB735 |
+--------------+---------+-------------------------------------------------------+------------------------------------------------+
| cost | integer | CPS behavioral model implementation cost | 1 |
+--------------+---------+-------------------------------------------------------+------------------------------------------------+
| lighthouse | string | Lighthouse address | 0xa1b60ED40E5A68184b3ce4f7bEf31521A57eD2dB1 |
+--------------+---------+-------------------------------------------------------+------------------------------------------------+
| validator | string | Observing network address | 0x0000000000000000000000000000000000000000 |
+--------------+---------+-------------------------------------------------------+------------------------------------------------+
| validatorFee | integer | Observing network commission | 0 |
+--------------+---------+-------------------------------------------------------+------------------------------------------------+
| deadline | integer | Deadline block number | 6393332 |
+--------------+---------+-------------------------------------------------------+------------------------------------------------+
| nonce | array | Random data | 0x8e0c...55cb |
+--------------+---------+-------------------------------------------------------+------------------------------------------------+
| signature | array | Sender's digital signature | 0x23bc...c617 |
+--------------+---------+-------------------------------------------------------+------------------------------------------------+
=============== ============================================================== ================================================ ================================================
Field Type Description Example
=============== ============================================================== ================================================ ================================================
model :ref:`ipfs_common/Multihash <IPFS-Common-Multihash.msg>` CPS behavioral model Identifier QmfXHZ2YkNC5vRjp1oAaRoDHD8H3zZznfhBPasTu348eWC
objective :ref:`ipfs_common/Multihash <IPFS-Common-Multihash.msg>` CPS behavioral model parameters in rosbag file QmUo3vvSXZPQaQWjb3cH3qQo1hc8vAUqNnqbdVABbSLb6r
token :ref:`ethereum_common/Address <Ethereum-common-Address.msg>` Operational token address 0xbD949595eE52346c225a19724084cE517B2cB735
cost :ref:`ethereum_common/UInt256 <Ethereum-common-UInt256.msg>` CPS behavioral model implementation cost 1
lighthouse :ref:`ethereum_common/Address <Ethereum-common-Address.msg>` Lighthouse address 0xa1b60ED40E5A68184b3ce4f7bEf31521A57eD2dB1
validator :ref:`ethereum_common/Address <Ethereum-common-Address.msg>` Observing network address 0x0000000000000000000000000000000000000000
validatorFee :ref:`ethereum_common/UInt256 <Ethereum-common-UInt256.msg>` Observing network commission 0
deadline :ref:`ethereum_common/UInt256 <Ethereum-common-UInt256.msg>` Deadline block number 6393332
nonce std_msgs/UInt8[] Random data 0x8e0c...55cb
signature std_msgs/UInt8[] Sender's digital signature 0x23bc...c617
=============== ============================================================== ================================================ ================================================

An Offer message has the same fields but instead of ``validatorFee`` there is a ``lighthouseFee`` field. This field determines the amount of fee for a lighthouse.

Expand All @@ -39,10 +30,10 @@ Now let's have a look at the following diagram and walk step by step from the mo
:alt: Scenario
:align: center

A liability contract is created only if the following fields match: ``model``, ``objective``, ``token``, ``cost``. A provider of Robonomics Network watches every message and finds those ones that have a match.
After the match is found the provider calls ``createLiability(demand, offer)`` method from the contract factory where ``demand`` and ``offer`` are serialized.
A liability contract is created only if the following fields match: ``model``, ``objective``, ``token``, ``cost``. A provider of Robonomics Network watches every message and finds those ones that have a match.
After the match is found the provider calls ``createLiability(demand, offer)`` method from the contract factory where ``demand`` and ``offer`` are serialized.

The factory deserializes arguments and recovers *promisee* and *promisor* addresses from signatures.
The factory deserializes arguments and recovers *promisee* and *promisor* addresses from signatures.

Next step is token transfer. The factory transfers **cost** tokens from the *promisee* address and **validatorFee** and **lighthouseFee** from the *promisor* address to the new liability address.

Expand All @@ -51,8 +42,8 @@ Next step is token transfer. The factory transfers **cost** tokens from the *pro
You should approve sufficient amount of tokens for the factory.

.. note::
It's not required to approve tokens from the *promisor* address if fees are null.

It's not required to approve tokens from the *promisor* address if fees are null.

Now the factory emits a NewLiability event with the liability address. An agent gets the address, reads fields, perform a task and at the same time writes a log file in rosbag format.

Expand Down
7 changes: 2 additions & 5 deletions docs/api/ethereum_common.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,11 @@ Published topics

.. py:method:: /eth/event/transfer (ethereum_common/TransferEvent)
The event `ethereum_common/TransferEvent`_ is emitted after the transfer of tokens was made
The event :ref:`ethereum_common/TransferEvent <Ethereum-common-TransferEvent.msg>` is emitted after the transfer of tokens was made

.. py:method:: /eth/event/approval (ethereum_common/ApprovalEvent)
The event `ethereum_common/ApprovalEvent`_ is emitted after the approval of tokens was made

.. _ethereum_common/TransferEvent: ethereum_common_msg.rst
.. _ethereum_common/ApprovalEvent: ethereum_common_msg.rst
The event :ref:`ethereum_common/ApprovalEvent <Ethereum-common-ApprovalEvent.msg>` is emitted after the approval of tokens was made

Services
--------
Expand Down
Loading

0 comments on commit e0dbf52

Please sign in to comment.