Skip to content

Commit

Permalink
chore(v1.0.0): Remove pallet-sudo from production Vara (#3279)
Browse files Browse the repository at this point in the history
  • Loading branch information
breathx authored Sep 15, 2023
1 parent 30af614 commit 9eea531
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 25 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
run: ./scripts/gear.sh init cargo

- name: "Build: Gear"
run: ./scripts/gear.sh build gear --locked --release
run: ./scripts/gear.sh build gear -F gear-cli/dev --locked --release

- name: "Build fuzzer"
run: ./scripts/gear.sh build fuzz --locked --release
Expand Down Expand Up @@ -96,7 +96,7 @@ jobs:

- name: "Test: Runtime benchmarks and benchmark tests work"
run: |
cargo build -p gear-cli --release --features=runtime-benchmarks,runtime-benchmarks-checkers
cargo build -p gear-cli --release --features=dev,runtime-benchmarks,runtime-benchmarks-checkers
# check that perf benchmarks works. `--steps=20` need to test, that benchmarks works for different input number.
./target/release/gear benchmark pallet --chain=dev --pallet=pallet_gear --steps=20 --extrinsic="*" --execution=wasm --wasm-execution=compiled --heap-pages=4096
# check that read_big_state benchmarks works
Expand All @@ -111,11 +111,11 @@ jobs:

- name: "Test: `try-runtime` feature tests"
run: |
cargo test -p "pallet-*" --features try-runtime --release --locked
cargo test -p "pallet-*" --features try-runtime,dev --release --locked
- name: "Test: Try runtime migrations"
run: |
cargo build -p gear-cli --features try-runtime --release --locked
cargo build -p gear-cli --features try-runtime,dev --release --locked
./target/release/gear try-runtime --runtime ./target/release/wbuild/gear-runtime/gear_runtime.wasm on-runtime-upgrade --checks live --uri wss://rpc-private-testnet.gear-tech.io:443
env:
RUST_LOG: info
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-measurements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
tar -xf /cache/check_cargo_registry_${{ github.ref_name }}.tar -C /
- name: "Build: Gear"
run: ./scripts/gear.sh build gear --release --locked --features=runtime-benchmarks,lazy-pages
run: ./scripts/gear.sh build gear --release --locked --features=dev,runtime-benchmarks,lazy-pages

- name: "Collect: Gear workspace tests"
run: |
Expand Down
2 changes: 2 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions node/authorship/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,4 @@ testing = {workspace = true, features = ["vara-native"] }
vara-runtime = { workspace = true, features = ["std", "dev"] }
demo-mul-by-const.workspace = true
env_logger.workspace = true
service = { workspace = true, features = ["dev", "vara-native"] }
8 changes: 7 additions & 1 deletion node/service/src/chain_spec/vara.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ use sp_consensus_babe::AuthorityId as BabeId;
use sp_consensus_grandpa::AuthorityId as GrandpaId;
use sp_core::{crypto::UncheckedInto, sr25519};
use sp_runtime::{Perbill, Perquintill};
#[cfg(feature = "dev")]
use vara_runtime::SudoConfig;
use vara_runtime::{
constants::currency::{ECONOMIC_UNITS, EXISTENTIAL_DEPOSIT, UNITS as TOKEN},
AuthorityDiscoveryConfig, BabeConfig, BalancesConfig, GenesisConfig, GrandpaConfig,
ImOnlineConfig, NominationPoolsConfig, SessionConfig, SessionKeys, StakerStatus, StakingConfig,
StakingRewardsConfig, SudoConfig, SystemConfig, VestingConfig, WASM_BINARY,
StakingRewardsConfig, SystemConfig, VestingConfig, WASM_BINARY,
};

/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.
Expand Down Expand Up @@ -558,6 +560,9 @@ fn testnet_genesis(
bank_account: AccountId,
_enable_println: bool,
) -> GenesisConfig {
#[cfg(not(feature = "dev"))]
let _ = root_key;

const ENDOWMENT: u128 = 1_000_000 * TOKEN;
const STASH: u128 = 100 * TOKEN;
const MIN_NOMINATOR_BOND: u128 = 50 * TOKEN;
Expand Down Expand Up @@ -609,6 +614,7 @@ fn testnet_genesis(
min_nominator_bond: MIN_NOMINATOR_BOND,
..Default::default()
},
#[cfg(feature = "dev")]
sudo: SudoConfig {
// Assign network admin rights.
key: Some(root_key),
Expand Down
5 changes: 3 additions & 2 deletions node/testing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pallet-gear-rpc-runtime-api.workspace = true
gear-runtime = { workspace = true, optional = true }
vara-runtime = { workspace = true, optional = true }
gear-runtime-interface.workspace = true
service = { workspace = true, features = ["dev"] }

# Substrate Client
sc-block-builder.workspace = true
Expand Down Expand Up @@ -72,5 +73,5 @@ std = [
"gear-runtime?/std",
"vara-runtime?/std",
]
gear-native = ["gear-runtime/dev"]
vara-native = ["vara-runtime/dev"]
gear-native = ["gear-runtime/dev", "service/gear-native"]
vara-native = ["vara-runtime/dev", "service/vara-native"]
12 changes: 8 additions & 4 deletions runtime/vara/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pallet-referenda.workspace = true
pallet-scheduler.workspace = true
pallet-session = { workspace = true, features = [ "historical" ] }
pallet-staking.workspace = true
pallet-sudo.workspace = true
pallet-sudo = { workspace = true, optional = true }
pallet-timestamp.workspace = true
pallet-transaction-payment.workspace = true
pallet-treasury.workspace = true
Expand Down Expand Up @@ -157,7 +157,7 @@ std = [
"pallet-session/std",
"pallet-scheduler/std",
"pallet-staking/std",
"pallet-sudo/std",
"pallet-sudo?/std",
"pallet-timestamp/std",
"pallet-transaction-payment/std",
"pallet-transaction-payment-rpc-runtime-api/std",
Expand Down Expand Up @@ -245,7 +245,7 @@ try-runtime = [
"pallet-scheduler/try-runtime",
"pallet-session/try-runtime",
"pallet-staking/try-runtime",
"pallet-sudo/try-runtime",
"pallet-sudo?/try-runtime",
"pallet-timestamp/try-runtime",
"pallet-transaction-payment/try-runtime",
"pallet-treasury/try-runtime",
Expand All @@ -255,7 +255,11 @@ try-runtime = [
"pallet-bags-list/try-runtime",
"runtime-common/try-runtime",
]
dev = ["pallet-gear-debug", "pallet-gear-program/dev"]
dev = [
"pallet-gear-debug",
"pallet-gear-program/dev",
"pallet-sudo",
]
lazy-pages = [
"pallet-gear/lazy-pages",
"pallet-gear-payment/lazy-pages",
Expand Down
32 changes: 20 additions & 12 deletions runtime/vara/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub use frame_system::Call as SystemCall;
pub use pallet_balances::Call as BalancesCall;
#[cfg(any(feature = "std", test))]
pub use pallet_staking::StakerStatus;
#[cfg(any(feature = "std", test))]
#[cfg(all(feature = "dev", any(feature = "std", test)))]
pub use pallet_sudo::Call as SudoCall;
#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
Expand Down Expand Up @@ -798,6 +798,7 @@ impl pallet_identity::Config for Runtime {
type WeightInfo = pallet_identity::weights::SubstrateWeight<Runtime>;
}

#[cfg(feature = "dev")]
impl pallet_sudo::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
Expand Down Expand Up @@ -869,13 +870,23 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
fn filter(&self, c: &RuntimeCall) -> bool {
match self {
ProxyType::Any => true,
ProxyType::NonTransfer => !matches!(
c,
RuntimeCall::Balances(..)
| RuntimeCall::Sudo(..)
| RuntimeCall::Vesting(pallet_vesting::Call::vested_transfer { .. })
| RuntimeCall::Vesting(pallet_vesting::Call::force_vested_transfer { .. })
),
ProxyType::NonTransfer => {
#[cfg(feature = "dev")]
return !matches!(
c,
RuntimeCall::Balances(..)
| RuntimeCall::Sudo(..)
| RuntimeCall::Vesting(pallet_vesting::Call::vested_transfer { .. })
| RuntimeCall::Vesting(pallet_vesting::Call::force_vested_transfer { .. })
);
#[cfg(not(feature = "dev"))]
return !matches!(
c,
RuntimeCall::Balances(..)
| RuntimeCall::Vesting(pallet_vesting::Call::vested_transfer { .. })
| RuntimeCall::Vesting(pallet_vesting::Call::force_vested_transfer { .. })
);
}
ProxyType::Governance => matches!(
c,
RuntimeCall::Treasury(..)
Expand Down Expand Up @@ -1158,7 +1169,6 @@ construct_runtime!(
GearVoucher: pallet_gear_voucher = 107,
GearBank: pallet_gear_bank = 108,

// TODO: Remove in stage 3
Sudo: pallet_sudo = 99,

// NOTE (!): `pallet_airdrop` used to be idx(198).
Expand Down Expand Up @@ -1222,9 +1232,7 @@ construct_runtime!(
GearVoucher: pallet_gear_voucher = 107,
GearBank: pallet_gear_bank = 108,

// TODO: Remove in stage 3
Sudo: pallet_sudo = 99,

// NOTE (!): `pallet_sudo` used to be idx(99).
// NOTE (!): `pallet_airdrop` used to be idx(198).
}
);
Expand Down
2 changes: 1 addition & 1 deletion scripts/benchmarking/run_all_benchmarks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ done
if [ "$skip_build" != true ]
then
echo "[+] Compiling Gear benchmarks..."
cargo build --profile=production --locked --features=runtime-benchmarks
cargo build --profile=production --locked --features=dev,runtime-benchmarks
fi

# The executable to use.
Expand Down

0 comments on commit 9eea531

Please sign in to comment.