1- # Sortition Pools
1+ :toc: macro
22
3- [ ![ GitHub Workflow Status (event)] ( https://img.shields.io/github/actions/workflow/status/keep-network/sortition-pools/solidity-test.yml?branch=main&event=schedule&label=Solidity%20tests )] ( https://github.com/keep-network/sortition-pools/actions/workflows/solidity-test.yml )
3+ = Sortition Pools
4+
5+ https://github.com/keep-network/sortition-pools/actions/workflows/solidity-test.yml[image:https://img.shields.io/github/actions/workflow/status/keep-network/sortition-pools/solidity-test.yml?branch=main&event=schedule&label=Solidity%20tests[GitHub Workflow Status]]
46
57Sortition pool is a logarithmic data structure used to store the pool of
6- eligible operators weighted by their stakes. In the [ Threshold
7- network] ( https://threshold.org/ ) the stake consists of staked T tokens. It
8- allows to select a group of operators based on the provided pseudo-random seed.
8+ eligible operators weighted by their stakes. In the
9+ https://threshold.org/[Threshold Network] the stake consists of staked T tokens.
10+ It allows to select a group of operators based on the provided pseudo-random
11+ seed.
912
1013Each privileged application has its own sortition pool and is responsible for
1114maintaining operator weights up-to-date.
1215
13- ## Setup
16+ == Setup
1417
15- ### Prerequisites
18+ === Prerequisites
1619
1720* clone the repository
18- + [ Node.js ] ( https://nodejs.org/en/ ) v14.21.2
21+ * https://nodejs.org/en/[Node.js] v14.21.2
1922* configure git to use https
2023
21- ```
24+ [source,sh]
25+ ----
2226git config --global url."https://".insteadOf git://
23- ```
27+ ----
2428
2529* Python 3.11.1 for `node-gyp`. It is
26- [ suggested ] ( https://opensource.com/article/19/5/python-3-default-mac ) to use
30+ https://opensource.com/article/19/5/python-3-default-mac[suggested] to use
2731 `pyenv` to manage multiple Python versions.
2832
29- ```
33+ [source,sh]
34+ ----
3035brew install pyenv
3136pyenv install 3.11.1
32- ```
37+ ----
3338
34- ### Build And Test
39+ === Build And Test
3540
36- ```
41+ [source,sh]
42+ ----
3743npm ci
3844npm test
39- ```
45+ ----
4046
41- ## In-Depth Reading
47+ == In-Depth Reading
4248
4349To familiarize yourself with the sortition pool and it's design, we provide
4450
45- + [ Building Intuition ] ( docs/building-intuition.md )
46- + [ Implementation Details ] ( docs/implementation-details.md )
47- + [ Rewards ] ( docs/rewards.md )
51+ * link: docs/building-intuition.md[Building Intuition]
52+ * link: docs/implementation-details.md[Implementation Details]
53+ * link: docs/rewards.md[Rewards]
4854
49- [ Building Intuition ] ( docs/building-intuition.md ) starts the reader from the
55+ link: docs/building-intuition.md[Building Intuition] starts the reader from the
5056problem description and an easy-to-understand naive solution, and then works its
5157way up to the current design of the sortition pool through a series of
5258optimizations.
5359
54- [ Implementation Details ] ( docs/implementation-details.md ) builds off of the
55- knowledge in [ Building Intuition ] ( docs/building-intuition.md ) , and gets into the
56- finer points about the data structure, data (de)serialization, how operators
60+ link: docs/implementation-details.md[Implementation Details] builds off of the
61+ knowledge in link: docs/building-intuition.md[Building Intuition] , and gets into
62+ the finer points about the data structure, data (de)serialization, how operators
5763join/leave the pool, and how it all comes together to select a full group.
5864
59- [ Rewards ] ( docs/rewards.md ) is a deep-dive into how the sortition pool keeps
65+ link: docs/rewards.md[Rewards] is a deep-dive into how the sortition pool keeps
6066track of rewards. It features code explanations and walk-throughs of state
6167transitions for common situations.
6268
63- ## Important Facts
69+ == Important Facts
6470
65- + The max number of operators is ` 2,097,152 `
66- + The sortition pool is for general purpose group selection. Feel free to use
71+ * The max number of operators is `2,097,152`
72+ * The sortition pool is for general purpose group selection. Feel free to use
6773 or fork it!
68- + The sortition pool can be [ optimistic ] ( # optimisic-group-selection) ! The
74+ * The sortition pool can be << optimisic-group-selection,optimistic>> ! The
6975 on-chain code then is only run in the case that the selection submission is
7076 challenged.
71- + The sortition pool tracks rewards!
77+ * The sortition pool tracks rewards!
7278
73- ## Safe Use
79+ == Safe Use
7480
7581Miners and other actors that can predict the selection seed (due to frontrunning
7682the beacon or a public cached seed being used) may be able to manipulate
@@ -81,12 +87,13 @@ state before seed used for the new selection is known and should unlock the pool
8187once the selection process is over, keeping in mind potential timeouts and
8288result challenges.
8389
84- ## Optimistic Group Selection
90+ [[optimistic-group-selection]]
91+ == Optimistic Group Selection
8592
86- When an application (like the [ Random
87- Beacon ] ( https://github.com/keep-network/keep-core/tree/main/solidity/random-beacon#group-creation ) )
88- needs a new group, sortition is performed off-chain according to the same
89- algorithm that would be performed on-chain, and the results are submitted
93+ When an application (like the
94+ https://github.com/keep-network/keep-core/tree/main/solidity/random-beacon#group-creation[Random
95+ Beacon]) needs a new group, sortition is performed off-chain according to the
96+ same algorithm that would be performed on-chain, and the results are submitted
9097on-chain.
9198
9299Then, we enter a challenge period where anyone can claim that the submitted
0 commit comments