Skip to content

Commit

Permalink
Cluster Governance Pallet (#249)
Browse files Browse the repository at this point in the history
### Description
<!-- Describe what change this PR is implementing -->
This PR introduces the Cluster Governance feature. Previously, only the
SUDO account was authorized to create an active cluster in the Cere
Network. Now, anyone can create an inactive cluster, bond tokens for
that cluster, add genesis nodes, invite external nodes, and later
initiate a proposal to the network to activate the cluster with certain
protocol parameters that impact economics and distribution of rewards
between Cere token holders.

In sake for the overview, I'll list the high-level changes the current
PR contains:
- Bonding for clusters is introduced
- Cluster Node Kind type is introduced (`Genesis`, `External`)
- Cluster Node Status is introduced (`AwaitsValidation`,
`ValidationSucceeded`, `ValidationFailed`)
- Cluster Local Referendum is introduced where cluster members can agree
on an initial set of protocol parameters before propagating the proposal
to the network
- Cluster Public Referendum (integrated with the OpenGov) is introduced
where the network participants can accept or reject changes in a cluster
protocol parameters proposed by its members.
- `ClusterGovParams` type was renamed to `ClusterProtocolParams` to
ensure ubiquitous naming and better reflect the type purpose. Also,
internal some traits such as `ClusterVisitor` were split and renamed to
more domain-specific types.
- Tests and benchmarks for new and changed functions are added
- Migrations for old data structures are provided

### Types of Changes
<!--- What types of changes does your code introduce? -->
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [x] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Dependency upgrade (A change in substrate or any 3rd party crate
version)

### Migrations and Hooks
<!--- Check the following box with an x if the following applies: -->
- [x] This change requires a runtime migration.
- [ ] Modifies `on_initialize`
- [ ] Modifies `on_finalize`

### Checklist
<!--- All boxes need to be checked. Follow this checklist before
requiring PR review -->
- [x] Change has been tested locally.
- [x] Change adds / updates tests.
- [x] Changelog doc updated.
  • Loading branch information
yahortsaryk authored May 17, 2024
1 parent ae76090 commit 1c1576b
Show file tree
Hide file tree
Showing 57 changed files with 10,057 additions and 1,734 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [C] Changes is `Cere` Runtime
- [D] Changes is `Cere Dev` Runtime

## [5.4.0]

### Changed

- [C,D] `pallet-ddc-clusters-gov`: Introduction of the Cluster Governance pallet for managing clusters protocol parameters.

## [5.3.0]

Expand Down
91 changes: 75 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace.package]
version = "5.3.0"
version = "5.4.0"
authors = ["Cerebellum-Network"]
edition = "2021"
homepage = "https://cere.network/"
Expand All @@ -19,6 +19,8 @@ members = [
"pallets/ddc-staking",
"pallets/erc20",
"pallets/erc721",
"pallets/ddc-clusters-gov",
"pallets/origins",
"primitives",
"runtime/cere",
"runtime/cere-dev",
Expand Down Expand Up @@ -175,12 +177,14 @@ cere-service = { path = "node/service" }
ddc-primitives = { path = "primitives", default-features = false }
pallet-chainbridge = { path = "pallets/chainbridge", default-features = false }
pallet-ddc-clusters = { path = "pallets/ddc-clusters", default-features = false }
pallet-ddc-clusters-gov = { path = "pallets/ddc-clusters-gov", default-features = false }
pallet-ddc-customers = { path = "pallets/ddc-customers", default-features = false }
pallet-ddc-nodes = { path = "pallets/ddc-nodes", default-features = false }
pallet-ddc-payouts = { path = "pallets/ddc-payouts", default-features = false }
pallet-ddc-staking = { path = "pallets/ddc-staking", default-features = false }
pallet-erc20 = { path = "pallets/erc20", default-features = false }
pallet-erc721 = { path = "pallets/erc721", default-features = false }
pallet-origins = { path = "pallets/origins", default-features = false }

[profile.release]
panic = "unwind"
69 changes: 69 additions & 0 deletions pallets/ddc-clusters-gov/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
[package]
name = "pallet-ddc-clusters-gov"
version.workspace = true
authors.workspace = true
edition.workspace = true
homepage.workspace = true
license.workspace = true
readme.workspace = true
repository.workspace = true

[dependencies]
codec = { workspace = true }
ddc-primitives = { workspace = true }
frame-benchmarking = { workspace = true, optional = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
hex-literal = { workspace = true }
log = { workspace = true }
pallet-referenda = { workspace = true }
scale-info = { workspace = true }
serde = { workspace = true }
sp-io = { workspace = true }
sp-runtime = { workspace = true }
sp-std = { workspace = true }

[dev-dependencies]
frame-benchmarking = { workspace = true, default-features = true }
lazy_static = { workspace = true, default-features = true }
pallet-balances = { workspace = true, default-features = true }
pallet-contracts = { workspace = true }
pallet-conviction-voting = { workspace = true }
pallet-ddc-clusters = { workspace = true }
pallet-ddc-nodes = { workspace = true }
pallet-ddc-staking = { workspace = true }
pallet-insecure-randomness-collective-flip = { workspace = true, default-features = true }
pallet-preimage = { workspace = true }
pallet-scheduler = { workspace = true }
pallet-timestamp = { workspace = true, default-features = true }
parking_lot = { workspace = true, default-features = true }
sp-arithmetic = { workspace = true }
sp-core = { workspace = true, default-features = true }
sp-io = { workspace = true, default-features = true }
sp-tracing = { workspace = true, default-features = true }
substrate-test-utils = { workspace = true, default-features = true }

[features]
default = ["std"]
std = [
"codec/std",
"ddc-primitives/std",
"frame-support/std",
"frame-system/std",
"frame-benchmarking/std",
"scale-info/std",
"sp-core/std",
"sp-runtime/std",
"sp-std/std",
]
runtime-benchmarks = [
"ddc-primitives/runtime-benchmarks",
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
try-runtime = [
"frame-system/try-runtime",
"pallet-referenda/try-runtime",
]
Loading

0 comments on commit 1c1576b

Please sign in to comment.