Skip to content

Commit e58c4d5

Browse files
chfastArachnid
authored andcommitted
EIP-210: Fixes for blockhash contracts (#1094)
* EIP-210: Fix blockhash contract for block number 1 This fixes the issue in the contract when executed from SYSTEM account at block 1. Then the number of the previous block is 0 and the contract executes the loop forever. * EIP-210: Correctly handle argument with negative value Fix fixes the issue in the blockhash contract where the negative value of the argument is not properly handled.
1 parent 7ceb961 commit e58c4d5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

EIPS/eip-210.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ The Serpent source code is:
4949
with offset = 0:
5050
if msg.sender == 0xfffffffffffffffffffffffffffffffffffffffe:
5151
with bn = block.number - 1:
52-
while 1:
52+
while bn:
5353
~sstore(offset + ~mod(bn, 256), ~calldataload(0))
5454
if ~mod(bn, 256):
5555
~stop()
5656
bn = ~div(bn, 256)
5757
offset += 256
58-
elif ~calldataload(0) < block.number:
58+
elif ~calldataload(0) >= 0 and ~calldataload(0) < block.number:
5959
with tbn = ~calldataload(0):
6060
with dist_minus_one = block.number - tbn - 1:
6161
while dist_minus_one >= 256 && ~mod(tbn, 256) == 0:
@@ -72,13 +72,13 @@ with offset = 0:
7272
The EVM init code is:
7373

7474
```
75-
0x6100e28061000e6000396100f056600073fffffffffffffffffffffffffffffffffffffffe33141561005957600143035b60011561005357600035610100820683015561010081061561004057005b6101008104905061010082019150610022565b506100e0565b4360003512156100d4576000356001814303035b61010081121515610085576000610100830614610088565b60005b156100a75761010083019250610100820491506101008104905061006d565b610100811215156100bd57600060a052602060a0f35b610100820683015460c052602060c0f350506100df565b600060e052602060e0f35b5b505b6000f3
75+
0x6100f58061000e60003961010356600073fffffffffffffffffffffffffffffffffffffffe33141561005857600143035b801561005257600035610100820683015561010081061561003f57005b6101008104905061010082019150610022565b506100f3565b600060003512151561006e574360003512610071565b60005b156100e7576000356001814303035b6101008112151561009857600061010083061461009b565b60005b156100ba57610100830192506101008204915061010081049050610080565b610100811215156100d057600060a052602060a0f35b610100820683015460c052602060c0f350506100f2565b600060e052602060e0f35b5b505b6000f3
7676
```
7777

7878
The EVM bytecode that the contract code should be set to is:
7979

8080
```
81-
0x600073fffffffffffffffffffffffffffffffffffffffe33141561005957600143035b60011561005357600035610100820683015561010081061561004057005b6101008104905061010082019150610022565b506100e0565b4360003512156100d4576000356001814303035b61010081121515610085576000610100830614610088565b60005b156100a75761010083019250610100820491506101008104905061006d565b610100811215156100bd57600060a052602060a0f35b610100820683015460c052602060c0f350506100df565b600060e052602060e0f35b5b50
81+
0x600073fffffffffffffffffffffffffffffffffffffffe33141561005857600143035b801561005257600035610100820683015561010081061561003f57005b6101008104905061010082019150610022565b506100f3565b600060003512151561006e574360003512610071565b60005b156100e7576000356001814303035b6101008112151561009857600061010083061461009b565b60005b156100ba57610100830192506101008204915061010081049050610080565b610100811215156100d057600060a052602060a0f35b610100820683015460c052602060c0f350506100f2565b600060e052602060e0f35b5b50
8282
```
8383

8484
### Rationale

0 commit comments

Comments
 (0)