Replies: 3 comments 4 replies
-
We never proposed speculative execution in #1459 really. We proposed state access unification rules that operated upon fairly explicit subblocks, which the host optionally runs in multiple threads. We both proposed that PVFs could spawn some worker threads with separate state access caches, but we only give them synchronization primitives that provably enforce determinism (Jeff) or were restricted to closely audited code (Gav). We'd structure blocks into subblocks that ran in these separate threads, meaning the PVF would create threads by invoking a subblock entry point, so subblocks would be our annotations. It's fairly clear that solana's per tx annotation are a memory model that enforce consistency in synchronization, but imho solana's per tx annotations sound less efficient and less flexible than simply structuring the tx into subblocks. Also, there exists a third proposal where all tx read state from before their thread was spawned, or from their own write cache, meaning earlier tx cannot modify the behavior of later tx in the same block. It's incompatible with "smart contract" chains, but increasingly we realize "smart contracts" make little sense. In this vein, there exist lovely designs in which different aspects of the same tx run in different threads, which becomes far more efficient, and incredible unfriendly to smart contracts. |
Beta Was this translation helpful? Give feedback.
-
We'd do the synchronization work in the block producer, so smart contract authors never see those parts. At an architectural level, we must enforce determinism in substrate's host, but transactions only exist in the runtime, making roughly #1459 essential for any proposal. Afaik any sane solution also annotates which tx, from which the runtime figures out what tx run in which thread, but I'm also suggesting these annotations look like parallel subblocks, not metadata on individual tx. |
Beta Was this translation helpful? Give feedback.
-
If I'm reading code correctly, this might be implemented in two ways without modifying Substrate itself:
1) seems like a proper solution and 2) as a hack, but at the same time having full support from both Polkadot.js apps and API is HUGE. Thoughts? |
Beta Was this translation helpful? Give feedback.
-
I'd like to start a follow-up discussion to https://github.com/paritytech/ink/discussions/1101 with a narrower goal of having support for parallel transaction execution in Substrate. Not necessarily parallel transaction execution itself, but means to achieve it at least.
I understand that Polkadot went with parallelization (effectively) using parachains, but the general concept is still useful and applicable even there.
I'm curious what community thinks about this and seeking for help in establishing more concrete set of implementation tasks that would make something like this possible.
Likely related issues:
Specifically I want to propose an idea that doesn't require complex memory models described in #1459.
Background
If the goal is to have many transactions to run in parallel, the primary thing needed to guarantee that they will not touch state that may result in conflicts. Solana requires transaction to specify state of which account it will touch (read and writes can be specified explicitly). Thus during transaction execution it is possible to run non-conflicting transactions concurrently without any chance of conflicts, no need to do complex analysis or resort to speculative execution [one] [two].
Proposal
For that to become possible in Substrate a few things are necessary (as far as my knowledge allows to describe them right now):
Usefulness
This is a limited and specific notion of parallel transaction execution, but it is very useful nevertheless. Think about balance transfer between Alice and Bob. If the total supply of coin doesn't change, their transfer just means editing two number and there is no reason for Dave and Charlie to be unable to do a similar balance transfer at the same time.
Beta Was this translation helpful? Give feedback.
All reactions