mirror of https://github.com/status-im/EIPs.git
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.
This commit is contained in:
parent
7ceb961c3e
commit
e58c4d5d60
|
@ -49,13 +49,13 @@ The Serpent source code is:
|
||||||
with offset = 0:
|
with offset = 0:
|
||||||
if msg.sender == 0xfffffffffffffffffffffffffffffffffffffffe:
|
if msg.sender == 0xfffffffffffffffffffffffffffffffffffffffe:
|
||||||
with bn = block.number - 1:
|
with bn = block.number - 1:
|
||||||
while 1:
|
while bn:
|
||||||
~sstore(offset + ~mod(bn, 256), ~calldataload(0))
|
~sstore(offset + ~mod(bn, 256), ~calldataload(0))
|
||||||
if ~mod(bn, 256):
|
if ~mod(bn, 256):
|
||||||
~stop()
|
~stop()
|
||||||
bn = ~div(bn, 256)
|
bn = ~div(bn, 256)
|
||||||
offset += 256
|
offset += 256
|
||||||
elif ~calldataload(0) < block.number:
|
elif ~calldataload(0) >= 0 and ~calldataload(0) < block.number:
|
||||||
with tbn = ~calldataload(0):
|
with tbn = ~calldataload(0):
|
||||||
with dist_minus_one = block.number - tbn - 1:
|
with dist_minus_one = block.number - tbn - 1:
|
||||||
while dist_minus_one >= 256 && ~mod(tbn, 256) == 0:
|
while dist_minus_one >= 256 && ~mod(tbn, 256) == 0:
|
||||||
|
@ -72,13 +72,13 @@ with offset = 0:
|
||||||
The EVM init code is:
|
The EVM init code is:
|
||||||
|
|
||||||
```
|
```
|
||||||
0x6100e28061000e6000396100f056600073fffffffffffffffffffffffffffffffffffffffe33141561005957600143035b60011561005357600035610100820683015561010081061561004057005b6101008104905061010082019150610022565b506100e0565b4360003512156100d4576000356001814303035b61010081121515610085576000610100830614610088565b60005b156100a75761010083019250610100820491506101008104905061006d565b610100811215156100bd57600060a052602060a0f35b610100820683015460c052602060c0f350506100df565b600060e052602060e0f35b5b505b6000f3
|
0x6100f58061000e60003961010356600073fffffffffffffffffffffffffffffffffffffffe33141561005857600143035b801561005257600035610100820683015561010081061561003f57005b6101008104905061010082019150610022565b506100f3565b600060003512151561006e574360003512610071565b60005b156100e7576000356001814303035b6101008112151561009857600061010083061461009b565b60005b156100ba57610100830192506101008204915061010081049050610080565b610100811215156100d057600060a052602060a0f35b610100820683015460c052602060c0f350506100f2565b600060e052602060e0f35b5b505b6000f3
|
||||||
```
|
```
|
||||||
|
|
||||||
The EVM bytecode that the contract code should be set to is:
|
The EVM bytecode that the contract code should be set to is:
|
||||||
|
|
||||||
```
|
```
|
||||||
0x600073fffffffffffffffffffffffffffffffffffffffe33141561005957600143035b60011561005357600035610100820683015561010081061561004057005b6101008104905061010082019150610022565b506100e0565b4360003512156100d4576000356001814303035b61010081121515610085576000610100830614610088565b60005b156100a75761010083019250610100820491506101008104905061006d565b610100811215156100bd57600060a052602060a0f35b610100820683015460c052602060c0f350506100df565b600060e052602060e0f35b5b50
|
0x600073fffffffffffffffffffffffffffffffffffffffe33141561005857600143035b801561005257600035610100820683015561010081061561003f57005b6101008104905061010082019150610022565b506100f3565b600060003512151561006e574360003512610071565b60005b156100e7576000356001814303035b6101008112151561009857600061010083061461009b565b60005b156100ba57610100830192506101008204915061010081049050610080565b610100811215156100d057600060a052602060a0f35b610100820683015460c052602060c0f350506100f2565b600060e052602060e0f35b5b50
|
||||||
```
|
```
|
||||||
|
|
||||||
### Rationale
|
### Rationale
|
||||||
|
|
Loading…
Reference in New Issue