mirror of
https://github.com/status-im/EIPs.git
synced 2025-03-01 07:00:36 +00:00
Automatically merged updates to draft EIP(s) 1109
Hi, I'm a bot! This change was automatically merged because: - It only modifies existing Draft or Last Call EIP(s) - The PR was approved or written by at least one author of each modified EIP - The build is passing
This commit is contained in:
parent
5ace6aa0f4
commit
7df9314343
@ -1,6 +1,6 @@
|
||||
---
|
||||
eip: 1109
|
||||
title: Remove CALL costs for precompiled contracts
|
||||
title: PRECOMPILEDCALL opcode (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
|
||||
@ -11,45 +11,73 @@ created: 2018-05-22
|
||||
|
||||
## Simple Summary
|
||||
|
||||
This EIP removes the gas costs of the CALL-like opcodes when calling precompiled contracts.
|
||||
This EIP creates a specific OPCODE named "PRECOMPILEDCALL" to call Precompiled contracts without the costs of a normal CALL.
|
||||
|
||||
## 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.
|
||||
This EIP tries to resolve the problem of high gas consumption when calling precompiled contracts with a small gas cost. Using this opcode for calling precompiled contracts allows to define precompiled contracts whose effective cost 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.
|
||||
Each precompiled contract has an already defined 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.
|
||||
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.
|
||||
If `block.number >= XXXXX`, define a new opcode named PRECOMPILEDCALL with code value 0xfb .
|
||||
|
||||
The gas cost of the OPCODE is 2 (Gbase) plus the Specific gas cost defined for each specific precompiled smart contract.
|
||||
|
||||
The OPCODE takes 5 words from the stack and returns 1 word to the stack.
|
||||
|
||||
The input stack values are:
|
||||
|
||||
mu_s[0] = The address of the precompiled smart contract that is called.
|
||||
mu_s[1] = Pointer to memory for the input parameters.
|
||||
mu_s[2] = Length of the input parametes in bytes.
|
||||
mu_s[3] = Pointer to memory where the output is stored
|
||||
mu_s[4] = Length of the output buffer.
|
||||
|
||||
|
||||
The return will be 1 in case of success call and 0 in any of the next cases:
|
||||
|
||||
1.- mu_s[0] is an address of an undefined precompiled smart contract.
|
||||
2.- The precompiled smart contract fails (as defined on each smart contract). Invalid input parameters for example.
|
||||
|
||||
Precompiled smart contracs, does not execute opcodes, so there is no need to pass a gas parameter as a normal CALL. If the available gas is less that 2 plus the required gas required for the specific precompiled smart cotract, the context just STOPS executing with an "Out of Gas" error.
|
||||
|
||||
There is no stack check for this call.
|
||||
|
||||
The normal CALLs to the precompiled smart contracts continue to work with the exact same behavior.
|
||||
|
||||
A PRECOMPILEDCALL to a regular address or regular smart contract, is considered a call to an "undefined smart contract", so the VM MUST not execute it and the opcode must return 0x0 .
|
||||
|
||||
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.
|
||||
There was a first proposal for removing the gast consts for the CALL, but it looks that it's easier to implement and test a new opcode just for that.
|
||||
|
||||
The code is just the next opcode available after the STATICCALL opcode.
|
||||
|
||||
## 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.
|
||||
This EIP is backwards compatible. Smart contracts that call precompiled contracts using this new opcode will cost less from now on.
|
||||
|
||||
Old contracts that call precompiled smart contracts with the CALL method, will continue working.
|
||||
|
||||
## Test Cases
|
||||
|
||||
- Normal call to a defined precompiled contract.
|
||||
- Call to undefined precompiled contract.
|
||||
- Call to defined precompiled contract with a value!=0 on the call.
|
||||
- Call to undefined precompiled contract with a value!=0 on the call.
|
||||
- Normal call to precompiled contract with remaining gas<700 but gas>[the cost of the call].
|
||||
- Call to a precompiled contract which forwards all gas but
|
||||
* 600
|
||||
* 700
|
||||
* 701
|
||||
- Call to a regular contract
|
||||
- Call to a regular account
|
||||
- Call to 0x0 smart contract (Does not exists).
|
||||
- Call with large values for the offste pointers and lenghts
|
||||
- Call with the exact gas remaining needed to call smart contract.
|
||||
- Call with the exact gas remaining minus one needed to call smart contract.
|
||||
|
||||
## Implementation
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user