def load_raw(): "rlp and hex encoded blocks in multiline file," "each line is in wrong order, which is also expected by chainmanager" data = [] for x in open("tests/raw_remote_blocks_hex.txt"): data.extend(reversed(rlp.decode(x.strip().decode("hex")))) return rlp.encode(list(reversed(data))).encode("hex")
def load_raw(): "rlp and hex encoded blocks in multiline file," "each line is in wrong order, which is also expected by chainmanager" data = [] for x in open('tests/raw_remote_blocks_hex.txt'): data.extend(reversed(rlp.decode(x.strip().decode('hex')))) return rlp.encode(list(reversed(data))).encode('hex')
def test_genesis_hash(): set_db() genesis = blocks.genesis() """ cpp: https://github.com/ethereum/cpp-ethereum/libethereum/BlockInfo.cpp#L64 h256() << sha3EmptyList << h160() << stateRoot << h256() << c_genesisDifficulty << 0 << 0 << 1000000 << 0 << (uint)0 << string() << sha3(bytes(1, 42)); PoC5 etherpad: https://ethereum.etherpad.mozilla.org/11 Genesis block is: ( B32(0, 0, ...), B32(sha3(B())), B20(0, 0, ...), B32(stateRoot), B32(0, 0, ...), P(2^22), P(0), P(0), P(1000000), P(0), P(0) << B() << B32(sha3(B(42))) ) Genesis hash: 69a7356a245f9dc5b865475ada5ee4e89b18f93c06503a9db3b3630e88e9fb4e YP: https://raw.githubusercontent.com/ethereum/latexpaper/master/Paper.tex 0256 , SHA3RLP(), 0160 , stateRoot, 0256 , 2**22 , 0, 0, 1000000, 0, 0, (), SHA3(42), (), () Where 0256 refers to the parent and state and transaction root hashes, a 256-bit hash which is all zeroes; 0160 refers to the coinbase address, a 160-bit hash which is all zeroes; 2**22 refers to the difficulty; 0 refers to the timestamp (the Unix epoch); () refers to the extradata and the sequences of both uncles and transactions, all empty. SHA3(42) refers to the SHA3 hash of a byte array of length one whose first and only byte is of value 42. SHA3RLP() values refer to the hashes of the transaction and uncle lists in RLP, both empty. The proof-of-concept series include a development premine, making the state root hash some value stateRoot. The latest documentation should be consulted for the value of the state root. """ h256 = "\x00" * 32 sr = CPP_PoC5_GENESIS_STATE_ROOT_HEX_HASH.decode('hex') genisi_block_defaults = [ ["prevhash", "bin", h256], # h256() ["uncles_hash", "bin", utils.sha3(rlp.encode([]))], # sha3EmptyList ["coinbase", "addr", "0" * 40], # h160() ["state_root", "trie_root", sr], # stateRoot ["tx_list_root", "trie_root", h256], # h256() ["difficulty", "int", 2**22], # c_genesisDifficulty ["number", "int", 0], # 0 ["min_gas_price", "int", 0], # 0 ["gas_limit", "int", 1000000], # 1000000 ["gas_used", "int", 0], # 0 ["timestamp", "int", 0], # 0 ["extra_data", "bin", ""], # "" ["nonce", "bin", utils.sha3(chr(42))], # sha3(bytes(1, 42)); ] cpp_genesis_block = rlp.decode(CPP_PoC5_GENESIS_HEX.decode('hex')) cpp_genesis_header = cpp_genesis_block[0] for i, (name, typ, genesis_default) in enumerate(genisi_block_defaults): # print name, repr(getattr(genesis, name)), repr(genesis_default) assert utils.decoders[typ](cpp_genesis_header[i]) == genesis_default assert getattr(genesis, name) == genesis_default assert genesis.hex_hash() == CPP_PoC5_GENESIS_HEX_HASH
def do_test(hex_rlp_encoded_data): from test_chain import get_chainmanager set_db() chain_manager = get_chainmanager() data = rlp.decode(hex_rlp_encoded_data.decode('hex')) transient_blocks = [blocks.TransientBlock(rlp.encode(b)) for b in data] assert len(transient_blocks) == 128 chain_manager.receive_chain(transient_blocks) print chain_manager.head
def do_test(hex_rlp_encoded_data): from test_chain import set_db, get_chainmanager set_db() chain_manager = get_chainmanager() data = rlp.decode(hex_rlp_encoded_data.decode('hex')) transient_blocks = [blocks.TransientBlock(rlp.encode(b)) for b in data] assert len(transient_blocks) == 128 chain_manager.receive_chain(transient_blocks) print chain_manager.head
def test_genesis_hash(genesis_fixture): set_db() genesis = blocks.genesis() """ YP: https://raw.githubusercontent.com/ethereum/latexpaper/master/Paper.tex 0256 , SHA3RLP(), 0160 , stateRoot, 0256 , 2**22 , 0, 0, 1000000, 0, 0, (), SHA3(42), (), () Where 0256 refers to the parent and state and transaction root hashes, a 256-bit hash which is all zeroes; 0160 refers to the coinbase address, a 160-bit hash which is all zeroes; 2**22 refers to the difficulty; 0 refers to the timestamp (the Unix epoch); () refers to the extradata and the sequences of both uncles and transactions, all empty. SHA3(42) refers to the SHA3 hash of a byte array of length one whose first and only byte is of value 42. SHA3RLP() values refer to the hashes of the transaction and uncle lists in RLP both empty. The proof-of-concept series include a development premine, making the state root hash some value stateRoot. The latest documentation should be consulted for the value of the state root. """ h256 = '\00' * 32 sr = genesis_fixture['genesis_state_root'].decode('hex') genesis_block_defaults = [ ["prevhash", "bin", h256], # h256() ["uncles_hash", "bin", utils.sha3(rlp.encode([]))], # sha3EmptyList ["coinbase", "addr", "0" * 40], # h160() ["state_root", "trie_root", sr], # stateRoot ["tx_list_root", "trie_root", trie.BLANK_ROOT], # h256() ["difficulty", "int", 2 ** 22], # c_genesisDifficulty ["number", "int", 0], # 0 ["min_gas_price", "int", 0], # 0 ["gas_limit", "int", 10 ** 6], # 10**6 for genesis ["gas_used", "int", 0], # 0 ["timestamp", "int", 0], # 0 ["extra_data", "bin", ""], # "" ["nonce", "bin", utils.sha3(chr(42))], # sha3(bytes(1, 42)); ] cpp_genesis_block = rlp.decode( genesis_fixture['genesis_rlp_hex'].decode('hex')) cpp_genesis_header = cpp_genesis_block[0] for i, (name, typ, genesis_default) in enumerate(genesis_block_defaults): assert utils.decoders[typ](cpp_genesis_header[i]) == genesis_default assert getattr(genesis, name) == genesis_default assert genesis.hex_hash() == genesis_fixture['genesis_hash'] assert genesis.hex_hash() == utils.sha3( genesis_fixture['genesis_rlp_hex'].decode('hex') ).encode('hex')
def test_genesis_hash(genesis_fixture): set_db() genesis = blocks.genesis() """ YP: https://raw.githubusercontent.com/ethereum/latexpaper/master/Paper.tex 0256 , SHA3RLP(), 0160 , stateRoot, 0256 , 2**22 , 0, 0, 1000000, 0, 0, (), SHA3(42), (), () Where 0256 refers to the parent and state and transaction root hashes, a 256-bit hash which is all zeroes; 0160 refers to the coinbase address, a 160-bit hash which is all zeroes; 2**22 refers to the difficulty; 0 refers to the timestamp (the Unix epoch); () refers to the extradata and the sequences of both uncles and transactions, all empty. SHA3(42) refers to the SHA3 hash of a byte array of length one whose first and only byte is of value 42. SHA3RLP() values refer to the hashes of the transaction and uncle lists in RLP both empty. The proof-of-concept series include a development premine, making the state root hash some value stateRoot. The latest documentation should be consulted for the value of the state root. """ h256 = '\00' * 32 sr = genesis_fixture['genesis_state_root'].decode('hex') genesis_block_defaults = [ ["prevhash", "bin", h256], # h256() ["uncles_hash", "bin", utils.sha3(rlp.encode([]))], # sha3EmptyList ["coinbase", "addr", "0" * 40], # h160() ["state_root", "trie_root", sr], # stateRoot ["tx_list_root", "trie_root", trie.BLANK_ROOT], # h256() ["difficulty", "int", 2**22], # c_genesisDifficulty ["number", "int", 0], # 0 ["min_gas_price", "int", 0], # 0 ["gas_limit", "int", 10**6], # 10**6 for genesis ["gas_used", "int", 0], # 0 ["timestamp", "int", 0], # 0 ["extra_data", "bin", ""], # "" ["nonce", "bin", utils.sha3(chr(42))], # sha3(bytes(1, 42)); ] cpp_genesis_block = rlp.decode( genesis_fixture['genesis_rlp_hex'].decode('hex')) cpp_genesis_header = cpp_genesis_block[0] for i, (name, typ, genesis_default) in enumerate(genesis_block_defaults): assert utils.decoders[typ](cpp_genesis_header[i]) == genesis_default assert getattr(genesis, name) == genesis_default assert genesis.hex_hash() == genesis_fixture['genesis_hash'] assert genesis.hex_hash() == utils.sha3( genesis_fixture['genesis_rlp_hex'].decode('hex')).encode('hex')
def test_genesis_hash(): set_db() genesis = blocks.genesis() """ cpp: https://github.com/ethereum/cpp-ethereum/libethereum/BlockInfo.cpp#L64 h256() << sha3EmptyList << h160() << stateRoot << h256() << c_genesisDifficulty << 0 << 0 << 1000000 << 0 << (uint)0 << string() << sha3(bytes(1, 42)); PoC5 etherpad: https://ethereum.etherpad.mozilla.org/11 Genesis block is: ( B32(0, 0, ...), B32(sha3(B())), B20(0, 0, ...), B32(stateRoot), B32(0, 0, ...), P(2^22), P(0), P(0), P(1000000), P(0), P(0) << B() << B32(sha3(B(42))) ) Genesis hash: 69a7356a245f9dc5b865475ada5ee4e89b18f93c06503a9db3b3630e88e9fb4e YP: https://raw.githubusercontent.com/ethereum/latexpaper/master/Paper.tex 0256 , SHA3RLP(), 0160 , stateRoot, 0256 , 2**22 , 0, 0, 1000000, 0, 0, (), SHA3(42), (), () Where 0256 refers to the parent and state and transaction root hashes, a 256-bit hash which is all zeroes; 0160 refers to the coinbase address, a 160-bit hash which is all zeroes; 2**22 refers to the difficulty; 0 refers to the timestamp (the Unix epoch); () refers to the extradata and the sequences of both uncles and transactions, all empty. SHA3(42) refers to the SHA3 hash of a byte array of length one whose first and only byte is of value 42. SHA3RLP() values refer to the hashes of the transaction and uncle lists in RLP, both empty. The proof-of-concept series include a development premine, making the state root hash some value stateRoot. The latest documentation should be consulted for the value of the state root. """ h256 = "\x00" * 32 sr = CPP_PoC5_GENESIS_STATE_ROOT_HEX_HASH.decode('hex') genisi_block_defaults = [ ["prevhash", "bin", h256], # h256() ["uncles_hash", "bin", utils.sha3(rlp.encode([]))], # sha3EmptyList ["coinbase", "addr", "0" * 40], # h160() ["state_root", "trie_root", sr], # stateRoot ["tx_list_root", "trie_root", h256], # h256() ["difficulty", "int", 2 ** 22], # c_genesisDifficulty ["number", "int", 0], # 0 ["min_gas_price", "int", 0], # 0 ["gas_limit", "int", 1000000], # 1000000 ["gas_used", "int", 0], # 0 ["timestamp", "int", 0], # 0 ["extra_data", "bin", ""], # "" ["nonce", "bin", utils.sha3(chr(42))], # sha3(bytes(1, 42)); ] cpp_genesis_block = rlp.decode(CPP_PoC5_GENESIS_HEX.decode('hex')) cpp_genesis_header = cpp_genesis_block[0] for i, (name, typ, genesis_default) in enumerate(genisi_block_defaults): # print name, repr(getattr(genesis, name)), repr(genesis_default) assert utils.decoders[typ](cpp_genesis_header[i]) == genesis_default assert getattr(genesis, name) == genesis_default assert genesis.hex_hash() == CPP_PoC5_GENESIS_HEX_HASH
def dump_NewBlock(self, block): """ NewBlock [+0x07, [blockHeader, transactionList, uncleList], totalDifficulty] Specify a single block that the peer should know about. The composite item in the list (following the message ID) is a block in the format described in the main Ethereum specification. totalDifficulty is the total difficulty of the block (aka score). """ total_difficulty = block.chain_difficulty() lst_block = rlp.decode(block.serialize()) # FIXME data = [self.cmd_map_by_name['NewBlock'], lst_block, total_difficulty] return self.dump_packet(data)
def deserialize_child(parent, rlpdata): """ deserialization w/ replaying transactions """ header_args, transaction_list, uncles = rlp.decode(rlpdata) assert len(header_args) == len(blocks.block_structure) kargs = dict(transaction_list=transaction_list, uncles=uncles) # Deserialize all properties for i, (name, typ, default) in enumerate(blocks.block_structure): kargs[name] = utils.decoders[typ](header_args[i]) block = blocks.Block.init_from_parent(parent, kargs['coinbase'], extra_data=kargs['extra_data'], timestamp=kargs['timestamp']) block.finalize() # this is the first potential state change # replay transactions for tx_lst_serialized, _state_root, _gas_used_encoded in transaction_list: tx = transactions.Transaction.create(tx_lst_serialized) logger.debug("data %r", tx.data) logger.debug('applying %r', tx) logger.debug('applying %r', tx.to_dict()) logger.debug('block.gas_used before: %r', block.gas_used) success, output = processblock.apply_transaction(block, tx) logger.debug('block.gas_used after: %r', block.gas_used) logger.debug('success: %r', success) diff = utils.decode_int(_gas_used_encoded) - block.gas_used logger.debug("GAS_USED DIFF %r", diff) assert utils.decode_int(_gas_used_encoded) == block.gas_used assert _state_root.encode('hex') == block.state.root_hash.encode('hex') # checks assert block.prevhash == parent.hash assert block.tx_list_root == kargs['tx_list_root'] assert block.gas_used == kargs['gas_used'] assert block.gas_limit == kargs['gas_limit'] assert block.timestamp == kargs['timestamp'] assert block.difficulty == kargs['difficulty'] assert block.number == kargs['number'] assert block.extra_data == kargs['extra_data'] assert utils.sha3(rlp.encode(block.uncles)) == kargs['uncles_hash'] assert block.state.root_hash.encode('hex') == kargs['state_root'].encode( 'hex') block.uncles_hash = kargs['uncles_hash'] block.nonce = kargs['nonce'] block.min_gas_price = kargs['min_gas_price'] return block
def deserialize_child(parent, rlpdata): """ deserialization w/ replaying transactions """ header_args, transaction_list, uncles = rlp.decode(rlpdata) assert len(header_args) == len(blocks.block_structure) kargs = dict(transaction_list=transaction_list, uncles=uncles) # Deserialize all properties for i, (name, typ, default) in enumerate(blocks.block_structure): kargs[name] = utils.decoders[typ](header_args[i]) block = blocks.Block.init_from_parent(parent, kargs['coinbase'], extra_data=kargs['extra_data'], timestamp=kargs['timestamp']) block.finalize() # this is the first potential state change # replay transactions for tx_lst_serialized, _state_root, _gas_used_encoded in transaction_list: tx = transactions.Transaction.create(tx_lst_serialized) logger.debug("data %r", tx.data) logger.debug('applying %r', tx) logger.debug('applying %r', tx.to_dict()) logger.debug('block.gas_used before: %r', block.gas_used) success, output = processblock.apply_transaction(block, tx) logger.debug('block.gas_used after: %r', block.gas_used) logger.debug('success: %r', success) diff = utils.decode_int(_gas_used_encoded) - block.gas_used logger.debug("GAS_USED DIFF %r", diff) assert utils.decode_int(_gas_used_encoded) == block.gas_used assert _state_root.encode('hex') == block.state.root_hash.encode('hex') # checks assert block.prevhash == parent.hash assert block.tx_list_root == kargs['tx_list_root'] assert block.gas_used == kargs['gas_used'] assert block.gas_limit == kargs['gas_limit'] assert block.timestamp == kargs['timestamp'] assert block.difficulty == kargs['difficulty'] assert block.number == kargs['number'] assert block.extra_data == kargs['extra_data'] assert utils.sha3(rlp.encode(block.uncles)) == kargs['uncles_hash'] assert block.state.root_hash.encode( 'hex') == kargs['state_root'].encode('hex') block.uncles_hash = kargs['uncles_hash'] block.nonce = kargs['nonce'] block.min_gas_price = kargs['min_gas_price'] return block
def import_chain_data(raw_blocks_fn, test_db_path, skip=0): utils.data_dir.set(test_db_path) chain_manager = chainmanager.ChainManager() chain_manager.configure(config=eth.get_default_config(), genesis=None) fh = open(raw_blocks_fn) for i in range(skip): fh.readline() for hex_rlp_encoded_data in fh: hexdata = hex_rlp_encoded_data.strip().decode('hex') data = rlp.decode(hexdata) blk = blocks.TransientBlock(hexdata) print blk.number, blk.hash.encode('hex'), '%d txs' % len(blk.transaction_list) chain_manager.receive_chain([blk]) assert blk.hash in chain_manager
def test_deserialize_cpp_block_42(): # 54.204.10.41 / NEthereum(++)/ZeroGox/v0.5.9/ncurses/Linux/g++ V:17L # E TypeError: ord() expected a character, but string of length 0 found # 00bab55f2e230d4d56c7a2c11e7f3132663cc6734a5d4406f2e4359f4ab56593 """ RomanJ dumped the block BlockData [ hash=00bab55f2e230d4d56c7a2c11e7f3132663cc6734a5d4406f2e4359f4ab56593 parentHash=0df28c56b0cc32ceb55299934fca74ff63956ede0ffd430367ebcb1bb94d42fe unclesHash=1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347 coinbase=a70abb9ed4b5d82ed1d82194943349bcde036812 stateHash=203838e6ea7b03bce4b806ab4e5c069d5cd98ca2ba27a2d343d809cc6365e1ce txTrieHash=78aaa0f3b726f8d9273ba145e0efd4a6b21183412582449cc9457f713422b5ae difficulty=4142bd number=48 minGasPrice=10000000000000 gasLimit=954162 gasUsed=500 timestamp=1400678342 extraData=null nonce=0000000000000000000000000000000000000000000000007d117303138a74e0 TransactionData [ hash=9003d7211c4b0d123778707fbdcabd93a6184be210390de4f73f89eae847556d nonce=null, gasPrice=09184e72a000, gas=01f4, receiveAddress=e559de5527492bcb42ec68d07df0742a98ec3f1e, value=8ac7230489e80000, data=null, signatureV=27, signatureR=18d646b8c4f7a804fdf7ba8da4d5dd049983e7d2b652ab902f7d4eaebee3e33b, signatureS=229ad485ef078d6e5f252db58dd2cce99e18af02028949896248aa01baf48b77] ] """ genesis = mkgenesis( {'a70abb9ed4b5d82ed1d82194943349bcde036812': 100000000000000000000L}) hex_rlp_data = \ """f9016df8d3a00df28c56b0cc32ceb55299934fca74ff63956ede0ffd430367ebcb1bb94d42fea01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934794a70abb9ed4b5d82ed1d82194943349bcde036812a0203838e6ea7b03bce4b806ab4e5c069d5cd98ca2ba27a2d343d809cc6365e1cea078aaa0f3b726f8d9273ba145e0efd4a6b21183412582449cc9457f713422b5ae834142bd308609184e72a000830e8f328201f484537ca7c680a00000000000000000000000000000000000000000000000007d117303138a74e0f895f893f86d808609184e72a0008201f494e559de5527492bcb42ec68d07df0742a98ec3f1e888ac7230489e80000801ba018d646b8c4f7a804fdf7ba8da4d5dd049983e7d2b652ab902f7d4eaebee3e33ba0229ad485ef078d6e5f252db58dd2cce99e18af02028949896248aa01baf48b77a06e957f0f99502ad60a66a016f72957eff0f3a5bf791ad4a0606a44f35a6e09288201f4c0""" header_args, transaction_list, uncles = rlp.decode( hex_rlp_data.decode('hex')) for tx_data, _state_root, _gas_used_encoded in transaction_list: tx = transactions.Transaction.create(tx_data) logger.debug('Block #48 failing tx %r', tx.to_dict()) processblock.apply_transaction(genesis, tx)
def import_chain_data(raw_blocks_fn, test_db_path, skip=0): from pyethereum import chainmanager utils.data_dir.set(test_db_path) chain_manager = chainmanager.ChainManager() chain_manager.configure(config=get_default_config(), genesis=None) fh = open(raw_blocks_fn) for i in range(skip): fh.readline() for hex_rlp_encoded_data in fh: hexdata = hex_rlp_encoded_data.strip().decode('hex') data = rlp.decode(hexdata) blk = blocks.TransientBlock(hexdata) print blk.number, blk.hash.encode('hex'), '%d txs' % len( blk.transaction_list) chain_manager.receive_chain([blk]) assert blk.hash in chain_manager
def setup_class(self): self.state = tester.state() # Create test blockchain # Solidity version _, self.mul7_evm = solc(self.mul7) # Compile print('>>> Solidity evm: {}'.format(self.mul7_evm)) self.addr = self.state.contract(self.mul7_evm, OWNER['key'], 0) print('>>> Solidity contract address: {}'.format(self.addr)) #self.mul7_evm = '0x{}'.format(self.mul7_evm) self.mul7_decoded = self.mul7_evm.decode('hex') print('>>> Solidity decode-hex: {}'.format( self.mul7_evm.decode('hex'))) #self.state.evm(self.mul7_evm, sender=self.OWNER, endowment=0) self.state.evm(self.mul7_decoded, sender=self.OWNER, endowment=0) # Serpent version #self.mul7se_evm = self.state.abi_contract(self.mul7se) self.mul7se_evm = serpent.compile(open(self.mul7se).read()) self.mul7se_rlp_decode = rlp.decode(self.mul7se_evm) print('>>> Serpent compile: {}'.format(self.mul7se_evm))
def import_chain_data(raw_blocks_fn, test_db_path, skip=0): chain_manager = new_chainmanager() fh = open(raw_blocks_fn) for i in range(skip): fh.readline() for hex_rlp_encoded_data in fh: hexdata = hex_rlp_encoded_data.strip().decode('hex') data = rlp.decode(hexdata) blk = blocks.TransientBlock(hexdata) print blk.number, blk.hash.encode('hex'), '%d txs' % len(blk.transaction_list) head = chain_manager.head assert blocks.check_header_pow(blk.header_args) chain_manager.receive_chain([blk]) if not blk.hash in chain_manager: print 'block could not be added' assert head == chain_manager.head chain_manager.head.deserialize_child(blk.rlpdata) assert blk.hash in chain_manager
data can be created with blockfetcherpatch.py """ import sys raw_blocks_fn = sys.argv[1] test_db_path = sys.argv[2] skip = int(sys.argv[3]) if len(sys.argv) == 4 or sys.argv[4] != "silent": logging.basicConfig(level=logging.DEBUG) global logger logger = logging.getLogger() print utils utils.data_dir.set(test_db_path) chain_manager = chainmanager.ChainManager() chain_manager.configure(config=eth.create_default_config(), genesis=None) fh = open(raw_blocks_fn) for i in range(skip): fh.readline() for hex_rlp_encoded_data in fh: hexdata = hex_rlp_encoded_data.strip().decode("hex") data = rlp.decode(hexdata) # print repr(data) blk = blocks.TransientBlock(hexdata) print blk.number, blk.hash.encode("hex") chain_manager.receive_chain([blk]) assert blk.hash in chain_manager
def lrlp_decode(data): "always return a list" d = rlp.decode(data) if isinstance(d, str): d = [d] return d
def dump_Blocks(self, blocks): blocks_as_lists = [rlp.decode(b.serialize()) for b in blocks] # FIXME, can we have a method to append rlp encoded data data = [self.cmd_map_by_name['Blocks']] + blocks_as_lists return self.dump_packet(data)
def step_impl(context): assert context.src == rlp.decode(context.dst)
py current: 7e2c3861f556686d7bc3ce4e93fa0011020868dc769838aca66bcc82010a2c60 fixtures 15.10.:f68067286ddb7245c2203b18135456de1fc4ed6a24a2d9014195faa7900025bf py poc6: 08436a4d33c77e6acf013e586a3333ad152f25d31df8b68749d85046810e1f4b fixtures 19.9,: 08436a4d33c77e6acf013e586a3333ad152f25d31df8b68749d85046810e1f4b """ genesis = blocks.genesis(new_db()) assert genesis.hex_hash() == genesis_fixture['genesis_hash'] if __name__ == '__main__': cpp_genesis_rlp_hex = 'f9012ff9012aa00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a0c67c70f5d7d3049337d1dcc0503a249881120019a8e7322774dbfe57b463718ca056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b84000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000830200008080830f4240808080a004994f67dc55b09e814ab7ffc8df3686b4afb2bb53e60eae97ef043fe03fb829c0c0' cpp_genesis_rlp = cpp_genesis_rlp_hex.decode('hex') poc7_genesis_hash_hex = '955f36d073ccb026b78ab3424c15cf966a7563aa270413859f78702b9e8e22cb' cpp_genesis = rlp.decode(cpp_genesis_rlp) cpp_genesis_hash_hex = utils.sha3(rlp.encode(cpp_genesis[0])).encode('hex') cpp_header = cpp_genesis[0] cpp_header_hex = [x.encode('hex') for x in cpp_header] py_genesis = rlp.decode(blocks.genesis().serialize()) py_genesis_hex_hash = blocks.genesis().hex_hash() py_header = py_genesis[0] py_header_hex = [x.encode('hex') for x in py_header] print 'py genesis hash hex', py_genesis_hex_hash print 'py state_root', py_header[blocks.block_structure_rev['state_root'] [0]].encode('hex') print 'py genesis rlp', blocks.genesis().hex_serialize()
data can be created with blockfetcherpatch.py """ import sys raw_blocks_fn = sys.argv[1] test_db_path = sys.argv[2] skip = int(sys.argv[3]) if len(sys.argv) == 4 or sys.argv[4] != 'silent': logging.basicConfig(level=logging.DEBUG) global logger logger = logging.getLogger() print utils utils.data_dir.set(test_db_path) chain_manager = chainmanager.ChainManager() chain_manager.configure(config=eth.create_default_config(), genesis=None) fh = open(raw_blocks_fn) for i in range(skip): fh.readline() for hex_rlp_encoded_data in fh: hexdata = hex_rlp_encoded_data.strip().decode('hex') data = rlp.decode(hexdata) # print repr(data) blk = blocks.TransientBlock(hexdata) print blk.number, blk.hash.encode('hex') chain_manager.receive_chain([blk]) assert blk.hash in chain_manager