From b67f10b69fad55df7a90f1b4d03b2423143a8b03 Mon Sep 17 00:00:00 2001 From: Jordi Baylina Date: Tue, 22 May 2018 17:58:55 +0200 Subject: [PATCH 1/7] Remove call costs for precompiled contracts --- EIPS/eip-call_0_precompiled.md | 54 ++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 EIPS/eip-call_0_precompiled.md diff --git a/EIPS/eip-call_0_precompiled.md b/EIPS/eip-call_0_precompiled.md new file mode 100644 index 00000000000000..47c3b0cba14fd3 --- /dev/null +++ b/EIPS/eip-call_0_precompiled.md @@ -0,0 +1,54 @@ +--- +eip: +title: Remove CALL costs for precompiled contracts +author: Jordi Baylina (@jbaylina) +discussions-to: jordi@baylina.cat +status: Draft +type: 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]. + +## Implementation + +Not implemented yet. + +## Copyright +Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). From 7657dd1c50bbebc875402621b1b1d5cc226ebf2e Mon Sep 17 00:00:00 2001 From: Jordi Baylina Date: Tue, 22 May 2018 18:05:53 +0200 Subject: [PATCH 2/7] EIP number added and file name changed --- EIPS/{eip-call_0_precompiled.md => eip-1109.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename EIPS/{eip-call_0_precompiled.md => eip-1109.md} (99%) diff --git a/EIPS/eip-call_0_precompiled.md b/EIPS/eip-1109.md similarity index 99% rename from EIPS/eip-call_0_precompiled.md rename to EIPS/eip-1109.md index 47c3b0cba14fd3..30244cfecb5f80 100644 --- a/EIPS/eip-call_0_precompiled.md +++ b/EIPS/eip-1109.md @@ -1,5 +1,5 @@ --- -eip: +eip: 1109 title: Remove CALL costs for precompiled contracts author: Jordi Baylina (@jbaylina) discussions-to: jordi@baylina.cat From 233b8da3fdd0e62d55c535fa46680aa0f4fd4ff3 Mon Sep 17 00:00:00 2001 From: Jordi Baylina Date: Tue, 22 May 2018 18:32:31 +0200 Subject: [PATCH 3/7] Fixed discussion-to field --- EIPS/eip-1109.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-1109.md b/EIPS/eip-1109.md index 30244cfecb5f80..8d98c79fe04cae 100644 --- a/EIPS/eip-1109.md +++ b/EIPS/eip-1109.md @@ -2,7 +2,7 @@ eip: 1109 title: Remove CALL costs for precompiled contracts author: Jordi Baylina (@jbaylina) -discussions-to: jordi@baylina.cat +discussions-to: https://github.com/ethereum/EIPs/pull/1109 status: Draft type: Core created: 2018-05-22 From 58222c6afb03a6005378884ccc0f43c52d269abf Mon Sep 17 00:00:00 2001 From: Jordi Baylina Date: Tue, 22 May 2018 18:34:33 +0200 Subject: [PATCH 4/7] Fixed type and category fields --- EIPS/eip-1109.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/EIPS/eip-1109.md b/EIPS/eip-1109.md index 8d98c79fe04cae..5551d3b405d03a 100644 --- a/EIPS/eip-1109.md +++ b/EIPS/eip-1109.md @@ -4,7 +4,8 @@ title: Remove CALL costs for precompiled contracts author: Jordi Baylina (@jbaylina) discussions-to: https://github.com/ethereum/EIPs/pull/1109 status: Draft -type: Core +type: Standards Track +category: Core created: 2018-05-22 --- From 69158dde6f636c0b6fbb92ed664ed56871b366b0 Mon Sep 17 00:00:00 2001 From: Jordi Baylina Date: Tue, 22 May 2018 19:09:21 +0200 Subject: [PATCH 5/7] discussion-to field changed to ethereum-magicians --- EIPS/eip-1087.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-1087.md b/EIPS/eip-1087.md index 2ce72ab3abf905..d7c6a4b92dac5d 100644 --- a/EIPS/eip-1087.md +++ b/EIPS/eip-1087.md @@ -2,7 +2,7 @@ eip: 1087 title: Net gas metering for SSTORE operations author: Nick Johnson (@arachnid) -discussions-to: https://ethereum-magicians.org/t/eip-net-storage-gas-metering-for-the-evm/383 +discussions-to: https://ethereum-magicians.org/t/eip-1109-remove-call-costs-for-precompiled-contracts/447 status: Draft type: Standards Track category: Core From 178ac1e3338ccbd71ba7f0b1996632cc53bd4fbc Mon Sep 17 00:00:00 2001 From: Jordi Baylina Date: Tue, 22 May 2018 19:44:05 +0200 Subject: [PATCH 6/7] Change a bad change --- EIPS/eip-1087.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-1087.md b/EIPS/eip-1087.md index d7c6a4b92dac5d..2ce72ab3abf905 100644 --- a/EIPS/eip-1087.md +++ b/EIPS/eip-1087.md @@ -2,7 +2,7 @@ eip: 1087 title: Net gas metering for SSTORE operations author: Nick Johnson (@arachnid) -discussions-to: https://ethereum-magicians.org/t/eip-1109-remove-call-costs-for-precompiled-contracts/447 +discussions-to: https://ethereum-magicians.org/t/eip-net-storage-gas-metering-for-the-evm/383 status: Draft type: Standards Track category: Core From 4b555411cf4144c8bb09fe9b664a38a8b16988f5 Mon Sep 17 00:00:00 2001 From: Jordi Baylina Date: Tue, 22 May 2018 19:46:53 +0200 Subject: [PATCH 7/7] Changed the discussion link --- EIPS/eip-1109.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-1109.md b/EIPS/eip-1109.md index 5551d3b405d03a..1a06bd05e129b4 100644 --- a/EIPS/eip-1109.md +++ b/EIPS/eip-1109.md @@ -2,7 +2,7 @@ eip: 1109 title: Remove CALL costs for precompiled contracts author: Jordi Baylina (@jbaylina) -discussions-to: https://github.com/ethereum/EIPs/pull/1109 +discussions-to: https://ethereum-magicians.org/t/eip-1109-remove-call-costs-for-precompiled-contracts/447 status: Draft type: Standards Track category: Core