From d37c8900bdc644d94ff2ddc6fd586d0edfdda7da Mon Sep 17 00:00:00 2001 From: ledgerwatch Date: Thu, 16 May 2019 22:23:52 +0100 Subject: [PATCH 01/12] Create eip-draft_StatelessClientGasRepricing.md --- EIPS/eip-draft_StatelessClientGasRepricing.md | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 EIPS/eip-draft_StatelessClientGasRepricing.md diff --git a/EIPS/eip-draft_StatelessClientGasRepricing.md b/EIPS/eip-draft_StatelessClientGasRepricing.md new file mode 100644 index 0000000000000..cd0d4b7f6597d --- /dev/null +++ b/EIPS/eip-draft_StatelessClientGasRepricing.md @@ -0,0 +1,75 @@ +--- +eip: +title: Stateless clients for contract storage - Gas repricing +author: Alexey Akhunov (@AlexeyAkhunov) +discussions-to: to be added when the number is known +status: Draft +type: Standards Track +category: Core +created: 2019-05-16 +--- + + + +## Simple Summary + +The gas cost of EVM opcodes `SLOAD` and `SSTORE` increases in order to accomodate extra bandwith required to propagate block proof together with the block +headers and block bodies, as explained [here](https://medium.com/@akhounov/data-from-the-ethereum-stateless-prototype-8c69479c8abc). + +## Abstract + +It is part of the State Rent roadmap. This particular change prepares Ethereum for introduction of the block proofs (current understanding is that they +can be introuced without a hard fork). The introductio of the block proofs allows any Ethereum node that wishes to receive them, to process transactions +in the blocks without needing to access the Ethereum state. All necessary information for the execution (and the proof of validity) is contined in the +block proofs. In most Ethereum nodes, it will speed up the block processing and reduce the memory footprint of such processing. For mining nodes, however, +there will be more work to do to construct and transmit the block proofs. Therefore, the extra charge (payable to the miners) is introduced. In the first +phase, only contract storage will be covered by the block proofs. It means that the Ethereum nodes will still need access to the accounts in the state, +but block proofs will make it optional to have access to contract storage for executing transactions. Therefore, only `SSTORE` and `SLOAD` opcodes are +affected. + +## Motivation + +There is [empirical analysis](https://github.com/holiman/vmstats/blob/master/README.md) showing that `SLOAD` opcode is currently underpriced in terms +of execution latency it adds to the block processing. The hypothesis is that it is due to the latency of the database accesses. In the same +analysis, `SSTORE` is not considered, because its effect on the database accesses can be (and are in many implementations) delayed until the end of +the block. Stateless clients approach to the contract storage will largely negate that latency because no database accesses will be required. +Instead, bandwidth consumption goes up. There is emprical analysis (unpublished, but will be) suggesting that 1 uncached `SSTORE` or `SLOAD` adds +at most 1 kB to the block proofs. At the current cost of data transmission (68 gas per byte), this translates to the increase of gas cost of both +operations by 69k gas. However, in light of proposal in EIP-2028 (link will be provided when EIP is merged), the increase can be made much smaller. + +## Specification + +Not very formal at the moment, but will be formalised with more research and prototyping. Gas of operations `SLOAD` and `SSTORE` increases by `X` gas +for those operations that access storage slots that were not previously accessed during the same transaction. + +Future variant (will be possible after the implentation of the *Gross contract size acccounting*) is researched, where the increase is varied +depending on the size of the contract storage, i.e. `SLOAD` and `SSTORE` for smaller contracts will be cheaper. + +## Rationale + +[EIP-1884](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1884.md) seeks to increase the gas cost of `SLOAD` but using a different justification +(latency of the execution as described in the Motivation). This EIP is likely to increase the cost of `SLOAD` by a larger amount, therefore partially +(because EIP-1884 also proposed other increases) supersedes EIP-1884. + +EIP-2028 (link will be provided when EIP is merged) describes the model that can be used for deciding the gas cost of data transmission. It is relevant +because in the stateless client regime `SSTORE` and `SLOAD` operations add more data to be transmitted (as well as computation to verify the proofs). + +The main alternate design is the rent proportional to the size of the contract storage, which unfortunately introduces a serious griefing +vulnerability problem, and so far the solution seems to be in redesigning and rewriting smart contracts in a way, which makes them not vulnerable. +However, this approach is likely to be very expensive on the non-technical (ecosystem) level. + +## Backwards Compatibility + +This change is not backwards compatible and requires hard fork to be activated. + +## Test Cases + +Tests cases will be generated out of a reference implementation. + +## Implementation + +There will be proof of concept implementation to refine and clarify the specification. + +## Copyright +Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). + From ba80e040d678fea91574ad7c4ea7f2856f486aae Mon Sep 17 00:00:00 2001 From: ledgerwatch Date: Thu, 16 May 2019 22:25:15 +0100 Subject: [PATCH 02/12] Update and rename eip-draft_StatelessClientGasRepricing.md to eip-2035.md --- EIPS/{eip-draft_StatelessClientGasRepricing.md => eip-2035.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename EIPS/{eip-draft_StatelessClientGasRepricing.md => eip-2035.md} (99%) diff --git a/EIPS/eip-draft_StatelessClientGasRepricing.md b/EIPS/eip-2035.md similarity index 99% rename from EIPS/eip-draft_StatelessClientGasRepricing.md rename to EIPS/eip-2035.md index cd0d4b7f6597d..4e8e0ecd4cdf6 100644 --- a/EIPS/eip-draft_StatelessClientGasRepricing.md +++ b/EIPS/eip-2035.md @@ -1,5 +1,5 @@ --- -eip: +eip: 2035 title: Stateless clients for contract storage - Gas repricing author: Alexey Akhunov (@AlexeyAkhunov) discussions-to: to be added when the number is known From f717af9ea43402cd7eaafa43d4c74c6b791d5cbb Mon Sep 17 00:00:00 2001 From: ledgerwatch Date: Thu, 16 May 2019 22:27:04 +0100 Subject: [PATCH 03/12] Update eip-2035.md --- EIPS/eip-2035.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-2035.md b/EIPS/eip-2035.md index 4e8e0ecd4cdf6..89592d3dc3dd1 100644 --- a/EIPS/eip-2035.md +++ b/EIPS/eip-2035.md @@ -2,7 +2,7 @@ eip: 2035 title: Stateless clients for contract storage - Gas repricing author: Alexey Akhunov (@AlexeyAkhunov) -discussions-to: to be added when the number is known +discussions-to: https://ethereum-magicians.org/t/eip-2035-stateless-clients-repricing-sload-and-sstore-to-pay-for-block-proofs/3284 status: Draft type: Standards Track category: Core From 0e68c96d819241769d6c4e09242566cbc604cd62 Mon Sep 17 00:00:00 2001 From: ledgerwatch Date: Fri, 17 May 2019 09:55:55 +0100 Subject: [PATCH 04/12] Update eip-2035.md --- EIPS/eip-2035.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/EIPS/eip-2035.md b/EIPS/eip-2035.md index 89592d3dc3dd1..7d2cd051ce3bd 100644 --- a/EIPS/eip-2035.md +++ b/EIPS/eip-2035.md @@ -13,7 +13,7 @@ created: 2019-05-16 ## Simple Summary -The gas cost of EVM opcodes `SLOAD` and `SSTORE` increases in order to accomodate extra bandwith required to propagate block proof together with the block +The gas cost of EVM opcodes `SLOAD` and `SSTORE` increases in order to accommodate extra bandwith required to propagate block proof together with the block headers and block bodies, as explained [here](https://medium.com/@akhounov/data-from-the-ethereum-stateless-prototype-8c69479c8abc). ## Abstract @@ -61,6 +61,13 @@ However, this approach is likely to be very expensive on the non-technical (ecos ## Backwards Compatibility This change is not backwards compatible and requires hard fork to be activated. +There might also be an adverse effect of this change on the already deployed contract. It is expected that after this EIP and +EIP-2026 (rent prepayment for accounts), the recommendation will be made to raise the gas limit. This can somewhat dampen the +adverse effect of EIP. The most problematic cases would be with the contracts that assume certain gas costs of `SLOAD` +and `SSTORE` and hard-code them in their internal gas computations. For others, the cost of interacting with the contract +storage will rise and may make some dApps based on such interactions, non-viable. This is a trade off to avoid even bigger +adverse effect of the rent proportional to the contract storage size. However, more research is needed to more fully +analyse the potentially impacted contracts. ## Test Cases From aea4ef8368965310d85a9e4106cef72ab25d8ba7 Mon Sep 17 00:00:00 2001 From: ledgerwatch Date: Fri, 17 May 2019 10:07:02 +0100 Subject: [PATCH 05/12] Update eip-2035.md --- EIPS/eip-2035.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-2035.md b/EIPS/eip-2035.md index 7d2cd051ce3bd..eeffd6f75c580 100644 --- a/EIPS/eip-2035.md +++ b/EIPS/eip-2035.md @@ -1,6 +1,6 @@ --- eip: 2035 -title: Stateless clients for contract storage - Gas repricing +title: Stateless Clients: Repricing SLOAD and SSTORE to pay for block proofs author: Alexey Akhunov (@AlexeyAkhunov) discussions-to: https://ethereum-magicians.org/t/eip-2035-stateless-clients-repricing-sload-and-sstore-to-pay-for-block-proofs/3284 status: Draft From f335933264875da0ee414915b91081244477b6c5 Mon Sep 17 00:00:00 2001 From: ledgerwatch Date: Fri, 17 May 2019 21:43:26 +0100 Subject: [PATCH 06/12] Update eip-2035.md --- EIPS/eip-2035.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-2035.md b/EIPS/eip-2035.md index eeffd6f75c580..a04fd49d21026 100644 --- a/EIPS/eip-2035.md +++ b/EIPS/eip-2035.md @@ -19,7 +19,7 @@ headers and block bodies, as explained [here](https://medium.com/@akhounov/data- ## Abstract It is part of the State Rent roadmap. This particular change prepares Ethereum for introduction of the block proofs (current understanding is that they -can be introuced without a hard fork). The introductio of the block proofs allows any Ethereum node that wishes to receive them, to process transactions +can be introuced without a hard fork). The introduction of the block proofs allows any Ethereum node that wishes to receive them, to process transactions in the blocks without needing to access the Ethereum state. All necessary information for the execution (and the proof of validity) is contined in the block proofs. In most Ethereum nodes, it will speed up the block processing and reduce the memory footprint of such processing. For mining nodes, however, there will be more work to do to construct and transmit the block proofs. Therefore, the extra charge (payable to the miners) is introduced. In the first From 76ece359ecec2feb51571adb114cf5378d4af566 Mon Sep 17 00:00:00 2001 From: ledgerwatch Date: Sat, 18 May 2019 07:29:21 +0100 Subject: [PATCH 07/12] Update eip-2035.md --- EIPS/eip-2035.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-2035.md b/EIPS/eip-2035.md index a04fd49d21026..44c9a36597adc 100644 --- a/EIPS/eip-2035.md +++ b/EIPS/eip-2035.md @@ -1,6 +1,6 @@ --- eip: 2035 -title: Stateless Clients: Repricing SLOAD and SSTORE to pay for block proofs +title: Stateless Clients - Repricing SLOAD and SSTORE to pay for block proofs author: Alexey Akhunov (@AlexeyAkhunov) discussions-to: https://ethereum-magicians.org/t/eip-2035-stateless-clients-repricing-sload-and-sstore-to-pay-for-block-proofs/3284 status: Draft From 1b0e87100d19457bfc0df1c8acba4b1ce2ea1dda Mon Sep 17 00:00:00 2001 From: ledgerwatch Date: Thu, 23 May 2019 08:00:08 +0100 Subject: [PATCH 08/12] Update eip-2035.md --- EIPS/eip-2035.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/EIPS/eip-2035.md b/EIPS/eip-2035.md index 44c9a36597adc..ca5c4264e5ae9 100644 --- a/EIPS/eip-2035.md +++ b/EIPS/eip-2035.md @@ -35,7 +35,7 @@ analysis, `SSTORE` is not considered, because its effect on the database accesse the block. Stateless clients approach to the contract storage will largely negate that latency because no database accesses will be required. Instead, bandwidth consumption goes up. There is emprical analysis (unpublished, but will be) suggesting that 1 uncached `SSTORE` or `SLOAD` adds at most 1 kB to the block proofs. At the current cost of data transmission (68 gas per byte), this translates to the increase of gas cost of both -operations by 69k gas. However, in light of proposal in EIP-2028 (link will be provided when EIP is merged), the increase can be made much smaller. +operations by 69k gas. However, in light of proposal in EIP-2028 (https://eips.ethereum.org/EIPS/eip-2028), the increase can be made much smaller. ## Specification @@ -47,7 +47,7 @@ depending on the size of the contract storage, i.e. `SLOAD` and `SSTORE` for sma ## Rationale -[EIP-1884](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1884.md) seeks to increase the gas cost of `SLOAD` but using a different justification +[EIP-1884](https://eips.ethereum.org/EIPS/eip-1884) seeks to increase the gas cost of `SLOAD` but using a different justification (latency of the execution as described in the Motivation). This EIP is likely to increase the cost of `SLOAD` by a larger amount, therefore partially (because EIP-1884 also proposed other increases) supersedes EIP-1884. @@ -62,7 +62,7 @@ However, this approach is likely to be very expensive on the non-technical (ecos This change is not backwards compatible and requires hard fork to be activated. There might also be an adverse effect of this change on the already deployed contract. It is expected that after this EIP and -EIP-2026 (rent prepayment for accounts), the recommendation will be made to raise the gas limit. This can somewhat dampen the +EIP-2026 (rent prepayment for accounts, https://github.com/ethereum/EIPs/pull/2026), the recommendation will be made to raise the gas limit. This can somewhat dampen the adverse effect of EIP. The most problematic cases would be with the contracts that assume certain gas costs of `SLOAD` and `SSTORE` and hard-code them in their internal gas computations. For others, the cost of interacting with the contract storage will rise and may make some dApps based on such interactions, non-viable. This is a trade off to avoid even bigger From 7f206061fbccabd033a6421958ee65e6405e9dce Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Thu, 23 May 2019 23:24:04 +0100 Subject: [PATCH 09/12] Fix typos --- EIPS/eip-2035.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/EIPS/eip-2035.md b/EIPS/eip-2035.md index ca5c4264e5ae9..0225d15aba820 100644 --- a/EIPS/eip-2035.md +++ b/EIPS/eip-2035.md @@ -13,14 +13,14 @@ created: 2019-05-16 ## Simple Summary -The gas cost of EVM opcodes `SLOAD` and `SSTORE` increases in order to accommodate extra bandwith required to propagate block proof together with the block +The gas cost of EVM opcodes `SLOAD` and `SSTORE` increases in order to accommodate extra bandwidth required to propagate block proof together with the block headers and block bodies, as explained [here](https://medium.com/@akhounov/data-from-the-ethereum-stateless-prototype-8c69479c8abc). ## Abstract It is part of the State Rent roadmap. This particular change prepares Ethereum for introduction of the block proofs (current understanding is that they can be introuced without a hard fork). The introduction of the block proofs allows any Ethereum node that wishes to receive them, to process transactions -in the blocks without needing to access the Ethereum state. All necessary information for the execution (and the proof of validity) is contined in the +in the blocks without needing to access the Ethereum state. All necessary information for the execution (and the proof of validity) is continued in the block proofs. In most Ethereum nodes, it will speed up the block processing and reduce the memory footprint of such processing. For mining nodes, however, there will be more work to do to construct and transmit the block proofs. Therefore, the extra charge (payable to the miners) is introduced. In the first phase, only contract storage will be covered by the block proofs. It means that the Ethereum nodes will still need access to the accounts in the state, @@ -42,7 +42,7 @@ operations by 69k gas. However, in light of proposal in EIP-2028 (https://eips.e Not very formal at the moment, but will be formalised with more research and prototyping. Gas of operations `SLOAD` and `SSTORE` increases by `X` gas for those operations that access storage slots that were not previously accessed during the same transaction. -Future variant (will be possible after the implentation of the *Gross contract size acccounting*) is researched, where the increase is varied +Future variant (will be possible after the implementation of the *Gross contract size acccounting*) is researched, where the increase is varied depending on the size of the contract storage, i.e. `SLOAD` and `SSTORE` for smaller contracts will be cheaper. ## Rationale From 4c9c03f15812747d5f36b9f61f91274bde62f657 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Thu, 23 May 2019 23:25:35 +0100 Subject: [PATCH 10/12] Use canonical links to other EIPs --- EIPS/eip-2035.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/EIPS/eip-2035.md b/EIPS/eip-2035.md index 0225d15aba820..67d171e2a2546 100644 --- a/EIPS/eip-2035.md +++ b/EIPS/eip-2035.md @@ -51,7 +51,7 @@ depending on the size of the contract storage, i.e. `SLOAD` and `SSTORE` for sma (latency of the execution as described in the Motivation). This EIP is likely to increase the cost of `SLOAD` by a larger amount, therefore partially (because EIP-1884 also proposed other increases) supersedes EIP-1884. -EIP-2028 (link will be provided when EIP is merged) describes the model that can be used for deciding the gas cost of data transmission. It is relevant +[EIP-2028](https://eips.ethereum.org/EIPS/eip-2028) describes the model that can be used for deciding the gas cost of data transmission. It is relevant because in the stateless client regime `SSTORE` and `SLOAD` operations add more data to be transmitted (as well as computation to verify the proofs). The main alternate design is the rent proportional to the size of the contract storage, which unfortunately introduces a serious griefing @@ -62,7 +62,7 @@ However, this approach is likely to be very expensive on the non-technical (ecos This change is not backwards compatible and requires hard fork to be activated. There might also be an adverse effect of this change on the already deployed contract. It is expected that after this EIP and -EIP-2026 (rent prepayment for accounts, https://github.com/ethereum/EIPs/pull/2026), the recommendation will be made to raise the gas limit. This can somewhat dampen the +[EIP-2026](https://eips.ethereum.org/EIPS/eip-2026) (rent prepayment for accounts), the recommendation will be made to raise the gas limit. This can somewhat dampen the adverse effect of EIP. The most problematic cases would be with the contracts that assume certain gas costs of `SLOAD` and `SSTORE` and hard-code them in their internal gas computations. For others, the cost of interacting with the contract storage will rise and may make some dApps based on such interactions, non-viable. This is a trade off to avoid even bigger From 3ae65de9e5ee1775e07a6842f8e8d6bfbe00d15c Mon Sep 17 00:00:00 2001 From: ledgerwatch Date: Fri, 24 May 2019 07:24:18 +0100 Subject: [PATCH 11/12] Update eip-2035.md --- EIPS/eip-2035.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/EIPS/eip-2035.md b/EIPS/eip-2035.md index 67d171e2a2546..1a10768a826ed 100644 --- a/EIPS/eip-2035.md +++ b/EIPS/eip-2035.md @@ -39,8 +39,7 @@ operations by 69k gas. However, in light of proposal in EIP-2028 (https://eips.e ## Specification -Not very formal at the moment, but will be formalised with more research and prototyping. Gas of operations `SLOAD` and `SSTORE` increases by `X` gas -for those operations that access storage slots that were not previously accessed during the same transaction. +Not very formal at the moment, but will be formalised with more research and prototyping. Gas of operations `SLOAD` and `SSTORE` increases by `X` gas when the storage slots accessed (read by `SLOAD` or written by `SSTORE`) were not previously accessed (by another `SLOAD` or `SSTORE`) during the same transaction. Future variant (will be possible after the implementation of the *Gross contract size acccounting*) is researched, where the increase is varied depending on the size of the contract storage, i.e. `SLOAD` and `SSTORE` for smaller contracts will be cheaper. From 79ebb3ff30e8df714523e00a0858aae8869ca6bd Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Fri, 24 May 2019 11:11:07 +0100 Subject: [PATCH 12/12] Fix link to EIP-2028 --- EIPS/eip-2035.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-2035.md b/EIPS/eip-2035.md index 1a10768a826ed..6b0eac7f5866a 100644 --- a/EIPS/eip-2035.md +++ b/EIPS/eip-2035.md @@ -35,7 +35,7 @@ analysis, `SSTORE` is not considered, because its effect on the database accesse the block. Stateless clients approach to the contract storage will largely negate that latency because no database accesses will be required. Instead, bandwidth consumption goes up. There is emprical analysis (unpublished, but will be) suggesting that 1 uncached `SSTORE` or `SLOAD` adds at most 1 kB to the block proofs. At the current cost of data transmission (68 gas per byte), this translates to the increase of gas cost of both -operations by 69k gas. However, in light of proposal in EIP-2028 (https://eips.ethereum.org/EIPS/eip-2028), the increase can be made much smaller. +operations by 69k gas. However, in light of proposal in [EIP-2028](https://eips.ethereum.org/EIPS/eip-2028), the increase can be made much smaller. ## Specification