Deterministic parallel execution of applications

in #eos4 years ago

Blockchain consensus depends on deterministic (reproducible) behavior. This means that all concurrent executions cannot use mutexes or other locking primitives. If there is no lock, there must be some way to ensure that concurrently executing accounts will not produce non-deterministic results.

The EOS.IO software released in June 2018 is single-threaded, but it also contains data structures for multi-threaded concurrent execution that will be required in the future.

In the EOS.IO software-based blockchain, once concurrent operations are performed, the block generator needs to pass the message to an independent thread for concurrent evaluation, but the process of generating the plan does not need to be determined. This means that block generators can use concurrent algorithms to arrange transactions.

Concurrent execution also means that when the script generates a new message, it will not be sent immediately, but in the next cycle. The reason for the inability to send immediately is that the receiver may actively modify its own state in another thread.

5.1 Minimize communication delay

Latency is the time it takes for one account to send a message to another account and receive a response. The goal of EOS.IO is to enable two accounts to exchange messages back and forth within a single block without having to wait 0.5 seconds between each message. In order to achieve this, the EOS.IO software divides each block into cycles. Each cycle is divided into threads, and each thread contains a list of transactions. Each transaction contains a set of messages to be delivered. This structure can be visualized as a tree structure, where each layer is processed concurrently in sequence.