forked from Graviton-One/gravity-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Ergo Contracts
Moein zargarzadeh edited this page Apr 28, 2021
·
3 revisions
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.
- Change Gravity Consuls:
- Inputs:
- create a new tx with current
Consul Box
as its input.
- create a new tx with current
- Outputs:
- put appropriate
BFT
value, in registerR4
of output. - put the
Public Key
of new consuls in registerR5
of output, as aGroupElement
list. - put the
signature
of current consuls accordingly in registersR6
andR7
.
- put appropriate
- Inputs:
In order to update Oracles
, this box is used as a Data Input
to authorize the change of Oracles
.
There are for boxes that form this contract:
-
Oracles Box
: In this box, the list ofOracles
and the value ofBFT
is stored. In order to change oracles, this box is being spent and a newOracles Box
is created.- Note that there is only one unspent
Oracles Box
in the network and it is protected with anNFT
token.
- Note that there is only one unspent
-
Pulse Box
: stores the latestPulseID
. Any newPulse
will spend this box, create a newPulse Box
with newPulseID
, and create a newSignal Box
.- Note that there is only one unspent
Pulse Box
in the network and it is protected with anNFT
token.
- Note that there is only one unspent
-
Pulse Token Repository
: Contains a large enough amount ofSignal Tokens
. On any new pulse, a newSignal
is created, which uses aSignal Token
from this repository (obviously with some required ERG). -
Signal Box
: contains a signal token and will be consumed by UserSC. WhenUserSC
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
-
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 registersR6
andR7
(Data to be signed is Public Key of new Oracles)
- New BFT value in
- This box is validated (mined), if at least BFT number of signatures are valid.
- Inputs:
-
Add Pulse:
- Inputs:
-
Pulse Box
as the first input. Note that there is only one unspentPulse Box
in the network and it is protected with anNFT
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 firstDataInput
-
- Outputs:
- First output is a
Pulse Box
which its pulse id is increased by one. The value ofMessage Hash
is inR4
, signatures inR5
,R6
register andR7
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
- First output is a
- Inputs:
-
Send Values to Subs:
- This function is declared explicitly in Ergo. Instead on invoking the
Subscribers
on changes, Nebula createsSignal Box
es. 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
- First input is
- Outputs:
- First output is
Token Repository
. This box must contain one more token from the inputPulse Token Repository
.
- First output is
- Inputs:
- This function is declared explicitly in Ergo. Instead on invoking the
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
- Consuls:
- Oracle:
- BTF value: the number of required signatures by Gravity Contarct