Skip to content

Better specify the fall function gas cost in the docs.#2945

Merged
chriseth merged 1 commit intoargotorg:developfrom
LefterisJP:docs_fix_fallback_gas
Sep 21, 2017
Merged

Better specify the fall function gas cost in the docs.#2945
chriseth merged 1 commit intoargotorg:developfrom
LefterisJP:docs_fix_fallback_gas

Conversation

@LefterisJP
Copy link
Contributor

@LefterisJP LefterisJP commented Sep 21, 2017

Better specify the fall function gas cost in the docs.

Ether through regular transactions.

In such a context, there is usually very little gas available to the function call (to be precise, 2300 gas),
In such a context, there is usually very little gas available to the function call (to be precise, 2300 gas). That is in addition to the simple value transfer gas cost of 21000. So in total 22300 gas.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 21k gas is not available to the called contract. You just pay 21k gas for the transaction itself. It might have multiple simple value transfers which each provide a stipend of 2.3k gas.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs rephrasing, since people get confused and copy around the 2.3k value as being the gas limit for the fallback which makes no sense. What would you propose?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add a sentence like: Note that the gas required by a transaction (as opposed to an internal call) that invokes the fallback function is much higher, because each transaction charges an additional amount of 21k gas or more for things like signature checking.

Specify that also 21k gas is needed for fallback functions originating from
external function calls.
@LefterisJP LefterisJP force-pushed the docs_fix_fallback_gas branch from d6209fa to 7f88d43 Compare September 21, 2017 12:16
@LefterisJP LefterisJP changed the title Fix the fallback function gas cost in the docs Better specify the fall function gas cost in the docs. Sep 21, 2017
@chriseth chriseth merged commit 68fbe1e into argotorg:develop Sep 21, 2017

In such a context, there is usually very little gas available to the function call (to be precise, 2300 gas),
so it is important to make fallback functions as cheap as possible.
In such a context, there is usually very little gas available to the function call (to be precise, 2300 gas), so it is important to make fallback functions as cheap as possible. Note that the gas required by a transaction (as opposed to an internal call) that invokes the fallback function is much higher, because each transaction charges an additional amount of 21000 gas or more for things like signature checking.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a bit confusing, it seems like 21000 gas is charged so the contract can do signature checking (which is not the case).

However, that 21000 is not usable by the contract if I am not mistaken?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not usable by the contract, no. I don't think it reads like what you said though. But ofcourse if you think it can be expressed in some more clear way let's change it.

@LefterisJP LefterisJP deleted the docs_fix_fallback_gas branch September 21, 2017 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants