Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Allow Sudo to do anything (#6375)
Browse files Browse the repository at this point in the history
* All Sudo to do anything.

* Rename old labels.
  • Loading branch information
gavofyork authored Jun 17, 2020
1 parent db8916a commit bdae39f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .maintain/gitlab/check_runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ sub_spec_version="$(git diff tags/release...${CI_COMMIT_SHA} ${VERSIONS_FILE} \
if [ "${add_spec_version}" != "${sub_spec_version}" ]
then

github_label "B2-breaksapi"
github_label "D2-breaksapi"

boldcat <<-EOT
Expand Down
10 changes: 5 additions & 5 deletions docs/CONTRIBUTING.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ A PR needs to be reviewed and approved by project maintainers unless:

. Please tag each PR with exactly one `A`, `B` and `C` label at the minimum.
. Once a PR is ready for review please add the https://github.com/paritytech/substrate/pulls?q=is%3Apr+is%3Aopen+label%3AA0-pleasereview[`A0-pleasereview`] label. Generally PRs should sit with this label for 48 hours in order to garner feedback. It may be merged before if all relevant parties had a look at it.
. If the first review is not an approval, swap `A0-pleasereview` to any label `[A3, A7]` to indicate that the PR has received some feedback, but needs further work. For example. https://github.com/paritytech/substrate/labels/A3-inprogress[`A3-inprogress`] is a general indicator that the PR is work in progress and https://github.com/paritytech/substrate/labels/A4-gotissues[`A4-gotissues`] means that it has significant problems that need fixing. Once the work is done, change the label back to `A0-pleasereview`. You might end up swapping a few times back and forth to climb up the A label group. Once a PR is https://github.com/paritytech/substrate/labels/A8-mergeoncegreen[`A8-mergeoncegreen`], it is ready to merge.
. If the first review is not an approval, swap `A0-pleasereview` to any label `[A3, A7]` to indicate that the PR has received some feedback, but needs further work. For example. https://github.com/paritytech/substrate/labels/A3-inprogress[`A3-inprogress`] is a general indicator that the PR is work in progress and https://github.com/paritytech/substrate/labels/A4-gotissues[`A4-gotissues`] means that it has significant problems that need fixing. Once the work is done, change the label back to `A0-pleasereview`. You might end up swapping a few times back and forth to climb up the A label group. Once a PR is https://github.com/paritytech/substrate/labels/A8-mergeoncegreen[`A8-mergeoncegreen`], it is ready to merge.
. PRs must be tagged with respect to _release notes_ with https://github.com/paritytech/substrate/labels/B0-silent[`B0-silent`] and `B1-..`. The former indicates that no changes should be mentioned in any release notes. The latter indicates that the changes should be reported in the corresponding release note
. PRs that break the external API must be tagged with https://github.com/paritytech/substrate/labels/B2-breaksapi[`B2-breaksapi`], when it changes the FRAME or consensus of running system with https://github.com/paritytech/substrate/labels/B3-breaksconsensus[`B3-breaksconsensus`].
. PRs that break the external API must be tagged with https://github.com/paritytech/substrate/labels/D2-breaksapi[`D2-breaksapi`], when it changes the FRAME or consensus of running system with https://github.com/paritytech/substrate/labels/B3-breaksconsensus[`B3-breaksconsensus`].
. PRs should be labeled with their release importance via the `C1-C9`.
. PRs should be categorized into projects.
. No PR should be merged until all reviews' comments are addressed and CI is successful.
Expand Down Expand Up @@ -69,12 +69,12 @@ To create a Polkadot companion PR:
. Pull latest Polkadot master (or clone it, if you haven't yet).
. Override your local cargo config to point to your local substrate (pointing to your WIP branch): place `paths = ["path/to/substrate"]` in `~/.cargo/config`.
. Make the changes required and build polkadot locally.
. Submit all this as a PR against the Polkadot Repo. Link to your Polkadot PR in the _description_ of your Substrate PR as "polkadot companion: [URL]" OR use the same name for your Polkdadot branch as the Substrate branch.
. Submit all this as a PR against the Polkadot Repo. Link to your Polkadot PR in the _description_ of your Substrate PR as "polkadot companion: [URL]" OR use the same name for your Polkdadot branch as the Substrate branch.
. Now you should see that the `check_polkadot` CI job will build your Substrate PR agains the mentioned Polkadot branch in your PR description.
. Wait for reviews on both
. Once both PRs have been green lit, they can both be merged 🍻.
. Once both PRs have been green lit, they can both be merged 🍻.

If your PR is reviewed well, but a Polkadot PR is missing, signal it with https://github.com/paritytech/substrate/labels/A7-needspolkadotpr[`A7-needspolkadotpr`] to prevent it from getting automatically merged.
If your PR is reviewed well, but a Polkadot PR is missing, signal it with https://github.com/paritytech/substrate/labels/A7-needspolkadotpr[`A7-needspolkadotpr`] to prevent it from getting automatically merged.

As there might be multiple pending PRs that might conflict with one another, a) you should not merge the substrate PR until the Polkadot PR has also been reviewed and b) both should be merged pretty quickly after another to not block others.

Expand Down
12 changes: 6 additions & 6 deletions frame/sudo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@
#![cfg_attr(not(feature = "std"), no_std)]

use sp_std::prelude::*;
use sp_runtime::{DispatchResult, traits::{StaticLookup, Dispatchable}};
use sp_runtime::{DispatchResult, traits::StaticLookup};

use frame_support::{
Parameter, decl_module, decl_event, decl_storage, decl_error, ensure,
};
use frame_support::weights::{Weight, GetDispatchInfo};
use frame_support::{weights::{Weight, GetDispatchInfo}, traits::UnfilteredDispatchable};
use frame_system::{self as system, ensure_signed};

#[cfg(test)]
Expand All @@ -106,7 +106,7 @@ pub trait Trait: frame_system::Trait {
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;

/// A sudo-able call.
type Call: Parameter + Dispatchable<Origin=Self::Origin> + GetDispatchInfo;
type Call: Parameter + UnfilteredDispatchable<Origin=Self::Origin> + GetDispatchInfo;
}

decl_module! {
Expand All @@ -132,7 +132,7 @@ decl_module! {
let sender = ensure_signed(origin)?;
ensure!(sender == Self::key(), Error::<T>::RequireSudo);

let res = call.dispatch(frame_system::RawOrigin::Root.into());
let res = call.dispatch_bypass_filter(frame_system::RawOrigin::Root.into());
Self::deposit_event(RawEvent::Sudid(res.map(|_| ()).map_err(|e| e.error)));
}

Expand All @@ -152,7 +152,7 @@ decl_module! {
let sender = ensure_signed(origin)?;
ensure!(sender == Self::key(), Error::<T>::RequireSudo);

let res = call.dispatch(frame_system::RawOrigin::Root.into());
let res = call.dispatch_bypass_filter(frame_system::RawOrigin::Root.into());
Self::deposit_event(RawEvent::Sudid(res.map(|_| ()).map_err(|e| e.error)));
}

Expand Down Expand Up @@ -195,7 +195,7 @@ decl_module! {

let who = T::Lookup::lookup(who)?;

let res = match call.dispatch(frame_system::RawOrigin::Signed(who).into()) {
let res = match call.dispatch_bypass_filter(frame_system::RawOrigin::Signed(who).into()) {
Ok(_) => true,
Err(e) => {
sp_runtime::print(e);
Expand Down
18 changes: 13 additions & 5 deletions frame/sudo/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ use frame_support::{
};
use sp_core::H256;
// The testing primitives are very useful for avoiding having to work with signatures
// or public keys.
// or public keys.
use sp_runtime::{Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header};
use sp_io;
use crate as sudo;
use frame_support::traits::Filter;

// Logger module to track execution.
pub mod logger {
Expand Down Expand Up @@ -58,15 +59,15 @@ pub mod logger {

#[weight = *weight]
fn privileged_i32_log(origin, i: i32, weight: Weight){
// Ensure that the `origin` is `Root`.
// Ensure that the `origin` is `Root`.
ensure_root(origin)?;
<I32Log>::append(i);
Self::deposit_event(RawEvent::AppendI32(i, weight));
}

#[weight = *weight]
fn non_privileged_log(origin, i: i32, weight: Weight){
// Ensure that the `origin` is some signed account.
// Ensure that the `origin` is some signed account.
let sender = ensure_signed(origin)?;
<I32Log>::append(i);
<AccountLog<T>>::append(sender.clone());
Expand Down Expand Up @@ -112,16 +113,23 @@ parameter_types! {
pub const AvailableBlockRatio: Perbill = Perbill::one();
}

pub struct BlockEverything;
impl Filter<Call> for BlockEverything {
fn filter(_: &Call) -> bool {
false
}
}

impl frame_system::Trait for Test {
type BaseCallFilter = ();
type BaseCallFilter = BlockEverything;
type Origin = Origin;
type Call = Call;
type Index = u64;
type BlockNumber = u64;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = TestEvent;
type BlockHashCount = BlockHashCount;
Expand Down

0 comments on commit bdae39f

Please sign in to comment.