CosmWasm vesting contracts
In Archway we developed CosmWasm
vesting contracts, which will be deployed to shore the tokens of the Archway
core contributors, the foundation and other stakeholders.
The vesting contracts are implemented using CosmWasm
, a shift away from the traditional Cosmos SDK
vesting that is done
using the x/vesting
module.
Let’s explore motivations and challenges!
Motivation
The decision to implement CosmWasm vesting contracts instead of SDK modules was driven by several key factors, which are outlined below.
First, using a module for vesting would necessitate the entire network to run that module, despite the use case being applicable to a limited set of users. This could place unnecessary strain on the network and affect its overall performance, whilst also increasing the surface of possible attack vectors. Archway aims to be a super-lean and robust network.
Second, the existing vesting options did not encompass all the necessary functionalities, such as clawback, that were required for our specific use case.
Third, we desired the ability to stake our vested coins and vote with them, which was not fully supported by the existing vesting options, if we added clawback on top.
Fourth, upgrading contracts does not necessitate a network upgrade, unlike upgrading modules. This offers greater flexibility and efficiency when implementing changes or improvements to the vesting contracts.
Fifth, the upgradeability of CosmWasm vesting contracts allows for emergency error recovery in case of unforeseen issues, providing an added layer of protection and adaptability.
Finally, the upgradeability feature also enables the extension of the vesting contracts to support future features and functionalities of the network. This ensures that the vesting contracts can evolve and adapt alongside the network, meeting the needs of its users as they change over time.
Taking these factors into account, it is clear that implementing CosmWasm vesting contracts is the preferable option, as it offers a more versatile, efficient, and future-proof solution for managing vested assets within the network.
Challenges
Implementing CosmWasm vesting contracts presented several difficulties that we had to overcome throughout the development process.
One major challenge was the pioneering nature of our effort, as there were no existing solutions for vesting in CosmWasm to draw upon. This meant that we had to create the vesting contracts from scratch, without the benefit of guidance from previous implementations.
In addition, our vesting contracts aimed to support a range of features, such as staking, governance, and custom vesting schedules with cliffs. The integration of these features introduced several complexities that needed to be carefully considered and addressed within the overall solution.
Integrating staking proved to be particularly challenging, given that the SDK’s staking mechanism is not entirely lazy. This resulted in staking rewards being withdrawn on delegations, redelegations, and undelegations, which complicated the calculation of vesting balances and staking rewards.
Another significant challenge was the difficulty of testing the CosmWasm contracts in conjunction with SDK modules like governance and staking. The lack of a concrete framework for testing these contracts forced us to develop a hybrid golang-rust solution. In this approach, the golang part was responsible for deploying and executing the contract and testing the outputs against the rust implementation. This was a time-consuming process that required a lot of effort to get right.
Despite these hurdles, we successfully implemented CosmWasm vesting contracts that met our requirements and provided a flexible, efficient, and robust solution for managing vested assets within the network. Overcoming these challenges not only contributed to the development of our vesting contracts but also set the stage for future projects in the CosmWasm ecosystem.
When open source?
We understand the importance of transparency and trust in the development of our CosmWasm vesting contracts. In order to ensure the security and reliability of our solution, the code has been thoroughly audited by a reputable third-party organization.
We have decided to make the code open source after the mainnet release. This approach allows us to further narrow down and address any potential issues that may arise during the initial launch phase. By doing so, we can provide a more robust and reliable solution for managing vested assets within the network.
Once the code is made open source, the community will be able to review, contribute, and collaborate on its development, fostering a healthy ecosystem and promoting ongoing improvements to the CosmWasm vesting contracts. Our commitment to open source principles reflects our dedication to transparency, trust, and the collaborative spirit that drives the success of blockchain networks.