Closed Ivshti closed 5 years ago
Proposal for the API:
/channels/campaign
- takes {channel}
- takes a full channel
object with a campaignSpec
property (as is usually returned by /channels
; saves the channel in a pending
state, with created
; all channels that are pending
for more than a week (actually, a configurable value) will be evicted by a query that's periodically done by the worker; this does not need to check if the channel is signed by the creator
, because the channel will be upgraded to an active
state only if it's found on-chain; before saving, we should check if (1) the channel is valid structurally, (2) it complies with our criteria (#30) as defined in the cfg and finally (3) set channel.id
to a hash, as defined by the adapter (which would use hash
here: https://github.com/AdExNetwork/adex-protocol-eth/blob/master/js/Channel.js)/channels/campaign-validate-query
- takes {channel, role}
- works similarly to the previous one, but (1) you always supply an empty array for validators
and (2) it doesn't save the channel, but rather checks if this validator would accept it (for role
where that is "leader"
or "validator"
); this depends on policies that will be defined in cfg
, but in the beginning this would just be an optional whitelist of creators (if it's null we don't apply it), minimal deposit and whitelist of tokens (see #30)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:
/channel/campaign-validate-query
; if something goes wrong, go back to step 1/channel/campaign
active
active
, each validator will start processing this channel in their tick, therefore emitting Heartbeat #17
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