def chain_without_block_validation( base_db, genesis_state): """ Return a Chain object containing just the genesis block. This Chain does not perform any validation when importing new blocks. The Chain's state includes one funded account and a private key for it, which can be found in the funded_address and private_keys variables in the chain itself. """ klass = MiningChain.configure( __name__='TestChainWithoutBlockValidation', vm_configuration=ConsensusApplier(NoProofConsensus).amend_vm_configuration( ( (eth_constants.GENESIS_BLOCK_NUMBER, SpuriousDragonVM), ) ), chain_id=1337, ) genesis_params = { 'block_number': eth_constants.GENESIS_BLOCK_NUMBER, 'difficulty': eth_constants.GENESIS_DIFFICULTY, 'gas_limit': 3141592, 'parent_hash': eth_constants.GENESIS_PARENT_HASH, 'coinbase': eth_constants.GENESIS_COINBASE, 'nonce': eth_constants.GENESIS_NONCE, 'mix_hash': eth_constants.GENESIS_MIX_HASH, 'extra_data': eth_constants.GENESIS_EXTRA_DATA, 'timestamp': 1501851927, } chain = klass.from_genesis(base_db, genesis_params, genesis_state) return chain
def disable_pow_check(chain_class: Type[ChainAPI]) -> Type[ChainAPI]: """ Disable the proof of work validation check for each of the chain's vms. This allows for block mining without generation of the proof of work seal. .. note:: blocks mined this way will not be importable on any chain that does not have proof of work disabled. """ original_vms = chain_class.vm_configuration no_pow_vms = ConsensusApplier(NoProofConsensus).amend_vm_configuration(original_vms) return chain_class.configure(vm_configuration=no_pow_vms)