Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module deploy estimated energy is slightly off #203

Open
Bargsteen opened this issue Jan 11, 2023 · 1 comment
Open

Module deploy estimated energy is slightly off #203

Bargsteen opened this issue Jan 11, 2023 · 1 comment
Labels
good first issue Good for newcomers [Type] Bug Something isn't working

Comments

@Bargsteen
Copy link
Contributor

Bargsteen commented Jan 11, 2023

Bug Description
Concordium-client estimates the cost of deploying a smart contract module upfront, but this estimate is slightly off compared to the actual cost on the node.

I am not sure whether this affects all modules, but it occurs for the Fibonacci example when compiled on my mac.

Steps to Reproduce

  1. Begin deploying a smart contract module with concordium-client and note the estimated cost to be X.
    • e.g.: Using default energy amount of 18262 NRG.
  2. Submit the transaction.

Expected Result
Actual cost was also X.

Actual Result
Actual cost is X + ε
e.g.: Transaction is finalized into block cef7813c2bac16c5d59951afaa478e7e15f61e92b4e40f61f0819fbde47b02eb with status "success" and cost 52.785161 CCD (18261 NRG).

Versions

  • Software Version: 5.0.2
  • OS: macOS Ventura

┆Issue is synchronized with this Jira Bug by Unito

@Bargsteen Bargsteen added the [Type] Bug Something isn't working label Jan 11, 2023
@abizjak
Copy link
Contributor

abizjak commented Jan 11, 2023

The difference is because in the Scheduler we do

(Cost.deployModuleCost (Wasm.moduleSourceLength (Wasm.wmvSource moduleV1)))

i.e., we take the size of the Wasm source for computing the cost.

In the client we do

Cost.deployModuleCost (fromIntegral payloadSize)

where

payloadSize = Types.payloadSize . Types.encodePayload . Types.DeployModule $ wasmMod

The payload size is 1 + 4 + 4 bytes longer than the actual size of the source module. So the estimate will either be 1 more or the same.

@abizjak abizjak added the good first issue Good for newcomers label Jan 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers [Type] Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants