Developer’s Log with Modefi CTO Jesse Ireland — July 2023

Modefi
3 min readJul 26, 2023

--

Hey Modefi Community,

I’m looking forward to the opportunity to share intermittent updates from the tech side! I’ll be working with the team to make sure these updates don’t get too technical, but let’s be honest, there might be some jargon that sneaks in from time to time. I hope you enjoy them!

Preamble

Earlier this year, we completed the first ODO (On-Demand Oracle) testing round with the help of our community. Based on these tests, we made the decision to upgrade our consensus mechanism, expand the functionality of the ODO as a whole, and perform several optimizations.

Testing, Testing, 1.. 2.. 22 000?

Over the past few months, my primary focus has been completing unit tests on the updated smart contracts. ‘Unit testing’ is a process where each individual component of an application is tested to make sure it works the way it should.

After coding additional contracts and refactoring several existing ones to improve organization and efficiency, we had a total of 31 smart contracts with varying levels of size and complexity.

Some of these smart contracts are ‘static’, meaning that they remain constant. Others function on an ‘on-demand’ basis, meaning that they are individually deployed based on data requests.

All totaled, the process required over 2000 tests and 22 000 individual assertions to ensure that contract states accurately reflected the results of every possible transaction. These were carried out using the Mocha framework with Hardhat — for non-developers this probably won’t mean anything, but the take home message is that the testing was very thorough.

July — A Month of Firsts

Within the last few weeks, unit testing has been winding down and as a result there are several ‘firsts’ to report:

1. First deployment and integration of static smart contracts

Unit testing doesn’t check if the individual contracts work properly when used together. By thoroughly planning during the design phase, we can ensure that the majority of things work correctly the first time. However, some tweaks were required to set up permissions and get everything just right.

2. First deployment and integration of ‘on-demand’ smart contracts

Getting the on-demand contracts initialized and integrated with the static contracts was another notable milestone, which required tweaks to ensure that storage is initialized correctly and in the proper order.

3. First data request

Registering the first dataset under the updated system was an important milestone. It’s one thing to get everything deployed; it’s another when the code activates and does what it was designed to do. Once the system was successfully storing datasets and preparing contracts for staking and validation, the main consensus algorithm is free to kick in.

4. First data provided, endorsements, consensus, and payout

The algorithm successfully ran for the first time. One user inputted the data, and the others approved it, leading to a consensus. The completion of this process was indicated by a small green checkmark, signifying that the contracts could now be deployed to the testnet for further evaluation with the front end. The front end team had been using simulated versions, but now they were able to test the real deal on the FTM Testnet.

This screenshot shows the successful end-to-end testing of a simple data request.

The summary above is highly condensed — over the course of the last few months, there were many fixes, optimizations, and other improvements.

One that sticks out in my mind involved the part of the consensus algorithm that tracks validators and determines the conditions under which they can be ‘bumped’ in a data request. A flaw was discovered that caused the algorithm to fail in certain edge cases.

After redesigning parts of the algorithm, an improved solution was implemented which checked for eligible users to bump far more efficiently, fixing the initial problem and lowering gas costs for all users.

Next Steps

My next areas of focus are:

  1. Finish cleaning, optimizing, and documenting the code
  2. Performing end-to-end tests for more complex datasets
  3. Collaborating with the front end team to attach the user interface to the back end

We are working hard to move towards the next phase of beta testing. Thank you for your patience and support!

--

--

Modefi

Building the foundation for real world adoption of Oracles and DeFi