Update pyevm backend subclass, use URI for provider connection

pull/391/head
Kieran Prasch 2018-08-18 16:24:13 -07:00 committed by Kieran R. Prasch
parent 5c922ba16d
commit 136b485664
2 changed files with 33 additions and 2 deletions

View File

@ -1,9 +1,15 @@
from urllib.parse import urlparse
from constant_sorrow import constants
from eth import constants as pyevm_constants
from eth_keys.datatypes import PublicKey, Signature
from eth_tester import EthereumTester
from eth_utils import to_canonical_address
<<<<<<< HEAD
from typing import Tuple, Union
=======
from eth_utils import to_wei
>>>>>>> 73225ce... Update pyevm backend subclass, use URI for provider connection
from web3 import Web3, WebsocketProvider, HTTPProvider, IPCProvider
from web3.contract import Contract
from web3.providers.eth_tester.main import EthereumTesterProvider
@ -206,10 +212,31 @@ class BlockchainInterface:
if uri_breakdown.scheme == 'pyevm':
if uri_breakdown.netloc == 'tester':
<<<<<<< HEAD
NUCYPHER_GAS_LIMIT = 4899698 # 4626271 # TODO: Move ME
genesis_parameter_overrides = {'gas_limit': NUCYPHER_GAS_LIMIT}
pyevm_backend = PyEVMBackend(genesis_parameter_overrides=genesis_parameter_overrides)
=======
from nucypher.blockchain.eth.utilities import OverridablePyEVMBackend
NUCYPHER_GAS_LIMIT = 4899698 # 4626271
GENESIS_PARAMS = {
'parent_hash': pyevm_constants.GENESIS_PARENT_HASH,
'uncles_hash': pyevm_constants.EMPTY_UNCLE_HASH,
'coinbase': pyevm_constants.ZERO_ADDRESS,
'transaction_root': pyevm_constants.BLANK_ROOT_HASH,
'receipt_root': pyevm_constants.BLANK_ROOT_HASH,
'difficulty': pyevm_constants.GENESIS_DIFFICULTY,
'block_number': pyevm_constants.GENESIS_BLOCK_NUMBER,
'gas_limit': NUCYPHER_GAS_LIMIT,
'extra_data': pyevm_constants.GENESIS_EXTRA_DATA,
'nonce': pyevm_constants.GENESIS_NONCE
}
pyevm_backend = OverridablePyEVMBackend(genesis_params=GENESIS_PARAMS)
>>>>>>> 73225ce... Update pyevm backend subclass, use URI for provider connection
eth_tester = EthereumTester(backend=pyevm_backend, auto_mine_transactions=True)
provider = EthereumTesterProvider(ethereum_tester=eth_tester)

View File

@ -1,19 +1,20 @@
import contextlib
import datetime
import os
import tempfile
import datetime
import maya
import pytest
from constant_sorrow import constants
from eth_utils import to_checksum_address
from nucypher.blockchain.eth.utilities import TemporaryEthereumContractRegistry
from sqlalchemy.engine import create_engine
from nucypher.blockchain.eth.chains import TesterBlockchain
from nucypher.blockchain.eth.deployers import PolicyManagerDeployer, NucypherTokenDeployer, MinerEscrowDeployer
from nucypher.blockchain.eth.interfaces import BlockchainDeployerInterface
from nucypher.blockchain.eth.sol.compile import SolidityCompiler
from nucypher.blockchain.eth.registry import TemporaryEthereumContractRegistry
from nucypher.blockchain.eth.sol.compile import SolidityCompiler
from nucypher.characters import Alice, Bob
from nucypher.data_sources import DataSource
from nucypher.keystore import keystore
@ -21,6 +22,8 @@ from nucypher.keystore.db import Base
from nucypher.keystore.keypairs import SigningKeypair
from nucypher.utilities.blockchain import make_ursulas, token_airdrop
from nucypher.utilities.network import MockRestMiddleware
#
# Setup
#
@ -247,6 +250,7 @@ def testerchain(solidity_compiler):
temp_registrar = TemporaryEthereumContractRegistry()
# Use the the custom provider and registrar to init an interface
circumflex = BlockchainDeployerInterface(compiler=solidity_compiler, # freshly recompile if not None
registry=temp_registrar,
provider_uri='pyevm://tester')