August 29, 2022: Advanced Tooling š§°š ļø
Titanoboaās journey to become the most advanced smart contract toolkit
Itās been almost two months since Vyper introduced Titanoboa to the world. During this time the industrious devs have managed to ship three new versions of Vyper while simultaneously rounding out Titanoboaās features.
With its present feature set, Titanoboa has already become among the most advanced smart contract development tools available on the market. Some of the newest features:
Per-Line Gas Estimation:
Admittedly, Iām salty because Iād spent several weeks deciphering gas usage values manually for a set of contracts, only to see this feature drop shortly after deployment. So it goes...
Vyper already does a wonderful job of optimizing gas usage, so most users will see gas savings without needing to worry too much. Yet the Vyper interpreter can only efficiently render the code as written ā itās up to the developer to decide whether or not a particular line of code should be included in the first place.
As we described at ETH LATAM, gas optimization is a race to the bottom. The EVM has a theoretical minimum limit no matter what language you are using.
Solidity remains a powerful tool for gas golfers due to Solidityās ability to manipulate raw bytecode. This gives Chad programmers the ability to bypass the compiler and try to scrape their way to this optimal efficiency with assembly-level optimization. It produces impossible to read code, however.
Vyper emphasizes the code being intelligible, so this level of direct bytecode manipulation is prohibited. Therefore, the onus of approaching this theoretical optimum falls onto the compiler. Fortunately the Vyper compiler is quite efficient, and will generally outperform Solidity that is not engineered to the raw bytecode level of optimization.
The new Titanoboa feature is particularly useful for those writing code at the smart contract level. I find it pairs particularly well with Brownieās āgas
flag on tests. If you have tests with about 100% coverage, Brownie provides you the gas profile of every function. From here you can drill down into the most expensive functions using Titanoboa.
While weāre on the subject of gas optimization, weād be remiss if we didnāt mention a tool recently published by the late, great @fiddy published a tool. This Curve Gas Estimates repo allows devs to use evm-trace to pull Curve gas estimates. Itās built on ApeWorx and Erigon, and has particular utility for MEV arbitrage bots and aggregators.
Check it out at: https://github.com/curvefi/curve-gas-estimates
Forked Mainnet
Another tool in the Titanoboa toolkit is the capability of forking mainnet. This is particularly useful for protocols like Curve that have no deployments on testnets.
For those who are interested, it is possible to deploy a skeletal set of Curve contracts to a local development environment or a forked mainnet. The fixtures by @skelletor in the veFunder contract provide a useful example.
However ā it can be difficult to jump from this makeshift setup to a robust testing environment. To test Curve youād need to launch a few stablecoin contracts and get them added as base pairs. Some stablecoins maintain peg by relying on price oracles, so youād also need a minimum deploy of, say, Chainlink oracles. Maybe you need to test how certain aggregators index transactions, which requires yet more deploys. Deploying a framework that looks like mainnet is a tough job.
Forking mainnet, in contrast, is so easy. You can just snapshot the Ethereum mainnet to a local blockchain. On this forked mainnet, you can simulate any transaction as any account. This allows you to fully test your protocol against any Contract already deployed, or to run transactions as even the largest whales. Why bother redeploying everything to a test environment, when you can just try it in a snapshot of the real world?
Outside of testing, this is particularly useful for data scientists. The ability to run complex simulations on existing smart contracts and pipe the results directly into a Jupyter Notebook is incredibly useful for number-crunching. Titanoboa makes the process quite fast!
Much, Much More
These are just two of the more accessible tools added to Titanoboa over the past few weeks, but by no means is this exhaustive. Titanoboa recently launched user-definable precompiles (cheats, in the parlance of Foundry).
It also has to be emphasized just how fast the team is polishing this tool. Asking for help in the Vyper Discord can see new builds published in minutes, it really is something else.
Tooling had previously been a weak point for the Vyper universe, but this narrative is swiftly being shattered.
The development ecosystem around Curve in particular is seeing the creation and utilization of advanced tools, the result of which is the advanced protocol we all enjoy. This also means there can be friction for other services to integrate fully with Curve.
One example of this was the popular CryptoFeesInfo, which undercounted Curve because it relied on an outdated subgraph. Progress is being made here, because in particular Benny stepped up and built an update directly.
Thereās ample opportunity for developers who want to get their hands dirty to contribute to building such projects that benefit the Curve ecosystem. If you are a developer, try pinging the Curve #dev channel on Discord or the Telegram channel and see if thereās any way to contribute.
If you want to offer help on the data science/research side, you might ping the Crypto Risks team. They have more protocols trying to integrate with Curve than they have time to review, so they have ample opportunity to contribute. Check out their latest blockbuster on Synthetix.
As Curve lives out the values of decentralization, it is only as strong as its community. We appreciate everybodyās help in keeping Curve incredible!