Skip to content

Commit 697236f

Browse files
authored
Merge pull request #169 from keep-network/implementation-details-readme
Restructure The Readme
2 parents f9a8e92 + 11191ce commit 697236f

2 files changed

Lines changed: 63 additions & 77 deletions

File tree

README.adoc

Lines changed: 0 additions & 77 deletions
This file was deleted.

README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Sortition Pools
2+
3+
Sortition pool is a logarithmic data structure used to store the pool of
4+
eligible operators weighted by their stakes. In the Keep network the stake
5+
consists of staked KEEP tokens. It allows to select a group of operators based
6+
on the provided pseudo-random seed.
7+
8+
Each privileged application has its own sortition pool and is responsible for
9+
maintaining operator weights up-to-date.
10+
11+
## In-Depth Reading
12+
13+
To familiarize yourself with the sortition pool and it's design, we provide
14+
15+
+ [Building Intuition](docs/building-intuition.md)
16+
+ [Implementation Details](docs/implementation-details.md)
17+
18+
[Building Intuition](docs/building-intuition.md) starts the reader from the
19+
problem description and an easy-to-understand naive solution, and then works
20+
its way up to the current design of the sortition pool through a series of
21+
optimizations.
22+
23+
[Implementation Details](docs/implementation-details.md) builds off of the
24+
knowledge in [Building Intuition](docs/building-intuition.md), and gets into
25+
the finer points about the data structure, data (de)serialization, how
26+
operators join/leave the pool, and how it all comes together to select a full
27+
group.
28+
29+
## Important Facts
30+
31+
+ The max number of operators is `2,097,152`
32+
+ The sortition pool is for general purpose group selection. Feel free to use
33+
or fork it!
34+
+ The sortition pool can be [optimistic](#optimisic-group-selection)! The
35+
on-chain code then is only run in the case that the selection submission is
36+
challenged.
37+
38+
## Safe Use
39+
40+
Miners and other actors that can predict the selection seed (due
41+
to frontrunning the beacon or a public cached seed being used) may be able to
42+
manipulate selection outcomes to some degree by selectively updating the pool.
43+
44+
To mitigate this, applications using sortition pool should lock sortition pool
45+
state before seed used for the new selection is known and should unlock the
46+
pool once the selection process is over, keeping in mind potential timeouts and
47+
result challenges.
48+
49+
## Optimistic Group Selection
50+
51+
When an application (like the [Random
52+
Beacon](https://github.com/keep-network/keep-core/tree/main/solidity/random-beacon#group-creation))
53+
needs a new group, sortition is performed off-chain according to the same
54+
algorithm that would be performed on-chain, and the results are submitted
55+
on-chain.
56+
57+
Then, we enter a challenge period where anyone can claim that the submitted
58+
results are inaccurate. If this happens, the on-chain sortition pool runs the
59+
same group selection with the same seed and validates the results.
60+
61+
If the submission was invalid, the challenger is rewarded and the submitter is
62+
punished, and we can accept another submission. If the submission was valid,
63+
the challenger loses out on their gas, and the submitter is unaffected.

0 commit comments

Comments
 (0)