Replies: 2 comments 10 replies
-
Cool idea! Always good to get these new discussions and I like exploring new innovations. A couple of questions for you:
What you have is great and I think more diagrams addressing the granularity of everything this touches will help drive this from an engineering perspective if they are to implement it. |
Beta Was this translation helpful? Give feedback.
-
Sei Network employs a much simpler incentive for correctly specifying dependencies i.e. a 50% discount on the gas price. So if all specified dependencies are used then a 50% discount is applied to the tx, however, if at least one incorrect(i.e. unused) dependency is specified then no discount is provided. |
Beta Was this translation helpful? Give feedback.
-
Background
EIP-648 proposes a simple and optional mechanism for enabling the EVM to process transactions in parallel[1]. As of now, the EIP has not been implemented on Ethereum or any other EVM chain except potentially BSC, which has publicly disclosed its efforts in parallel transaction execution(however may have taken their own approach)[5]. However, multiple non-EVM chains such as Solana, Aptos, and Sui have implemented parallel transaction execution to increase the throughput of their smart contract services significantly. Both Sui and Solana enable this using an implementation similar to that proposed in EIP-648, i.e., either optional or mandatory specification of read and write access lists to state by a transaction[2][4]. On the other hand, Aptos uses a more novel mechanism called Block-STM that enables it to process 160k non-trivial Move transactions per second[3].
Proposal
This discussion proposes the implementation of parallel transaction execution for the Hedera Smart Contract Service (HSCS) in a manner similar to that proposed in EIP-648. However, unlike EIP-648, which uses RLP lists to determine the ranges of addresses a transaction can access to read and/or write, we propose specifying the exact Hedera entity ids/addresses (either account/contract/token ids). Since Hedera entity ids are not distributed pseudorandomly across the address/id space like Ethereum addresses, using RLP lists as EIP-648 proposes would not be practical, as all entity ids would fall into a single range. Therefore, specifying the entity id in the read and write dependency lists allows for transactions that share at least one entity dependency to be assigned to the same thread. Note as EIP-648 proposes this would be done on a per block level; see the Client Implementation algorithm in EIP-648.
To incentivize and disincentivize correct and incorrect entity ids in the read and write dependency lists, a reward and penalty mechanism is proposed. A correct entity id is an entity id that is indeed called in a given transaction's execution, and an incorrect entity id is an entity that is never called. A penalty gas is charged preemptively for each entity specified in the dependency lists, and for every entity that is called correctly, gas is awarded that is either equal to the penalty (in which case, it is an exact refund for the penalty charged) or slightly more to incentivize developers to specify correct entity dependencies. This allows for transactions to be optimally assigned to threads for parallel transaction execution, resulting in increased throughput, as opposed to developers simply not specifying dependency lists. Additionally, the mirror node can expose an endpoint to determine contracts that are invoked in the static execution of a transaction if the exact read&write lists of entity dependencies are not known in advance; similar reasoning for static
eth_call
oreth_estimateGas
.If a transaction calls the HTS precompile (0x167) to read and/or write from/to state, then instead of specifying the precompile address in the read and/or write entity dependency lists, the Hedera entity addresses that are being read and/or updated via the precompile contract can be specified. Since the HTS precompile contract is frequently called by many smart contracts, it makes more sense to specify the upstream entities that are being read from or written to, in order to enable parallelization across transactions that all call the HTS precompile contract but are not reading from or writing to the same entity.
Parallelization of such transactions that call the HTS precompile can be further optimised by considering dependency in HTS actions between transactions, though this will require explicit specification of the type of action and its entity dependencies. For example(Example 1), if Alice signs 2 contract calls to separate contracts within the same "block" that do a Fungible HTS transfer from her account to Bob's account but on 2 separate HTS tokens, then these 2 transactions can be executed in parallel. Or in another example(Example 2), if Alice signs a contract call to contract X that transfers TokenA to Bob and Carol signs a contract call to contract Y that also transfers TokenA but to Dave, then both Alice's and Carol's transactions can be executed in parallel.
Example 1 Write Dependency List:
Alice's 1st transaction's write dependency list:
Alice's 2nd transaction's write dependency list:
Example 2 Write Dependency List:
Alice's transaction's write dependency list:
Carol's transaction's write dependency list:
Potential Issues
Alternative Considerations
References
[1] Easy parallelizability (EIP-648)
[2] Sealevel — Parallel Processing Thousands of Smart Contracts
[3] Block-STM: How We Execute Over 160k Transactions Per Second on the Aptos Blockchain
[4] How Sui Works
[5] BNB Chain New Milestone: The Implementation of Parallel EVM 2.0
[6] Monad Block-STM Parallel Execution
Beta Was this translation helpful? Give feedback.
All reactions