Overview

The Solidity Gateway to Arcology Concurrency Control

Solidity, the programming language used to develop smart contracts on the Ethereum platform, isn't designed for concurrent use. It does not include the features and capabilities necessary for efficient concurrent programming.

Why This

Arcology features a fully parallelized execution engine. However, contracts designed with a sequential philosophy may not automatically benefit from the power of parallel execution. To fully leverage this design, developers need a way to access and control concurrency features within native Solidity. This is where the Concurrent Library comes into play.

Concurrent Library

Arcology offers a suite of Solidity APIs 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.

Compatibility

The provided APIs can be seen as an extension to the original language features of Solidity. Arcology supports 100% of native Solidity, and the reverse is also true, as long as the contracts do not include any Arcology-specific features.

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