Skip to content

Commit

Permalink
Fix ethereum#12 Can bloat contract with a dummy block that has a high…
Browse files Browse the repository at this point in the history
… target
  • Loading branch information
ethers committed Dec 14, 2015
1 parent af400a6 commit 888962e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions btcrelay.se
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,7 @@ def storeBlockHeader(blockHeaderBytes:str):
# we only check the target and do not do other validation (eg timestamp)
# to save gas
if blockHash > 0 && blockHash < target:
m_saveAncestors(blockHash, hashPrevBlock) # increments ibIndex

save(self.block[blockHash]._blockHeader[0], blockHeaderBytes, chars=80)

blockHeight = m_getHeight(blockHash)
blockHeight = 1 + m_getHeight(hashPrevBlock)
prevBits = m_getBits(hashPrevBlock)
if !m_difficultyShouldBeAdjusted(blockHeight) || self.ibIndex == 1: # since blockHeight is 1 more than blockNumber; OR clause is special case for 1st header
# we need to check prevBits isn't 0 otherwise the 1st header
Expand All @@ -131,6 +127,10 @@ def storeBlockHeader(blockHeaderBytes:str):
log(type=Failure, ERR_RETARGET)
return(ERR_RETARGET)

m_saveAncestors(blockHash, hashPrevBlock) # increments ibIndex

save(self.block[blockHash]._blockHeader[0], blockHeaderBytes, chars=80)

difficulty = 0x00000000FFFF0000000000000000000000000000000000000000000000000000 / target # https://en.bitcoin.it/wiki/Difficulty
scoreBlock = scorePrevBlock + difficulty
m_setScore(blockHash, scoreBlock)
Expand Down

0 comments on commit 888962e

Please sign in to comment.