Uniswap v4 is just announced. Although it's not fully built out yet, we expect the community to widely explore the boundary of newly enabled possibilities. Since there might be a ton of articles explaining how powerful v4 is on the defi side of things, I would like to address how Uniswap v4 can inspire a new category of blockchain infrastructure: coprocessors.
As described in the whitepaper , v4 contains mainly 4 improvements:
Most gas savings will certainly come out of the last 3 improvements, but certainly the most exciting new feature brought in is by the first mentioned new shiny bits: the hooks.
Uniswap v4's primary enhancement revolves around the programmability unlocked by hooks. This feature introduces a new level of complexity and power to liquidity pools, allowing them to be more flexible and customizable than ever before. In comparison to v3's concentrated liquidity, which was a net upgrade from v2, v4's hooks provide a wider spectrum of possibilities for how liquidity pools can behave.
This can be viewed as a net upgrade from v3, but it might not be when it comes to actual implementation. Uniswap v3 pools will always be an upgrade comparing to v2 pools, since the "worst" upgrade you can do in v3 is to "concentrate" the liquidity across the entire price range, which works the same as in v2. In v4, however, liquidity pools can be programmed to an extent that might not result in a good trading or liquidity providing experience. Bugs can occur and there will be new attack vectors. Due to the wider array of changes to the liquidity pool's behavior, developers wishing to utilize the hook feature must exercise caution. They need to thoroughly understand the implications of their design choices on the pool's functionality and the potential risks for liquidity providers.
The introduction of hooks in Uniswap v4 represents a significant shift in how code is executed on the blockchain. Traditionally, blockchain code is executed in a predetermined sequential manner. However, hooks allow for a more flexible execution order, ensuring that certain code is executed before other code. This feature pushes complex computations towards the edge of the stack, rather than solving them in a monolithic stack.
In essence, hooks enable more complicated computations to be performed outside of the Uniswap native contract. While this was achievable in v2 and v3 through manual computation outside of Uniswap and triggering with external activators such as other smart contracts, v4 integrates hooks directly into the liquidity pool's smart contract. This integration makes the process more transparent, verifiable, and trustless compared to the previously manual process.
Another side benefits hooks bring is extensibility. Uniswap now no longer have to rely on new smart contract (which requires liquidity migration) or forks to deploy innovations. Hooks can now make an old liquidity pool feels like a new one by directly implementing new features.
I expect more and more dapps to push computation outside of their own smart contracts, just like Uniswap v4.
What v4 is doing here is by allowing the liquidity pool executions to be broken up at any step, arbitrary conditions can be inserted and triggering computation that's outside of the v4 contract. The only similar things we have seen so far is flash loan, where the executions will be reverted if the loan is not given back within the same block. Just that the computation still happens in the flashloan contract.
Uniswap v4's design brings multiple benefits that either weren't possible or were suboptimal to implement in v3. For instance, the use of embedded oracles is now possible, reducing the reliance on external oracles that often introduce potential attack vectors. This embedded design enhances the security and reliability of price information, a critical factor in the operation of DeFi protocols.
Furthermore, automation, which previously had to be triggered externally, can now be embedded directly into the liquidity pool. This integration not only mitigates security concerns but also addresses reliability issues associated with external triggers. It provides a more seamless and efficient operation of the liquidity pool, enhancing its overall performance and user experience.
Finally, the introduction of hooks in Uniswap v4 opens up the possibility for more diverse security features to be implemented directly into the liquidity pool. In the past, the primary security measures available to liquidity pools were audits, bug bounties, and insurance purchases. With v4, developers can now design and implement a variety of fail-safes and low liquidity warnings directly into the pool's smart contract. This development not only enhances the security of the pool but also provides greater transparency and control to liquidity providers.
Compared to traditional phone, smart phones win on programability. Smart contracts has kind of lived under the shadow of "persistent scripts" for a long time. Now, thanks for the advant of v4, liquidity pool smart contracts gets a new programmable upgrade, getting "smarter". I can't imagine why not all dapps wants to upgrade in this direction given the opportunity to upgrade yourself from a Nokia into an iPhone. Since Nokia is more reliable than iPhone I can see plenty of reasons why some smart contracts would like to stay the way it is, but you get my point on where the future of Dapps is heading to.
Imagine applying this to all the other dapps, where we can insert conditions to be triggered, and then insert arbitrary computation in between the original sequence of transactions.
This sounds like how MEVworks, but MEV is not an open design space for the dapp developers. It's more like a uncertain hike into a dark forest, best they can do is to seek external MEV protection but can only hope for the best.
Assume that the flexibility of Uniswap v4 inspires a new generation of dapps (or upgrade from existing dapp) to adopt similar philosophy, where they allow their own execution sequence to be more programmable. Since these dapps are usually only deployed on one chain (an L1 or an L2), we expect most state changes are run on this chain.
Summarizing the problem: incorporating all computations into state-altering smart contract execution on one single chain is far from optimal.
To solve this problem brought by the new generation of dapps (which might be largely inspired by Uniswap v4), we have to look into the core of the problem: that 1 single chain. Blockchain works as distributed computer, with one single CPU processing everything. On a PC, modern CPU has come a long way to solve that exact problem.
Just as computers have transitioned from single-core monolithic CPUs to a modular design comprising multiple efficiency cores, performance cores, GPUs, and NPUs.
DApp computation can scale in a similar manner. By specializing processors and combine their efforts, outsourcing some computation outside of the main processor offers flexibility, optimality, security, scalability, and upgradability.
Enter coprocessors, the new kid in town of the already densely populated blockchain infrastructure stack. Coprocessors work in a very straight forward fashion: be triggered by some condition, compute on the fly, and return the result back to the main processor so the rest of the tasks can move on.
There are really only two categories of coprocessors:
External coprocessors is like a GPU on the cloud. It's nice and powerful, but you have additional internet lag between the CPU and the GPU communication. Plus you are not ultimately controlling the GPU, so you have to trust that it's doing the job right.
Using Uniswap v4 as an example, lets say some ETH and USDC were to be added to a liquidity pool at the last 5 mins TWAP. If the TWAP calculation is done in Axiom, v4 is essentially using Ethereum as the main processor and Axiom as the coprocessor.
Axiom is a ZK coprocessor for Ethereum which provides smart contracts trustless access to all on-chain data and arbitrary expressive compute over it.
Developers can make queries into Axiom and trustlessly use the ZK-verified results on-chain in their smart contracts. To fulfill queries, Axiom performs three steps:
Warp Contracts is the most popular implementation of SmartWeave, which is an architecture aimed at creating a reliable, fast, and production-ready smart contracts platform / engine on Arweave. Essentially, SmartWeave is a sequenced array of Arweave transactions that benefits from the absence of a fee market for transaction block inclusion on Arweave. These unique properties allow for unlimited transaction data without additional fees beyond storage costs.
SmartWeave utilizes a unique approach known as “lazy evaluation,” which transfers the responsibility of executing smart contract code from network nodes to the users of the smart contract. In essence, this means that the computation of transaction validation is deferred until it is required, reducing the workload on network nodes and allowing for more efficient processing of transactions. This approach enables users to execute as much computation as needed without incurring additional fees, offering functionalities that are not feasible with other smart contract systems. Obviously attempting to evaluate contracts with thousands of interactions on a user’s CPU would be a futile exercise. To overcome this challenge, an abstraction layer, such as Warp’s DRE, has been developed. It comprises a network of distributed validators that handle contract computations, leading to significant improvements in response-time and user experience.
Furthermore, the open-ended design of SmartWeave enables developers to write the logic in any programming language, offering a refreshing alternative to the often rigid Solidity codebase. By delegating certain high-cost or high-throughput actions to Warp, existing social graph protocols built on EVM chains can be enhanced with seamless SmartWeave integration, leveraging the strengths of both technologies.
Hyper Oracle is a network of zkOracles designed for blockchains. At present, the zkOracle network operates solely for the Ethereum blockchain. It retrieves the data from every block of the blockchain as a data source with zkPoS and processes the data using programmable zkGraphs that run on zkWASM, all in a trustless and secure manner.
Developers can define custom off-chain computations with JavaScript, deploy those computations to Hyper Oracle network, and utilize Hyper Oracle Meta Apps to index and automate their smart contracts.
Hyper Oracle's indexing and automation Meta Apps are fully customizable and flexible. Any computation can be defined and all computations will be secured by a generated zk proof, eveb machine learning computation.
There are also a few projects that can be used as an external coprocessor if you decided to use them in that way. It's just that they have overlapping positioning in other verticals of the blockchain infra space that they don't uniquely classify as a coprocessor.
Note that all of the above is async use cases, because the customer dapp need to calls external coprocessors' smart contract when triggered in block N. When coprocessors return the computation result, the result has to be accepted or verified in some shapes or forms in at least the bery next block, which is N+1. This makes the utlisation of co-processing result happening at least on the next block of triggering. It's really like a cloud based GPU. It runs your ML model well, but you can't really play fast paced games on it very well due to the lag.
Embeded coprocessors is like a GPU on your PC's motherboard, sitting right beside the CPU. It has very little lag communicating with the CPU. Also it's right below your palm so you can be pretty certain it's not tampered with. Just that it will get very expensive if you wish it can run ML as fast as a cloud GPU.
Still using Uniswap v4 as an example, assume that some ETH and USDC were to be added to a liquidity pool deployed on Artela at the last 5 mins TWAP. If the pool is deployed in the EVM on Artela, and the TWAP calculation is done in the WASM on Aretla, this pool is essentially using Artela's EVM as the main processor and Artela's WASM as the coprocessor.
Artela is an L1 built with Tendermint BFT. It provides a framework that supports the dynamic extensions for any execution layer to achieve on-chain customized functionalities. Every Artela full node runs two VMs at the same time.
Aspects represent arbitrary computation that a developer wishes to run without touching the state of the smart contracts. Think of it as a Rust script that provides dApps with customized functionality beyond native composability of smart contracts.
If this is a bit hard to comprehend, try from the two following perspectives.
The really exciting breakthrough Artela makes by introducing this embeded coprocessor is that now, Aspects, the arbitrary extension module, can be executed THROUGHOUT THE SAME TRANSACTION as smart contracts. Developers can bind its smart contract to Aspects and having all transactions calling the smart contract processed by Aspects.
Also, like smart contracts, Aspects store data on-chain, , which enable smart contracts and Aspects to read the global state of each others.
These two features unlock a new level of composability and interoperability between smart contracts and Aspects
Compared to smart contracts, Aspects provide capabilities primarily focused on pre and post-transaction execution. Aspects do not replace smart contracts but rather complement them. In comparison to smart contracts, aspects offer the following distinct capabilities for applications:
What sets Aspects apart from smart contracts is:
Aspects are simply pieces of code logic and are not associated with an account. Therefore, they do not have the ability to:
These aspects make Artela a unique platform that extends the capabilities of smart contracts and offers a more comprehensive and customizable development environment.
*Note that the Aspects we mentioned above is strictly called "built-in" Aspects, which is embeded coprocessors run by the full nodes of the Artela Chain. Dapps can also deploy their own Heterogeneous Aspect, which is run by external coprocessors. These external coprocessors can be executed on external networks, or by a subset of nodes in another consensus. It's more flexible as the dapp developer can literally do anything they want with it as long as they feel safe and reasonable doing so. It's still under exploration, and specific details are yet to be announced.
Dapps getting big, bloaty and uncomfortably complicated is inevitable. Therefore the adoption of coprocessors is also inevitable. It's only a matter of time and adoption curve.
Running external coprocessors allows dapps to stay in their comfort zone: whatever chain they previously lives on. However, for the new dapp developers out there looking for an execution environment to deploy to, embeded coprocessors is like a GPU for a PC. If it calls itself a high performance PC, it has to have a decent GPU.
Unfortunately none of the above mentioned projects are on mainnet yet. We can't really benchmark and show which one is better for which use case. However, one thing is certain. Technology progresses in an upward spiral. It looks like we are going around in circles, but remember when seen from aside, history shows that it's up only.
Long live the scailability trilemma, long live coprocessors.
https://www.axiom.xyz/blog/intro
https://docs.artela.network/main
https://docs.axiom.xyz/using-axiom/what-does-axiom-do
https://docs.hyperoracle.io/how-hyper-oracle-works
https://github.com/Uniswap/v4-core/blob/main/whitepaper-v4-draft.pdf
https://medium.com/logos-network/everything-you-know-about-the-scalability-trilemma-is-probably-wrong-bc4f4b7a7ef
https://medium.com/@warp_contracts/smartweave-vs-evm-403487e88fc6
https://mirror.xyz/hyperoracleblog.eth/qbefsToFgFxBZBocwlkX-HXbpeUzZiv2UB5CmxcaFTM
https://twitter.com/delitzer/status/1661755779240841222?s=20