referrerpolicy=no-referrer-when-downgrade

frame_benchmarking_cli/overhead/
fake_runtime_api.rs

1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: Apache-2.0
5
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// 	http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17
18//! A fake runtime struct that allows us to instantiate a client.
19//! Has all the required runtime APIs implemented to satisfy trait bounds,
20//! but the methods are never called since we use WASM exclusively.
21
22use sp_core::OpaqueMetadata;
23use sp_runtime::{
24	generic,
25	traits::{BlakeTwo256, Block as BlockT},
26	transaction_validity::{TransactionSource, TransactionValidity},
27	ApplyExtrinsicResult, OpaqueExtrinsic,
28};
29
30/// Block number
31type BlockNumber = u32;
32/// Opaque block header type.
33type Header = generic::Header<BlockNumber, BlakeTwo256>;
34/// Opaque block type.
35type Block = generic::Block<Header, OpaqueExtrinsic>;
36
37#[allow(unused)]
38pub struct Runtime;
39
40sp_api::impl_runtime_apis! {
41	impl sp_api::Core<Block> for Runtime {
42		fn version() -> sp_version::RuntimeVersion {
43			unimplemented!()
44		}
45
46		fn execute_block(_: Block) {
47			unimplemented!()
48		}
49
50		fn initialize_block(_: &<Block as BlockT>::Header) -> sp_runtime::ExtrinsicInclusionMode {
51			unimplemented!()
52		}
53	}
54
55	impl sp_api::Metadata<Block> for Runtime {
56		fn metadata() -> OpaqueMetadata {
57			unimplemented!()
58		}
59
60		fn metadata_at_version(_: u32) -> Option<OpaqueMetadata> {
61			unimplemented!()
62		}
63
64		fn metadata_versions() -> Vec<u32> {
65			unimplemented!()
66		}
67	}
68	impl sp_block_builder::BlockBuilder<Block> for Runtime {
69		fn apply_extrinsic(_: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
70			unimplemented!()
71		}
72
73		fn finalize_block() -> <Block as BlockT>::Header {
74			unimplemented!()
75		}
76
77		fn inherent_extrinsics(_: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
78			unimplemented!()
79		}
80
81		fn check_inherents(_: Block, _: sp_inherents::InherentData) -> sp_inherents::CheckInherentsResult {
82			unimplemented!()
83		}
84	}
85
86	impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
87		fn validate_transaction(
88			_: TransactionSource,
89			_: <Block as BlockT>::Extrinsic,
90			_: <Block as BlockT>::Hash,
91		) -> TransactionValidity {
92			unimplemented!()
93		}
94	}
95
96	impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
97		fn build_state(_: Vec<u8>) -> sp_genesis_builder::Result {
98			unimplemented!()
99		}
100
101		fn get_preset(_id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
102			unimplemented!()
103		}
104
105		fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
106			unimplemented!()
107		}
108	}
109}