-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Set StateBackend::Transaction to PrefixedMemoryDB
#14612
Set StateBackend::Transaction to PrefixedMemoryDB
#14612
Conversation
…e-transaction-cache
| } | ||
| } | ||
|
|
||
| impl<H: Hasher> Clone for OverlayedChanges<H> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't this be derived?
davxy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome cleanup
| /// [`child_storage_changes`](StorageChanges::child_storage_changes). | ||
| /// [`offchain_storage_changes`](StorageChanges::offchain_storage_changes). | ||
| pub transaction: Transaction, | ||
| pub transaction: PrefixedMemoryDB<H>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit. Replace PrefixedMemoryDB<H> in the overall file with the alias BackendTransaction<H> (import crate::backend::BackendTransaction).
I know it's just an alias, but for sure is more explicit about the usage intent
| /// These transactions can be reused for importing the block into the | ||
| /// storage. So, we cache them to not require a recomputation of those transactions. | ||
| pub struct StorageTransactionCache<Transaction, H: Hasher> { | ||
| pub struct StorageTransactionCache<H: Hasher> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| pub struct StorageTransactionCache<H: Hasher> { | |
| struct StorageTransactionCache<H: Hasher> { |
If only used here maybe we can keep it private?
|
|
||
| /// Trie backend with in-memory storage. | ||
| pub type InMemoryBackend<H> = TrieBackend<MemoryDB<H>, H>; | ||
| pub type InMemoryBackend<H> = TrieBackend<PrefixedMemoryDB<H>, H>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really related to this PR, but since there is some overhaul in progress...
Can't we define the InMemoryBackend in in_memory_backend.rs (maybe as a newtype) and replace the function new_in_mem with a new constructor in the impl block for that newtype?
Co-authored-by: Davide Galassi <davxy@datawok.net>
…e-transaction-cache
|
bot merge |
* Companion for Substrate#14612 paritytech/substrate#14612 * Remove patch * Cargo.lock * Fix * Fix compilation * Fix Fix * ... * :face_palm: * ................. * update lockfile for {"polkadot", "substrate"} * ".git/.scripts/commands/fmt/fmt.sh" --------- Co-authored-by: parity-processbot <>
* Yep * Try to get it working everywhere * Make `from_raw_storage` start with an empty db * More fixes! * Make everything compile * Fix `child_storage_root` * Fix after merge * Cleanups * Update primitives/state-machine/src/overlayed_changes/mod.rs Co-authored-by: Davide Galassi <davxy@datawok.net> * Review comments * Fix issues * Silence warning * FMT * Clippy --------- Co-authored-by: Davide Galassi <davxy@datawok.net>
The main change this pull request doing is the removal of
Transactionassociated type fromsp_state_machine::Backend. The transaction is then fixed toPrefixedMemoryDB. BasicallyPrefixedMemoryDBwas always the transaction type being used in Substrate. This removes a lot of generics which simplifies the code in a lot of places. Another important change this pull request is doing is to move the so called "storage transaction cache" into theOverlayedChanges. There is no real need to have this cache out of theOverlayedChangesand thus, we can also simplify some things here and there.This is works towards: paritytech/polkadot-sdk#27
Downstream Code changes
TransactionFororStateBackend::Transactionwas used in where bounds or similar can just be removed to make the code compile again.BlockImportParamswas also changed to only take one generic argument, the block type and not anymore the transaction type as the second generic parameter.DefaultImportQueueis also only taking one generic argument after this pr, the block type.polkadot companion: paritytech/polkadot#7536
cumulus companion: paritytech/cumulus#2923