Atomic Composability#
DeFi is so powerful because open-source dApps can be reused, modified and plugged into existing dApps to access existing functionality and network effect – adding value to the ecosystem as a whole. Certain applications, including those that use flash loans or involve instant arbitrage, require atomic composability: the property whereby all relevant transactions are executed successfully, or else none are. Certain scaling solutions – including some forms of sharding and L2 platforms – can introduce friction and complexity, meaning that atomic composability does not work reliably or at all.
The challenge for blockchain is not just to scale, but to maintain atomic composability at scale. Ergo is not currently seeking to scale by implementing untested technologies for now. Instead, it aims to use the ‘headroom’ that is still available for conventional blockchain platforms by using resources more intelligently.
Scaling solutions often involve dividing the platform into subsections, such as shards (in sharding) or creating a new layer (Layer 2) to scale the base layer (Layer 1). When implemented incorrectly, these solutions can hinder the seamless interaction between assets and applications residing in different parts of the platform.
Atomic composability in Ergo is achieved through a combination of the eUTXO model, ErgoScript, Layer 2 solutions, and other proposed techniques. This allows for complex operations to be executed atomically, meaning that either all parts of a transaction succeed or the entire transaction fails. This ensures that the integrity of the operations is maintained and enhances the overall functionality of the platform.
- eUTXO Model and ErgoScript: The eUTXO model, along with the ErgoScript smart contract language, ensures that complex, multi-stage transactions can be executed atomically within a single transaction. By design, multistage protocols ensure that either all parts of a transaction are executed or none are, which is the core principle of atomic composability. This allows users to create and execute intricate smart contracts with confidence in their outcomes, while maintaining the advantages of the UTXO model, such as statelessness, better parallelism, and less error-prone data handling.
- eUTXO: Additionally, UTXO provides superior scalability, as parallel transaction processing is more straightforward in UTXO. The use of UTXOs allows for better scaling and less error-proneness, while also allowing for persistent storage and shared global context through multi-stage protocols.
- Hydra State Channels: Atomic composability is also supported by Layer 2 solutions like Hydra state channels. Cross-head communication in Hydra enables atomic composability across different heads, allowing complex operations to be executed atomically even when involving multiple state channel participants.
- ACE (Asynchronous and Concurrent Execution of Complex Smart Contracts): ideas like ACE could be implemented to further enhance Ergo's ability to execute complex, composable smart contracts. ACE proposes a mechanism to break down smart contracts into smaller, concurrent tasks that can be executed independently, improving the blockchain's overall performance and throughput. One of the key advantages of ACE is that it allows one contract to safely call another contract executed by a different set of service providers. This feature enables off-chain execution of interactive smart contracts with flexible trust assumptions and enhances atomic composability between smart contracts in the system.
Ergo's innovative architecture and diverse set of solutions offer a comprehensive approach to addressing scalability while preserving atomic composability. Ergo's use of the eUTXO model, ErgoScript, sharding, and Layer 2 solutions allow for composable smart contracts and complex transaction structures while maintaining high transaction throughput and network efficiency. As such, Ergo effectively addresses the scalability challenges that have hindered other blockchain platforms without compromising atomic composability, providing a solid foundation for the development of decentralized applications and the future of blockchain technology.
Sharding#
Sharding is a technique that divides a blockchain network into smaller partitions called shards. Each shard processes a subset of transactions independently, thus improving scalability. However, maintaining atomic composability, which ensures that either all parts of a multi-step transaction are executed or none are, can be challenging in a sharded environment.
Here are some potential ways to maintain atomic composability when sharding:
- Cross-shard transactions: Implement a mechanism for cross-shard transactions that enables secure and efficient communication between shards. This mechanism should ensure that all parts of a multi-step transaction are either committed or rolled back, even if they span multiple shards.
- Locking mechanisms: Introduce locking mechanisms to prevent double-spending or other forms of fraud during cross-shard transactions. Locking the involved assets temporarily until the transaction is complete will help maintain atomic composability.
- Two-phase commit protocols: Leverage two-phase commit protocols to coordinate cross-shard transactions. In the first phase, shards involved in a transaction tentatively execute it and lock the relevant assets. In the second phase, once all shards confirm the transaction, it is committed, and the locked assets are released. If any shard fails to confirm, the transaction is rolled back, and the locked assets are released.
- Optimistic execution: Allow shards to optimistically execute transactions while assuming that dependencies between shards have been resolved correctly. If a conflict is detected later, the transaction can be rolled back, and the network can learn from the conflict to prevent similar issues in the future.
- State channels or sidechains: Use state channels or sidechains to process transactions off-chain, and then settle the final state back on the main chain. These off-chain solutions can help maintain atomic composability by allowing users to perform complex, multi-step transactions without involving multiple shards directly.
These are just general strategies that could be employed to maintain atomic composability in a sharded blockchain environment. The specific implementation would depend on the requirements and design of dApps yet to emerge.