Skip to content
This repository has been archived by the owner on Nov 15, 2021. It is now read-only.

Updated Storage.Put() GAS calculation #111

Closed
wants to merge 1 commit into from

Conversation

king-smith
Copy link

@king-smith king-smith commented Dec 9, 2017

What current issue(s) does this address?, or what feature is it adding?
Storage.Put() currently overcharges by setting a default GAS fee of 1 (compared to the documented system fees of 1 GAS per KB).

How did you solve this problem?
Proposed an updated formula for GAS calculation.

How did you make sure your solution works?
Logged new return value to ensure (1024 bytes x 1000) / 1024 == 1000

Did you add any tests?
Not yet. PR & solution up for discussion.

Are there any special changes in the code that we should be aware of?
N/A

There seems to be a similar code for the C# engine: https://github.com/neo-project/neo/blob/f6b2c8a556b2cad17f1180faabb6a42fcd16a019/neo/SmartContract/ApplicationEngine.cs#L255

I cannot confirm they have the same issue but it seems likely by the code. I haven't written any tests for this, I've had a look at the current tests but it isn't immediately clear to me how I would go about it other than confirming the formula.

I'm also not entirely sure that the -1 is necessary either, l1 and l2 directly correlate to the number of bytes being stored e.g. PUT(ctx, "abc", "defghi") mean l1 = 3 l2 = 6

@coveralls
Copy link

Coverage Status

Coverage remained the same at 67.642% when pulling 267303f on king-smith:put-gas-cost into fe5f65f on CityOfZion:master.

@localhuman
Copy link
Collaborator

I would bring up the discussion or make a PR on the neo core project, as the calculation here needs to remain the same as the calculation there.

@localhuman
Copy link
Collaborator

Did the neo core implementation change on this? If not, it seems like the current implementation matches the neo core one?

@localhuman
Copy link
Collaborator

localhuman commented Jan 3, 2018

I'm going to close this out.

@localhuman localhuman closed this Jan 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants