Overview

The Solidity Gateway to Arcology Concurrency Control

Arcology features a fully parallelized execution engine. To fully leverage this powerful design, developers must eliminate contention points in their contracts that cause conflicts and reversion. However, Solidity, the programming language used for Ethereum smart contracts, lacks the features necessary to achieve this. This is where the concurrent library comes into play.

Concurrent Library

Arcology offers a suite of Solidity methods customized for concurrent programming tasks in Solidity. The tools and data structures in the suite are the doorways to fully harness the power of Arcology Network's parallel execution design.

All Arcology's concurrent tools are not only thread-safe but also always deterministic by design. This means that the behavior and outcomes of operations on these data structures are guaranteed to be predictable and consistent, regardless of the order or timing of concurrent state accesses.

Note: The packages in the guide are not meant for production deployment but rather experimental for now. Developers are encouraged to explore and learn from the code while emphasizing collaboration and feedback to improve the platform.

What Are in the Suite

In parallel programming, the key is to eliminate shared variables and data structures, enabling maximum parallelism. The suite is designed with this concept in mind, providing the following components:

Concurrent Data Structures

Arcology's concurrent data structures can be considered a form of blockchain-specific Conflict-Free Replicated Data Types (CRDTs) designed to enable efficient and conflict-free updates.

  • Concurrent Arrays: Merging thread-safe design with determinism to facilitate efficient parallel processing in multi-threaded environments. Resembling a conventional array, it permits concurrent push-back operations to the container and supports random reads, as long as they don't target the same elements.

  • Concurrent Maps: Data structures combining the function of standard maps and arrays. A concurrent map differentiates itself from native mapping by providing the ability to iterate its keys and values deterministically.

  • Cumulative Variables: A commutative variable can receive concurrent delta updates from multiple transactions, and the final result consistently remains the same, irrespective of the order in which the updates are processed.

  • Custom Data structures: In addition, users can build the concurrent data structures of their choice based on the built-in ones provided by Arcology.

Tools

  • Multiprocessing: multiprocessing feature enables developers to write code to start subprocesses to handle multiple tasks, similar to using multiple threads in general-purpose languages.

  • Runtime: The package provides runtime information to developers, enabling Arcology to execute their transitions more effectively.

Installation

npm install @arcologynetwork/concurrentlib

Usage

Once installed, you can use the library by importing them in your contracts:

pragma solidity >=0.8.0 <0.9.0;

import "@arcologynetwork/concurrentlib/lib/commutative/U256Cum.sol";
import "@arcologynetwork/concurrentlib/lib/map/AddressUint256.sol";

contract MyToken {
    bool                             public  stopped;
    U256Cumulative                   public  totalSupply;
    AddressUint256Map                public  balanceOf = new AddressUint256Map();
}

Contribution

Please feel free to contact us if you would like to contribute your own examples.

Last updated