Presenting Aspect Programming Whitepaper
Nov 22, 2023
Technical
In conjunction with the recent announcement of our open source devnet, the Artela would like to present V1 of our Aspect Programming Whitepaper. This whitepaper outlines our core ideas beyond the Artela network, based on several years of large-scale blockchain architecture engineering.
Over the past few months, the Artela team has been working hard on implementing the Aspect Programming framework and developing the core modules of the Artela blockchain. The moment has arrived to experience the magic of Aspect. Join us in contributing your innovative ideas by creating a pull request and becoming the very first contributors!
Aspect Programming Whitepaper Overview
Abstract
Aspect Programming is a programming model for the Artela blockchain that enables native extensions (Aspects) on the blockchain. An Aspect is a programmable extension used to dynamically integrate additional custom functionality onto a blockchain at runtime; this works in conjunction with smart contracts to enhance on-chain functionality. The distinguishing feature of an Aspect is the ability to access system-level APIs of the base layer and perform designated actions at join points throughout the transaction’s life cycle. Smart contracts can bind specified Aspects to activate additional functionality. When a transaction invokes smart contracts on a blockchain with Aspects, it interacts with the associated Aspects as well. With Aspect Programming, developers can implement basic logic in smart contracts and extend additional features to build feature-rich dApps beyond the capabilities of EVM.
Extensibility of Blockchain
EVM is a widely adopted execution environment for smart contracts (you probably already know this if you’re reading this), used across numerous blockchains. While EVM is designed to be Turing-complete, blockchains relying on the EVM face challenges in supporting complex dApps with advanced functionality:
Limited functionality of smart contracts. EVM programs are restricted from using loops and must terminate within a specified number of steps. Developers have to minimize computation steps to avoid exceeding gas limits.
Limited extensibility of EVM. The precompiled smart contract is prohibited from being built at the user level, and its ownership is controlled by the platform.
Limited customization of transaction process. The transaction process is static pre-configured and cannot be customized.
Solution to These Limitations
Aspects are unique in both form and function as compared to legacy methods to improve core function on blockchains. Some of these unique features include:
Blockchain-Native: Native extensions are programs that run entirely on-chain, executed deterministically by all validators in the network.
Dynamic: Different from precompiled contracts, native extensions are dynamic programs that can be deployed onto the blockchain at runtime.
Permissionless: Users can define and deploy their own programs. The blockchain acts solely as the execution environment, without any restrictions or permissions imposed by a centralized authority.
Localized Activated: Smart contracts activate native extensions locally, ensuring their effects occur within the local scope rather than the global scope.
Generic: Native extensions provide access to the entire blockchain state and runtime context, allowing developers to customize outside EVM and participate in controlling the transaction lifecycle to realize generic and versatile customization.
With native extensions, users can independently introduce system-level functionality to their dApp. These native extensions seamlessly collaborate with smart contracts, enhancing the overall functionality and potential of the dApp ecosystem.
Aspect Programming Overview
The core principle of the Aspect Programming framework is the Join Point Model (JPM), which comprises three key components:
Join Point. This specifies where the Aspect can run. A join point represents a specific point in the transaction and block processing flow. It acts as a hook, allowing additional functional logic to be added at these points.
Aspect. This specifies the code to run on the join points. Aspects can access the runtime context and make system calls, enabling participation in transaction lifecycle management.
Binding. This specifies when the Aspect can run. Smart contract owners can bind Aspects to specific join points with their smart contracts. The bound Aspects are triggered when transaction processing steps reach these join points.
The Join Point serves as the hook point at the blockchain level, and allow users to infuse customized logic. Users can access specific contexts within each Join Point and employ system APIs to establish customized functionalities.
An example of how Aspects work:
This Aspect monitors and verifies any deposit changes in the vault. It is triggered after the smart contract execution. If an unexpected fund flow occurs during runtime, the Aspect will revert the suspicious transaction.
How Aspects work:
Aspects are implemented with Assembly Script and compiled into WebAssembly (WASM) byte code.
Process deployment transaction of Aspects: include Aspect byte code in a deployment transaction and dispatched to the blockchain’s world state.
Process binding transaction between Aspect and smart contract: smart contract owner signs a binding transaction using the same externally owned account (EOA) that facilitates the deployment of the smart contract. This binds Aspects to their smart contract.
The Aspect runtime retrieves the Aspect’s byte code and loads it into a WASM runtime environment. The runtime invokes entry functions of Aspect.
Layout of Join Points
Various Join Points are defined throughout the lifecycle of blocks and transactions. These enable Aspect developers to implement substantial customizations for dApps.
Aspect-Boost
The first implementation of the Aspect Programming framework on Artela is known as “Aspect-Boost”. This is a framework for any kind of blockchain or modular execution layer to integrate and enable the first features of Aspect Programming. For more info on Aspect-Boost, please refer to the full version whitepaper.
New World with Aspect
Smart Contract Runtime Protection: Aspects can achieve real-time runtime protection in a black box, enhance the execution layer, and eliminate reentrancy attacks.
Intent Solver On-Chain: Aspects can empowers the on-chain functionality for intent-centric protocols. This enables users to add customized on-chain intent processing logic and build dApps in a modular manner.
Just-in-time (JIT) Operation: Aspects empowers users to execute on-chain logic concurrently with smart contracts within a single atomic transaction. This facilitates on-chain JIT operations, including JIT liquidation, JIT LP management, and capturing MEV in AMM.
Event-Driven Action: This allows users to subscribe to specific, real-time, on-chain events (including token transfers, state changes, transaction completions, etc.) that trigger another event. This tool can also be utilized for atomic asynchronous cross-chain message notifications, and maintaining consistency between on-chain and off-chain states.
On-Chain MicroService: Users can leverage Aspects to create public on-chain services on blockchain networks, fostering collective maintenance and governance by diverse users and organizations.
Fully On-Chain Game: Aspects empowers users to enhance the programmability of game equipment NFTs by integrating Aspect, providing a more versatile user experience.
Aspects introduce a built-in “Feature Layer” for the blockchain networks, enabling the extension of native capabilities from the base layer by any smart contract. Through Aspect Programming, users can implement the program’s core features on smart contracts, and incorporate additional customized functionality through modules (aspects) — blockchain level customization within an interoperable, boundless, blockchain network.
Conclusion
In summary, our efforts to enhance blockchain extensibility encompass the following key initiatives:
Design a novel programming model to enable native extensions within the blockchain
Implement a framework that aligns with this programming model
Apply Aspect Programming framework to the Artela blockchain to build a boundless network that empowers developers to tailor application-specific extensions for their dApps
Make the framework adaptable for integration into various blockchains to enhance their extensibility
In the immediate future, our focus will be on refining the framework’s implementation to address the unique challenges presented by the Artela blockchain’s rich dApps ecosystem. We will also explore the creation of public, universal Aspects, that dApps can readily leverage on the Artela blockchain.
In subsequent phases, we will be focused on further enhancing Aspect-Boost’s versatility, and enabling its integration into other blockchain ecosystems. We have plans to develop a novel Aspect variant that supports heterogeneous computing, which will unlocking a broader spectrum of programming models for blockchain innovation.
Follow us to Learn More
To explore the technical details of Aspect Programming, you can access the complete whitepaper by downloading it here. Build your first Aspect, play around with our DevNet, and don’t hesitate to reach out for support or offer feedback on our Discord. Stay up-to-date with the latest developments on our project, including the open-source progress of our Github, by following us on Twitter. Join our community. We’re excited to hear how Aspect Programming can enhance what you build next.