1
// Copyright 2025 Moonbeam Foundation.
2
// This file is part of Moonbeam.
3

            
4
// Moonbeam is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8

            
9
// Moonbeam is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13

            
14
// You should have received a copy of the GNU General Public License
15
// along with Moonbeam.  If not, see <http://www.gnu.org/licenses/>.
16

            
17
//! This pallet is designed for benchmarking precompile functions. It should not be used in
18
//! production.
19

            
20
#![cfg_attr(not(feature = "std"), no_std)]
21

            
22
#[cfg(feature = "runtime-benchmarks")]
23
mod benchmarks;
24
mod mock;
25
pub mod weights;
26

            
27
pub use crate::weights::WeightInfo;
28

            
29
pub use pallet::*;
30

            
31
use frame_support::pallet;
32
use sp_core::H256;
33

            
34
20
#[pallet]
35
pub mod pallet {
36
	use storage_proof_primitives::RawStorageProof;
37

            
38
	use super::*;
39

            
40
	#[pallet::config]
41
	pub trait Config: frame_system::Config + pallet_relay_storage_roots::Config {
42
		type WeightInfo: WeightInfo;
43
	}
44

            
45
72
	#[pallet::pallet]
46
	#[pallet::without_storage_info]
47
	pub struct Pallet<T>(_);
48

            
49
	#[pallet::error]
50
	pub enum Error<T> {
51
		BenchmarkError,
52
	}
53

            
54
	impl<T: Config> Pallet<T> {
55
		pub fn verify_entry(
56
			expected_root: H256,
57
			proof: RawStorageProof,
58
			key: &[u8],
59
		) -> Result<(), Error<T>> {
60
			storage_proof_primitives::verify_entry(expected_root, proof, key)
61
				.map_err(|_| Error::<T>::BenchmarkError)?;
62
			Ok(())
63
		}
64
	}
65
}