diff --git a/README.md b/README.md index 9cbaf74..3ca6946 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,13 @@ This repository contains the base chain implementation that Colinear's compute marketplace uses as a settlement layer. +## Technical Documentation + +| Component | Docs Path | +| :-------- | :-------- | +| Leasing & settlement module | [x/colinearcore](./x/colinearcore/README.md) | +| In-memory bid database | [x/colinearcore/memdb](./x/colinearcore/memdb/README.md) | + ## Validators ### Requirements diff --git a/x/colinearcore/README.md b/x/colinearcore/README.md new file mode 100644 index 0000000..d5d66b4 --- /dev/null +++ b/x/colinearcore/README.md @@ -0,0 +1,56 @@ +# Colinear Core Module: Leasing & Settlement + +## Provider Flow + +Providers are required to stake a set amount of CLR (which is dictated by the protocol, and can be changed by governance proposals). This CLR will be slashed if they go offline. + +```mermaid +flowchart + +subgraph u[Users] +r([Render]) +p([Provider]) +end + +subgraph Chain +st{{CLR Staking}} +a[(Auctions)] +end + +r -- Create Auction --> a + +p -- Check staking requirement --> st +st -- Allow provider to bid --> a +``` + +## Audit Flow + +To determine whether a provider is online, validators will read from the chain state to see which leases are active, and ping every provider every *n* blocks (determined by governance). If a quorum of validators does not receive a response, they will continuously slash the staked amount of the provider and end all leases they are providing for. If a provider runs out of staked CLR to slash, they will be removed from all leases and lease funds will be returned to the user. + +```mermaid +flowchart LR + +pOff(["Provider (Offline)"]) + +subgraph Active Validator Set +v1((Validator)) +v2((Validator)) +v3((Validator)) +end + +subgraph Chain State +ll[(Active Lease List)] +b{{Bank Module}} +end + +ll -- Read --> v1 +ll -- Read --> v2 +ll -- Read --> v3 + +v1 -- Ping --> pOff +v2 -- Ping --> pOff +v3 -- Ping --> pOff + +v2 -- Slash User --> b +v3 -- Slash User --> b +``` diff --git a/x/colinearcore/memdb/README.md b/x/colinearcore/memdb/README.md index 365ee0d..ceaac8e 100644 --- a/x/colinearcore/memdb/README.md +++ b/x/colinearcore/memdb/README.md @@ -5,7 +5,14 @@ ```mermaid flowchart -s[Submit Bid] --> rdb{{Read MemBids}} --> h{Is Highest Bid?} +s[Submit Bid] --> rstake{{Read Staked Amount}} + +rstake --> st{Has min amount staked?} + +st -- No --> re0[[Error]] +st -- Yes --> rdb{{Read MemBids}} + +rdb --> h{Is Highest Bid?} h -- Yes --> m{{Add to MemBids}} h -- No --> re1[[Error]]