sc_client_api/
backend.rs

1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
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//! Substrate Client data backend
20
21use std::collections::HashSet;
22
23use parking_lot::RwLock;
24
25use sp_api::CallContext;
26use sp_consensus::BlockOrigin;
27use sp_core::offchain::OffchainStorage;
28use sp_runtime::{
29	traits::{Block as BlockT, HashingFor, NumberFor},
30	Justification, Justifications, StateVersion, Storage,
31};
32use sp_state_machine::{
33	backend::AsTrieBackend, ChildStorageCollection, IndexOperation, IterArgs,
34	OffchainChangesCollection, StorageCollection, StorageIterator,
35};
36use sp_storage::{ChildInfo, StorageData, StorageKey};
37pub use sp_trie::MerkleValue;
38
39use crate::{blockchain::Backend as BlockchainBackend, UsageInfo};
40
41pub use sp_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<sp_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) -> sp_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) -> sp_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	) -> sp_blockchain::Result<()>;
186
187	/// Inject storage data into the database.
188	fn update_db_storage(
189		&mut self,
190		update: BackendTransaction<HashingFor<Block>>,
191	) -> sp_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	) -> sp_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	) -> sp_blockchain::Result<Block::Hash>;
208
209	/// Set storage changes.
210	fn update_storage(
211		&mut self,
212		update: StorageCollection,
213		child_update: ChildStorageCollection,
214	) -> sp_blockchain::Result<()>;
215
216	/// Write offchain storage changes to the database.
217	fn update_offchain_storage(
218		&mut self,
219		_offchain_update: OffchainChangesCollection,
220	) -> sp_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) -> sp_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	) -> sp_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) -> sp_blockchain::Result<()>;
242
243	/// Add a transaction index operation.
244	fn update_transaction_index(&mut self, index: Vec<IndexOperation>)
245		-> sp_blockchain::Result<()>;
246
247	/// Configure whether to create a block gap if newly imported block is missing parent
248	fn set_create_gap(&mut self, create_gap: bool);
249}
250
251/// Interface for performing operations on the backend.
252pub trait LockImportRun<Block: BlockT, B: Backend<Block>> {
253	/// Lock the import lock, and run operations inside.
254	fn lock_import_and_run<R, Err, F>(&self, f: F) -> Result<R, Err>
255	where
256		F: FnOnce(&mut ClientImportOperation<Block, B>) -> Result<R, Err>,
257		Err: From<sp_blockchain::Error>;
258}
259
260/// Finalize Facilities
261pub trait Finalizer<Block: BlockT, B: Backend<Block>> {
262	/// Mark all blocks up to given as finalized in operation.
263	///
264	/// If `justification` is provided it is stored with the given finalized
265	/// block (any other finalized blocks are left unjustified).
266	///
267	/// If the block being finalized is on a different fork from the current
268	/// best block the finalized block is set as best, this might be slightly
269	/// inaccurate (i.e. outdated). Usages that require determining an accurate
270	/// best block should use `SelectChain` instead of the client.
271	fn apply_finality(
272		&self,
273		operation: &mut ClientImportOperation<Block, B>,
274		block: Block::Hash,
275		justification: Option<Justification>,
276		notify: bool,
277	) -> sp_blockchain::Result<()>;
278
279	/// Finalize a block.
280	///
281	/// This will implicitly finalize all blocks up to it and
282	/// fire finality notifications.
283	///
284	/// If the block being finalized is on a different fork from the current
285	/// best block, the finalized block is set as best. This might be slightly
286	/// inaccurate (i.e. outdated). Usages that require determining an accurate
287	/// best block should use `SelectChain` instead of the client.
288	///
289	/// Pass a flag to indicate whether finality notifications should be propagated.
290	/// This is usually tied to some synchronization state, where we don't send notifications
291	/// while performing major synchronization work.
292	fn finalize_block(
293		&self,
294		block: Block::Hash,
295		justification: Option<Justification>,
296		notify: bool,
297	) -> sp_blockchain::Result<()>;
298}
299
300/// Provides access to an auxiliary database.
301///
302/// This is a simple global database not aware of forks. Can be used for storing auxiliary
303/// information like total block weight/difficulty for fork resolution purposes as a common use
304/// case.
305pub trait AuxStore {
306	/// Insert auxiliary data into key-value store.
307	///
308	/// Deletions occur after insertions.
309	fn insert_aux<
310		'a,
311		'b: 'a,
312		'c: 'a,
313		I: IntoIterator<Item = &'a (&'c [u8], &'c [u8])>,
314		D: IntoIterator<Item = &'a &'b [u8]>,
315	>(
316		&self,
317		insert: I,
318		delete: D,
319	) -> sp_blockchain::Result<()>;
320
321	/// Query auxiliary data from key-value store.
322	fn get_aux(&self, key: &[u8]) -> sp_blockchain::Result<Option<Vec<u8>>>;
323}
324
325/// An `Iterator` that iterates keys in a given block under a prefix.
326pub struct KeysIter<State, Block>
327where
328	State: StateBackend<HashingFor<Block>>,
329	Block: BlockT,
330{
331	inner: <State as StateBackend<HashingFor<Block>>>::RawIter,
332	state: State,
333}
334
335impl<State, Block> KeysIter<State, Block>
336where
337	State: StateBackend<HashingFor<Block>>,
338	Block: BlockT,
339{
340	/// Create a new iterator over storage keys.
341	pub fn new(
342		state: State,
343		prefix: Option<&StorageKey>,
344		start_at: Option<&StorageKey>,
345	) -> Result<Self, State::Error> {
346		let mut args = IterArgs::default();
347		args.prefix = prefix.as_ref().map(|prefix| prefix.0.as_slice());
348		args.start_at = start_at.as_ref().map(|start_at| start_at.0.as_slice());
349		args.start_at_exclusive = true;
350
351		Ok(Self { inner: state.raw_iter(args)?, state })
352	}
353
354	/// Create a new iterator over a child storage's keys.
355	pub fn new_child(
356		state: State,
357		child_info: ChildInfo,
358		prefix: Option<&StorageKey>,
359		start_at: Option<&StorageKey>,
360	) -> Result<Self, State::Error> {
361		let mut args = IterArgs::default();
362		args.prefix = prefix.as_ref().map(|prefix| prefix.0.as_slice());
363		args.start_at = start_at.as_ref().map(|start_at| start_at.0.as_slice());
364		args.child_info = Some(child_info);
365		args.start_at_exclusive = true;
366
367		Ok(Self { inner: state.raw_iter(args)?, state })
368	}
369}
370
371impl<State, Block> Iterator for KeysIter<State, Block>
372where
373	Block: BlockT,
374	State: StateBackend<HashingFor<Block>>,
375{
376	type Item = StorageKey;
377
378	fn next(&mut self) -> Option<Self::Item> {
379		self.inner.next_key(&self.state)?.ok().map(StorageKey)
380	}
381}
382
383/// An `Iterator` that iterates keys and values in a given block under a prefix.
384pub struct PairsIter<State, Block>
385where
386	State: StateBackend<HashingFor<Block>>,
387	Block: BlockT,
388{
389	inner: <State as StateBackend<HashingFor<Block>>>::RawIter,
390	state: State,
391}
392
393impl<State, Block> Iterator for PairsIter<State, Block>
394where
395	Block: BlockT,
396	State: StateBackend<HashingFor<Block>>,
397{
398	type Item = (StorageKey, StorageData);
399
400	fn next(&mut self) -> Option<Self::Item> {
401		self.inner
402			.next_pair(&self.state)?
403			.ok()
404			.map(|(key, value)| (StorageKey(key), StorageData(value)))
405	}
406}
407
408impl<State, Block> PairsIter<State, Block>
409where
410	State: StateBackend<HashingFor<Block>>,
411	Block: BlockT,
412{
413	/// Create a new iterator over storage key and value pairs.
414	pub fn new(
415		state: State,
416		prefix: Option<&StorageKey>,
417		start_at: Option<&StorageKey>,
418	) -> Result<Self, State::Error> {
419		let mut args = IterArgs::default();
420		args.prefix = prefix.as_ref().map(|prefix| prefix.0.as_slice());
421		args.start_at = start_at.as_ref().map(|start_at| start_at.0.as_slice());
422		args.start_at_exclusive = true;
423
424		Ok(Self { inner: state.raw_iter(args)?, state })
425	}
426}
427
428/// Provides access to storage primitives
429pub trait StorageProvider<Block: BlockT, B: Backend<Block>> {
430	/// Given a block's `Hash` and a key, return the value under the key in that block.
431	fn storage(
432		&self,
433		hash: Block::Hash,
434		key: &StorageKey,
435	) -> sp_blockchain::Result<Option<StorageData>>;
436
437	/// Given a block's `Hash` and a key, return the value under the hash in that block.
438	fn storage_hash(
439		&self,
440		hash: Block::Hash,
441		key: &StorageKey,
442	) -> sp_blockchain::Result<Option<Block::Hash>>;
443
444	/// Given a block's `Hash` and a key prefix, returns a `KeysIter` iterates matching storage
445	/// keys in that block.
446	fn storage_keys(
447		&self,
448		hash: Block::Hash,
449		prefix: Option<&StorageKey>,
450		start_key: Option<&StorageKey>,
451	) -> sp_blockchain::Result<KeysIter<B::State, Block>>;
452
453	/// Given a block's `Hash` and a key prefix, returns an iterator over the storage keys and
454	/// values in that block.
455	fn storage_pairs(
456		&self,
457		hash: <Block as BlockT>::Hash,
458		prefix: Option<&StorageKey>,
459		start_key: Option<&StorageKey>,
460	) -> sp_blockchain::Result<PairsIter<B::State, Block>>;
461
462	/// Given a block's `Hash`, a key and a child storage key, return the value under the key in
463	/// that block.
464	fn child_storage(
465		&self,
466		hash: Block::Hash,
467		child_info: &ChildInfo,
468		key: &StorageKey,
469	) -> sp_blockchain::Result<Option<StorageData>>;
470
471	/// Given a block's `Hash` and a key `prefix` and a child storage key,
472	/// returns a `KeysIter` that iterates matching storage keys in that block.
473	fn child_storage_keys(
474		&self,
475		hash: Block::Hash,
476		child_info: ChildInfo,
477		prefix: Option<&StorageKey>,
478		start_key: Option<&StorageKey>,
479	) -> sp_blockchain::Result<KeysIter<B::State, Block>>;
480
481	/// Given a block's `Hash`, a key and a child storage key, return the hash under the key in that
482	/// block.
483	fn child_storage_hash(
484		&self,
485		hash: Block::Hash,
486		child_info: &ChildInfo,
487		key: &StorageKey,
488	) -> sp_blockchain::Result<Option<Block::Hash>>;
489
490	/// Given a block's `Hash` and a key, return the closest merkle value.
491	fn closest_merkle_value(
492		&self,
493		hash: Block::Hash,
494		key: &StorageKey,
495	) -> sp_blockchain::Result<Option<MerkleValue<Block::Hash>>>;
496
497	/// Given a block's `Hash`, a key and a child storage key, return the closest merkle value.
498	fn child_closest_merkle_value(
499		&self,
500		hash: Block::Hash,
501		child_info: &ChildInfo,
502		key: &StorageKey,
503	) -> sp_blockchain::Result<Option<MerkleValue<Block::Hash>>>;
504}
505
506/// Specify the desired trie cache context when calling [`Backend::state_at`].
507///
508/// This is used to determine the size of the local trie cache.
509#[derive(Debug, Clone, Copy)]
510pub enum TrieCacheContext {
511	/// This is used when calling [`Backend::state_at`] in a trusted context.
512	///
513	/// A trusted context is for example the building or importing of a block.
514	/// In this case the local trie cache can grow unlimited and all the cached data
515	/// will be propagated back to the shared trie cache. It is safe to let the local
516	/// cache grow to hold the entire data, because importing and building blocks is
517	/// bounded by the block size limit.
518	Trusted,
519	/// This is used when calling [`Backend::state_at`] in from untrusted context.
520	///
521	/// The local trie cache will be bounded by its preconfigured size.
522	Untrusted,
523}
524
525impl From<CallContext> for TrieCacheContext {
526	fn from(call_context: CallContext) -> Self {
527		match call_context {
528			CallContext::Onchain => TrieCacheContext::Trusted,
529			CallContext::Offchain => TrieCacheContext::Untrusted,
530		}
531	}
532}
533
534/// Client backend.
535///
536/// Manages the data layer.
537///
538/// # State Pruning
539///
540/// While an object from `state_at` is alive, the state
541/// should not be pruned. The backend should internally reference-count
542/// its state objects.
543///
544/// The same applies for live `BlockImportOperation`s: while an import operation building on a
545/// parent `P` is alive, the state for `P` should not be pruned.
546///
547/// # Block Pruning
548///
549/// Users can pin blocks in memory by calling `pin_block`. When
550/// a block would be pruned, its value is kept in an in-memory cache
551/// until it is unpinned via `unpin_block`.
552///
553/// While a block is pinned, its state is also preserved.
554///
555/// The backend should internally reference count the number of pin / unpin calls.
556pub trait Backend<Block: BlockT>: AuxStore + Send + Sync {
557	/// Associated block insertion operation type.
558	type BlockImportOperation: BlockImportOperation<Block, State = Self::State>;
559	/// Associated blockchain backend type.
560	type Blockchain: BlockchainBackend<Block>;
561	/// Associated state backend type.
562	type State: StateBackend<HashingFor<Block>>
563		+ Send
564		+ AsTrieBackend<
565			HashingFor<Block>,
566			TrieBackendStorage = <Self::State as StateBackend<HashingFor<Block>>>::TrieBackendStorage,
567		>;
568	/// Offchain workers local storage.
569	type OffchainStorage: OffchainStorage;
570
571	/// Begin a new block insertion transaction with given parent block id.
572	///
573	/// When constructing the genesis, this is called with all-zero hash.
574	fn begin_operation(&self) -> sp_blockchain::Result<Self::BlockImportOperation>;
575
576	/// Note an operation to contain state transition.
577	fn begin_state_operation(
578		&self,
579		operation: &mut Self::BlockImportOperation,
580		block: Block::Hash,
581	) -> sp_blockchain::Result<()>;
582
583	/// Commit block insertion.
584	fn commit_operation(
585		&self,
586		transaction: Self::BlockImportOperation,
587	) -> sp_blockchain::Result<()>;
588
589	/// Finalize block with given `hash`.
590	///
591	/// This should only be called if the parent of the given block has been finalized.
592	fn finalize_block(
593		&self,
594		hash: Block::Hash,
595		justification: Option<Justification>,
596	) -> sp_blockchain::Result<()>;
597
598	/// Append justification to the block with the given `hash`.
599	///
600	/// This should only be called for blocks that are already finalized.
601	fn append_justification(
602		&self,
603		hash: Block::Hash,
604		justification: Justification,
605	) -> sp_blockchain::Result<()>;
606
607	/// Returns reference to blockchain backend.
608	fn blockchain(&self) -> &Self::Blockchain;
609
610	/// Returns current usage statistics.
611	fn usage_info(&self) -> Option<UsageInfo>;
612
613	/// Returns a handle to offchain storage.
614	fn offchain_storage(&self) -> Option<Self::OffchainStorage>;
615
616	/// Pin the block to keep body, justification and state available after pruning.
617	/// Number of pins are reference counted. Users need to make sure to perform
618	/// one call to [`Self::unpin_block`] per call to [`Self::pin_block`].
619	fn pin_block(&self, hash: Block::Hash) -> sp_blockchain::Result<()>;
620
621	/// Unpin the block to allow pruning.
622	fn unpin_block(&self, hash: Block::Hash);
623
624	/// Returns true if state for given block is available.
625	fn have_state_at(&self, hash: Block::Hash, _number: NumberFor<Block>) -> bool {
626		self.state_at(hash, TrieCacheContext::Untrusted).is_ok()
627	}
628
629	/// Returns state backend with post-state of given block.
630	fn state_at(
631		&self,
632		hash: Block::Hash,
633		trie_cache_context: TrieCacheContext,
634	) -> sp_blockchain::Result<Self::State>;
635
636	/// Attempts to revert the chain by `n` blocks. If `revert_finalized` is set it will attempt to
637	/// revert past any finalized block, this is unsafe and can potentially leave the node in an
638	/// inconsistent state. All blocks higher than the best block are also reverted and not counting
639	/// towards `n`.
640	///
641	/// Returns the number of blocks that were successfully reverted and the list of finalized
642	/// blocks that has been reverted.
643	fn revert(
644		&self,
645		n: NumberFor<Block>,
646		revert_finalized: bool,
647	) -> sp_blockchain::Result<(NumberFor<Block>, HashSet<Block::Hash>)>;
648
649	/// Discard non-best, unfinalized leaf block.
650	fn remove_leaf_block(&self, hash: Block::Hash) -> sp_blockchain::Result<()>;
651
652	/// Insert auxiliary data into key-value store.
653	fn insert_aux<
654		'a,
655		'b: 'a,
656		'c: 'a,
657		I: IntoIterator<Item = &'a (&'c [u8], &'c [u8])>,
658		D: IntoIterator<Item = &'a &'b [u8]>,
659	>(
660		&self,
661		insert: I,
662		delete: D,
663	) -> sp_blockchain::Result<()> {
664		AuxStore::insert_aux(self, insert, delete)
665	}
666	/// Query auxiliary data from key-value store.
667	fn get_aux(&self, key: &[u8]) -> sp_blockchain::Result<Option<Vec<u8>>> {
668		AuxStore::get_aux(self, key)
669	}
670
671	/// Gain access to the import lock around this backend.
672	///
673	/// _Note_ Backend isn't expected to acquire the lock by itself ever. Rather
674	/// the using components should acquire and hold the lock whenever they do
675	/// something that the import of a block would interfere with, e.g. importing
676	/// a new block or calculating the best head.
677	fn get_import_lock(&self) -> &RwLock<()>;
678
679	/// Tells whether the backend requires full-sync mode.
680	fn requires_full_sync(&self) -> bool;
681}
682
683/// Mark for all Backend implementations, that are making use of state data, stored locally.
684pub trait LocalBackend<Block: BlockT>: Backend<Block> {}