Skip to content

Ergo Contracts

Moein zargarzadeh edited this page Apr 28, 2021 · 3 revisions

Contracts

Gravity Contract

This contract is used to keep the record of current Consuls.

Register values:

  • R4: the BFT value
  • R5: list of Consuls
  • R6: the list of a parts of signature of form (a,z)
  • R7: the list of z parts of signature of form (a,z)

In order to change the Consuls, this box is being spent and a new box with new Consuls is created.

Functions

  • Change Gravity Consuls:
    • Inputs:
      • create a new tx with current Consul Box as its input.
    • Outputs:
      • put appropriate BFT value, in register R4 of output.
      • put the Public Key of new consuls in register R5 of output, as a GroupElement list.
      • put the signature of current consuls accordingly in registers R6 and R7.

In order to update Oracles, this box is used as a Data Input to authorize the change of Oracles.

Nebula Contracts

There are for boxes that form this contract:

  • Oracles Box: In this box, the list of Oracles and the value of BFT is stored. In order to change oracles, this box is being spent and a new Oracles Box is created.
    • Note that there is only one unspent Oracles Box in the network and it is protected with an NFT token.
  • Pulse Box: stores the latest PulseID. Any new Pulse will spend this box, create a new Pulse Box with new PulseID, and create a new Signal Box.
    • Note that there is only one unspent Pulse Box in the network and it is protected with an NFT token.
  • Pulse Token Repository: Contains a large enough amount of Signal Tokens. On any new pulse, a new Signal is created, which uses a Signal Token from this repository (obviously with some required ERG).
  • Signal Box: contains a signal token and will be consumed by UserSC. When UserSC consumes a signal box, the signal token along with it's ERG, will be returned to Pulse Token Repository.

//pulse token repo and signal contracts

Functions

  • Change Oracles:

    • Inputs:
      • Current oracle box as input
    • DataInputs:
      • Current consul box (Gravity box) as DataInput
    • Outputs:
      • New BFT value in R4
      • New oracles in R5
      • Signature of Consuls in registers R6 and R7 (Data to be signed is Public Key of new Oracles)
    • This box is validated (mined), if at least BFT number of signatures are valid.
  • Add Pulse:

    • Inputs:
      • Pulse Box as the first input. Note that there is only one unspent Pulse Box in the network and it is protected with an NFT token.
      • One of the unspent boxes of Pulse Token Repository as the second input
      • Any number of boxes as other inputs
    • DataInputs:
      • Oracle Box as the first DataInput
    • Outputs:
      • First output is a Pulse Box which its pulse id is increased by one. The value of Message Hash is in R4, signatures in R5, R6 register and R7 is in pulse id.
        • Message Hash is the hex decoded data of the request.
      • Second output is from Pulse Token Repository type. The number of tokens in repository must exactly be reduced by one (and some Erg for token transfer). Other properties must remain unchanged.
      • Third output is one Signal Box which contains the withdrawn token from the repository.
      • Fee box
      • Other boxes
  • Send Values to Subs:

    • This function is declared explicitly in Ergo. Instead on invoking the Subscribers on changes, Nebula creates Signal Boxes. The subscribers spend this box accordingly.
    • Spending Signal Box is satisfied when:
      • Inputs:
        • First input is Signal Box
        • Second input is a box from Pulse Token Repository
      • Outputs:
        • First output is Token Repository. This box must contain one more token from the input Pulse Token Repository.

Proxy

The proxy resides between Gravity and Ergo node, and is responsible for all offchain logics. Since the contracts of Ergo cannot be used by function calls (like Ethereum and Waves), the proxy mimics this for Gravity.

This swimlane shows the role of proxy and it's corresponding actions: see in swimlane.io

Definitions

  • Consuls:
  • Oracle:
  • BTF value: the number of required signatures by Gravity Contarct
Clone this wiki locally