AmbireTech / adex-validator

AdEx validator stack reference implementation: sentry, validator worker
https://www.adex.network
GNU Affero General Public License v3.0
8 stars 11 forks source link

API to negotiate whether the validator will accept a channel, and API to submit channel info #44

Closed Ivshti closed 5 years ago

Ivshti commented 5 years ago

since the ethereum channels can't be entirely collected from the blockchain, we need to be able to submit info about the channel to the sentry

we also need to be able to negotiate whether the validator will take the channel beforehand: for example, the validator should have a configurable threshold of funds/whitelisted tokens (see #30)

in practice, this should probably work like this:

if the second operation fails for some reason, we repeat the whole thing

after the second operation, we should create some sort of a temporary record that will not be considered by the ticks and routes (https://github.com/AdExNetwork/adex-validator-stack-js/blob/master/bin/validatorWorker.js#L32 and https://github.com/AdExNetwork/adex-validator-stack-js/blob/master/routes/channel.js#L55) until the watcher approves it; otherwise, this record should also auto-expire; the watcher approval should happen when it sees the channel on the blockchain, possibly after having some # of blocks after as a safety threshold against block reorgs

Ivshti commented 5 years ago

Proposal for the API:

The watcher's job is, per tick, to get all new on-chain channels, match them against channels that are pending with the same channel.id, and if there's a match, change that channel state to active. It will also periodically evict all pending that are older than a configurable threshold (e.g. a week)

This will in turn trigger the validator worker ticks, including #17

The full flow would be:

  1. dApp user picks advertiser/publisher nodes
  2. They negotiate with these nodes whether they'd validate their campaign via POST /channel/campaign-validate-query; if something goes wrong, go back to step 1
  3. They post the campaign via POST /channel/campaign
  4. they submit the channel on-chain
  5. Each validator's watcher will see the channel on-chain, match it against the submitted channel info (campaign) and change it's state to active
  6. once it's active, each validator will start processing this channel in their tick, therefore emitting Heartbeat #17
  7. once the user observes that all validators are emitting a heartbeat, they will see that the campaign is now live
  8. this has other consequences too: the Market will register this, and so the campaign will start appearing in the dApp, in the Explorer and will start getting considered by the SDK