From 5996a007ae767e9591815de923ce8e3782793af2 Mon Sep 17 00:00:00 2001 From: Sander Bosma Date: Mon, 30 Aug 2021 15:29:24 +0200 Subject: [PATCH] feat: start mainnet deployment in shutdown --- crates/security/src/lib.rs | 2 +- parachain/runtime/src/lib.rs | 1 + parachain/src/chain_spec.rs | 20 ++++++++++++++++++-- standalone/runtime/src/lib.rs | 1 + standalone/src/chain_spec.rs | 15 +++++++++++++-- 5 files changed, 34 insertions(+), 5 deletions(-) diff --git a/crates/security/src/lib.rs b/crates/security/src/lib.rs index 2bec3ac885..63bbc93ee0 100644 --- a/crates/security/src/lib.rs +++ b/crates/security/src/lib.rs @@ -91,7 +91,7 @@ pub mod pallet { #[pallet::genesis_config] pub struct GenesisConfig { - initial_status: StatusCode, + pub initial_status: StatusCode, } #[cfg(feature = "std")] diff --git a/parachain/runtime/src/lib.rs b/parachain/runtime/src/lib.rs index ef18f9b9a8..9df31aa7dd 100644 --- a/parachain/runtime/src/lib.rs +++ b/parachain/runtime/src/lib.rs @@ -51,6 +51,7 @@ pub use sp_runtime::{Perbill, Permill}; // interBTC exports pub use btc_relay::{bitcoin, Call as RelayCall, TARGET_SPACING}; pub use module_oracle_rpc_runtime_api::BalanceWrapper; +pub use security::StatusCode; pub use primitives::{ self, AccountId, Balance, BlockNumber, CurrencyId, Hash, Moment, Nonce, Signature, SignedFixedPoint, SignedInner, diff --git a/parachain/src/chain_spec.rs b/parachain/src/chain_spec.rs index 09daf50f0e..7206165924 100644 --- a/parachain/src/chain_spec.rs +++ b/parachain/src/chain_spec.rs @@ -3,8 +3,9 @@ use cumulus_primitives_core::ParaId; use hex_literal::hex; use interbtc_runtime::{ AccountId, AuraConfig, BTCRelayConfig, Balance, CurrencyId, FeeConfig, GenesisConfig, IssueConfig, - NominationConfig, OracleConfig, ParachainInfoConfig, RedeemConfig, RefundConfig, ReplaceConfig, Signature, - SudoConfig, SystemConfig, TokensConfig, VaultRegistryConfig, BITCOIN_BLOCK_SPACING, DAYS, KSM, WASM_BINARY, + NominationConfig, OracleConfig, ParachainInfoConfig, RedeemConfig, RefundConfig, ReplaceConfig, SecurityConfig, + Signature, StatusCode, SudoConfig, SystemConfig, TokensConfig, VaultRegistryConfig, BITCOIN_BLOCK_SPACING, DAYS, + KSM, WASM_BINARY, }; use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup}; use serde::{Deserialize, Serialize}; @@ -109,6 +110,7 @@ pub fn local_config(id: ParaId) -> ChainSpec { )], id, DEFAULT_BITCOIN_CONFIRMATIONS, + false, ) }, vec![], @@ -161,6 +163,7 @@ pub fn development_config(id: ParaId) -> ChainSpec { ], id, DEFAULT_BITCOIN_CONFIRMATIONS, + false, ) }, Vec::new(), @@ -203,6 +206,7 @@ pub fn rococo_testnet_config(id: ParaId) -> ChainSpec { ], id, DEFAULT_BITCOIN_CONFIRMATIONS, + false, ) }, Vec::new(), @@ -263,6 +267,7 @@ pub fn westend_testnet_config(id: ParaId) -> ChainSpec { ], id, DEFAULT_BITCOIN_CONFIRMATIONS, + false, ) }, Vec::new(), @@ -283,6 +288,7 @@ fn testnet_genesis( authorized_oracles: Vec<(AccountId, Vec)>, id: ParaId, bitcoin_confirmations: u32, + start_shutdown: bool, ) -> GenesisConfig { GenesisConfig { system: SystemConfig { @@ -297,6 +303,13 @@ fn testnet_genesis( aura_ext: Default::default(), parachain_system: Default::default(), parachain_info: ParachainInfoConfig { parachain_id: id }, + security: SecurityConfig { + initial_status: if start_shutdown { + StatusCode::Shutdown + } else { + StatusCode::Error + }, + }, sudo: SudoConfig { // Assign network admin rights. key: root_key.clone(), @@ -491,6 +504,9 @@ fn mainnet_genesis( aura_ext: Default::default(), parachain_system: Default::default(), parachain_info: ParachainInfoConfig { parachain_id: id }, + security: SecurityConfig { + initial_status: StatusCode::Shutdown, + }, sudo: SudoConfig { // Assign network admin rights. key: root_key.clone(), diff --git a/standalone/runtime/src/lib.rs b/standalone/runtime/src/lib.rs index 3668695f62..769ec2618d 100644 --- a/standalone/runtime/src/lib.rs +++ b/standalone/runtime/src/lib.rs @@ -46,6 +46,7 @@ pub use sp_runtime::{Perbill, Permill}; // interBTC exports pub use btc_relay::{bitcoin, Call as RelayCall, TARGET_SPACING}; pub use module_oracle_rpc_runtime_api::BalanceWrapper; +pub use security::StatusCode; use currency::Amount; pub use primitives::{ diff --git a/standalone/src/chain_spec.rs b/standalone/src/chain_spec.rs index 329ad4e701..be52662ff5 100644 --- a/standalone/src/chain_spec.rs +++ b/standalone/src/chain_spec.rs @@ -2,8 +2,8 @@ use bitcoin::utils::{virtual_transaction_size, InputType, TransactionInputMetada use hex_literal::hex; use interbtc_runtime::{ AccountId, AuraConfig, BTCRelayConfig, CurrencyId, FeeConfig, GenesisConfig, GrandpaConfig, IssueConfig, - NominationConfig, OracleConfig, RedeemConfig, RefundConfig, ReplaceConfig, Signature, SudoConfig, SystemConfig, - TokensConfig, VaultRegistryConfig, BITCOIN_BLOCK_SPACING, DAYS, DOT, WASM_BINARY, + NominationConfig, OracleConfig, RedeemConfig, RefundConfig, ReplaceConfig, SecurityConfig, Signature, StatusCode, + SudoConfig, SystemConfig, TokensConfig, VaultRegistryConfig, BITCOIN_BLOCK_SPACING, DAYS, DOT, WASM_BINARY, }; use sp_consensus_aura::sr25519::AuthorityId as AuraId; use sp_core::crypto::UncheckedInto; @@ -88,6 +88,7 @@ pub fn local_config() -> ChainSpec { "Bob".as_bytes().to_vec(), )], 0, + false, ) }, vec![], @@ -151,6 +152,7 @@ pub fn beta_testnet_config() -> ChainSpec { ), ], 1, + false, ) }, Vec::new(), @@ -199,6 +201,7 @@ pub fn development_config() -> ChainSpec { ), ], 1, + false, ) }, Vec::new(), @@ -215,6 +218,7 @@ fn testnet_genesis( endowed_accounts: Vec, authorized_oracles: Vec<(AccountId, Vec)>, bitcoin_confirmations: u32, + start_shutdown: bool, ) -> GenesisConfig { GenesisConfig { system: SystemConfig { @@ -229,6 +233,13 @@ fn testnet_genesis( grandpa: GrandpaConfig { authorities: initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect(), }, + security: SecurityConfig { + initial_status: if start_shutdown { + StatusCode::Shutdown + } else { + StatusCode::Error + }, + }, sudo: SudoConfig { // Assign network admin rights. key: root_key.clone(),