gear icon indicating copy to clipboard operation
gear copied to clipboard

parallel smart contracts execution

Open grishasobol opened this issue 4 years ago • 0 comments

Problem to Solve

Implement smart contracts multithread execution.

Possible Solution

As I can see we must use substrate crate sp-tasks to run smart contracts in different threads. Actually, I think that gear_core_processor::process in process queue can be parallelised. Sometimes there can be a demand to get data from storage during gear_core_processor::process execution (lazy-pages as example). Because storage externalities are thread local in substrate, we cannot get storage data directly inside process. But we can get it sending data between main thread which has access to storage and contracts process threads.

A variant of architecture:

 | main thread in process queue
 |_________________________________
 |                                 | thread which works as thread pool
 |                                 |
 | main thread now listen for storage data requests
 |                                 |__________________________
 |                                 |                       / | \  pool thread generates many threads for smart contracts execution
 |                                 |                      /  |  \ 

Notes

No response

grishasobol avatar Mar 25 '22 17:03 grishasobol