Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Cargo.lock

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

5 changes: 0 additions & 5 deletions crates/security/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,6 @@ impl<T: Config> Pallet<T> {
}
}

/// Checks if the Parachain has Shutdown
pub fn is_parachain_shutdown() -> bool {
Self::parachain_status() == StatusCode::Shutdown
}

/// Checks if the Parachain has a OracleOffline Error state
pub fn is_parachain_error_oracle_offline() -> bool {
Self::parachain_status() == StatusCode::Error && <Errors<T>>::get().contains(&ErrorCode::OracleOffline)
Expand Down
36 changes: 0 additions & 36 deletions crates/security/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,6 @@ macro_rules! assert_emitted {
};
}

#[test]
fn test_get_and_set_status() {
run_test(|| {
let status_code = Security::parachain_status();
assert_eq!(status_code, StatusCode::Running);
Security::set_status(StatusCode::Shutdown);
let status_code = Security::parachain_status();
assert_eq!(status_code, StatusCode::Shutdown);
})
}

#[test]
fn test_is_ensure_parachain_running_succeeds() {
run_test(|| {
Expand All @@ -45,26 +34,6 @@ fn test_is_ensure_parachain_running_fails() {
Security::ensure_parachain_status_running(),
TestError::ParachainNotRunning
);

Security::set_status(StatusCode::Shutdown);
assert_noop!(
Security::ensure_parachain_status_running(),
TestError::ParachainNotRunning
);
})
}

#[test]
fn test_is_parachain_shutdown_succeeds() {
run_test(|| {
Security::set_status(StatusCode::Running);
assert!(!Security::is_parachain_shutdown());

Security::set_status(StatusCode::Error);
assert!(!Security::is_parachain_shutdown());

Security::set_status(StatusCode::Shutdown);
assert!(Security::is_parachain_shutdown());
})
}

Expand Down Expand Up @@ -135,11 +104,6 @@ fn test_get_active_block_not_incremented_if_not_running() {
Security::set_status(StatusCode::Error);
Security::increment_active_block();
assert_eq!(Security::active_block_number(), initial_active_block);

// not updated if there is shutdown
Security::set_status(StatusCode::Shutdown);
Security::increment_active_block();
assert_eq!(Security::active_block_number(), initial_active_block);
})
}

Expand Down
2 changes: 0 additions & 2 deletions crates/security/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ pub enum StatusCode {
Running = 0,
/// An error has occurred. See Errors for more details.
Error = 1,
/// BTC Parachain operation has been fully suspended.
Shutdown = 2,
}

impl Default for StatusCode {
Expand Down
62 changes: 62 additions & 0 deletions crates/tx-pause/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
[package]
name = "tx-pause"
version = "4.0.0-dev"
authors = ["Parity Technologies <[email protected]>"]
edition = "2021"
license = "Apache-2.0"
homepage = "https://substrate.io"
repository = "https://github.com/paritytech/substrate/"
description = "FRAME transaction pause pallet"
readme = "README.md"

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
scale-info = { version = "2.2.0", default-features = false, features = ["derive"] }

frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }
frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false, optional = true }
pallet-utility = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false, optional = true }
pallet-proxy = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false, optional = true }

[dev-dependencies]
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }
pallet-utility = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }
pallet-proxy = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false }


[features]
default = ["std"]
std = [
"codec/std",
"scale-info/std",
"frame-benchmarking/std",
"frame-support/std",
"frame-system/std",
"pallet-balances?/std",
"pallet-utility?/std",
"pallet-proxy?/std",
"sp-runtime/std",
"sp-std/std",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-utility/runtime-benchmarks",
"pallet-proxy/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
]
61 changes: 61 additions & 0 deletions crates/tx-pause/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// This file is part of Substrate.

// Copyright (C) 2022 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#![cfg(feature = "runtime-benchmarks")]

use super::{Pallet as TxPause, *};

use frame_benchmarking::benchmarks;

benchmarks! {
pause {
let full_name: FullNameOf<T> = (name::<T>(b"SomePalletName"), Some(name::<T>(b"SomePalletName")));
// let pallet_name: PalletNameOf<T> = name::<T>(b"SomePalletName");
// let maybe_call_name: Option<CallNameOf<T>> = Some(name::<T>(b"some_call_name"));
let origin = T::PauseOrigin::successful_origin();
// let call = Call::<T>::pause { full_name: full_name.clone() };
// let call = Call::<T>::pause { pallet_name: pallet_name.clone(), maybe_call_name: maybe_call_name.clone() };

}: _<T::RuntimeOrigin>(origin, full_name.clone())
verify {
assert!(TxPause::<T>::paused_calls(full_name.clone()).is_some())
}

unpause {
let full_name: FullNameOf<T> = (name::<T>(b"SomePalletName"), Some(name::<T>(b"SomePalletName")));
let pause_origin = T::PauseOrigin::successful_origin();

TxPause::<T>::pause(
pause_origin,
full_name.clone(),
)?;

let unpause_origin = T::UnpauseOrigin::successful_origin();
// let call = Call::<T>::unpause { pallet_name: pallet_name.clone(), maybe_call_name: maybe_call_name.clone() };

}: _<T::RuntimeOrigin>(unpause_origin, full_name.clone())
verify {
assert!(TxPause::<T>::paused_calls(full_name.clone()).is_none())

}

impl_benchmark_test_suite!(TxPause, crate::mock::new_test_ext(), crate::mock::Test);
}

pub fn name<T: Config>(bytes: &[u8]) -> BoundedVec<u8, T::MaxNameLen> {
bytes.to_vec().try_into().unwrap()
}
Loading