diff --git a/Cargo.lock b/Cargo.lock index 0b833015..9690f4f9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10855,7 +10855,7 @@ dependencies = [ [[package]] name = "sora2-parachain-node" -version = "2.1.0" +version = "2.2.0" dependencies = [ "beefy-gadget", "beefy-gadget-rpc", @@ -10934,7 +10934,7 @@ dependencies = [ [[package]] name = "sora2-parachain-runtime" -version = "2.1.0" +version = "2.2.0" dependencies = [ "beefy-light-client", "beefy-light-client-runtime-api", diff --git a/node/Cargo.toml b/node/Cargo.toml index b266308d..9f1ed5d3 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sora2-parachain-node" -version = "2.1.0" +version = "2.2.0" authors = ["Anonymous"] description = "Sora2 Parachain node. Is used as a gateway to SORA2 from any relaychain ecosysytem" license = "Unlicense" diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index 633bc6fb..9494f20f 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -667,6 +667,7 @@ fn testnet_genesis( polkadot_xcm: sora2_parachain_runtime::PolkadotXcmConfig { safe_xcm_version: Some(SAFE_XCM_VERSION), }, + #[cfg(feature = "rococo")] sudo: sora2_parachain_runtime::SudoConfig { key: Some(root_key) }, technical_committee: TechnicalCommitteeConfig { members: technical_committee_accounts, diff --git a/parachain-gen/src/bytes/parachain_metadata.scale b/parachain-gen/src/bytes/parachain_metadata.scale index dad7d94d..f3ebb18e 100644 Binary files a/parachain-gen/src/bytes/parachain_metadata.scale and b/parachain-gen/src/bytes/parachain_metadata.scale differ diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 9d0d3633..a0d625bc 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sora2-parachain-runtime" -version = "2.1.0" +version = "2.2.0" authors = ["Anonymous"] description = "sora2 parachain runtime" license = "Unlicense" @@ -67,7 +67,7 @@ pallet-beefy = { git = "https://github.com/paritytech/substrate.git", default-fe pallet-beefy-mmr = { git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.38" } pallet-mmr = { git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.38" } pallet-session = { git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.38" } -pallet-sudo = { git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.38" } +pallet-sudo = { git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.38", optional = true } pallet-timestamp = { git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.38" } pallet-transaction-payment = { git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.38" } pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.38" } @@ -224,7 +224,7 @@ try-runtime = ["frame-executive/try-runtime", "frame-try-runtime"] parachain-gen = [] -rococo = [] +rococo = ["pallet-sudo"] kusama = [] diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 2772dc85..ebd722fa 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -221,10 +221,10 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("sora_ksm"), impl_name: create_runtime_str!("sora_ksm"), authoring_version: 1, - spec_version: 9, + spec_version: 10, impl_version: 0, apis: RUNTIME_API_VERSIONS, - transaction_version: 9, + transaction_version: 10, state_version: 1, }; @@ -497,6 +497,7 @@ impl pallet_beefy_mmr::Config for Runtime { type BeefyDataProvider = LeafProvider; } +#[cfg(feature = "rococo")] impl pallet_sudo::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; @@ -1058,6 +1059,7 @@ construct_runtime!( // ORML XTokens: orml_xtokens::{Pallet, Storage, Event} = 41, + #[cfg(feature = "rococo")] Sudo: pallet_sudo::{Pallet, Call, Storage, Event, Config} = 100, XCMApp: xcm_app::{Pallet, Call, Storage, Event} = 101, diff --git a/runtime/src/migrations.rs b/runtime/src/migrations.rs index 776579bf..ca49f04f 100644 --- a/runtime/src/migrations.rs +++ b/runtime/src/migrations.rs @@ -28,48 +28,30 @@ // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#[cfg(feature = "kusama")] use crate::*; +#[cfg(feature = "kusama")] use frame_support::{ - traits::{Currency, ExistenceRequirement, LockableCurrency, OnRuntimeUpgrade, WithdrawReasons}, + traits::OnRuntimeUpgrade, weights::Weight, }; -use sp_std::collections::btree_set::BTreeSet; -pub type Migrations = (RemoveMintedAccountsBalance,); +#[cfg(feature = "kusama")] +pub type Migrations = (RemoveSudoKey,); -pub struct RemoveMintedAccountsBalance; +#[cfg(any(feature = "rococo", feature = "polkadot"))] +pub type Migrations = (); -impl OnRuntimeUpgrade for RemoveMintedAccountsBalance { +#[cfg(feature = "kusama")] +pub struct RemoveSudoKey; + +#[cfg(feature = "kusama")] +impl OnRuntimeUpgrade for RemoveSudoKey { fn on_runtime_upgrade() -> Weight { - let mut accounts_to_skip = - pallet_collator_selection::Invulnerables::::get().to_vec(); - if let Some(sudo_key) = Sudo::key() { - // Fees was updated, so we need to update sudo account balance - // to be able to resolve possible issues after runtime upgrade. - let _ = Balances::deposit_creating(&sudo_key, UNIT * 1000); - accounts_to_skip.push(sudo_key); - } - let accounts_to_skip = BTreeSet::from_iter(accounts_to_skip.into_iter()); - for (account, info) in frame_system::Account::::iter() { - if accounts_to_skip.contains(&account) { - continue - } - let locks = Balances::locks(&account); - for lock in locks { - Balances::remove_lock(lock.id, &account); - } - if let Err(err) = Balances::withdraw( - &account, - info.data.free - EXISTENTIAL_DEPOSIT, - WithdrawReasons::all(), - ExistenceRequirement::KeepAlive, - ) { - frame_support::log::error!( - "Failed to withdraw funds from account {:?}: {:?}", - account, - err - ); - } + if let Some(key) = frame_support::storage::migration::take_storage_value::(b"Sudo", b"Key", &[]) { + frame_support::log::error!("Sudo key removed: {:?}", key); + } else { + frame_support::log::error!("Sudo key not found in storage"); } RuntimeBlockWeights::get().max_block }