Skip to content

Parallel Execution of Transactions #152

Description

@ajlopez

Description

This improvement proposals specifies a way to run transactions IN A BLOCK in parallel. To do so, the transactions in a block should be distributed in one more than one lists of transactions. To know these lists, two approaches are proposed:

  • The block builder informs the lists, having executed the transactions in a sequential way, and knowing the data they read/write
  • The block executor make a guess, and then, if the execution of transactions results in the incompatibility of parallelization, back to normal sequential execution.

Notably, this proposal could be implemented without using any internal information about token contracts or other specific information from transactions. In some way, it is transaction agnostic.

And many of these improvements could be implemented as a soft fork.

Notation

Ta, Tb: Different transactions (different lower case letter)
Ta < Tb: The first transactions is before than the second one in the block
Ta << Tb: Tb SHOULD be executed AFTER Ta
Ta || Tb: Tb COULD be executed in parallel with Ta
Ta <> Tb: Ta CANNOT be executed in parallel with Tb

Data

A datum can be read or write/change during the execution of transaction. Account balance, storage cell are examples of datum.

Some facts

If Ta and Tb have the same sender, and Ta nonce is less than Tb nonce, then Ta << Tb
If Ta reads datum X and Tb writes datum X, then Ta <> Tb
If Ta writes datum X and Tb writes datum X, then Ta <> Tb
If Ta does not invoke a contract, and Ta sender != Tb sender, then Ta || Tb
If not (Ta << Tb) AND not (Ta <> Tb) then Ta || Tb

These relations could be discovered during the sequencial execution of transactions during the block building process in miners. Then, the miner, given the data used by each transaction and any read/write conflict, could divide the transactions in many lists of transactions, that could be run in parallel. Such sublists could be informed inside the block, ie: additional data in the Remasc transaction. The rest of the nodes, could read such extra information and execute the block in parallel, then the state root at the end is the same than the state root obtained from sequential full execution of the block. The nodes that not have implemented this parallel execution approach, still could verify the block using sequential execution.

The other solution is: the block is unchanged, but each execution node could make a guess about the grouping of transactions, without executing them. During the execution, they could check if two parallelized transactions Ta Tb broke the above condition about read/write the same datum. In such case, the execution node back to sequential execution.

The first solution (mining added clue), could be improved with a reward for the miner that adds that information. Except for this reward, all the above algorithm and both solutions could be implemented as a soft fork.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions