Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

In block in memory storage #12415

Closed
xlc opened this issue Oct 4, 2022 · 2 comments
Closed

In block in memory storage #12415

xlc opened this issue Oct 4, 2022 · 2 comments

Comments

@xlc
Copy link
Contributor

xlc commented Oct 4, 2022

We don't really have a block scoped temporary variable solution currently. We are currently just use storage for that and kill them at on_finalize hook to ensure they are never persisted. However this is just a workaround and could be improved to reduce overhead of enocde/decode/hash/overlay work.

This isn't as simple as an unsafe static global variable as we are exiting wasm context during block production phase and hence in wasm memory global variable can't be persisted. A quick solution is add new host function to store the in memory data on the host side with a stack so it is possible to pop the data if block producer decided to discard a bad tx. A later optimization could make this purely in wasm memory call during block evaluation / import phase to completely eliminate the overhead of host call and potentially encode/decode work.

This makes it possible to build an in memory trie builder to build a more efficient event system paritytech/polkadot-sdk#278

@bkchr
Copy link
Member

bkchr commented Oct 4, 2022

Probably the same as: paritytech/polkadot-sdk#359 ?

@xlc
Copy link
Contributor Author

xlc commented Oct 4, 2022

Right. I knew it exists but wasn't use the right keyword when searching. Now we just need to actually have it implemented.

@xlc xlc closed this as completed Oct 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants