-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
EIP-1109: Remove call costs for precompiled contracts #1109
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b67f10b
Remove call costs for precompiled contracts
jbaylina 7657dd1
EIP number added and file name changed
jbaylina 233b8da
Fixed discussion-to field
jbaylina 58222c6
Fixed type and category fields
jbaylina 69158dd
discussion-to field changed to ethereum-magicians
jbaylina 178ac1e
Change a bad change
jbaylina 4b55541
Changed the discussion link
jbaylina File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
eip: 1109 | ||
title: Remove CALL costs for precompiled contracts | ||
author: Jordi Baylina (@jbaylina) | ||
discussions-to: https://ethereum-magicians.org/t/eip-1109-remove-call-costs-for-precompiled-contracts/447 | ||
status: Draft | ||
type: Standards Track | ||
category: Core | ||
created: 2018-05-22 | ||
--- | ||
|
||
## Simple Summary | ||
|
||
This EIP removes the gas costs of the CALL-like opcodes when calling precompiled contracts. | ||
|
||
## Abstract | ||
|
||
This EIP tries to resolve the problem of high gas consumption when calling precompiled contracts with a small gas cost. Setting the gas costs to 0 when calling a precompiled contract allows to define precompiled contracts whose effective cost when calling it is less than 700. | ||
|
||
## Motivation | ||
|
||
Each precompiled contract has an already defined a cost for calling it. It does not make sense to add the implicit extra gas cost of the CALL opcode. | ||
|
||
As an example, SHA256 precompiled contract costs 60 and ECADD costs 500 (proposed to costs only 50 in [EIP1108](https://github.com/ethereum/EIPs/pull/1108) . When a precompiled contract is called, 700 gas is consumed just for the CALL opcode besides the costs of the precompiled contract. | ||
|
||
This makes no sense, and right now it's impossible to define a precompiled contract whose effective cost for using it is less than 700. | ||
|
||
## Specification | ||
|
||
If `block.number >= XXXXX`, for each CALL, DELEGATECALL and CALLCODE opcode with a destination address < 256 use a Gcall (basic cost of the call) of 0 instead of 700. | ||
|
||
The cost of the CALL opcode is calculated in exactly the same way that any normal call, including the cost for using a value different than 0 and for creating a new account. The only difference is that Gcall is not added when calculating Cextra. | ||
|
||
## Rationale | ||
|
||
This implementation is the one that needs less modification of the clients. | ||
|
||
## Backwards Compatibility | ||
|
||
This EIP is backwards compatible. Smart contracts that call precompiled contracts will cost less from now on. Smart contracts that relay in a high gas consumption for a specific code are not expected. | ||
|
||
## Test Cases | ||
|
||
- Normal call to a defined smart contract. | ||
- Call to undefined smart contract. | ||
- Call to defined smart contract with a value!=0 on the call. | ||
- Call to undefined smart contract with a value!=0 on the call. | ||
- Normal call with remaining gas<700 but gas>[the cost of the call]. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Call to a precompiled contract which forwards all gas but
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added! |
||
## Implementation | ||
|
||
Not implemented yet. | ||
|
||
## Copyright | ||
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just throwing it out there: Another option is to keep the default behavior for the
*CALL*
opcodes for backwards compatibility, but introduce aPRECOMPILE
opcode that removes the excessive gas costs.