From cff11daf06ce709e9778252a5d210295e4cd492b Mon Sep 17 00:00:00 2001 From: vbuterin Date: Fri, 10 Feb 2017 14:39:33 -0500 Subject: [PATCH 01/12] Create blockhash_refactoring.md Stores blockhashes in the state, reducing the protocol complexity and the need for client implementation complexity in order to process the BLOCKHASH opcode. Also extends the range of how far back blockhash checking can go, with the side effect of creating direct links between blocks with very distant block numbers, facilitating much more efficient initial light client syncing. --- EIPS/blockhash_refactoring.md | 86 +++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 EIPS/blockhash_refactoring.md diff --git a/EIPS/blockhash_refactoring.md b/EIPS/blockhash_refactoring.md new file mode 100644 index 0000000000000..468bb0ef2da03 --- /dev/null +++ b/EIPS/blockhash_refactoring.md @@ -0,0 +1,86 @@ +### Preamble + + EIP: + Title: Blockhash refactoring + Author: Vitalik Buterin + Type: Standard Track + Category: Core + Status: Draft + Created: 2017-02-10 + +### Summary + +Stores blockhashes in the state, reducing the protocol complexity and the need for client implementation complexity in order to process the BLOCKHASH opcode. Also extends the range of how far back blockhash checking can go, with the side effect of creating direct links between blocks with very distant block numbers, facilitating much more efficient initial light client syncing. + +### Parameters + +* `METROPOLIS_FORK_BLKNUM`: TBD +* `SUPER_USER`: 2**160 - 2 +* `BLOCKHASH_CONTRACT_ADDR`: 0xf0 (ie. 240) +* `BLOCKHASH_CONTRACT_CODE`: see below + +### Specification + +If `block.number == METROPOLIS_FORK_BLKNUM`, then when processing the block, before processing any transactions set the code of BLOCKHASH_CONTRACT_ADDR to BLOCKHASH_CONTRACT_CODE. + +If `block.number >= METROPOLIS_FORK_BLKNUM`, then when processing a block, before processing any transactions execute a call with the parameters: + +* `SENDER`: SUPER_USER +* `GAS`: 1000000 +* `TO`: BLOCKHASH_CONTRACT_ADDR +* `VALUE`: 0 +* `DATA`: <32 bytes corresponding to the block's prevhash> + +If `block.number >= METROPOLIS_FORK_BLKNUM + 256`, then the BLOCKHASH opcode instead returns the result of executing a call with the parameters: + +* `SENDER`: +* `GAS`: 1000000 +* `TO`: BLOCKHASH_CONTRACT_ADDR +* `VALUE`: 0 +* `DATA`: 32 byte zero-byte-leftpadded integer representing the stack argument with which the opcode was called + +Also, the gas cost is increased from 20 to 350 to reflect the higher costs of processing the algorithm in the contract code. + +### BLOCKHASH_CONTRACT_CODE + +BLOCKHASH_CONTRACT_CODE is set to the compile output of the following Serpent code: + +```python +if msg.sender == {SUPERUSER}: + prevblock_number = block.number - 1 + ~sstore(prevblock_number % 256, ~calldataload(0)) + if prevblock_number % 256 == 0: + ~sstore(256 + (prevblock_number / 256) % 256, ~calldataload(0)) + if prevblock_number % 65536 == 0: + ~sstore(512 + (prevblock_number / 65536) % 256, ~calldataload(0)) +else: + if ~calldataload(0) >= block.number or ~calldataload(0) < {METROPOLIS_FORK_BLKNUM}: + return 0 + if block.number - ~calldataload(0) >= 256: + return ~sload(~calldataload(0) % 256) + elif block.number - ~calldataload(0) >= 65536 and ~calldataload(0) % 256 == 0: + return ~sload(256 + (~calldataload(0) / 256) % 256) + elif block.number - ~calldataload(0) >= 16777216 and ~calldataload(0) % 65536 == 0: + return ~sload(512 + (~calldataload(0) / 65536) % 256) + else: + return 0 + +``` + +### Rationale + +This removes the need for implementaitons to have an explicit way to look into historical block hashes, simplifying the protocol definition and removing a large component of the "implied state" (information that is technically state but is not part of the state tree) and thereby making the protocol more "pure". Additionally, it allows blocks to directly point to blocks far behind them, which enables extremely efficient and secure light client protocols. + +### Description of light client protocol + +We can define a "probabilistic total-difficulty proof" as an RLP list as follows: + + [header1, proof1, header2, proof2, ...] + +Where each header is a block header, and each proof[i] is a Merkle branch from header[i] to the hash of header[i + 1]. More formally, the proof is an RLP list where each element contains as a substring the hash of the next element, and the last element is the hash of the next header; the elements are taken from the branch of the state tree in header[i] that points to the hash of header[i + 1] that is available in the storage of the BLOCKHASH_CONTRACT_ADDR. + +The proof serves to verify that the headers are linked to each other in the given order, and that the given chain has an approximate total difficulty equal to `sum(2 ** 256 / mining_result[i])` where `mining_result[i]` is the result of running the ethash verification function on the given header. A node producing a proof will take case to create a proof that contains as many low-mining-result blocks as possible; a specific algorithm would be to look for all "key blocks" whose mining result is less than 1/50000 of maximum for a valid block allowed by the most recent block difficulty, and then if these blocks do not have a direct connection because they are not an even multiple of 256 or 65536 apart, it would find "glue blocks" to link between them; for example, linking 3904322 to 3712498 might go through 3735552 (multiple of 65536, directly linked in 3904322) and 3712512 (multiple of 256, directly linked in 3735552), and finally 3712512 links directly to 3712498. + +For a chain 1 million blocks long, such an algorithm would find 20 key blocks, of which ~1% require zero glue blocks, ~72% require one glue block and ~27% require two glue blocks, so a total sub-chain of ~45 blocks. Each header is ~500 bytes, and each proof will be another ~1500 bytes, so the total size would be ~90 KB. + +TODO: provide the algorithm by which a light client would use these proofs to authenticate the chain, and exactly how it would switch between asking for probabilistic proofs and simply asking for the most recent blocks in the chain from a particular point that already has been probabilistically proven. From 600b28fb1cb2b496fbbbe73b346e5f8b3ee9470f Mon Sep 17 00:00:00 2001 From: vbuterin Date: Sat, 11 Feb 2017 05:34:37 -0500 Subject: [PATCH 02/12] Update blockhash_refactoring.md --- EIPS/blockhash_refactoring.md | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/EIPS/blockhash_refactoring.md b/EIPS/blockhash_refactoring.md index 468bb0ef2da03..eb7a25ed668f1 100644 --- a/EIPS/blockhash_refactoring.md +++ b/EIPS/blockhash_refactoring.md @@ -70,17 +70,3 @@ else: ### Rationale This removes the need for implementaitons to have an explicit way to look into historical block hashes, simplifying the protocol definition and removing a large component of the "implied state" (information that is technically state but is not part of the state tree) and thereby making the protocol more "pure". Additionally, it allows blocks to directly point to blocks far behind them, which enables extremely efficient and secure light client protocols. - -### Description of light client protocol - -We can define a "probabilistic total-difficulty proof" as an RLP list as follows: - - [header1, proof1, header2, proof2, ...] - -Where each header is a block header, and each proof[i] is a Merkle branch from header[i] to the hash of header[i + 1]. More formally, the proof is an RLP list where each element contains as a substring the hash of the next element, and the last element is the hash of the next header; the elements are taken from the branch of the state tree in header[i] that points to the hash of header[i + 1] that is available in the storage of the BLOCKHASH_CONTRACT_ADDR. - -The proof serves to verify that the headers are linked to each other in the given order, and that the given chain has an approximate total difficulty equal to `sum(2 ** 256 / mining_result[i])` where `mining_result[i]` is the result of running the ethash verification function on the given header. A node producing a proof will take case to create a proof that contains as many low-mining-result blocks as possible; a specific algorithm would be to look for all "key blocks" whose mining result is less than 1/50000 of maximum for a valid block allowed by the most recent block difficulty, and then if these blocks do not have a direct connection because they are not an even multiple of 256 or 65536 apart, it would find "glue blocks" to link between them; for example, linking 3904322 to 3712498 might go through 3735552 (multiple of 65536, directly linked in 3904322) and 3712512 (multiple of 256, directly linked in 3735552), and finally 3712512 links directly to 3712498. - -For a chain 1 million blocks long, such an algorithm would find 20 key blocks, of which ~1% require zero glue blocks, ~72% require one glue block and ~27% require two glue blocks, so a total sub-chain of ~45 blocks. Each header is ~500 bytes, and each proof will be another ~1500 bytes, so the total size would be ~90 KB. - -TODO: provide the algorithm by which a light client would use these proofs to authenticate the chain, and exactly how it would switch between asking for probabilistic proofs and simply asking for the most recent blocks in the chain from a particular point that already has been probabilistically proven. From cebb3e220c62b9fbe896b474391c3e26c380082c Mon Sep 17 00:00:00 2001 From: vbuterin Date: Wed, 26 Apr 2017 05:04:58 -0400 Subject: [PATCH 03/12] Update blockhash_refactoring.md --- EIPS/blockhash_refactoring.md | 52 +++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/EIPS/blockhash_refactoring.md b/EIPS/blockhash_refactoring.md index eb7a25ed668f1..6e902fdfc14a9 100644 --- a/EIPS/blockhash_refactoring.md +++ b/EIPS/blockhash_refactoring.md @@ -23,7 +23,7 @@ Stores blockhashes in the state, reducing the protocol complexity and the need f If `block.number == METROPOLIS_FORK_BLKNUM`, then when processing the block, before processing any transactions set the code of BLOCKHASH_CONTRACT_ADDR to BLOCKHASH_CONTRACT_CODE. -If `block.number >= METROPOLIS_FORK_BLKNUM`, then when processing a block, before processing any transactions execute a call with the parameters: +If `block.number >= METROPOLIS_FORK_BLKNUM + 256`, then when processing a block, before processing any transactions execute a call with the parameters: * `SENDER`: SUPER_USER * `GAS`: 1000000 @@ -39,32 +39,44 @@ If `block.number >= METROPOLIS_FORK_BLKNUM + 256`, then the BLOCKHASH opcode ins * `VALUE`: 0 * `DATA`: 32 byte zero-byte-leftpadded integer representing the stack argument with which the opcode was called -Also, the gas cost is increased from 20 to 350 to reflect the higher costs of processing the algorithm in the contract code. +Also, the gas cost is increased from 20 to 800 to reflect the higher costs of processing the algorithm in the contract code. ### BLOCKHASH_CONTRACT_CODE -BLOCKHASH_CONTRACT_CODE is set to the compile output of the following Serpent code: +BLOCKHASH_CONTRACT_CODE is set to: + +``` +0x73fffffffffffffffffffffffffffffffffffffffe33141561006a5760014303600035610100820755610100810715156100455760003561010061010083050761010001555b6201000081071515610064576000356101006201000083050761020001555b50610146565b4360003512151561008457600060405260206040f3610145565b61010060003543031315156100a857610100600035075460605260206060f3610144565b6101006000350715156100c55762010000600035430313156100c8565b60005b156100ea576101006101006000350507610100015460805260206080f3610143565b620100006000350715156101095763010000006000354303131561010c565b60005b1561012f57610100620100006000350507610200015460a052602060a0f3610142565b6000610100600035071460c052602060c0f35b5b5b5b5b +``` + +The Serpent source code is: ```python -if msg.sender == {SUPERUSER}: - prevblock_number = block.number - 1 - ~sstore(prevblock_number % 256, ~calldataload(0)) - if prevblock_number % 256 == 0: - ~sstore(256 + (prevblock_number / 256) % 256, ~calldataload(0)) - if prevblock_number % 65536 == 0: - ~sstore(512 + (prevblock_number / 65536) % 256, ~calldataload(0)) +# Setting the block hash +if msg.sender == 2**160 - 2: + with prev_block_number = block.number - 1: + # Use storage fields 0..255 to store the last 256 hashes + ~sstore(prev_block_number % 256, ~calldataload(0)) + # Use storage fields 256..511 to store the hashes of the last 256 + # blocks with block.number % 256 == 0 + if not (prev_block_number % 256): + ~sstore(256 + (prev_block_number / 256) % 256, ~calldataload(0)) + # Use storage fields 512..767 to store the hashes of the last 256 + # blocks with block.number % 65536 == 0 + if not (prev_block_number % 65536): + ~sstore(512 + (prev_block_number / 65536) % 256, ~calldataload(0)) +# Getting the block hash else: - if ~calldataload(0) >= block.number or ~calldataload(0) < {METROPOLIS_FORK_BLKNUM}: - return 0 - if block.number - ~calldataload(0) >= 256: - return ~sload(~calldataload(0) % 256) - elif block.number - ~calldataload(0) >= 65536 and ~calldataload(0) % 256 == 0: - return ~sload(256 + (~calldataload(0) / 256) % 256) - elif block.number - ~calldataload(0) >= 16777216 and ~calldataload(0) % 65536 == 0: - return ~sload(512 + (~calldataload(0) / 65536) % 256) + if ~calldataload(0) >= block.number: + return(0) + elif block.number - ~calldataload(0) <= 256: + return(~sload(~calldataload(0) % 256)) + elif (not (~calldataload(0) % 256) and block.number - ~calldataload(0) <= 65536): + return(~sload(256 + (~calldataload(0) / 256) % 256)) + elif (not (~calldataload(0) % 65536) and block.number - ~calldataload(0) <= 16777216): + return(~sload(512 + (~calldataload(0) / 65536) % 256)) else: - return 0 - + return(~calldataload(0) % 256 == 0) ``` ### Rationale From 9df24a3714af42e3bf350265bdc75b486c909d7f Mon Sep 17 00:00:00 2001 From: vbuterin Date: Wed, 26 Apr 2017 05:21:57 -0400 Subject: [PATCH 04/12] Update blockhash_refactoring.md --- EIPS/blockhash_refactoring.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/EIPS/blockhash_refactoring.md b/EIPS/blockhash_refactoring.md index 6e902fdfc14a9..21d19c4365594 100644 --- a/EIPS/blockhash_refactoring.md +++ b/EIPS/blockhash_refactoring.md @@ -46,7 +46,7 @@ Also, the gas cost is increased from 20 to 800 to reflect the higher costs of pr BLOCKHASH_CONTRACT_CODE is set to: ``` -0x73fffffffffffffffffffffffffffffffffffffffe33141561006a5760014303600035610100820755610100810715156100455760003561010061010083050761010001555b6201000081071515610064576000356101006201000083050761020001555b50610146565b4360003512151561008457600060405260206040f3610145565b61010060003543031315156100a857610100600035075460605260206060f3610144565b6101006000350715156100c55762010000600035430313156100c8565b60005b156100ea576101006101006000350507610100015460805260206080f3610143565b620100006000350715156101095763010000006000354303131561010c565b60005b1561012f57610100620100006000350507610200015460a052602060a0f3610142565b6000610100600035071460c052602060c0f35b5b5b5b5b +0x73fffffffffffffffffffffffffffffffffffffffe33141561006a5760014303600035610100820755610100810715156100455760003561010061010083050761010001555b6201000081071515610064576000356101006201000083050761020001555b5061013e565b4360003512151561008457600060405260206040f361013d565b61010060003543031315156100a857610100600035075460605260206060f361013c565b6101006000350715156100c55762010000600035430313156100c8565b60005b156100ea576101006101006000350507610100015460805260206080f361013b565b620100006000350715156101095763010000006000354303131561010c565b60005b1561012f57610100620100006000350507610200015460a052602060a0f361013a565b600060c052602060c0f35b5b5b5b5b ``` The Serpent source code is: @@ -76,7 +76,7 @@ else: elif (not (~calldataload(0) % 65536) and block.number - ~calldataload(0) <= 16777216): return(~sload(512 + (~calldataload(0) / 65536) % 256)) else: - return(~calldataload(0) % 256 == 0) + return(0) ``` ### Rationale From ea4930e5cf7d9c152becab9885ac75a18ff74508 Mon Sep 17 00:00:00 2001 From: vbuterin Date: Wed, 26 Apr 2017 05:24:02 -0400 Subject: [PATCH 05/12] Update blockhash_refactoring.md --- EIPS/blockhash_refactoring.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/blockhash_refactoring.md b/EIPS/blockhash_refactoring.md index 21d19c4365594..acb05c802e8c0 100644 --- a/EIPS/blockhash_refactoring.md +++ b/EIPS/blockhash_refactoring.md @@ -23,7 +23,7 @@ Stores blockhashes in the state, reducing the protocol complexity and the need f If `block.number == METROPOLIS_FORK_BLKNUM`, then when processing the block, before processing any transactions set the code of BLOCKHASH_CONTRACT_ADDR to BLOCKHASH_CONTRACT_CODE. -If `block.number >= METROPOLIS_FORK_BLKNUM + 256`, then when processing a block, before processing any transactions execute a call with the parameters: +If `block.number >= METROPOLIS_FORK_BLKNUM`, then when processing a block, before processing any transactions execute a call with the parameters: * `SENDER`: SUPER_USER * `GAS`: 1000000 From 14e8a35a9ff7294db1cf1195144f3f834e0670b4 Mon Sep 17 00:00:00 2001 From: vbuterin Date: Fri, 19 May 2017 10:39:11 -0400 Subject: [PATCH 06/12] Update blockhash_refactoring.md --- EIPS/blockhash_refactoring.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/blockhash_refactoring.md b/EIPS/blockhash_refactoring.md index acb05c802e8c0..9676f928c2e6b 100644 --- a/EIPS/blockhash_refactoring.md +++ b/EIPS/blockhash_refactoring.md @@ -39,7 +39,7 @@ If `block.number >= METROPOLIS_FORK_BLKNUM + 256`, then the BLOCKHASH opcode ins * `VALUE`: 0 * `DATA`: 32 byte zero-byte-leftpadded integer representing the stack argument with which the opcode was called -Also, the gas cost is increased from 20 to 800 to reflect the higher costs of processing the algorithm in the contract code. +Also, for blocks where `block.number >= METROPOLIS_FORK_BLKNUM`, the gas cost is increased from 20 to 800 to reflect the higher costs of processing the algorithm in the contract code. ### BLOCKHASH_CONTRACT_CODE From f271d17065d5e7c8bbdf53e05dffd52cfe73a91f Mon Sep 17 00:00:00 2001 From: vbuterin Date: Fri, 19 May 2017 10:41:23 -0400 Subject: [PATCH 07/12] Update blockhash_refactoring.md --- EIPS/blockhash_refactoring.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/blockhash_refactoring.md b/EIPS/blockhash_refactoring.md index 9676f928c2e6b..35d3cc1faf651 100644 --- a/EIPS/blockhash_refactoring.md +++ b/EIPS/blockhash_refactoring.md @@ -31,7 +31,7 @@ If `block.number >= METROPOLIS_FORK_BLKNUM`, then when processing a block, befor * `VALUE`: 0 * `DATA`: <32 bytes corresponding to the block's prevhash> -If `block.number >= METROPOLIS_FORK_BLKNUM + 256`, then the BLOCKHASH opcode instead returns the result of executing a call with the parameters: +If `block.number >= METROPOLIS_FORK_BLKNUM + 256`, then the BLOCKHASH opcode instead returns the result of executing a call (NOT a transaction) with the parameters: * `SENDER`: * `GAS`: 1000000 From 0fee5457ab66cadf50343833359a9db0b7a656b8 Mon Sep 17 00:00:00 2001 From: vbuterin Date: Mon, 14 Aug 2017 07:32:08 -0500 Subject: [PATCH 08/12] Update blockhash_refactoring.md --- EIPS/blockhash_refactoring.md | 54 ++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/EIPS/blockhash_refactoring.md b/EIPS/blockhash_refactoring.md index 35d3cc1faf651..4d064fab81b23 100644 --- a/EIPS/blockhash_refactoring.md +++ b/EIPS/blockhash_refactoring.md @@ -52,33 +52,41 @@ BLOCKHASH_CONTRACT_CODE is set to: The Serpent source code is: ```python -# Setting the block hash -if msg.sender == 2**160 - 2: - with prev_block_number = block.number - 1: - # Use storage fields 0..255 to store the last 256 hashes - ~sstore(prev_block_number % 256, ~calldataload(0)) - # Use storage fields 256..511 to store the hashes of the last 256 - # blocks with block.number % 256 == 0 - if not (prev_block_number % 256): - ~sstore(256 + (prev_block_number / 256) % 256, ~calldataload(0)) - # Use storage fields 512..767 to store the hashes of the last 256 - # blocks with block.number % 65536 == 0 - if not (prev_block_number % 65536): - ~sstore(512 + (prev_block_number / 65536) % 256, ~calldataload(0)) -# Getting the block hash -else: - if ~calldataload(0) >= block.number: - return(0) - elif block.number - ~calldataload(0) <= 256: - return(~sload(~calldataload(0) % 256)) - elif (not (~calldataload(0) % 256) and block.number - ~calldataload(0) <= 65536): - return(~sload(256 + (~calldataload(0) / 256) % 256)) - elif (not (~calldataload(0) % 65536) and block.number - ~calldataload(0) <= 16777216): - return(~sload(512 + (~calldataload(0) / 65536) % 256)) +with offset = 0: + if msg.sender == 0xfffffffffffffffffffffffffffffffffffffffe: + with bn = block.number - 1: + while 1: + ~sstore(offset + ~mod(bn, 256), ~calldataload(0)) + if ~mod(bn, 256): + ~stop() + bn = ~div(bn, 256) + offset += 256 + elif ~calldataload(0) < block.number: + with tbn = ~calldataload(0): + with dist_minus_one = block.number - tbn - 1: + while dist_minus_one >= 256 && ~mod(tbn, 256) == 0: + offset += 256 + tbn = ~div(tbn, 256) + dist_minus_one = ~div(dist_minus_one, 256) + if dist_minus_one >= 256: + return(0) + return(~sload(offset + ~mod(tbn, 256))) else: return(0) ``` +The EVM init code is: + +``` +0x6100e28061000e6000396100f056600073fffffffffffffffffffffffffffffffffffffffe33141561005957600143035b60011561005357600035610100820683015561010081061561004057005b6101008104905061010082019150610022565b506100e0565b4360003512156100d4576000356001814303035b61010081121515610085576000610100830614610088565b60005b156100a75761010083019250610100820491506101008104905061006d565b610100811215156100bd57600060a052602060a0f35b610100820683015460c052602060c0f350506100df565b600060e052602060e0f35b5b505b6000f3 +``` + +The EVM bytecode for the contract is: + +``` +0x600073fffffffffffffffffffffffffffffffffffffffe33141561005957600143035b60011561005357600035610100820683015561010081061561004057005b6101008104905061010082019150610022565b506100e0565b4360003512156100d4576000356001814303035b61010081121515610085576000610100830614610088565b60005b156100a75761010083019250610100820491506101008104905061006d565b610100811215156100bd57600060a052602060a0f35b610100820683015460c052602060c0f350506100df565b600060e052602060e0f35b5b50 +``` + ### Rationale This removes the need for implementaitons to have an explicit way to look into historical block hashes, simplifying the protocol definition and removing a large component of the "implied state" (information that is technically state but is not part of the state tree) and thereby making the protocol more "pure". Additionally, it allows blocks to directly point to blocks far behind them, which enables extremely efficient and secure light client protocols. From 2f8d0f5e6192a0fb236ffb3c1b95f5fea871270e Mon Sep 17 00:00:00 2001 From: vbuterin Date: Fri, 8 Sep 2017 16:07:31 +0200 Subject: [PATCH 09/12] Update blockhash_refactoring.md --- EIPS/blockhash_refactoring.md | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/EIPS/blockhash_refactoring.md b/EIPS/blockhash_refactoring.md index 4d064fab81b23..d8ef56d30c56a 100644 --- a/EIPS/blockhash_refactoring.md +++ b/EIPS/blockhash_refactoring.md @@ -43,12 +43,6 @@ Also, for blocks where `block.number >= METROPOLIS_FORK_BLKNUM`, the gas cost is ### BLOCKHASH_CONTRACT_CODE -BLOCKHASH_CONTRACT_CODE is set to: - -``` -0x73fffffffffffffffffffffffffffffffffffffffe33141561006a5760014303600035610100820755610100810715156100455760003561010061010083050761010001555b6201000081071515610064576000356101006201000083050761020001555b5061013e565b4360003512151561008457600060405260206040f361013d565b61010060003543031315156100a857610100600035075460605260206060f361013c565b6101006000350715156100c55762010000600035430313156100c8565b60005b156100ea576101006101006000350507610100015460805260206080f361013b565b620100006000350715156101095763010000006000354303131561010c565b60005b1561012f57610100620100006000350507610200015460a052602060a0f361013a565b600060c052602060c0f35b5b5b5b5b -``` - The Serpent source code is: ```python @@ -81,7 +75,7 @@ The EVM init code is: 0x6100e28061000e6000396100f056600073fffffffffffffffffffffffffffffffffffffffe33141561005957600143035b60011561005357600035610100820683015561010081061561004057005b6101008104905061010082019150610022565b506100e0565b4360003512156100d4576000356001814303035b61010081121515610085576000610100830614610088565b60005b156100a75761010083019250610100820491506101008104905061006d565b610100811215156100bd57600060a052602060a0f35b610100820683015460c052602060c0f350506100df565b600060e052602060e0f35b5b505b6000f3 ``` -The EVM bytecode for the contract is: +The EVM bytecode that the contract code should be set to is: ``` 0x600073fffffffffffffffffffffffffffffffffffffffe33141561005957600143035b60011561005357600035610100820683015561010081061561004057005b6101008104905061010082019150610022565b506100e0565b4360003512156100d4576000356001814303035b61010081121515610085576000610100830614610088565b60005b156100a75761010083019250610100820491506101008104905061006d565b610100811215156100bd57600060a052602060a0f35b610100820683015460c052602060c0f350506100df565b600060e052602060e0f35b5b50 From 4df6564af770c06a26d5c0ae427b90d6a2d986fd Mon Sep 17 00:00:00 2001 From: Nick Johnson Date: Thu, 19 Apr 2018 19:24:21 +0100 Subject: [PATCH 10/12] Update blockhash_refactoring.md --- EIPS/blockhash_refactoring.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/EIPS/blockhash_refactoring.md b/EIPS/blockhash_refactoring.md index d8ef56d30c56a..19dd5187c856a 100644 --- a/EIPS/blockhash_refactoring.md +++ b/EIPS/blockhash_refactoring.md @@ -1,13 +1,13 @@ -### Preamble - - EIP: - Title: Blockhash refactoring - Author: Vitalik Buterin - Type: Standard Track - Category: Core - Status: Draft - Created: 2017-02-10 - +--- +eip: 210 +title: Blockhash refactoring +author: Vitalik Buterin (@vbuterin) +type: Standards Track +category: core +status: Draft +created: 2017-02-10 +--- + ### Summary Stores blockhashes in the state, reducing the protocol complexity and the need for client implementation complexity in order to process the BLOCKHASH opcode. Also extends the range of how far back blockhash checking can go, with the side effect of creating direct links between blocks with very distant block numbers, facilitating much more efficient initial light client syncing. From bce69eb72584e5c674788ae6f5b8769b4a77e491 Mon Sep 17 00:00:00 2001 From: Nick Johnson Date: Thu, 19 Apr 2018 19:25:11 +0100 Subject: [PATCH 11/12] Update blockhash_refactoring.md --- EIPS/blockhash_refactoring.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/EIPS/blockhash_refactoring.md b/EIPS/blockhash_refactoring.md index 19dd5187c856a..2d3e7bf011876 100644 --- a/EIPS/blockhash_refactoring.md +++ b/EIPS/blockhash_refactoring.md @@ -14,16 +14,16 @@ Stores blockhashes in the state, reducing the protocol complexity and the need f ### Parameters -* `METROPOLIS_FORK_BLKNUM`: TBD +* `CONSTANTINOPLE_FORK_BLKNUM`: TBD * `SUPER_USER`: 2**160 - 2 * `BLOCKHASH_CONTRACT_ADDR`: 0xf0 (ie. 240) * `BLOCKHASH_CONTRACT_CODE`: see below ### Specification -If `block.number == METROPOLIS_FORK_BLKNUM`, then when processing the block, before processing any transactions set the code of BLOCKHASH_CONTRACT_ADDR to BLOCKHASH_CONTRACT_CODE. +If `block.number == CONSTANTINOPLE_FORK_BLKNUM`, then when processing the block, before processing any transactions set the code of BLOCKHASH_CONTRACT_ADDR to BLOCKHASH_CONTRACT_CODE. -If `block.number >= METROPOLIS_FORK_BLKNUM`, then when processing a block, before processing any transactions execute a call with the parameters: +If `block.number >= CONSTANTINOPLE_FORK_BLKNUM`, then when processing a block, before processing any transactions execute a call with the parameters: * `SENDER`: SUPER_USER * `GAS`: 1000000 @@ -31,7 +31,7 @@ If `block.number >= METROPOLIS_FORK_BLKNUM`, then when processing a block, befor * `VALUE`: 0 * `DATA`: <32 bytes corresponding to the block's prevhash> -If `block.number >= METROPOLIS_FORK_BLKNUM + 256`, then the BLOCKHASH opcode instead returns the result of executing a call (NOT a transaction) with the parameters: +If `block.number >= CONSTANTINOPLE_FORK_BLKNUM + 256`, then the BLOCKHASH opcode instead returns the result of executing a call (NOT a transaction) with the parameters: * `SENDER`: * `GAS`: 1000000 @@ -39,7 +39,7 @@ If `block.number >= METROPOLIS_FORK_BLKNUM + 256`, then the BLOCKHASH opcode ins * `VALUE`: 0 * `DATA`: 32 byte zero-byte-leftpadded integer representing the stack argument with which the opcode was called -Also, for blocks where `block.number >= METROPOLIS_FORK_BLKNUM`, the gas cost is increased from 20 to 800 to reflect the higher costs of processing the algorithm in the contract code. +Also, for blocks where `block.number >= CONSTANTINOPLE_FORK_BLKNUM`, the gas cost is increased from 20 to 800 to reflect the higher costs of processing the algorithm in the contract code. ### BLOCKHASH_CONTRACT_CODE From 028099fade9dad019b4be746de1c6bffb398fb3b Mon Sep 17 00:00:00 2001 From: Nick Johnson Date: Thu, 19 Apr 2018 19:25:55 +0100 Subject: [PATCH 12/12] Rename blockhash_refactoring.md to eip-210.md --- EIPS/{blockhash_refactoring.md => eip-210.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename EIPS/{blockhash_refactoring.md => eip-210.md} (100%) diff --git a/EIPS/blockhash_refactoring.md b/EIPS/eip-210.md similarity index 100% rename from EIPS/blockhash_refactoring.md rename to EIPS/eip-210.md