Andrew Miller's Sep 2015 Serpent blockhash oracle: stores block-number-to-blockhash mappings beyond the EVM's 256-block BLOCKHASH window.
Key Facts
Description
A Serpent contract by Andrew Miller (github.com/amiller/ethereum-blockhashes) that keeps a permanent mapping from block number to blockhash, working around the 256-block limit of block.blockhash that had broken Etherpot. add_recent(n) stores a hash still visible to the EVM; add_old(header, n) proves an older block by checking that sha3(header) equals the stored hash of its child, then stores the parent hash read from the header. This is the live instance deployed by Kobi Gurk on 2015-09-04 and linked from the project README; it matches kobigurk/ethereum-blockhashes commit c4b5f33 exactly (runtime and creation), which adds get_blockhash_from_storage(n).
Source Verified
Exact runtime and creation match, ethereum/serpent f67c1a9 (also 6faaebb, a7716d3, fd9b0b6). Source blockhashes_kobigurk_c4b5f33.se, unmodified.
Heuristic Analysis
The following characteristics were detected through bytecode analysis and may not be accurate.
Frontier Era
The initial release of Ethereum. A bare-bones implementation for technical users.
Bytecode Overview
Verified Source Available
Source verified through compiler archaeology and exact bytecode matching.
View Verification ProofShow source code (Serpent)
event Error(x:str)
# Add one of the most recent 256 blocks
def add_recent(n):
h = block.prevhash(block.number - n)
if h == 0:
log(type=Error, text("block.prevhash failed"))
else:
self.storage[n] = h
# Add a block at any height, as long as we have the child
def add_old(header:str, n):
with h = self.storage[n+1]:
with p = sha3(header:str):
with parent = ~calldataload(72+32): # I don't know how calldataload works
if h - p == 0:
self.storage[n] = parent
else:
log(type=Error, text("sha3 hash does not match"))
# Returns the blockhash, or 0
def get_blockhash(n):
h = block.prevhash(block.number - n)
if h == 0:
return self.storage[n]
else:
return h
def get_blockhash_from_storage(n):
return self.storage[n]