Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add license
  • Loading branch information
kianenigma committed Sep 16, 2021
commit cc7a546767fd6e8ca5edb4ca5dbbf04bbc41f4d0
20 changes: 19 additions & 1 deletion utils/frame/try-runtime/cli/src/commands/execute_block.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
// This file is part of Substrate.

// Copyright (C) 2021 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.

use crate::{
build_executor, ensure_matching_spec_name, extract_code, full_extensions, hash_of,
local_spec_name, state_machine_call, SharedParams, State, LOG_TARGET,
Expand All @@ -8,6 +25,7 @@ use sp_core::storage::well_known_keys;
use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor};
use std::{fmt::Debug, str::FromStr};

/// Configurations of the [`Command::ExecuteBlock`].
#[derive(Debug, Clone, structopt::StructOpt)]
pub struct ExecuteBlockCmd {
/// Overwrite the wasm code in state or not.
Expand Down Expand Up @@ -86,7 +104,7 @@ impl ExecuteBlockCmd {
}
}

pub async fn execute_block<Block, ExecDispatch>(
pub(crate) async fn execute_block<Block, ExecDispatch>(
shared: SharedParams,
command: ExecuteBlockCmd,
config: Configuration,
Expand Down
22 changes: 19 additions & 3 deletions utils/frame/try-runtime/cli/src/commands/follow_chain.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
// This file is part of Substrate.

// Copyright (C) 2021 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.

use crate::{
build_executor, ensure_matching_spec_name, extract_code, full_extensions, local_spec_name,
parse, state_machine_call, SharedParams, LOG_TARGET,
Expand All @@ -14,9 +31,10 @@ use sp_core::H256;
use sp_runtime::traits::{Block as BlockT, Header, NumberFor};
use std::{fmt::Debug, str::FromStr};

/// Configurations of the [`Command::FollowChain`].
#[derive(Debug, Clone, structopt::StructOpt)]
pub struct FollowChainCmd {
/// The url to connect to
/// The url to connect to.
#[structopt(
short,
long,
Expand Down Expand Up @@ -62,7 +80,6 @@ where
while let Some(header) = subscription.next().await.unwrap() {
let hash = header.hash();
let number = header.number();
let parent = header.parent_hash();

let block = rpc_api::get_block::<Block, _>(&command.uri, hash).await.unwrap();

Expand Down Expand Up @@ -108,7 +125,6 @@ where
block.encode().as_ref(),
full_extensions(),
)?;
// .set_parent_hash(*parent)

let consumed_weight = <u64 as Decode>::decode(&mut &*encoded_result)
.map_err(|e| format!("failed to decode output: {:?}", e))?;
Expand Down
25 changes: 21 additions & 4 deletions utils/frame/try-runtime/cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
pub mod execute_block;
pub mod follow_chain;
pub mod offchain_worker;
pub mod on_runtime_upgrade;
// This file is part of Substrate.

// Copyright (C) 2021 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.

pub(crate) mod execute_block;
pub(crate) mod follow_chain;
pub(crate) mod offchain_worker;
pub(crate) mod on_runtime_upgrade;
20 changes: 19 additions & 1 deletion utils/frame/try-runtime/cli/src/commands/offchain_worker.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
// This file is part of Substrate.

// Copyright (C) 2021 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.

use crate::{
build_executor, ensure_matching_spec_name, extract_code, full_extensions, hash_of,
local_spec_name, parse, state_machine_call, SharedParams, State, LOG_TARGET,
Expand All @@ -10,6 +27,7 @@ use sp_core::storage::well_known_keys;
use sp_runtime::traits::{Block as BlockT, Header, NumberFor};
use std::{fmt::Debug, str::FromStr};

/// Configurations of the [`Command::OffchainWorker`].
#[derive(Debug, Clone, structopt::StructOpt)]
pub struct OffchainWorkerCmd {
/// Overwrite the wasm code in state or not.
Expand Down Expand Up @@ -81,7 +99,7 @@ impl OffchainWorkerCmd {
}
}

pub async fn offchain_worker<Block, ExecDispatch>(
pub(crate) async fn offchain_worker<Block, ExecDispatch>(
shared: SharedParams,
command: OffchainWorkerCmd,
config: Configuration,
Expand Down
20 changes: 19 additions & 1 deletion utils/frame/try-runtime/cli/src/commands/on_runtime_upgrade.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
// This file is part of Substrate.

// Copyright (C) 2021 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.

use std::{fmt::Debug, str::FromStr};

use parity_scale_codec::Decode;
Expand All @@ -10,14 +27,15 @@ use crate::{
SharedParams, State, LOG_TARGET,
};

/// Configurations of the [`Command::OnRuntimeUpgrade`].
#[derive(Debug, Clone, structopt::StructOpt)]
pub struct OnRuntimeUpgradeCmd {
/// The state type to use.
#[structopt(subcommand)]
pub state: State,
}

pub async fn on_runtime_upgrade<Block, ExecDispatch>(
pub(crate) async fn on_runtime_upgrade<Block, ExecDispatch>(
shared: SharedParams,
command: OnRuntimeUpgradeCmd,
config: Configuration,
Expand Down