concordium-rust-smart-contracts icon indicating copy to clipboard operation
concordium-rust-smart-contracts copied to clipboard

Cargo concordium should output NRG cost in addition to just the interpreter energy.

Open abizjak opened this issue 4 years ago • 0 comments

Task description

When executing contracts with cargo concordium it currently outputs "interpreter energy", which is not the same as NRG used by the chain. Additionally, it only accounts for execution costs, not for other costs associated with contract execution.

The formula for calculating cost of smart contract invocation has contract specific cost

The cost of a smart contract update is

(MS+ SE) / 10 + IE + B * SS + 300

where

  • MS is size of the smart contract module in bytes
  • SE is the size of the contract state
  • IE is the execution cost of the contract in NRG. The only practical way to estimate this is to execute it and observe it, e.g., with cargo-concordium.
  • B is 1 if invocation succeeds, and 0 otherwise
  • SS is the size of the new contract state.

Additionally there is the general contract cost based on the number of signatures and size. This should probably not be part of cargo-concordium, but it should communicate this.

The first step should be designing a good interface for the output that communicates clearly.

abizjak avatar Sep 01 '21 10:09 abizjak