Skip to content

Commit

Permalink
Add Committee Management Module
Browse files Browse the repository at this point in the history
  • Loading branch information
balqaasem committed Mar 16, 2024
1 parent df3e165 commit 032bb8f
Show file tree
Hide file tree
Showing 7 changed files with 1,350 additions and 0 deletions.
52 changes: 52 additions & 0 deletions blockchain/modules/committee-management/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[package]
name = "module-committee-management"
version = "0.2.0"
authors.workspace = true
edition.workspace = true
homepage.workspace = true
repository.workspace = true

[dependencies]
parity-scale-codec = { workspace = true, features = ["derive"] }
rand = { workspace = true }
rand_pcg = { workspace = true }
scale-info = { workspace = true, features = ["derive"] }
log = { workspace = true }

frame-support = { workspace = true }
frame-system = { workspace = true }
pallet-authorship = { workspace = true }
pallet-session = { workspace = true }
pallet-staking = { workspace = true }
sp-io = { workspace = true }
sp-runtime = { workspace = true }
sp-staking = { workspace = true }
sp-std = { workspace = true }

module-support = { workspace = true }
primitives = { workspace = true }

[features]
default = ["std"]
std = [
"parity-scale-codec/std",
"rand/std",
"scale-info/std",
"log/std",

"frame-support/std",
"frame-system/std",
"pallet-authorship/std",
"pallet-session/std",
"pallet-staking/std",
"sp-io/std",
"sp-runtime/std",
"sp-staking/std",
"sp-std/std",
"primitives/std",
"module-support/std",
]

try-runtime = [
"frame-support/try-runtime",
]
26 changes: 26 additions & 0 deletions blockchain/modules/committee-management/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Committee Management Module

## Ban logic

In case of insufficient validator's uptime, we need to remove such validators from
the committee, so that the network is as healthy as possible. This is achieved by calculating
number of _underperformance_ sessions, which means that number of blocks produced by the
validator is less than some predefined threshold.

In other words, if a validator:

* performance in a session is less or equal to a configurable threshold
`BanConfig::minimal_expected_performance` (from 0 to 100%), and,
* it happened at least `BanConfig::underperformed_session_count_threshold` times,
then the validator is considered an underperformer and hence removed (ie _banned out_) from the
committee.

### Thresholds

There are two ban thresholds described above, see [`BanConfig`].

#### Next era vs current era

Current and next era have distinct thresholds values, as we calculate bans during the start of the new era.
They follow the same logic as next era committee seats: at the time of planning the first
session of next the era, next values become current ones.
56 changes: 56 additions & 0 deletions blockchain/modules/committee-management/TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# To-Do List

This list contains all TODOs in the Repo


<!-- TOC -->
- [ToDo List - The Monofile for Setheum Repo ToDos](#to-do-list)
- [1. Introduction](#1-guidelines)
- [2. Contribution](#2-contribution)
- [3. Lists](#3-lists)
- [4. Tasks](#4-tasks)
<!-- /TOC -->


## 1. Guidelines

Note: Before you write a ToDo in this repo, please read the below guidelines carefully.

Whenever you write a ToDo, you need to follow this standard syntax

```rust
//TODO:[file_name:task_number] - task_details
```

for example:

```rust
//TODO:[TODO.md:0] - Add Todo Guidelines
```

Note > the `//TODO:[filename:task_number] - ` is what we call the `task_prefix`.

Whenever adding/writing a Task/ToDo, you need to describe the task on this list. Whenever you write a TODO in any file, add a reference to it here. Please make sure the task reference here is titled correctly and as detailed as possible\.

Whenever you `complete` a task/TODO from any file, please tick/complete its reference here and make sure you do it in the same `commit` that completes the task.

Whenever a task is cancelled (discontinued or not needed for w/e reason), please note in the details why it is cancelled, make sure you do it in the same `commit` that removes/cancels the TODO, and add this `-C` as a suffix to its `file_name` in the list here, for example:

```rust
//TODO:[TODO.md-C:0] - Add Todo Guidelines
```

## 2. Contribution

You can contribute to this list by completing tasks or by adding tasks(TODOs) that are currently in the repo but not on the list. You can also contribute by updating old tasks to the new Standard.

## 3. Lists

Each package/module/directory has its own `TODO.md`.

## 4. Tasks

These tasks are just for this file specifically.

- [x] [[TODO.md:0] - Add TODO.md File](TODO.md): Add a TODO.md file to organise TODOs in the repo.
- [x] [[TODO.md:1] - Add a `task_title`](/TODO.md/#tasks): Adda `task_title`.
Loading

0 comments on commit 032bb8f

Please sign in to comment.