pezsc_client_api/
backend.rs

1// This file is part of Bizinikiwi.
2
3// Copyright (C) Parity Technologies (UK) Ltd. and Dijital Kurdistan Tech Institute
4// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
5
6// This program is free software: you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
10
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// You should have received a copy of the GNU General Public License
17// along with this program. If not, see <https://www.gnu.org/licenses/>.
18
19//! Bizinikiwi Client data backend
20
21use std::collections::HashSet;
22
23use parking_lot::RwLock;
24
25use pezsp_api::CallContext;
26use pezsp_consensus::BlockOrigin;
27use pezsp_core::offchain::OffchainStorage;
28use pezsp_runtime::{
29	traits::{Block as BlockT, HashingFor, NumberFor},
30	Justification, Justifications, StateVersion, Storage,
31};
32use pezsp_state_machine::{
33	backend::AsTrieBackend, ChildStorageCollection, IndexOperation, IterArgs,
34	OffchainChangesCollection, StorageCollection, StorageIterator,
35};
36use pezsp_storage::{ChildInfo, StorageData, StorageKey};
37pub use pezsp_trie::MerkleValue;
38
39use crate::{blockchain::Backend as BlockchainBackend, UsageInfo};
40
41pub use pezsp_state_machine::{Backend as StateBackend, BackendTransaction, KeyValueStates};
42
43/// Extracts the state backend type for the given backend.
44pub type StateBackendFor<B, Block> = <B as Backend<Block>>::State;
45
46/// Describes which block import notification stream should be notified.
47#[derive(Debug, Clone, Copy)]
48pub enum ImportNotificationAction {
49	/// Notify only when the node has synced to the tip or there is a re-org.
50	RecentBlock,
51	/// Notify for every single block no matter what the sync state is.
52	EveryBlock,
53	/// Both block import notifications above should be fired.
54	Both,
55	/// No block import notification should be fired.
56	None,
57}
58
59/// Import operation summary.
60///
61/// Contains information about the block that just got imported,
62/// including storage changes, reorged blocks, etc.
63pub struct ImportSummary<Block: BlockT> {
64	/// Block hash of the imported block.
65	pub hash: Block::Hash,
66	/// Import origin.
67	pub origin: BlockOrigin,
68	/// Header of the imported block.
69	pub header: Block::Header,
70	/// Is this block a new best block.
71	pub is_new_best: bool,
72	/// Optional storage changes.
73	pub storage_changes: Option<(StorageCollection, ChildStorageCollection)>,
74	/// Tree route from old best to new best.
75	///
76	/// If `None`, there was no re-org while importing.
77	pub tree_route: Option<pezsp_blockchain::TreeRoute<Block>>,
78	/// What notify action to take for this import.
79	pub import_notification_action: ImportNotificationAction,
80}
81
82/// A stale block.
83#[derive(Clone, Debug)]
84pub struct StaleBlock<Block: BlockT> {
85	/// The hash of this block.
86	pub hash: Block::Hash,
87	/// Is this a head?
88	pub is_head: bool,
89}
90
91/// Finalization operation summary.
92///
93/// Contains information about the block that just got finalized,
94/// including tree heads that became stale at the moment of finalization.
95pub struct FinalizeSummary<Block: BlockT> {
96	/// Last finalized block header.
97	pub header: Block::Header,
98	/// Blocks that were finalized.
99	///
100	/// The last entry is the one that has been explicitly finalized.
101	pub finalized: Vec<Block::Hash>,
102	/// Blocks that became stale during this finalization operation.
103	pub stale_blocks: Vec<StaleBlock<Block>>,
104}
105
106/// Import operation wrapper.
107pub struct ClientImportOperation<Block: BlockT, B: Backend<Block>> {
108	/// DB Operation.
109	pub op: B::BlockImportOperation,
110	/// Summary of imported block.
111	pub notify_imported: Option<ImportSummary<Block>>,
112	/// Summary of finalized block.
113	pub notify_finalized: Option<FinalizeSummary<Block>>,
114}
115
116/// Helper function to apply auxiliary data insertion into an operation.
117pub fn apply_aux<'a, 'b: 'a, 'c: 'a, B, Block, D, I>(
118	operation: &mut ClientImportOperation<Block, B>,
119	insert: I,
120	delete: D,
121) -> pezsp_blockchain::Result<()>
122where
123	Block: BlockT,
124	B: Backend<Block>,
125	I: IntoIterator<Item = &'a (&'c [u8], &'c [u8])>,
126	D: IntoIterator<Item = &'a &'b [u8]>,
127{
128	operation.op.insert_aux(
129		insert
130			.into_iter()
131			.map(|(k, v)| (k.to_vec(), Some(v.to_vec())))
132			.chain(delete.into_iter().map(|k| (k.to_vec(), None))),
133	)
134}
135
136/// State of a new block.
137#[derive(Debug, Clone, Copy, PartialEq, Eq)]
138pub enum NewBlockState {
139	/// Normal block.
140	Normal,
141	/// New best block.
142	Best,
143	/// Newly finalized block (implicitly best).
144	Final,
145}
146
147impl NewBlockState {
148	/// Whether this block is the new best block.
149	pub fn is_best(self) -> bool {
150		match self {
151			NewBlockState::Best | NewBlockState::Final => true,
152			NewBlockState::Normal => false,
153		}
154	}
155
156	/// Whether this block is considered final.
157	pub fn is_final(self) -> bool {
158		match self {
159			NewBlockState::Final => true,
160			NewBlockState::Best | NewBlockState::Normal => false,
161		}
162	}
163}
164
165/// Block insertion operation.
166///
167/// Keeps hold if the inserted block state and data.
168pub trait BlockImportOperation<Block: BlockT> {
169	/// Associated state backend type.
170	type State: StateBackend<HashingFor<Block>>;
171
172	/// Returns pending state.
173	///
174	/// Returns None for backends with locally-unavailable state data.
175	fn state(&self) -> pezsp_blockchain::Result<Option<&Self::State>>;
176
177	/// Append block data to the transaction.
178	fn set_block_data(
179		&mut self,
180		header: Block::Header,
181		body: Option<Vec<Block::Extrinsic>>,
182		indexed_body: Option<Vec<Vec<u8>>>,
183		justifications: Option<Justifications>,
184		state: NewBlockState,
185	) -> pezsp_blockchain::Result<()>;
186
187	/// Inject storage data into the database.
188	fn update_db_storage(
189		&mut self,
190		update: BackendTransaction<HashingFor<Block>>,
191	) -> pezsp_blockchain::Result<()>;
192
193	/// Set genesis state. If `commit` is `false` the state is saved in memory, but is not written
194	/// to the database.
195	fn set_genesis_state(
196		&mut self,
197		storage: Storage,
198		commit: bool,
199		state_version: StateVersion,
200	) -> pezsp_blockchain::Result<Block::Hash>;
201
202	/// Inject storage data into the database replacing any existing data.
203	fn reset_storage(
204		&mut self,
205		storage: Storage,
206		state_version: StateVersion,
207	) -> pezsp_blockchain::Result<Block::Hash>;
208
209	/// Set storage changes.
210	fn update_storage(
211		&mut self,
212		update: StorageCollection,
213		child_update: ChildStorageCollection,
214	) -> pezsp_blockchain::Result<()>;
215
216	/// Write offchain storage changes to the database.
217	fn update_offchain_storage(
218		&mut self,
219		_offchain_update: OffchainChangesCollection,
220	) -> pezsp_blockchain::Result<()> {
221		Ok(())
222	}
223
224	/// Insert auxiliary keys.
225	///
226	/// Values are `None` if should be deleted.
227	fn insert_aux<I>(&mut self, ops: I) -> pezsp_blockchain::Result<()>
228	where
229		I: IntoIterator<Item = (Vec<u8>, Option<Vec<u8>>)>;
230
231	/// Mark a block as finalized, if multiple blocks are finalized in the same operation then they
232	/// must be marked in ascending order.
233	fn mark_finalized(
234		&mut self,
235		hash: Block::Hash,
236		justification: Option<Justification>,
237	) -> pezsp_blockchain::Result<()>;
238
239	/// Mark a block as new head. If both block import and set head are specified, set head
240	/// overrides block import's best block rule.
241	fn mark_head(&mut self, hash: Block::Hash) -> pezsp_blockchain::Result<()>;
242
243	/// Add a transaction index operation.
244	fn update_transaction_index(
245		&mut self,
246		index: Vec<IndexOperation>,
247	) -> pezsp_blockchain::Result<()>;
248
249	/// Configure whether to create a block gap if newly imported block is missing parent
250	fn set_create_gap(&mut self, create_gap: bool);
251}
252
253/// Interface for performing operations on the backend.
254pub trait LockImportRun<Block: BlockT, B: Backend<Block>> {
255	/// Lock the import lock, and run operations inside.
256	fn lock_import_and_run<R, Err, F>(&self, f: F) -> Result<R, Err>
257	where
258		F: FnOnce(&mut ClientImportOperation<Block, B>) -> Result<R, Err>,
259		Err: From<pezsp_blockchain::Error>;
260}
261
262/// Finalize Facilities
263pub trait Finalizer<Block: BlockT, B: Backend<Block>> {
264	/// Mark all blocks up to given as finalized in operation.
265	///
266	/// If `justification` is provided it is stored with the given finalized
267	/// block (any other finalized blocks are left unjustified).
268	///
269	/// If the block being finalized is on a different fork from the current
270	/// best block the finalized block is set as best, this might be slightly
271	/// inaccurate (i.e. outdated). Usages that require determining an accurate
272	/// best block should use `SelectChain` instead of the client.
273	fn apply_finality(
274		&self,
275		operation: &mut ClientImportOperation<Block, B>,
276		block: Block::Hash,
277		justification: Option<Justification>,
278		notify: bool,
279	) -> pezsp_blockchain::Result<()>;
280
281	/// Finalize a block.
282	///
283	/// This will implicitly finalize all blocks up to it and
284	/// fire finality notifications.
285	///
286	/// If the block being finalized is on a different fork from the current
287	/// best block, the finalized block is set as best. This might be slightly
288	/// inaccurate (i.e. outdated). Usages that require determining an accurate
289	/// best block should use `SelectChain` instead of the client.
290	///
291	/// Pass a flag to indicate whether finality notifications should be propagated.
292	/// This is usually tied to some synchronization state, where we don't send notifications
293	/// while performing major synchronization work.
294	fn finalize_block(
295		&self,
296		block: Block::Hash,
297		justification: Option<Justification>,
298		notify: bool,
299	) -> pezsp_blockchain::Result<()>;
300}
301
302/// Provides access to an auxiliary database.
303///
304/// This is a simple global database not aware of forks. Can be used for storing auxiliary
305/// information like total block weight/difficulty for fork resolution purposes as a common use
306/// case.
307pub trait AuxStore {
308	/// Insert auxiliary data into key-value store.
309	///
310	/// Deletions occur after insertions.
311	fn insert_aux<
312		'a,
313		'b: 'a,
314		'c: 'a,
315		I: IntoIterator<Item = &'a (&'c [u8], &'c [u8])>,
316		D: IntoIterator<Item = &'a &'b [u8]>,
317	>(
318		&self,
319		insert: I,
320		delete: D,
321	) -> pezsp_blockchain::Result<()>;
322
323	/// Query auxiliary data from key-value store.
324	fn get_aux(&self, key: &[u8]) -> pezsp_blockchain::Result<Option<Vec<u8>>>;
325}
326
327/// An `Iterator` that iterates keys in a given block under a prefix.
328pub struct KeysIter<State, Block>
329where
330	State: StateBackend<HashingFor<Block>>,
331	Block: BlockT,
332{
333	inner: <State as StateBackend<HashingFor<Block>>>::RawIter,
334	state: State,
335}
336
337impl<State, Block> KeysIter<State, Block>
338where
339	State: StateBackend<HashingFor<Block>>,
340	Block: BlockT,
341{
342	/// Create a new iterator over storage keys.
343	pub fn new(
344		state: State,
345		prefix: Option<&StorageKey>,
346		start_at: Option<&StorageKey>,
347	) -> Result<Self, State::Error> {
348		let mut args = IterArgs::default();
349		args.prefix = prefix.as_ref().map(|prefix| prefix.0.as_slice());
350		args.start_at = start_at.as_ref().map(|start_at| start_at.0.as_slice());
351		args.start_at_exclusive = true;
352
353		Ok(Self { inner: state.raw_iter(args)?, state })
354	}
355
356	/// Create a new iterator over a child storage's keys.
357	pub fn new_child(
358		state: State,
359		child_info: ChildInfo,
360		prefix: Option<&StorageKey>,
361		start_at: Option<&StorageKey>,
362	) -> Result<Self, State::Error> {
363		let mut args = IterArgs::default();
364		args.prefix = prefix.as_ref().map(|prefix| prefix.0.as_slice());
365		args.start_at = start_at.as_ref().map(|start_at| start_at.0.as_slice());
366		args.child_info = Some(child_info);
367		args.start_at_exclusive = true;
368
369		Ok(Self { inner: state.raw_iter(args)?, state })
370	}
371}
372
373impl<State, Block> Iterator for KeysIter<State, Block>
374where
375	Block: BlockT,
376	State: StateBackend<HashingFor<Block>>,
377{
378	type Item = StorageKey;
379
380	fn next(&mut self) -> Option<Self::Item> {
381		self.inner.next_key(&self.state)?.ok().map(StorageKey)
382	}
383}
384
385/// An `Iterator` that iterates keys and values in a given block under a prefix.
386pub struct PairsIter<State, Block>
387where
388	State: StateBackend<HashingFor<Block>>,
389	Block: BlockT,
390{
391	inner: <State as StateBackend<HashingFor<Block>>>::RawIter,
392	state: State,
393}
394
395impl<State, Block> Iterator for PairsIter<State, Block>
396where
397	Block: BlockT,
398	State: StateBackend<HashingFor<Block>>,
399{
400	type Item = (StorageKey, StorageData);
401
402	fn next(&mut self) -> Option<Self::Item> {
403		self.inner
404			.next_pair(&self.state)?
405			.ok()
406			.map(|(key, value)| (StorageKey(key), StorageData(value)))
407	}
408}
409
410impl<State, Block> PairsIter<State, Block>
411where
412	State: StateBackend<HashingFor<Block>>,
413	Block: BlockT,
414{
415	/// Create a new iterator over storage key and value pairs.
416	pub fn new(
417		state: State,
418		prefix: Option<&StorageKey>,
419		start_at: Option<&StorageKey>,
420	) -> Result<Self, State::Error> {
421		let mut args = IterArgs::default();
422		args.prefix = prefix.as_ref().map(|prefix| prefix.0.as_slice());
423		args.start_at = start_at.as_ref().map(|start_at| start_at.0.as_slice());
424		args.start_at_exclusive = true;
425
426		Ok(Self { inner: state.raw_iter(args)?, state })
427	}
428}
429
430/// Provides access to storage primitives
431pub trait StorageProvider<Block: BlockT, B: Backend<Block>> {
432	/// Given a block's `Hash` and a key, return the value under the key in that block.
433	fn storage(
434		&self,
435		hash: Block::Hash,
436		key: &StorageKey,
437	) -> pezsp_blockchain::Result<Option<StorageData>>;
438
439	/// Given a block's `Hash` and a key, return the value under the hash in that block.
440	fn storage_hash(
441		&self,
442		hash: Block::Hash,
443		key: &StorageKey,
444	) -> pezsp_blockchain::Result<Option<Block::Hash>>;
445
446	/// Given a block's `Hash` and a key prefix, returns a `KeysIter` iterates matching storage
447	/// keys in that block.
448	fn storage_keys(
449		&self,
450		hash: Block::Hash,
451		prefix: Option<&StorageKey>,
452		start_key: Option<&StorageKey>,
453	) -> pezsp_blockchain::Result<KeysIter<B::State, Block>>;
454
455	/// Given a block's `Hash` and a key prefix, returns an iterator over the storage keys and
456	/// values in that block.
457	fn storage_pairs(
458		&self,
459		hash: <Block as BlockT>::Hash,
460		prefix: Option<&StorageKey>,
461		start_key: Option<&StorageKey>,
462	) -> pezsp_blockchain::Result<PairsIter<B::State, Block>>;
463
464	/// Given a block's `Hash`, a key and a child storage key, return the value under the key in
465	/// that block.
466	fn child_storage(
467		&self,
468		hash: Block::Hash,
469		child_info: &ChildInfo,
470		key: &StorageKey,
471	) -> pezsp_blockchain::Result<Option<StorageData>>;
472
473	/// Given a block's `Hash` and a key `prefix` and a child storage key,
474	/// returns a `KeysIter` that iterates matching storage keys in that block.
475	fn child_storage_keys(
476		&self,
477		hash: Block::Hash,
478		child_info: ChildInfo,
479		prefix: Option<&StorageKey>,
480		start_key: Option<&StorageKey>,
481	) -> pezsp_blockchain::Result<KeysIter<B::State, Block>>;
482
483	/// Given a block's `Hash`, a key and a child storage key, return the hash under the key in that
484	/// block.
485	fn child_storage_hash(
486		&self,
487		hash: Block::Hash,
488		child_info: &ChildInfo,
489		key: &StorageKey,
490	) -> pezsp_blockchain::Result<Option<Block::Hash>>;
491
492	/// Given a block's `Hash` and a key, return the closest merkle value.
493	fn closest_merkle_value(
494		&self,
495		hash: Block::Hash,
496		key: &StorageKey,
497	) -> pezsp_blockchain::Result<Option<MerkleValue<Block::Hash>>>;
498
499	/// Given a block's `Hash`, a key and a child storage key, return the closest merkle value.
500	fn child_closest_merkle_value(
501		&self,
502		hash: Block::Hash,
503		child_info: &ChildInfo,
504		key: &StorageKey,
505	) -> pezsp_blockchain::Result<Option<MerkleValue<Block::Hash>>>;
506}
507
508/// Specify the desired trie cache context when calling [`Backend::state_at`].
509///
510/// This is used to determine the size of the local trie cache.
511#[derive(Debug, Clone, Copy)]
512pub enum TrieCacheContext {
513	/// This is used when calling [`Backend::state_at`] in a trusted context.
514	///
515	/// A trusted context is for example the building or importing of a block.
516	/// In this case the local trie cache can grow unlimited and all the cached data
517	/// will be propagated back to the shared trie cache. It is safe to let the local
518	/// cache grow to hold the entire data, because importing and building blocks is
519	/// bounded by the block size limit.
520	Trusted,
521	/// This is used when calling [`Backend::state_at`] in from untrusted context.
522	///
523	/// The local trie cache will be bounded by its preconfigured size.
524	Untrusted,
525}
526
527impl From<CallContext> for TrieCacheContext {
528	fn from(call_context: CallContext) -> Self {
529		match call_context {
530			CallContext::Onchain => TrieCacheContext::Trusted,
531			CallContext::Offchain => TrieCacheContext::Untrusted,
532		}
533	}
534}
535
536/// Client backend.
537///
538/// Manages the data layer.
539///
540/// # State Pruning
541///
542/// While an object from `state_at` is alive, the state
543/// should not be pruned. The backend should internally reference-count
544/// its state objects.
545///
546/// The same applies for live `BlockImportOperation`s: while an import operation building on a
547/// parent `P` is alive, the state for `P` should not be pruned.
548///
549/// # Block Pruning
550///
551/// Users can pin blocks in memory by calling `pin_block`. When
552/// a block would be pruned, its value is kept in an in-memory cache
553/// until it is unpinned via `unpin_block`.
554///
555/// While a block is pinned, its state is also preserved.
556///
557/// The backend should internally reference count the number of pin / unpin calls.
558pub trait Backend<Block: BlockT>: AuxStore + Send + Sync {
559	/// Associated block insertion operation type.
560	type BlockImportOperation: BlockImportOperation<Block, State = Self::State>;
561	/// Associated blockchain backend type.
562	type Blockchain: BlockchainBackend<Block>;
563	/// Associated state backend type.
564	type State: StateBackend<HashingFor<Block>>
565		+ Send
566		+ AsTrieBackend<
567			HashingFor<Block>,
568			TrieBackendStorage = <Self::State as StateBackend<HashingFor<Block>>>::TrieBackendStorage,
569		>;
570	/// Offchain workers local storage.
571	type OffchainStorage: OffchainStorage;
572
573	/// Begin a new block insertion transaction with given parent block id.
574	///
575	/// When constructing the genesis, this is called with all-zero hash.
576	fn begin_operation(&self) -> pezsp_blockchain::Result<Self::BlockImportOperation>;
577
578	/// Note an operation to contain state transition.
579	fn begin_state_operation(
580		&self,
581		operation: &mut Self::BlockImportOperation,
582		block: Block::Hash,
583	) -> pezsp_blockchain::Result<()>;
584
585	/// Commit block insertion.
586	fn commit_operation(
587		&self,
588		transaction: Self::BlockImportOperation,
589	) -> pezsp_blockchain::Result<()>;
590
591	/// Finalize block with given `hash`.
592	///
593	/// This should only be called if the parent of the given block has been finalized.
594	fn finalize_block(
595		&self,
596		hash: Block::Hash,
597		justification: Option<Justification>,
598	) -> pezsp_blockchain::Result<()>;
599
600	/// Append justification to the block with the given `hash`.
601	///
602	/// This should only be called for blocks that are already finalized.
603	fn append_justification(
604		&self,
605		hash: Block::Hash,
606		justification: Justification,
607	) -> pezsp_blockchain::Result<()>;
608
609	/// Returns reference to blockchain backend.
610	fn blockchain(&self) -> &Self::Blockchain;
611
612	/// Returns current usage statistics.
613	fn usage_info(&self) -> Option<UsageInfo>;
614
615	/// Returns a handle to offchain storage.
616	fn offchain_storage(&self) -> Option<Self::OffchainStorage>;
617
618	/// Pin the block to keep body, justification and state available after pruning.
619	/// Number of pins are reference counted. Users need to make sure to perform
620	/// one call to [`Self::unpin_block`] per call to [`Self::pin_block`].
621	fn pin_block(&self, hash: Block::Hash) -> pezsp_blockchain::Result<()>;
622
623	/// Unpin the block to allow pruning.
624	fn unpin_block(&self, hash: Block::Hash);
625
626	/// Returns true if state for given block is available.
627	fn have_state_at(&self, hash: Block::Hash, _number: NumberFor<Block>) -> bool {
628		self.state_at(hash, TrieCacheContext::Untrusted).is_ok()
629	}
630
631	/// Returns state backend with post-state of given block.
632	fn state_at(
633		&self,
634		hash: Block::Hash,
635		trie_cache_context: TrieCacheContext,
636	) -> pezsp_blockchain::Result<Self::State>;
637
638	/// Attempts to revert the chain by `n` blocks. If `revert_finalized` is set it will attempt to
639	/// revert past any finalized block, this is unsafe and can potentially leave the node in an
640	/// inconsistent state. All blocks higher than the best block are also reverted and not counting
641	/// towards `n`.
642	///
643	/// Returns the number of blocks that were successfully reverted and the list of finalized
644	/// blocks that has been reverted.
645	fn revert(
646		&self,
647		n: NumberFor<Block>,
648		revert_finalized: bool,
649	) -> pezsp_blockchain::Result<(NumberFor<Block>, HashSet<Block::Hash>)>;
650
651	/// Discard non-best, unfinalized leaf block.
652	fn remove_leaf_block(&self, hash: Block::Hash) -> pezsp_blockchain::Result<()>;
653
654	/// Insert auxiliary data into key-value store.
655	fn insert_aux<
656		'a,
657		'b: 'a,
658		'c: 'a,
659		I: IntoIterator<Item = &'a (&'c [u8], &'c [u8])>,
660		D: IntoIterator<Item = &'a &'b [u8]>,
661	>(
662		&self,
663		insert: I,
664		delete: D,
665	) -> pezsp_blockchain::Result<()> {
666		AuxStore::insert_aux(self, insert, delete)
667	}
668	/// Query auxiliary data from key-value store.
669	fn get_aux(&self, key: &[u8]) -> pezsp_blockchain::Result<Option<Vec<u8>>> {
670		AuxStore::get_aux(self, key)
671	}
672
673	/// Gain access to the import lock around this backend.
674	///
675	/// _Note_ Backend isn't expected to acquire the lock by itself ever. Rather
676	/// the using components should acquire and hold the lock whenever they do
677	/// something that the import of a block would interfere with, e.g. importing
678	/// a new block or calculating the best head.
679	fn get_import_lock(&self) -> &RwLock<()>;
680
681	/// Tells whether the backend requires full-sync mode.
682	fn requires_full_sync(&self) -> bool;
683}
684
685/// Mark for all Backend implementations, that are making use of state data, stored locally.
686pub trait LocalBackend<Block: BlockT>: Backend<Block> {}