From 69b540cde8c6aae177d6e09b67f509ea4ebed220 Mon Sep 17 00:00:00 2001 From: Alex Wice Date: Fri, 23 Aug 2019 02:42:56 +0900 Subject: [PATCH] simple loop working --- lib/chiavdf/inkfish/proof_wesolowski.py | 1 + src/blockchain.py | 11 ++++++----- src/consensus/constants.py | 6 +++--- src/consensus/pot_iterations.py | 2 +- src/full_node.py | 2 +- src/timelord.py | 2 ++ src/types/block_header.py | 2 +- src/util/api_decorators.py | 2 +- src/util/genesis_block.py | 7 +++---- 9 files changed, 19 insertions(+), 16 deletions(-) diff --git a/lib/chiavdf/inkfish/proof_wesolowski.py b/lib/chiavdf/inkfish/proof_wesolowski.py index 9ce818ef..91f2cc4e 100644 --- a/lib/chiavdf/inkfish/proof_wesolowski.py +++ b/lib/chiavdf/inkfish/proof_wesolowski.py @@ -24,6 +24,7 @@ def approximate_parameters(T): # 1/w is the approximate proportion of time spent on the proof w = math.floor(T / (T/k + L * pow(2, k+1))) - 2 + w = max(w, 0) return (L, k, w) diff --git a/src/blockchain.py b/src/blockchain.py index 87ba069b..a1d2bfa7 100644 --- a/src/blockchain.py +++ b/src/blockchain.py @@ -17,7 +17,7 @@ from src.consensus.constants import ( ) log = logging.getLogger(__name__) -genesis_block_bytes: bytes = b'\x15N3\xd3\xf9H\xc2K\x96\xfe\xf2f\xa2\xbf\x87\x0e\x0f,\xd0\xd4\x0f6s\xb1".\\\xf5\x8a\xb4\x03\x84\x8e\xf9\xbb\xa1\xca\xdef3:\xe4?\x0c\xe5\xc6\x12\x80\x15N3\xd3\xf9H\xc2K\x96\xfe\xf2f\xa2\xbf\x87\x0e\x0f,\xd0\xd4\x0f6s\xb1".\\\xf5\x8a\xb4\x03\x84\x8e\xf9\xbb\xa1\xca\xdef3:\xe4?\x0c\xe5\xc6\x12\x80\x13\x00\x00\x00\x98\xf9\xeb\x86\x90Kj\x01\x1cZk_\xe1\x9c\x03;Z\xb9V\xe2\xe8\xa5\xc8\n\x0c\xbbU\xa6\xc5\xc5\xbcH\xa3\xb3fd\xcd\xb8\x83\t\xa9\x97\x96\xb5\x91G \xb2\x9e\x05\\\x91\xe1<\xee\xb1\x06\xc3\x18~XuI\xc8\x8a\xb5b\xd7.7\x96Ej\xf3DThs\x18s\xa5\xd4C\x1ea\xfd\xd5\xcf\xb9o\x18\xea6n\xe22*\xb0]%\x15\xd0i\x83\xcb\x9a\xa2.+\x0f1\xcd\x03Z\xf3]\'\xbf|\x8b\xa6\xbcF\x10\xe8Q\x19\xaeZ~\xe5\x1f\xf1)\xa3\xfb\x82\x1a\xb8\x12\xce\x19\xc8\xde\xb9n\x08[\xef\xfd\xf9\x0c\xec\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x12k\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x90\xe5\xc3\xbc;4\xda-1L3\xa2\xe3\xb5\xab\x91\xd3\xbb8!\xaa\xade~j(\r\xf3M`\xc8\x19\xbe\xd4\'\x93q\x9d\xc9N\xc48~\xcc\xd1\xab\x10\x86\xd7\xd7\xa1\x1c#f\xf8\x012>$\x8c\x1btr\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x9d\x9c~\xa4\x96`\x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I|\xad\x1d*(\x11X\xe3\xd3\xaa7#!4\xe2\xad|\xf1!\x01~[u\x1f\x81\x7f\x0c)\x05\xe6\xfd\xe5\xd14\\a\n\xc6I\xccJ\x0cXk\xcf,Z\x1c\xdb>\xe0\xc3\x99\xe3\x93Z\xf2/\x9ec\xc4B\xca\xee\x9c\xe9\xc5B\x85\x0fG\x9c\x0e{\xda8\xa5?\x84\xb8\xa3$\xd7$\x00\x00\x00\x00\x00\x00\x00\x17Hv\xe8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00]J\xa4\xed\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00~[u\x1f\x81\x7f\x0c)\x05\xe6\xfd\xe5\xd14\\a\n\xc6I\xccJ\x0cXk\xcf,Z\x1c\xdb>\xe0\xc3z!\xc9N\xd5\x03\x8b^\xd9\xe6\xc7I\xba\xb1\x0fm\xd4\xa0=\xb6^s\x94_f\xb5\xc1\\n\xfe\xf9\xd2\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00Q]\xdaO\xd8\x84 \xcb\xebh\x8ei]7\xd4\x0b\xf1\xb6\xd8%\x9eh\x9a}\x04\xa3u\xe7!v\xb3\xc0c\xba\x9b\xe02\xc9\x13\x85\xa7\x93R\x9bZ\x1a-\xc4\x07\xbd\xd2;\xa3\x9f\x17\x9c\xdc\xc3\xc3\x8d\x9b\x81\xcd\x0e\x9acb\xc2M\xd9j\xa2k\xb6S\xa6\xe2\x97>&\x1b\x05_sv\xfc\xdf\xd6\x17\xff\xb8u+\x1f\x1c\xb5\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\n+\x93\xa0\x02\xe4\xc2\x1d\xaa5R\xe5,\xbd\xa5\x15|%}\xa4@\xe5\x11\x00\x80\x1fG\x8aH\x0b\xe7\xe9\x10\xd3tK\xda`\xb5u\xca\x8c\xa2\xf7n\x1d\xd5\x92l\xb13k\xdb\n+\xbe/\x1e\xc0\xfe\xbf\xd9\x83\x88V\x11]~.<\x14\x0f\xce`\x8b\xbf\xb9\xa7\xce"6\x19\xa5\x19|\x81!r\x15V\xa6\x82\x07\x96w\x98F\xce\xb2(G\xcfm\x17@t\xb2\x1b\xba\xcf4I}\x0b\xc4\n\xd4\x9b\xe2E\x9e\x84\x98mY||\xa8[+\x93\xa0\x02\xe4\xc2\x1d\xaa5R\xe5,\xbd\xa5\x15|%}\xa4@\xe5\x11\x00\x80\x1fG\x8aH\x0b\xe7\xe9\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' # noqa: E501 +genesis_block_bytes: bytes = b'\x15N3\xd3\xf9H\xc2K\x96\xfe\xf2f\xa2\xbf\x87\x0e\x0f,\xd0\xd4\x0f6s\xb1".\\\xf5\x8a\xb4\x03\x84\x8e\xf9\xbb\xa1\xca\xdef3:\xe4?\x0c\xe5\xc6\x12\x80\x15N3\xd3\xf9H\xc2K\x96\xfe\xf2f\xa2\xbf\x87\x0e\x0f,\xd0\xd4\x0f6s\xb1".\\\xf5\x8a\xb4\x03\x84\x8e\xf9\xbb\xa1\xca\xdef3:\xe4?\x0c\xe5\xc6\x12\x80\x13\x00\x00\x00\x98\xf9\xeb\x86\x90Kj\x01\x1cZk_\xe1\x9c\x03;Z\xb9V\xe2\xe8\xa5\xc8\n\x0c\xbbU\xa6\xc5\xc5\xbcH\xa3\xb3fd\xcd\xb8\x83\t\xa9\x97\x96\xb5\x91G \xb2\x9e\x05\\\x91\xe1<\xee\xb1\x06\xc3\x18~XuI\xc8\x8a\xb5b\xd7.7\x96Ej\xf3DThs\x18s\xa5\xd4C\x1ea\xfd\xd5\xcf\xb9o\x18\xea6n\xe22*\xb0]%\x15\xd0i\x83\xcb\x9a\xa2.+\x0f1\xcd\x03Z\xf3]\'\xbf|\x8b\xa6\xbcF\x10\xe8Q\x19\xaeZ~\xe5\x1f\xf1)\xa3\xfb\x82\x1a\xb8\x12\xce\x19\xc8\xde\xb9n\x08[\xef\xfd\xf9\x0c\xec\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00@\xeb\xc4\x10\xb4$Y\x1b\r\xa3\x1c*\xc9\xb9\xb8\xa8\xd3]\xf6\x9a\x10MJ\xe9\xfc-\x19dU\xda2B\x9bgJ\x0c\xd3\x1f\xdc\xf6\xbd\xe9\x8b\x83k\x87.{\x96\xa2z\xbf\xf8\xe1bT\xef\x95\xa6\x8f\xd8g\xb9\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00?\x02U~X\xc2\x1bE\x87y\xf4\xf8#D\'\xaf5\xc3\xe4\xc7#\x7fAb\x9d}\xeb$o^,\x7f7lK\xbam\xe9\x9e\xfd\x04\xee\x0f\x93\xfe\x0c\xba{B\xe91\xeeT\x03!\x11\xc6k\xb9\x1e\xad\x1e\x07\xfd\x03\x00\x00\x03\x8e\x00%^\xd5&;\xb5g\x9ae\xc6\x07\xf0\xc8\xdcV\x08\xf8\xb4\xfc\xdc5_\x8e\x87\xc1\xca\x99\xb6_\xf7D\xa2}\x81y{\rz\xaf\xf1\xf0\x08\xd9\xc0\x97\x08v\x19\x9f\x82\xa3\xcc\xb2\x176N\xa2\x8f>\xa3\x92\xb27\xc9\x00\x01\x97\xeb\x18:\xfc\xb2\x8e\'1r\xdf\xb9\xcc\x1a\xa3\xff\xc6\x162\xf0;\xb5\xd1\x8a\xc0K^\xbdO\x8b\xf5\xdesh1\x91\tu\x0e\xd7~\x9d\xb7\x86EG$"\x9f\x92\xaeP\x94D[.\xfa\xbb\x91w\xf9O-\x00\x02\xb4\x8f:nb\x02\x00\x15\xf2r3s\xa7x\xb6\xf7\x8a\xd8\xc4\xb1v\xd1m4Jk\xee!\x0f\x80\x1e|\xf7\x1c\x9e\x86\x91\xa9\xf9\x9e\xddj\x81\x0bk\x86\x9d(a\xd3\x84\xc7\xbd\xd2E\xe7\x07\xdf\x1b\x06;\xfc$\x00\x01GA\x861-\xc6+\xbcJ5,\xa6\xd13\x8ez\xb0\xc8#\xa4\xcf\xa2\xbc\xf9\xfc!\xae7a\xc1+\x948x\x90\x86\x0c\xbceG\xb6\xc4y\xaa\xe8-\x04%c\x950\x95\xc2e\x1a\r\xc3&wO\x15\xd2\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x02\xb4\x8f:nb\x02\x00\x15\xf2r3s\xa7x\xb6\xf7\x8a\xd8\xc4\xb1v\xd1m4Jk\xee!\x0f\x80\x1e|\xf7\x1c\x9e\x86\x91\xa9\xf9\x9e\xddj\x81\x0bk\x86\x9d(a\xd3\x84\xc7\xbd\xd2E\xe7\x07\xdf\x1b\x06;\xfc$\x00\x01GA\x861-\xc6+\xbcJ5,\xa6\xd13\x8ez\xb0\xc8#\xa4\xcf\xa2\xbc\xf9\xfc!\xae7a\xc1+\x948x\x90\x86\x0c\xbceG\xb6\xc4y\xaa\xe8-\x04%c\x950\x95\xc2e\x1a\r\xc3&wO\x15\xd2\x0f\x00\x17\x0e\x06\x0co\x13\xe3Q\xdc\xd6K\x184\x95\x97\x83a\x85in\x89K\xc6\x16!\xd2\xa9\xac\xba\x9b\xefb+\x93q\x1b\xb6\x95F7aH\xd1[+qA\x9a#x\xa3{\xd4B\xc8\xab*\x0f\x82\xe4>\xd4\xeb\xfc\x00\t\xea\x12\x959\xc4J\x12\x1a\x813\t\xb8\x17\xbd0T\xa2>k~&\xaa\xdf|\xfcC\xda\xd8\xb0\x19kC"\xbd\x9c\x17.\x9e\xf1\x9a\xeb\xfc\xe9)I\x93o\xe7\xe3((\x9b\xd3\x8cJ\x02\xc2\xe7\xb9\x8a\xb3\x1c\xff\x00S\xdd\x08\x06\x9f )\xda\x87\xbb\xac\\\xdd|hx\xd4\x9dO\x03\xa71\xc2\x8b_\x8b\x8c)\x04+-\xcf}\x9d\x96\x92`\xea\xee\xb2\x1f\xccm\x0fN\xe1\xectRa\xbb4\x0f\xba\nj\x1b\x108@\xf0\x8bK\xaf\xff\xf4f\xf6>\t\xe0c\xfcs\x00\x14\xe0\xf6H\x8eb\x05\x80\xb4\x96\xf4\xe4d\x82\xf4\x9a\xe0\xc3\xec\xcf\x04\xab\x06\xac\xe62g\x15i\x13\xd4\xda\xdc\xee\xbd\xb6\xea\x19\x1d\x1a3p\xc6\xdb\x0e\x15\xcf\x90\x0f\x02\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00]^8\x9e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00~[u\x1f\x81\x7f\x0c)\x05\xe6\xfd\xe5\xd14\\a\n\xc6I\xccJ\x0cXk\xcf,Z\x1c\xdb>\xe0\xc3z!\xc9N\xd5\x03\x8b^\xd9\xe6\xc7I\xba\xb1\x0fm\xd4\xa0=\xb6^s\x94_f\xb5\xc1\\n\xfe\xf9\xd2\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xca\x10\x1d\xda\xf1@\xb0C\x0eG\xc9\x8e\xc5Af\xa5\x98hb\xb5l\xcb\x1dO"\xbe\x96\x0b\xfc\x1d\x7f@\xda\x91\x042\xfd\xcc\x16\xae\xff0\xe2\x13\x811H\xc4\x10\xabs\x8f\xb0\x98|J\xf8\xd2\xd7\xeb\x1e]\x10\xacS\x15d\x88Nw\x8c\x9e\xe0\xb50\x8f\xda\xbd\xf5j&.P\x8d\x91\xf7ZY\xbd\x10\x8c\x9eJ\x01\x0bT\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\n+\x93\xa0\x02\xe4\xc2\x1d\xaa5R\xe5,\xbd\xa5\x15|%}\xa4@\xe5\x11\x00\x80\x1fG\x8aH\x0b\xe7\xe9\x10\xd3tK\xda`\xb5u\xca\x8c\xa2\xf7n\x1d\xd5\x92l\xb13k\xdb\n+\xbe/\x1e\xc0\xfe\xbf\xd9\x83\x88V\x11]~.<\x14\x0f\xce`\x8b\xbf\xb9\xa7\xce"6\x19\xa5\x19|\x81!r\x15V\xa6\x82\x07\x96w\x98F\xce\xb2(G\xcfm\x17@t\xb2\x1b\xba\xcf4I}\x0b\xc4\n\xd4\x9b\xe2E\x9e\x84\x98mY||\xa8[+\x93\xa0\x02\xe4\xc2\x1d\xaa5R\xe5,\xbd\xa5\x15|%}\xa4@\xe5\x11\x00\x80\x1fG\x8aH\x0b\xe7\xe9\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' class Blockchain: @@ -80,9 +80,10 @@ class Blockchain: if trunk.challenge.height % DIFFICULTY_DELAY != 1: return warped_trunk = self.blocks[trunk.prev_header_hash] - while warped_trunk.challenge.height % DIFFICULTY_DELAY != 1: - warped_trunk = self.blocks[warped_trunk.header.header_hash] - self.header_warp[trunk.header.header_hash] = warped_trunk.header.header_hash + while warped_trunk and warped_trunk.challenge.height % DIFFICULTY_DELAY != 1: + warped_trunk = self.blocks.get(warped_trunk.prev_header_hash, None) + if warped_trunk is not None: + self.header_warp[trunk.header.header_hash] = warped_trunk.header.header_hash def get_difficulty(self, header_hash: bytes32) -> uint64: trunk = self.blocks.get(header_hash, None) @@ -90,7 +91,7 @@ class Blockchain: raise Exception("No block found for given header_hash") elif trunk is self.genesis_trunk: return uint64(DIFFICULTY_STARTING) - + prev_trunk = self.blocks.get(trunk.prev_header_hash, None) if prev_trunk is None: raise Exception("No previous block found to compare total weight to") diff --git a/src/consensus/constants.py b/src/consensus/constants.py index fba52706..1c68e7c0 100644 --- a/src/consensus/constants.py +++ b/src/consensus/constants.py @@ -1,9 +1,9 @@ -DIFFICULTY_STARTING = 1 << 32 +DIFFICULTY_STARTING = 1 # These are in units of 2^32 DIFFICULTY_EPOCH = 2016 # The number of blocks per epoch DIFFICULTY_TARGET = 200 # The target number of seconds per block DIFFICULTY_FACTOR = 4 # The next difficulty is truncated to range [prev / FACTOR, prev * FACTOR] DIFFICULTY_WARP_FACTOR = 4 # DELAY divides EPOCH in order to warp efficiently. -DIFFICULTY_DELAY = DIFFICULTY_EPOCH // DIFFICULTY_WARP_FACTOR # The delay in blocks before the difficulty reset applies. +DIFFICULTY_DELAY = DIFFICULTY_EPOCH // DIFFICULTY_WARP_FACTOR # The delay in blocks before the difficulty reset applies DISCRIMINANT_SIZE_BITS = 1024 MIN_BLOCK_TIME_PERCENT = 20 -MIN_VDF_ITERATIONS = 1 << 10 +MIN_VDF_ITERATIONS = 1 # These are in units of 2^32 diff --git a/src/consensus/pot_iterations.py b/src/consensus/pot_iterations.py index 613218b0..3035c774 100644 --- a/src/consensus/pot_iterations.py +++ b/src/consensus/pot_iterations.py @@ -43,7 +43,7 @@ def calculate_iterations_quality(quality: bytes32, size: uint8, difficulty: uint between 0 and 1, then divided by expected plot size, and finally multiplied by the difficulty. """ - dec_iters = (Decimal(int(difficulty)) * + dec_iters = (Decimal(int(difficulty) << 32) * (_quality_to_decimal(quality) / _expected_plot_size(size))) return uint64(max(MIN_VDF_ITERATIONS, int(dec_iters.to_integral_exact(rounding=ROUND_UP)))) diff --git a/src/full_node.py b/src/full_node.py index 3fe08be9..a5e9be5e 100644 --- a/src/full_node.py +++ b/src/full_node.py @@ -198,6 +198,7 @@ async def proof_of_time_finished(request: timelord_protocol.ProofOfTimeFinished, A proof of time, received by a peer timelord. We can use this to complete a block, and call the block routine (which handles propagation and verification of blocks). """ + log.info("POT finished!") async with db.lock: dict_key = (request.proof.output.challenge_hash, request.proof.output.number_of_iterations) unfinished_block_obj: FullBlock = db.unfinished_blocks[dict_key] @@ -311,7 +312,6 @@ async def block(block: peer_protocol.Block, if header_hash in db.bodies and block.block.body in db.bodies[header_hash]: log.info(f"Already have block {header_hash}") return - # TODO(alex): Check if we care about this block, we don't want to add random # disconnected blocks. For example if it's on one of the heads, or if it's an older # block that we need diff --git a/src/timelord.py b/src/timelord.py index bbd44799..c52d93b5 100644 --- a/src/timelord.py +++ b/src/timelord.py @@ -52,6 +52,7 @@ async def challenge_start(challenge_start: timelord_protocol.ChallengeStart, # TODO: Start a VDF process +@api_request async def challenge_end(challenge_end: timelord_protocol.ChallengeEnd, source_connection: ChiaConnection, all_connections: PeerConnections): @@ -64,6 +65,7 @@ async def challenge_end(challenge_end: timelord_protocol.ChallengeEnd, db.process_running = False +@api_request async def proof_of_space_info(proof_of_space_info: timelord_protocol.ProofOfSpaceInfo, source_connection: ChiaConnection, all_connections: PeerConnections): diff --git a/src/types/block_header.py b/src/types/block_header.py index 72ffa6db..34ade8ce 100644 --- a/src/types/block_header.py +++ b/src/types/block_header.py @@ -30,4 +30,4 @@ class BlockHeader: @property def header_hash(self): - return sha256(self.serialize()).digest() + return bytes32(sha256(self.serialize()).digest()) diff --git a/src/util/api_decorators.py b/src/util/api_decorators.py index 10a84f5f..ab1a9f72 100644 --- a/src/util/api_decorators.py +++ b/src/util/api_decorators.py @@ -20,6 +20,6 @@ def api_request(f): inter = dict(binding.arguments) print_args = {k: v for (k, v) in inter.items() if k != "source_connection" and k != "all_connections"} - log.info(f"{f.__name__}({print_args})") + log.info(f"{f.__name__}({print_args})"[:200]) return f(**inter) return f_substitute diff --git a/src/util/genesis_block.py b/src/util/genesis_block.py index af67c1f4..dba71b0e 100644 --- a/src/util/genesis_block.py +++ b/src/util/genesis_block.py @@ -63,10 +63,9 @@ def create_genesis_block(challenge_hash=bytes([0]*32)) -> FullBlock: disc: int = create_discriminant(challenge_hash, constants.DISCRIMINANT_SIZE_BITS) start_x: ClassGroup = ClassGroup.from_ab_discriminant(2, 1, disc) - y, proof_bytes = create_proof_of_time_nwesolowski(disc, start_x, number_iters, - constants.DISCRIMINANT_SIZE_BITS, n_wesolowski) - y_cl = ClassGroup.from_bytes(y, disc) - print(y_cl) + y_cl, proof_bytes = create_proof_of_time_nwesolowski( + disc, start_x, number_iters, constants.DISCRIMINANT_SIZE_BITS, n_wesolowski) + output = ProofOfTimeOutput(challenge_hash, number_iters, ClassgroupElement(y_cl[0], y_cl[1]))