DsToken

Case overview

ERC-20 is the most popular token standard on Ethereum platform. Numerous numbers of ERC-20 cryptocurrencies have launched on Ethereum. The ds-token a simple and sufficient implementation of ERO-20 standard under GPL-3.0 License and the source code can be found here  https://github.com/dapphub/ds-token.

It is also complex enough to cover some of challenges developers may face in their daily work when considering possible code parallelization. The main purpose of the this ERC20 showcase is to demonstrate how our concurrency framework takes one step further to help handle large volumes of concurrent user calls to the same contract.

The Brief

Like other smart contracts, ERC-20 tokens can significantly benefit from Arcology’s concurrency framework. We replace some data structures with our concurrent containers while keeping internal logic unchanged. 

The key to the effective parallelization is to avoid conflicts wherever possible. Conflicts happen when some shared states are accessed by multiple transactions simultaneously. Thus, we substituted the majority of global variables with local ones. We also used the deferred functions to handle the ones that couldn’t be easily replaced. Please check out the concurrent programming guide for details.

Our Approach

The key to the effective parallelization is to avoid contention wherever possible. Conflicts happen when some shared states are accessed by multiple transactions simultaneously. We made the minor modifications to the original implementation with tools available in our concurrency library to make parallelization possible. In general, we substituted the majority of global variables with local ones. We also used a deferred function to handle the ones that couldn’t be easily replaced. Please check out the concurrent programming guide for details.

  • Saved the ‘mint’ to a concurrent array.
  • Saved the ‘burn’ to a concurrent array.
  • Moved totalSupply calculation to a deferred function

The Results

The new implementation allows parallel processing of concurrent calls to the same contract/interface. Given enough resources, the system can process all the transactions simultaneously without causing any conflict of rollback at all.

1%

Changes to the code logic

100%

User experience preserved

1,000x

Faster on Arcology than on Ethereum

Similar cases