How Yearn Finance Speeds up Development Cycles on Collaborative Virtual TestNets

"The shared state is a killer feature for us. It saves hours on debugging because I don’t have to figure out why a revert happened in the first place, which is the case when everyone has a local fork with a different state."
wavey
Protocol engineer at Yearn Finance
As one of the OGs in the DeFi space, Yearn Finance started as a yield aggregator, with its innovative vaults as the underlying infrastructure for yield farming. Striving to simplify access to yield for everyday users, Yearn enables them to participate in passive yield farming more easily by depositing into the vaults and allowing automated strategies to allocate capital across the safest and most trusted yield farms in Defi.
Known for its strong emphasis on decentralization, Yearn’s engineers prioritize transparency and permissionlessness in their development processes. This approach gives their users confidence, enabling them to deposit into the Yearn vaults and get the best yield possible thanks to top-tier strategy building.
Aside from vaults as the core of their protocol, Yearn Finance also has a range of other functionalities and more specialized products. One of them is Resupply, a stablecoin lending market and sub-DAO created in partnership with Convex Finance. For its development and testing, the Yearn and Convex teams used Tenderly Virtual TestNets as a shared development infrastructure for Solidity and frontend teams.
The challenges of ensuring a consistent state on local forks
Ensuring a consistent state of their testing infrastructure is essential for producing accurate results when testing protocol upgrades. Initially, this required some Solidity engineers to write detailed instructions on how to spin up local forks in the repo to ensure consistency across teams when doing integration testing. They would also provide instructions for the frontend team on using Anvil forks.
However, running different local copies of the chain required the Yearn team to spend a lot of time on the manual setup. Plus, it provided divergent testing results due to differences in local environments.
So, since most Yearn engineers already used Tenderly’s infrastructure and tools across different projects, they quickly replaced local forks with Virtual TestNets, introducing them into their development cycles.
Enabling collaborative development on shared Virtual TestNets
As a shared development infrastructure with built-in collaborative functionalities, Virtual TestNets enable Yearn’s engineers to work more closely over a shared state. The Yearn team has around 30-40 contracts for the Resupply protocol, so they deploy and verify everything on Virtual TestNets.
Additionally, the teams can synchronize all new contract deployments on a Virtual TestNet and share the RPC URL with the frontend team so they can connect and test the UI. If they come across a bug, they can determine whether it’s a contract or UI issue more easily.
“Having a common environment and being able to share a link with my coworkers or testers is really powerful. I can just share the issue and exact sequence of transactions so they can validate on their own without requiring anything to run locally. This helps us iterate quickly and collaborate more easily.” – wavey, protocol engineer at Yearn Finance
The team would test every contract update to ensure each iteration works as expected. So, having a shared environment with a consistent state facilitates this process significantly. If one tester finds a bug, they can share the Virtual TestNet URL with full context for the rest of the team to replicate the issue.
“The shared state is a killer feature for us. It saves hours on debugging because I don’t have to figure out why a revert happened in the first place, which is the case when everyone has a local fork with a different state.” – wavey, protocol engineer at Yearn Finance
The Yearn engineers can then use the built-in Debugger to step through a transaction and identify the reason behind a revert quickly.
Facilitating external collaboration on Virtual TestNets
Since the Yearn team built Resupply in collaboration with Convex Finance, Virtual TestNets also enabled them to collaborate outside their organization. With both Admin and Public RPCs, the Yearn team could easily share Virtual Testnets without the risk of someone polluting the state.
The Admin RPC enables the Yearn team to manipulate the state of Virtual TestNets. For instance, the Yearn engineers can use the unlimited faucet via custom RPC methods or advance the timestamp on a Virtual TestNet. On the other hand, the Public RPC is for public sharing and comes with a public explorer for external use.
Making yield farming more accessible to end users
With one of Yearn’s primary goals to allow users to be passive yield farmers, the team will continue exploring ways to make farming strategies even more accessible and offer the best yield possible to users in the most trustless way. As they work on new products, the team will continue relying on Tenderly as their partner.
“Tenderly’s customer support is so quick to act and extremely technical, with someone always ready to jump on things no matter the time of day. You make us feel so well-treated, it really stands out in the space.” – wavey, protocol engineer at Yearn Finance
The Yearn engineers will also explore using Virtual TestNets as part of their CI/CD setup to further optimize their development cycles. To try out Virtual TestNets for development and testing on mainnet data, fork any of the 90+ supported chains in milliseconds!