Last updated a week ago
There are a ton of design patterns that address many of the most difficult problems for smart contract development, but they are so unintuitive that barely anyone knows about them.
Two wrapper libraries for Plutarch and Aiken smart contracts, that streamline development by abstracting unintuitive design patterns.
This is the total amount allocated to Anastasia Labs - Streamlining Development: A User-Friendly Smart Contract Library for Plutarch and Aiken Design Patterns & Efficiency. 5 out of 5 milestones are completed.
1/5
Phase 1 - Robust Documentation of these Design Patterns
Cost: ₳ 55,000
Delivery: Month 2 - Dec 2023
2/5
Phase 2 - Design Pattern Wrapper Libraries for Aiken
Cost: ₳ 55,000
Delivery: Month 3 - Jan 2024
3/5
Phase 2 - Design Pattern Wrapper Libraries for Plutarch
Cost: ₳ 55,000
Delivery: Month 4 - Feb 2024
4/5
Phase 4 - Unit Testing - Property Based Testing
Cost: ₳ 45,000
Delivery: Month 5 - Mar 2024
5/5
Complete library delivered with completion video
Cost: ₳ 40,000
Delivery: Month 6 - Apr 2024
Jonathan Rodriguez
Mladen Lamesevic
No dependencies.
Project will be fully open source.
This proposal is to create two smart contract libraries (to support Plutarch and Aiken) to abstract away unintuitive design patterns that even some of the best developers in the ecosystem don't know (because of how bizarre they are).
This includes:
Why is this important?
Transaction level validation via stake validators by withdrawing 0 ADA
Why does the txInfoMint Value contain 0 lovelace?
Transaction validity range not respected
Due to the computations limitation inherent in blockchain development, there is always a number of hacky / unintuitive trick and tips that developers use to squeeze out extra efficiency to fit more logic in their applications or to facilitate a higher transaction throughput for their protocol. Very often, these hacky tricks are very obscure (only a small number of developers know about them) and their usage incurs a cost (namely, it damages readability of the code). This proposal is important to Cardano because it will make these design patterns readily available to all the developers in the ecosystem, and it will provide a clean intuitive interface for using these tricks so that developers can obtain the improved efficiency without needing to sacrifice the readability of their code.
The design of these smart contract wrappers will be very similar in architecture to Agora Effects
Clarification:
The wording "transaction level validation" and "Transaction level validation for spending validators" is confusing because technically spending validators still are validating against the whole transaction. For clarification, in this proposal when we refer to "transaction level validators" and "input level validators" we are referring to the following:
Spending validators are executed once for each input being unlocked from the script. This means if you are unlocking eight inputs from a script address, the spending validator is executed eight times in the same transaction. The successful execution of a spending validator means "The conditions for unlocking this individual UTxO were satisfied by the transaction".
With the stake validator withdraw zero design pattern, the logic for validating inputs from the spending validator is executed once regardless of how many inputs are being unlocked from the script. This means if you are unlocking eight inputs from a script address, the core validation logic is executed only once in that transaction. The successful execution of the staking validator (in the context of this trick) means "The conditions for unlocking ALL the UTxOs locked by script X were satisfied by the transaction".
Some very useful design patterns on Cardano can be extremely unintuitive and not widely known; The causes for this are numerous, including the differences in functional vs imperative philosophies; the newness of eUTXO; the quirks in how scripts get evaluated on Cardano; and the strict constraints the chain is under. For example, there is a pattern that allows you to run global logic once, rather than for each input, by utilizing the "Withdraw" redeemer in staking script; this relies on the ability on Cardano to withdraw 0 staking rewards. I had been building on Cardano for nearly a year before Las from MLabs showed me this trick, and many of the other top developers on Cardano such as Pi (SundaeSwap CEO) and the WingRiders smart contract team were similarly unexposed to the idea.
Depending on the number of script inputs in the transaction, transaction level validation can be a 5-10x efficiency improvement over current design patterns.
It was not through any fault of their own that these developers did not know about this pattern. The ecosystem is hyper-competitive, and anything that gives a developer a competitive advantage is as closely guarded a secret as their private key.
First of all, this proposal will include robust up to date documentation for all these design patterns, as-well-as simple examples of their practical applications. This alone will be massively beneficial to the Cardano developer community. This documentation will be published in standalone Github repository, as-well-as to existing developer documentation Github repositories such as the Plutonomicon, Developer Portal, Aiken Documentation, and Plutarch Documentation.
Even when projects do adopt these advanced design patterns, many of these patterns are so unintuitive and hacky that the resulting code sacrifices readability. This can result in a higher auditing cost for their projects. Furthermore, for projects that are open-source these design patterns make it much harder for aspiring developers reading the code to actually understand what is going on and apply the patterns themselves.
The core of the proposal is the wrapper libraries which will make using these design patterns actually make sense. Currently, even if you know about the transaction level validation with stake validators design pattern, using it feels clunky and unintuitive and the resulting code is very hard to understand for those unfamiliar with the tricks involved. The design of the wrappers will be similar to that of the makeEffect wrapper from Agora. For instance, the wrapper library will include mkTxLevelValidator which can be used to create a spending validator that operates at the transaction level, validating the whole txInfo as-opposed to an individual input (via the stake validator trick). This abstracts away the unintuitive hacky components of this design pattern from the user, so that anyone unfamiliar with the trick can immediately understand what is going on and apply it to their own projects.
Good metrics for the success of this project is:
The most important metric for the success of this project is the number of developers that that adopt these advanced design patterns. The main focus of the proposal is to make the developer community aware of these techniques and how incredibly efficient they are compared to the design patterns currently in use. The secondary purpose is to provide a clean interface (the wrapper libraries) for using these design patterns without sacrificing readability. The success of this can be easily measured by the number of developers & projects using the wrapper library.
Wrapper libraries to make using the design patterns intuitive in Aiken and Plutarch.
Robust documentation of the design patterns.
Examples using the design patterns directly.
Examples using the design patterns with the abstraction / wrapper library.
As a reach goal, we will include an implementation of CIP 57 for Plutarch.
The outputs of this proposal will be continuously maintained by Anastasia Labs. We will incorporate new design patterns & efficiency tricks as they are introduced to the ecosystem. Our goal is to encourage adoption of these wrapper libraries, so naturally we will want to continue the development and maintenance of them.
Anastasia Labs has rapidly established itself as a leading development firm within the Cardano Ecosystem. Our team consists of highly skilled developers who have made significant contributions to various community projects, including Lucid, Agora, Liqwid-Plutarch-Extra, and Aada Finance. Furthermore our developers have had experience developing and publishing end-to-end DApps including production projects such as WingRiders.
In addition to our project involvement, our team has been actively engaged in the developer experience domain. We have actively participated in educational panels focused on DApp Security Practices and Design Patterns, and our members have served as co-chairs of the IOHK developer experience working group.
Furthermore, our collaboration with Emurgo Academy has been instrumental in educating aspiring developers, with our team playing an essential role in this endeavor. We have also recognized and recruited the most exceptional talents from the academy's classes.
We have developed software development kits (SDKs) that facilitate the integration of existing dApps with other systems through off-chain code. Our team has also designed various protocols, including bridges and staking systems, while also actively contributing to open-source smart contract languages and their associated standard libraries.
Overall, Anastasia Labs has established itself as a highly capable and versatile development firm with a broad range of expertise within the Cardano Ecosystem.
The main goals of this proposal are:
Phase 1 - Robust Documentation of these Design Patterns
1 months
This time will be spent to create robust documentation for these unintuitive / hacky design patterns and publish said documentation to a standalone Github repository, as-well-as to existing developer documentation Github repositories such as the Plutonomicon, Developer Portal, Aiken Documentation, and Plutarch Documentation.
Phase 2 - Design Pattern Wrapper Libraries for Plutarch & Aiken
3 months
Implement the design pattern wrapper libraries for Plutarch & Aiken. Provide documentation to clearly illustrate the purpose of each design pattern and how the associated wrapper function can be used to apply the design pattern without sacrificing readability.
Phase 3 - Unit Testing - Property Based Testing
1 month
Implement extensive unit tests & property based tests for the wrapper libraries. Provide documentation that clearly illustrates the purpose of each test, and how each component of the testing framework is used (Aiken Check, Plutus-Simple-Model, Plutarch-Context-Builder, Plutarch-Unit).
Phase 1 - Robust Documentation of these Design Patterns
Deliverable:
Robust documentation of unintuitive / hacky design patterns published to a standalone Github repository, as-well-as to existing developer documentation Github repositories such as the Plutonomicon, Developer Portal, Aiken Documentation, and Plutarch Documentation.
Phase 2 - Design Pattern Wrapper Libraries for Plutarch & Aiken
Deliverables:
An Aiken library that allows users to apply the unintuitive design patterns & hacky efficiency tricks without sacrificing readability and without needing to write a ton of repetitive boilerplate.
An Plutarch library that allows users to apply the unintuitive design patterns & hacky efficiency tricks without sacrificing readability and without needing to write a ton of repetitive boilerplate.
Phase 3 - Unit Testing - Property Based Testing
A series of unit-tests and property based tests that provide some assurance that the implementations of the wrapper functions adhere to their technical specifications.
Robust documentation of the design patterns and efficiency tricks:
Engineering hours for thoroughly documenting the design patterns and efficiency tricks we are familiar with; as-well-as reaching out to other teams and in the unlikely event that they share one that we did not know, documenting it. Getting the documentation published to all the relevant sources of Cardano developer documentation.
₳50,000
Design Pattern Wrapper Libraries for Plutarch & Aiken:
Engineering hours for designing and implementing the efficiency / design pattern wrapper libraries for Plutarch and Aiken.
₳150,000
Unit Testing - Property Based Testing :
Engineering hours for writing a series of unit-tests and property based tests that provide some assurance that the implementations of the wrapper functions adhere to their technical specifications.
₳50,000
Currently there are many DApps live on Cardano that are simply unaware of these design patterns & efficiency techniques. Even after introducing them to the techniques, they have some reservations about using them because of their negative impact on readability (and the possible impact that could have on audit costs).
This proposal will get projects to adopt these design patterns and efficiency techniques which in will result in a large increase in the efficiency of new DApps (and even old DApps who choose to upgrade to gain access to these new efficiency improvements). For many live projects (ex. WingRiders) they consider the hassle of upgrading the protocol to V2 to outweigh the efficiency improvements offered by Vasil. Now projects will have another reason to upgrade to V2, namely, they will have access to all these new efficiency techniques and design patterns.
To put it into perspective, the MuesliSwap team published the following benchmarks regarding improvements of Vasil:
Plutus v1 Transaction
Size: 14.73 kB
Fee: 1.44 $ADA
Plutus v2 Transaction
Size: 1.31 kB
Fee: 0.73 $ADA
Our benchmarks demonstrate a similar level of improvement when comparing PlutusV2 Spending Scripts without the tx-level-validation design pattern to Plutus V2 Spending Scripts with the tx-level-validation design pattern.
Depending the number of script inputs in the transaction, transaction level validation can result in a 5-10x efficiency improvement over current design patterns. For protocols using the batcher architecture, this directly translates to a 5-10x increase in protocol throughput.
NB: Monthly reporting was deprecated from January 2024 and replaced fully by the Milestones Program framework. Learn more here
Compiler & Programming Language Research
Philip DiSarro
Philip is a Computer Science Graduate School Student specializing in Compiler Development & Programming Language Theory. He was one of the first developers to formally verify smart contracts in Cardano using Agda. Philip was the lead architect of many features (both live and upcoming) on WingRiders DEX. Philip has also made significant contributions to the Cardano developer ecosystem. As a co-chair of the IOHK developer experience working group he worked to identify and resolve pain points that DApp developers experience in Cardano, and had an integral role in getting Lucid & Plutus Simple Model included in the Plutus Pioneer Program. He is a blockchain consultant & educational lecturer for Emurgo. Many know him as the primary instructor for the Cardano Solutions Architect course.
Philip is currently the lead smart contract developer at Ikigai Technologies, a consultant and lecturer for Emurgo and a founder of Anastasia Labs.
His previous experience includes:
WingRiders - Lead Smart Contract Developer
Agora - open-source contributor
Plutarch - Liqwid-Extra - open-source contributor
Plaid - FinTech Software Engineer
Philip is responsible for creating the design pattern documentation, implementing the Plutarch wrapper library, and maintaining them to reflect advancements in the developer ecosystem such as new efficiency tricks or design patterns.
Functional Programming & TypeScript SDKs
Jonathan Rodriguez
Jonathan is a highly skilled smart contract developer specializing in Cardano, a blockchain technology that he is deeply passionate about.
His passion in smart contract development drives him to constantly polish his technical knowledge. In the pursuit of that knowledge he obtained the following certifications: Cardano Solution Architect, Cardano Developer Professional, and Associate Certificate.
With an extensive background in Haskell development, which is a critical language for Cardano, he possesses a thorough understanding of functional programming concepts.
His expertise extends to various aspects of the Cardano ecosystem, including the Cardano Toolchain, Transaction Structure, Plutus Smart Contracts, Native Tokens, DApp Connector, and other essential components.
Jonathan is well-versed in conducting use case analysis and tokenomics, as well as interfacing with decentralized storage, server APIs, and integrating databases.
He is knowledgeable in establishing robust CI/CD (Continuous Integration/Continuous Deployment) flows and integrating them into development processes. Additionally, he is skilled in conducting thorough unit testing to ensure the reliability and security of his smart contract solutions.
Johnathon is responsible for contributing to the documentation, implementing the Aiken wrapper library, and maintaining them to remain up-to-date with advancements in the developer ecosystem.