Postmortem of CosmWASM Kontraŭa testnet

kaustubh kapatral
Regen Network
Published in
8 min readMay 15, 2020

Kontraŭa COSMWASM Testnet Retrospective

24th April 2020 marked the end of Regen network’s 2nd incentivized testnet slated for Q1 of 2020. This testnet was designed to let the validator community get familiar with COSMWASM module of Cosmos-sdk which is a PoS implementation of of a web assembly based smart contracting platform. The focus of this testnet was to continue testing and upgrading the capacity and capability of validators to manage upgrades, governance and maintenance of the cosmos SDK based Regen Ledger blockchain.

Here is a link to the Regen Testnet Leaderboard maintained by Team Vitwit.

Kontraŭa testnet had six phases with specific objectives. Before we dive deep into the the intricacies of objectives let’s start from the beginning.

Phase 1: Get off the ground

Photo by SpaceX on Unsplash

Gentx submissions were opened at 9th March 0900UTC. Validators had till 12th March 0900 UTC to submit their the PR to the testnets repo. 62 validators submitted their gentx which was a new record for a Regen network testnet and not one of them were faulty. This made the job of generating genesis file a lot easier as pinpointing faulty gentxs can be quite a pain. The genesis file was released at 12th March 1600UTC, 23 hours before the scheduled network launch time. Unfortunately, the network launch was not as smooth and was delayed by about 25 min. This testnet was built on v0.38.1 version of Cosmos-sdk that had a small bug in it which prevented the seed nodes from being spun up. This created a problem as the validators were not able to form a connection between one another. Because the validator community is so tightly knit, everyone came together on the telegram channel and shared their peer addresses to help form a consensus. After a while consensus was reached and the network started producing blocks. As the peer addresses were shared in the chat, which was pretty hard to keep track of at that moment, quite a number of validators who were part of the gentx submissions could not connect to the network in time. This resulted in many validators being jailed through no fault of their own as the slashing conditions were pretty harsh in the genesis. To give ample time to remaining validators to get back in the active set, a decision was taken by the lead validator team to start the the uptime calculation after block number 15,000. This gave all the affected validators 25hrs after network launch time to get their nodes back online.

Phase 2: The “wow, it’s monday morning” task.

Photo by Danielle MacInnes on Unsplash

Phase 2 of the testnet started on 16th March 0500UTC and ran till 19th March 0500UTC. This phase gave the first taste of smart contract deployment and execution to many validators. The task involved giving away ERC-20 tokens to any 5 validators of one’s own choosing. A detailed guide was also released along with the start of the phase which held all the important instructions and prerequisites needed to complete the challenge successfully. There were bonus points earmarked as well for special custom implementations. 50 bonus points were set aside for editing the contract to add any custom feature like send extra tokens than allowed, hardcode recipient address etc. Another 100 points were for creating an allowance and using transferFrom to send tokens from a second address. No instructions were provided for these bonus challenges.

Phase 3: Ameliorate network

Photo by Michael Dziedzic on Unsplash

Phase 3 of the testnet was the good ole software upgrade phase for which Regen Network is famous. The title of this upgrade was named “Himalaya” and a proposal was made for this upgrade was made on 23rd March and the upgrade was scheduled to occur at 26th March 1200UTC . Validators had time from 23rd to 25th March to vote on the proposal. Unfortunately the way AVL tress were being stored in this version of SDK, prevented the use of cosmosd. This software upgrade was to be done manually by all the validators. To give some clarity on upgrade procedure to the newer validators, an instructions guide was released. This phase also had a bonus phase which awarded points to validators who tweeted about the upgrade. Details to submit the tweet info were also provided in the instructions. As this was a manual upgrade, it was not as quick as the previous network upgrades. It took roughly 40 mins to achieve consensus again.

Phase 3.1: Skip upgrade

This phase of the testnet was one of a kind in not only Regen’s community but also in the entire Cosmos ecosystem. This phase focused on skipping a planned software upgrade. It might be important sometime in the future to have this skill developed by the validator community in case of an emergency. This was to test out the skip upgrade flag ( — skip-upgrades) of the upgrade module which skips an upgrade at the given height. For this upgrade, proposal was created on 30 March 1200 UTC and voting period lasted from 30th March to 1 Apr. Upgrade height was specified as 288888. As this was the first time skip-upgrade functionality was being tested, an instructions doc was released which detailed the procedure along with instructions for tweet submission as well. All the validators had updated their nodes before the upgrade height and the network did not halt and trucked on after block 288888.

Phase 4: Deploy Escrow contract

Photo by Sebastian Herrmann on Unsplash

Phase-4 involved deploying and executing functions of an escrow contract. This was a little more complicated than the Phase-2 and had more functions which needed to be executed. As is customary with all the phases, a detailed guide was released to help the validators complete this challenge. This phase started on 7th Apr 2100 UTC and ended on 9th Apr 2100 UTC.

Phase 5: High skill time

Source

This phase of the testnet was a completely optional and a bonus phase for all the validators. This phase involved creating a custom payout contract for ecological credits which would be something that would be used in mainnet. As this was a bonus phase, an instructions guide was not released but a doc with contract requirements and hints for building it was released. As this phase was more developer oriented, not many validators participated in this phase and rightly so, as writing and building smart contracts is not something that is required of a skilled validator. Even though it was very developer oriented, 7 validators submitted their PRs to the repo with their contract details. This phase was originally intended to run from 14 Apr 0200 UTC to 22 Apr 0200 UTC, but at the request of few validators this phase was extended till the end of network scheduled at 24th Apr 0900 UTC.

Phase 6: Silent blast

The last phase of Kontraŭa testnet was to test how well the validators had their nodes configured to avoid spam transactions. A stress test was undertaken by the lead validator team by bombarding the network with a boatload of transactions. 119395 transactions were executed in a span of just 7 hrs. Block number 584239 had an astonishing 457 transactions in it. This stress test continued till 24th Apr 0900UTC at block 611300 when the incentivized phase of Kontraŭa ended. A few validators who did not configure their nodes against this type attack went down and got jailed.

Key takeaways from Kontraŭa Testnet

  • Testing of COSMWASM module was undertaken successfully.
  • Validators got well acquainted with contract deployment and function execution.
  • Testing of skip upgrade functionality was completed successfully.
  • 7 validators who participated in Phase-5 got to deploy and test their own payout contract for ecological credits.
  • 78 validators were in the active validator set at one point—a new record for a Regen testnet!
  • Discovered that allowing re-uploading of same bytecode is very important for DevUX (that was fixed in wasmd 0.7.1, xrnd 0.7.2)
  • Demonstrated stability and scalability of CosmWasm — no issues when hundreds of contracts were deployed.
  • Exposure to many new devs in CosmWasm community.
  • Valuable feedback was gathered on tutorial and cli/repl documentation

Special thanks to Ethan Frey and Simon Warta for their help in debugging issues with contract deployment and their help in answering queries posted by the validator community.

Why are we so excited about CosmWASM contracting on Regen Network? It fullfills a large element of the functionality outlined in our whitepaper focused on flexible ecostate contracting.

Here is a fantastic overview of working being done with the OpenTEAM community written up by Cory Levinson, Regen Network’s Blockchain Product Manager.

As part of the Regen Network’s recent CosmWasm focused testnet, we invited members from our OpenTEAM community to collaborate with our validator community on our first protype of a ecological smart contract! One of the final challenges for the Kontraua Testnet involved writing a CosmWasm smart contract that acts as an escrow, sending tokens to an account dependent on a measurable change in some ecological state. As OpenTEAM is a technology initiative around open source tools soil health, and interoperability for agricultural data management, the member organizations within OpenTEAM served as the perfect group to incubate a prototype with. FarmOS and OurSci are the two projects from OpenTEAM that took up the offer and each successfully prototyped a basic Oracle functionality into their existing farm data management applications. The result is that real world agricultural management applications can register a Regen Network smart contract address, and users of these OpenTEAM applications can send live ecological state updates to Regen Network. For more information, take a look at this example smart contract, and some screenshots of the Oracle interfaces in FarmOS and OurSci below!

Photo by Federico Respini on Unsplash

The way forward.

The next incentivized testnet named Aplikiĝo is scheduled to start in June (exact date TBD). It will focus on application specific testing and simulation of ecosystem service credit creation and trading with production ready MVP blockchain. In addition to the credits module,we will be testing the Groups Module As this will be the last testnet before mainnet launch, the focus will be on delivering a testnet which will resemble the mainnet conditions as closely as possible.

With thanks to Gregory Landua for additions.

--

--