Concerning Gas comsuption issue

All you need to know about the gas consumption issue.

Image for post
Image for post

The main issue

This buffRate was used to calculate the plasmaPower of each user and so, to calculate the totalPlasmaPower.

The plasmaPower and totalPlasmaPower were then needed to calculate the proportion of each user in the pool, and so calculate the rewards.

In the first contract, the solution to update and calculate these values was done by a loop.

This loop worked well in a test environment with a few users. However, it didn’t scale. As you can guess and as we all saw, with several dozens of users this loop started to need a lot of resources to browse all the users. And since the more resources an action requires, the more gas it costs for the user, the system soon becomes inoperable.

Technical approach

We thought it was really important to know how to reproduce the problem in our test environment so we found new tools and were able to get gas consumption audits for each function using eth-gas-reporter.

We integrated this in our automated test system (it’s like a script that can simulate multiple actions from different addresses that run on a local blockchain).

And the result was obvious, $26 for a withdrawal with the old code for only 100 users.

Image for post
Image for post

It brings us to the next step: thinking differently about the plasmaPower and buffRate to remove these loops.

A new algorithm

It works with a new whales status detection based on the amount on LP. This detection gives the user a buffRate which will be updated after each operation, withdraw or deposit. This buffrate is stored in the contract state.

The buffRate split users in 4 categories : tiny, medium, huge, whales.

As before, the buffRate continues to impact the plasmaPower of each user and so his reward (PlasmaPower = user staked amount * buffRate).

Of course this new contract keep our others main features:

  • Cycle and Halving on NOVA mint
  • Redemption Fees

We’ve made a deep gas consumption audit on this new contract to be sure it can handle several thousands of users. And in addition, we’ve worked hard on details which can reduce a little more gas usage (typing, function visibility ..).

Image for post
Image for post
Gas consumption on the latest fixed version

New security feature to prevent DDOS attack

Therefore we installed a new threshold of minimum LP token required.

NOVA v1 to NOVA v2

For the others, we will setup a simple way to recover your NOVA v1 and to transform them into NOVA v2.

1 NOVA v1 = 1 NOVA v2 (1:1 swap)

Next Steps

  • Help our users to move from the old to the new staking
  • Swap the old NOVA to new NOVA
  • Contracts Audit
  • Run the new contracts on testNet
  • Run on mainNet

Supporters rewarded

This is why we have decided that the addresses still “blocked” in the NOVA v1 staking process will receive 2x their NOVA staked.

We would like to take this opportunity to thank you once again for all your support and dedication to the project. The integrity of our code and user experience stays paramount to our mission at Komet Finance.

We are convinced that this step has made us grow and that it will be very beneficial for the project and future developments.

Stronger together

A community-powered hedge fund. Governed and owned by the people. For the people. Launching soon on Ethereum.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store