Sudden jump in cost calling contract functions consecutively


We have been testing our V1 smart contact on the testnet, to determine the cost of the whole contract with 40 participants. This means that we have 40 consecutive calls to 3 different functions from the same node. For 2 of these functions the cost should not increase with the number of calls. It does not increase for the first 30 calls, however suddenly after the 30th call the price increases dramatically.

What could be the cause of this? Is there some sort of mechnasim to prevent spamming from the same node that could have caused this?

There no mechanism such as you describe. The cost of executing a smart contract depends on the energy (or NRG) usage of the call and the CCD to Euro rate.

The Energy to Euro rate is fixed, but the CCD to Euro rate varies, so a drop in the value of CCD can mean that the price of a transaction in CCD increases. You could inspect the CCD to Euro rates at the blocks using:

concordium-client consensus show-chain-parameters --block <block-hash>

I suspect this might not be the cause of your issue, however. Perhaps if you give us more information about the smart contract you are using, we could give more insight.

The only contracts that have vaguely the behaviour your describe on testnet seem to be

  • 5090
  • 5093
  • 5094
  • 5095

But the differences I see are not massive and could be easily explained by the contract’s state changing. Are you referring to any of these contracts?

1 Like

I forgot to say that the energy increases along with the price.

Yes these are some of the instances we have tested. Well spotted. We have since deployed an upgrade to our contract with reference:

The most recent instance being 5100. In the new one the energy increases with the number of calls at around 20-50 energy which we expected. However at a certain amount of calls (in this instance 34th call) it jumps 1000, and continues to do that at certain intervals afterwards.

The function is doing the same thing for each of the calls. We are saving some information in our state in each of the calls, but how come it suddenly jumps like that?

To answer that I’d have to see details of the contract. In general the high-level state interface hides quite a bit of complexity underneath which could cause this behaviour. But it could be bugs in concordium-std where it is doing things in a suboptimal way.

But to analyze further I’d have to see the contract. It’s not practical to just analyze from the Wasm module. :slight_smile:

If you don’t want to share the contract publicly you can contact me directly.


We are working on the branch concordium_ver_3. The contract functions we are calling can be found in voting/src/ It happens when calling the commit and vote functions repeatedly.

1 Like

We seem to have fixed the issue by restructuring the code. We had some comparisons that might have caused the issue.