diff --git a/README.md b/README.md index 3823ebf..2c5fdb8 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,81 @@ flowchart TD API <-- matrix-bot-sdk --> Matrix ``` +## Rollup + +Instead of calling `DAO.initiateValidationPool()`, a contract can call `Rollup.addItem()`. + +We demonstrate this by extending our base `Work` contract as `RollableWork`. + +Our work contract normally triggeres a validation pool when the customer submits work approval. Instead, the fee and worker availability stakes are transferred to the `Rollup` contract. + +The `Rollup` contract itself uses the `Availability` contract to assign a batch worker. This worker is responsible for making sure off-chain pools are conducted. + +When ready, the worker submits the current batch on-chain by creating a batch post and a validation pool targeting the batch post. +```mermaid +sequenceDiagram + participant client as Staking client + participant matrix as Matrix room + box Blockchain + participant worker as Worker + participant customer as Customer + participant work as Work contract + participant rollup as Rollup contract + participant vp as Validation pool + participant forum as Forum + end + + + worker ->> work : Availability stake
(REP) + activate worker + activate work + customer ->> work : Request work
(fee) + activate customer + worker ->> work : Submit work evidence
(postId) + deactivate worker + customer ->> work : Submit work approval + deactivate customer + work ->> rollup : Add item
(fee, REP, postId) + activate rollup + deactivate work + + rollup ->> client : Event: BatchItemAdded + activate client + client ->> matrix : io.dgov.pool.start
(postId) + activate matrix + matrix -->> client : + client ->> matrix : io.dgov.pool.stake
(postId, REP, inFavor) + matrix -->> client : + client ->> matrix : io.dgov.pool.result
(postId, votePasses, quorumMet) + matrix -->> client : + + note right of matrix : All staking clients
record each other's stakes + + client ->> forum : Add post
(batchPostId) + activate forum + client ->> rollup : Submit batch
(batchPostId) + client ->> matrix : io.dgov.rollup.submit + matrix -->> client : + deactivate matrix + rollup ->> vp : Initiate validation pool
(fee, REP, batchPostId) + activate vp + note right of vp : Mints REP in
proportion to fee + deactivate rollup + + vp ->> client : Event: ValidationPoolInitiated + + note right of client : Each staking client
verifies the rollup post + + client ->> vp : Stake for/against + client ->> vp : Evaluate outcome + + vp ->> client : REP rewards for policin + deactivate client + vp ->> forum : Minted REP + deactivate vp + forum ->> worker : REP rewards for batch post authors + deactivate forum +``` ## Local development setup