Document contains entities and possible interactions in kalypso. :information_source: Internals of Matching Engine and Smart Contracts are not mentioned in this docs. Refer the github for the same. ## Happy Path Scenario :::info :information_source: Dotted lines either represent reading the data, or off-chain process :information_source: Dashed lines represted on chain transactions ::: ```plantuml skinparam maxMessageSize 300 actor Prover as P box Kalypso #lightblue control "Matching\nEngine" as ME entity "Kalypso \nSmart Contracts" as KSC end box box Generator #lightgrey control "Kalypso\nClient" as KCL entity "Generator\nClient" as GCL actor "Generator\nOperator" as GO end box == Begin Market Creation == [->>o KSC: Anyone can create market [->>o KSC: Deploy verifier contract KSC --> ME: Matching Engine is expected to cache the market ID as soon as market is created == End Market Creation == == Begin Generator Registration == KSC --> GO: Generator can read the smart contract and download all the requirements for joining the market place. note left of GO this is an offchain process generator will download the circuit, verifier, and setup-client end note GO -->(5) KCL: Join the market KCL ->(5) KSC: Submit the registration transaction == End Generator Registration == == Begin Proof Request == P ->(5) KSC: Submit the prover request with inputs KSC --> ME: Listen to the newly created ASK activate ME ME -> KSC: Assign the generator to the the ASK request deactivate ME == End Proof Request == == Begin Proof Generation == KSC --> KCL: Listen to the newly assigned ASK (which is TASK now) KCL --> GCL: Start proof Generation activate GCL GCL -> GCL: Proof Generation note right of GCL Proof generation is expected to take some time end note GCL --> KCL: Send the proof KCL -> KSC: Submit the proof on chain deactivate GCL note right of KSC If proof is valid, it transfer reward to generator's address end note == End Proof Generation == ``` ## Generator Operations All the operations of generator #### :information_source: Register/Join the network ```plantuml skinparam maxMessageSize 300 actor Prover as P box Kalypso #lightblue control "Matching\nEngine" as ME entity "Kalypso \nSmart Contracts" as KSC end box box Generator #lightgrey control "Kalypso\nClient" as KCL entity "Generator\nClient" as GCL actor "Generator\nOperator" as GO end box == Begin Generator Registration == KSC --> GO: Generator can read the smart contract and download all the requirements for joining the market place. note left of GO this is an offchain process generator will download the circuit, verifier, and setup-client end note GO -->(5) KCL: Join the market KCL ->(5) KSC: Submit the registration transaction == End Generator Registration == ``` #### :information_source: De-register Network :::danger Generator won't be able to leave/de-register the network, if there is an active task assigned to it. ::: ```plantuml skinparam maxMessageSize 300 actor Prover as P box Kalypso #lightblue control "Matching\nEngine" as ME entity "Kalypso \nSmart Contracts" as KSC end box box Generator #lightgrey control "Kalypso\nClient" as KCL entity "Generator\nClient" as GCL actor "Generator\nOperator" as GO end box == Begin Generator Deregistering == GO -> KSC: De-register/Leave the market KSC --> ME: Listen the De-Register Event note right of ME Matching Engine will not assign any tasks after this end note == End Generator Deregistering == ``` #### :information_source: Submit the Proof ```plantuml skinparam maxMessageSize 300 actor Prover as P box Kalypso #lightblue control "Matching\nEngine" as ME entity "Kalypso \nSmart Contracts" as KSC end box box Generator #lightgrey control "Kalypso\nClient" as KCL entity "Generator\nClient" as GCL actor "Generator\nOperator" as GO end box == Start Submit Proof == KSC --> KCL: Listen to the newly assigned ASK (which is TASK now) KCL --> GCL: Start proof Generation activate GCL GCL -> GCL: Proof Generation note right of GCL Proof generation is expected to take some time end note GCL --> KCL: Send the proof KCL -> KSC: Submit the proof on chain deactivate GCL note right of KSC If proof is valid, it transfer reward to generator's address end note == End Submit Proof == ``` ## Matching Engine Operation Matching is expected to listen data from other source. ME will ideally only commit one type of transaction on chain #### :information_source: Assign Task ```plantuml skinparam maxMessageSize 300 actor Prover as P box Kalypso #lightblue control "Matching\nEngine" as ME entity "Kalypso \nSmart Contracts" as KSC end box box Generator #lightgrey control "Kalypso\nClient" as KCL entity "Generator\nClient" as GCL actor "Generator\nOperator" as GO end box == Begin Proof Request == KSC --> ME: Listen to the newly created ASK activate ME ME -> KSC: Assign the generator to the the ASK request deactivate ME == End Proof Request == ``` ## Prover Operations #### :information_source: Submit Request :::warning :warning: Ensure that the prover has enough balance approved to the proof market place contract before creating the request ::: ```plantuml skinparam maxMessageSize 300 actor Prover as P box Kalypso #lightblue control "Matching\nEngine" as ME entity "Kalypso \nSmart Contracts" as KSC end box box Generator #lightgrey control "Kalypso\nClient" as KCL entity "Generator\nClient" as GCL actor "Generator\nOperator" as GO end box == Begin Proof Request == P ->(5) KSC: Submit the prover request with inputs (createASK) == End Proof Request == ``` #### :information_source: Slash Request :::warning :warning: this operation can be done by anyone(not only prover), but the slashing penalty is received only by prover ::: ```plantuml skinparam maxMessageSize 300 actor Prover as P box Kalypso #lightblue control "Matching\nEngine" as ME entity "Kalypso \nSmart Contracts" as KSC end box box Generator #lightgrey control "Kalypso\nClient" as KCL entity "Generator\nClient" as GCL actor "Generator\nOperator" as GO end box == Slah Proof Request == P ->(5) KSC: Slash Request == Slash Proof Request ==