diff --git a/docs/architecture/0013-remove-sudo.md b/docs/architecture/0013-remove-sudo.md new file mode 100644 index 000000000..13a489889 --- /dev/null +++ b/docs/architecture/0013-remove-sudo.md @@ -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;` in RuntimeUpgrade pallet. This origin is defined in the runtime (runtime/lib.rs) and can only be called by the council. diff --git a/docs/assets/propose.png b/docs/assets/propose.png new file mode 100644 index 000000000..856251994 Binary files /dev/null and b/docs/assets/propose.png differ diff --git a/docs/assets/upgrade_runtime.png b/docs/assets/upgrade_runtime.png deleted file mode 100644 index e5236373e..000000000 Binary files a/docs/assets/upgrade_runtime.png and /dev/null differ diff --git a/docs/misc/council.md b/docs/misc/council.md new file mode 100644 index 000000000..a05d7abbd --- /dev/null +++ b/docs/misc/council.md @@ -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` \ No newline at end of file diff --git a/docs/production/upgrade_process.md b/docs/production/upgrade_process.md index d83ead981..e9b5c3136 100644 --- a/docs/production/upgrade_process.md +++ b/docs/production/upgrade_process.md @@ -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 diff --git a/readme.md b/readme.md index 577a514d4..0b6833894 100644 --- a/readme.md +++ b/readme.md @@ -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. \ No newline at end of file +See [upgrade](./docs/production/upgrade_process.md) for more information on how to upgrade the runtime. \ No newline at end of file diff --git a/substrate-node/node/src/chain_spec.rs b/substrate-node/node/src/chain_spec.rs index e19b78e44..d5c827ce2 100644 --- a/substrate-node/node/src/chain_spec.rs +++ b/substrate-node/node/src/chain_spec.rs @@ -124,7 +124,6 @@ pub fn development_config() -> Result { vec![ get_account_id_from_seed::("Alice"), get_account_id_from_seed::("Bob"), - get_account_id_from_seed::("Ferdie") ], ) }, @@ -215,7 +214,6 @@ pub fn local_testnet_config() -> Result { vec![ get_account_id_from_seed::("Alice"), get_account_id_from_seed::("Bob"), - get_account_id_from_seed::("Ferdie") ], ) }, diff --git a/tools/fork-off-substrate/index.js b/tools/fork-off-substrate/index.js index 3f7e9e7a1..d6599e578 100644 --- a/tools/fork-off-substrate/index.js +++ b/tools/fork-off-substrate/index.js @@ -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() ]; @@ -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