We're proud to announce that Ape now fully supports Titanoboa via the ape-titanoboa plugin! With it you can speed up your workflow, lower dev time and do hybrid testing, utilizing the built-in testing suite in Ape alongside Titanoboa to find bugs up to 2x quicker!
Let's go through everything:
One of the biggest struggles of smart contract development is balancing proper testing with speed. You can have the most solid contract code in the world but testing it will be nothing but a headache if you're forced to test it in a language lacking proper testing support. Ape framework solves this by allowing you to write full integration tests with the structured flexibility of python and pytest behind it, but for many tests doing a full provider construction, transaction, block mining, and tear-down takes too much time and can really add up in the full test suite.
Enter Titanoboa, a Vyper interpreter that Ape uses to streamline the testing of smart contracts by eliminating the need for transactions, signing processes, and reliance on provider applications.
Titanoboa simplifies this by running EVM opcodes directly, significantly reducing the overhead and drastically speeding up testing.
When you compile a smart contract, it generates Ethereum Virtual Machine (EVM) opcodes. These opcodes are the fundamental instructions that dictate how the contract operates within the blockchain environment. Typically, users interact with blockchains through transactions that include a "data" field, specifying which code to execute from the smart contract. This method is effective but introduces significant overhead during the testing phase. Most traditional testing tools require devs to manage private keys, sign transactions, and run developer nodes (Hardhat, Geth, Anvil, etc), slowing down the development and testing processes massively.
Ape-titanoboa is different. It runs EVM opcodes rather than relying on transactions, signing, or any of the above, lowering overhead massively.
By cutting out the transaction burden, Titanoboa allows for much faster execution of the smart contract logic, drastically speeding up the processes and cutting out a massive amount of time needed in the testing process.
Now you still can (and should!) do slower, full integration tests, but you are no longer forced to.
Here's an (almost) complete rundown of the pros/cons of Titanoboa:
Faster Testing: The primary benefit is speed; developers can test their code more quickly, leading to more iterations and improvements.
Reduced Overhead: The elimination of transaction-related complexities makes it easier to focus on specific logic within smart contracts.
Enhanced Testing: Titanoboa makes it easier to test your smart contract's specific logic and target specific parts too ensure they run the way you want them to.
Simplicity: Developers can focus on testing specific functionalities without getting bogged down by transaction mechanics.
Flexibility: Titanoboa provides tools to manipulate execution blocks and timestamps, enabling more dynamic testing scenarios.
Realism Issues: Because it cuts out some transactions, some aspects may not reflect real-world scenarios accurately.
Potential Bugs: Running code in a simplified environment may expose developers to bugs that wouldn’t appear in a fully integrated system.
Limited Integration Testing: While unit tests can be executed quickly, integration tests are still necessary to ensure you're fully covered.
While it may not fully replace regular testing completely (especially for integration testing) Boa is basically the new testing standard and an incredibly powerful tool to streamline development and for actually making your project a reality.
Integrating Titanoboa with Ape Framework
There's three key things to understand about this integration:
TestProviderAPI: This API includes essential methods like set_balance(), pending_timestamp (which lets you manipulate time) and mine() which controls blockchain changes during testing.
The Titanoboa Plugin itself: The new plugin processes transactions directly by executing EVM opcodes and returning a computation-wrapper akin to receipts (which can even implement the ReceiptAPI).
Using these alongside your regular Ape tools will let you try out ape-titanoboa, letting you cut out the cruft and test what you want to test as fast as possible.
To show just how much of an improvement ape-titanoboa is, lets test it with our tool ApePay using both ape-foundry and ape-titanoboa:
As you can see, its no contest. In our other tests it reached up to +2x speed increases (and we aim to bump that up even more with the upcoming updates).
People say that speed is a luxury or a frill, but in reality it's a necessity in the world of crypto development.
Tools like Titanoboa allow you to have quicker testing cycles, focus on actually building vs waiting around, and let you avoid getting bogged down by unintuitive processes like writing tests in Solidity. One of our goals this year is to become one of the fastest frameworks, not only the most customizable one.
If you want to experience the newer, faster, Ape+Titanoboa, download it here: https://github.com/ApeWorX/ape-titanoboa
Need help? Join our Discord where we can help you get set up and make the project of your dreams: https://discord.com/invite/apeworx
🦍🤝🐍
Over 200 subscribers