Skip to content

Workflow

Sina Mahmoodi edited this page Aug 23, 2018 · 1 revision

Suggested workflow overview

  • A registry contract is being deployed, its address is being published in a publicly accessible location.

  • A miner declares that he is supporting events communication over that registry.

The registry holds two main structs:

  1. Mapping (emittingEventContractAddress, eventType) => (subscriberEventContractAddress, functionToBeInvoked, invokationBounty)
  2. Mapping eventSubscriberContract => balanceOfSubscriberContract

The registry contains (at least) the following functions:

  1. addEntry - Adding an entry to mapping (1)
  2. getBalanceOf - Retrieving the current balance of subscriber from mapping (2)
  3. addToBalanceOf - Adding value to the balance of a subscriber
  4. invokeEvent - Recieving the event that was mined and a proof (TBD) for that event.
  5. rewardMiner - Transfer bounties from subscirbers to an event miner
  6. removeEntry - Removes an entry from mapping (1) and return remaining funds in mapping (2)

Now to the flow:

  1. Devloper which requires event handling logic, estimates the gas required for executing his callback function. Then calls the addEntry and lists:

    • which event he is interested in
    • which callback function should be invoked upon recieving that event.
    • Funds as he see fit to invoke the callback function.
      • Those should include (the invokation gas + a bounty to incentivize miners to publish events mined) * initial number of times he wishes that eventHandling to take place.
  2. Event of type E is being emitted from a contract.

  3. Miner M (the publisher) is mining that event and calls the invokeEvent.

  4. The registry varifies E using the proof provided with it.

  5. Upon successful varification, the registery invokes the callback function of all the subscribers that are listed for E, using capital from their registry balances (mapping (2)).

  6. Regisgtry invokes rewardMiner transferring all the bounties from the above subscribers to M.

Note, it is up for the subscriber contract to validate its funds at the registry and update them accordingly to meet its needs.