Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

The Consumer gas is not constant? #1286

Answered by lucastheo
lucastheo asked this question in Q&A
Discussion options

You must be logged in to vote

I found out what it was, we have two things.

The first thing is about space allocation, in Ethereum the allocation is by block and a block fits 32 booleans, so when I'm going to allocate an element that takes a position 32n+1(33,65,97,...) Ethereum need to add new block costing more gas than normal (this explains the large peaks on the graph).

The second thing is about the lower dense part of the graph. The reason it happens is because saving a false is cheaper than true.
To explore the behavior I tested it with integers. I've found that saving 0 is cheaper than a positive number and saving a positive number is cheaper than saving a negative.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@lucastheo
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by lucastheo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants