Skip to content

Commit

Permalink
chore: add council docs & align tools / runtime (#784)
Browse files Browse the repository at this point in the history
* chore: add council docs & align tools / runtime

* chore: revert runtime spec bump
  • Loading branch information
DylanVerstraete authored Jul 13, 2023
1 parent 023de44 commit 5001ae1
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 26 deletions.
28 changes: 28 additions & 0 deletions docs/architecture/0013-remove-sudo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 13. Remove sudo functionality

Date: 2023-07-10

## Status

Accepted

## Context

We want to remove the sudo functionality from the chain. The main reason being security and not having a "root" key that can do anything on the chain.

Anything meaning: transfers, creating new accounts, changing the chain configuration, etc.

## Decision

Remove Sudo functionality from the chain and allow the `Council` (a group of ppl) to have elevated privileges to do a set of actions.

These actions are:

- Upgrading the runtime
- Changing the chain configuration
- Adding / Removing new council members
- ..

An important note here is that the council origin is not "root", so the council can only make actions that are allowed by specific pallets.

For example see `type SetCodeOrigin: EnsureOrigin<Self::RuntimeOrigin>;` in RuntimeUpgrade pallet. This origin is defined in the runtime (runtime/lib.rs) and can only be called by the council.
Binary file added docs/assets/propose.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/assets/upgrade_runtime.png
Binary file not shown.
39 changes: 39 additions & 0 deletions docs/misc/council.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Council

The Council is a group of people that have collective interests in the Threefold Chain. The council is responsible for the following:

- Proposing & Approving runtime upgrades
- Approving chain configuration changes
- Approving new council members
- Approving new validators
- ..

## Council members

Council members are configurable at runtime, members can be added and removed by the council itself.

## Proposals

Proposals are created by council members and can be voted on by other council members. Proposals can be created as following:

Browse to the Polkadot UI and connect to the Node, select the `Governance` -> `Council` page

Select `Motions` on top and click `Propose Motion` on the right.

Now select any motion (any extrinsic from any pallet can be proposed) and click `Propose`

## Voting

Voting can be done by council members, the voting process is as following:

Browse to the Polkadot UI and connect to the Node, select the `Governance` -> `Council` page

View any open motion and click `Vote` (Select Aye or Nay)

## Closing motions

When a motion is closed, the motion is executed on the chain. This means that the extrinsic is executed and the state of the chain is changed.

To close a motion, browse to the Polkadot UI and connect to the Node, select the `Governance` -> `Council` page

View any open motion and click `Close`
32 changes: 14 additions & 18 deletions docs/production/upgrade_process.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,31 @@

## Check first

- Make sure CI passes and it compiles locally
- Create a release first, runtime binary will be uploaded to the release on github.
- Make sure CI (build & tests) passes
- Test migrations (if any) with the tools described in [try-runtime](../misc/try_runtime.md) and [tools](../../tools/fork-off-substrate/README.md)

## Increment spec version
## Download the latest release from github

Open `substrate-node/runtime/src/lib.rs` and increment the spec version with the current spec version. You can see what spec version a node is running on the polkadot ui.
In the top left you should see something like: `substrate-threefold/1` which means it's running the runtime `substrate-threefold` with spec version `1`.
Download the latest release from github tfchain repository release page.

## Compile a runtime wasm build
## Propose a runtime upgrade using the Council

You can pass an optional release flag.
Note: this can only be done if you are a council member. See [council](../misc/council.md).

```sh
cargo build [--release] -p tfchain-runtime
```
Browse to the Polkadot UI and connect to the Node, select the `Governance` -> `Council` page

## Upload the wasm build to the Node using Polkadot UI
Select `Motions` on top and click `Propose Motion` on the right.

Browse to the Polkadot UI and connect to the Node, select `Developer` -> `Extrinsics`.
Now select:

Now select a `Root` account to upgrade the runtime with, if the node is running in `Dev`, the default `Root` account is Alice.
- Account (your account)
- Threshold (Super Majority)
- Proposal: `runtimeUpgrade` -> `setCode` (upload wasm file)

[example](./doc/upgrade_runtime.png)
Now click `Propose`

Select `Sudo` -> `sudoUncheckedWeight` -> `System` -> `setCode` -> Toggle `file upload` and click the box.

Navigate to `tfchain/substrate-node/target/release/wbuild/tfchain-runtime/tfchain_runtime.compact.wasm` and upload that file.

Submit the transaction, wait a couple of seconds and the runtime version should be incremented and the code will be live.
[example](../assets/propose.png)

## IMPORTANT

Expand Down
3 changes: 1 addition & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,4 @@ A changelog will be generated based on the Pull requests merged, so having PRs w

### Upgrade runtime

To upgrade the runtime for a network based on a release, download the runtime attached to the release (tfchain_runtime.compact.compressed.wasm)
and upload it to the network using a council proposal. The proposal should be a `set_code` proposal with the runtime as the code and majority of the council should vote in favor of the proposal.
See [upgrade](./docs/production/upgrade_process.md) for more information on how to upgrade the runtime.
2 changes: 0 additions & 2 deletions substrate-node/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ pub fn development_config() -> Result<ChainSpec, String> {
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Ferdie")
],
)
},
Expand Down Expand Up @@ -215,7 +214,6 @@ pub fn local_testnet_config() -> Result<ChainSpec, String> {
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Ferdie")
],
)
},
Expand Down
6 changes: 2 additions & 4 deletions tools/fork-off-substrate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_cla
let prefixes = ['0x26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da9' /* System.Account */];
const skippedModulesPrefix = ['System', 'Session', 'Babe', 'Grandpa', 'GrandpaFinality', 'FinalityTracker', 'Authorship'];

async function fixParachinStates (api, forkedSpec) {
async function fixParachinStates(api, forkedSpec) {
const skippedKeys = [
api.query.parasScheduler.sessionStartBlock.key()
];
Expand Down Expand Up @@ -146,10 +146,8 @@ async function main() {
forkedSpec.genesis.raw.top['0x5f3e4907f716ac89b6347d15ececedcaf7dad0317324aecae8744b87fc95f2f3'] = '0x02';

if (alice !== '') {
// Set sudo key to //Alice
forkedSpec.genesis.raw.top['0x5c0d1176a568c1f92944340dbfed9e9c530ebca703c85910e7164cb7d1c9e47b'] = '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d';
// Council
forkedSpec.genesis.raw.top['0xaebd463ed9925c488c112434d61debc0ba7fb8745735dc3be2a2c61a72c39e78'] = '0x0c1cbd2d43530a44705ad088af313e18f80b53ef16b36177cd4b77b846f2a5f07c8eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d'
forkedSpec.genesis.raw.top['0xaebd463ed9925c488c112434d61debc0ba7fb8745735dc3be2a2c61a72c39e78'] = '0x088eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d'
// Pallet validator validators
forkedSpec.genesis.raw.top['0x7d9fe37370ac390779f35763d98106e888dcde934c658227ee1dfafcd6e16903'] = '0x04d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d';
// Session validators
Expand Down

0 comments on commit 5001ae1

Please sign in to comment.