Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Utilize pyeth changes for solc >= 0.4.9 #351

Merged
merged 4 commits into from
Jan 26, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions raiden/network/rpc/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ def deploy_contract(self, contract_name, contract_file, constructor_parameters=N
contracts,
dict(),
constructor_parameters,
contract_path=contract_path,
gasprice=default_gasprice,
timeout=self.poll_timeout,
)
Expand Down
1 change: 1 addition & 0 deletions raiden/tests/fixtures/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ def _jsonrpc_services(
registry_contracts,
dict(),
tuple(),
contract_path=registry_path,
gasprice=default_gasprice,
timeout=poll_timeout,
)
Expand Down
11 changes: 9 additions & 2 deletions raiden/tests/integration/test_blockchainservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import pytest
from ethereum import _solidity
from ethereum._solidity import compile_file
from ethereum._solidity import compile_file, solidity_get_contract_data
from ethereum.utils import denoms
from pyethapp.rpc_client import JSONRPCClient
from pyethapp.jsonrpc import default_gasprice
Expand Down Expand Up @@ -191,6 +191,7 @@ def test_blockchain(
humantoken_contracts,
dict(),
(total_asset, 'raiden', 2, 'Rd'),
contract_path=humantoken_path,
gasprice=default_gasprice,
timeout=poll_timeout,
)
Expand All @@ -203,6 +204,7 @@ def test_blockchain(
registry_contracts,
dict(),
tuple(),
contract_path=registry_path,
gasprice=default_gasprice,
timeout=poll_timeout,
)
Expand Down Expand Up @@ -257,8 +259,13 @@ def test_blockchain(
assert channel_manager_address == event['channel_manager_address'].decode('hex')
assert token_proxy.address == event['asset_address'].decode('hex')

contract_data = solidity_get_contract_data(
registry_contracts,
get_contract_path('ChannelManagerContract.sol'),
'ChannelManagerContract'
)
channel_manager_proxy = jsonrpc_client.new_contract_proxy(
registry_contracts['ChannelManagerContract']['abi'],
contract_data['abi'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use the exposed abi from the raiden.blockchain.abi module?

https://github.com/raiden-network/raiden/blob/master/raiden/blockchain/abi.py#L90

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that is a really good idea

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see, the abi.py only computes the abi, it doesn't compile the smart contract, that's why the test is using compile_file, so the question is then, what is the difference between solidity_get_contract_data and compile_file?

Copy link
Contributor Author

@LefterisJP LefterisJP Jan 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compile_file just compiles the file and returns the output.
solidity_get_contract_data() is a new function I added in the linked pyethapp PR, to abstract away the reading of the contract data (the compile_file output) in a backwards compatible way which would work with all current solc versions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, so never mind my comment then, I had the impression that solidity_get_contract_data called the compiler again.

channel_manager_address,
)

Expand Down
4 changes: 3 additions & 1 deletion raiden/ui/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,14 @@ def create_token(
Returns:
token_address: the hex encoded address of the new token/asset.
"""
contract_path = get_contract_path('HumanStandardToken.sol')
# Deploy a new ERC20 token
token_proxy = self._chain.client.deploy_solidity_contract(
self._raiden.address, 'HumanStandardToken',
compile_file(get_contract_path('HumanStandardToken.sol')),
compile_file(contract_path),
dict(),
(initial_alloc, name, decimals, symbol),
contract_path=contract_path,
gasprice=gasprice,
timeout=timeout)
token_address = token_proxy.address.encode('hex')
Expand Down
7 changes: 5 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
pysha3
# temporary until https://github.com/ethereum/pyethapp/pull/184 comes upstream (see also setup.py)
-e git+https://github.com/konradkonrad/pyethapp@71f940c6d287b98a35ef524f4c5e3c13d530bfc5#egg=pyethapp
#-e git+https://github.com/konradkonrad/pyethapp@71f940c6d287b98a35ef524f4c5e3c13d530bfc5#egg=pyethapp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be removed instead of commented out

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it should, left it in there to ask @konradkonrad if we still need it but it's actually included in my branch anyway so it can go away

# temporary until new version of pyethereum is released, that supports solc >= v0.4.9
-e git+https://github.com/LefterisJP/pyethapp@use_new_solc_combinedjson_key#egg=pyethapp
ipython<5.0.0
rlp>=0.4.3,<=0.4.6
secp256k1==0.12.1
pycryptodome>=3.4.3
miniupnpc
networkx
ethereum>=1.3.2
# temporary until new version of pyethereum is released, that supports solc >= v0.4.9
-e git+https://github.com/LefterisJP/pyethereum@fix_solidity_key_combinedjson#egg=ethereum
ethereum-serpent
repoze.lru
gevent-websocket==0.9.4
Expand Down
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ def run_tests(self):


install_requires_replacements = {
"-e git+https://github.com/konradkonrad/pyethapp@71f940c6d287b98a35ef524f4c5e3c13d530bfc5#egg=pyethapp": "pyethapp"
# "-e git+https://github.com/konradkonrad/pyethapp@71f940c6d287b98a35ef524f4c5e3c13d530bfc5#egg=pyethapp": "pyethapp",
"-e git+https://github.com/LefterisJP/pyethapp@use_new_solc_combinedjson_key#egg=pyethapp": "pyethapp",
"-e git+https://github.com/LefterisJP/pyethereum@fix_solidity_key_combinedjson#egg=ethereum": "ethereum"
}

install_requires = list(set(
install_requires_replacements.get(requirement.strip(), requirement.strip())
for requirement in open('requirements.txt')
for requirement in open('requirements.txt') if not requirement.lstrip().startswith('#')
))

test_requirements = []
Expand Down
1 change: 1 addition & 0 deletions tools/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def deploy_files(contract_files, client):
compiled_contracts,
libraries,
'',
contract_path=c,
gasprice=default_gasprice
)
libraries[name] = proxy.address
Expand Down
17 changes: 11 additions & 6 deletions tools/init_blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,31 @@ def connect(host='127.0.0.1',
return client


def create_and_distribute_token(client, receivers,
amount_per_receiver=1000,
name=None,
gasprice=default_gasprice,
timeout=120):
def create_and_distribute_token(
client,
receivers,
amount_per_receiver=1000,
name=None,
gasprice=default_gasprice,
timeout=120
):
"""Create a new ERC-20 token and distribute it among `receivers`.
If `name` is None, the name will be derived from hashing all receivers.
"""
name = name or sha3(''.join(receivers)).encode('hex')
contract_path = get_contract_path('HumanStandardToken.sol')
token_proxy = client.deploy_solidity_contract(
client.sender,
'HumanStandardToken',
compile_file(get_contract_path('HumanStandardToken.sol')),
compile_file(contract_path),
dict()
(
len(receivers) * amount_per_receiver,
name,
2, # decimals
name[:4].upper() # symbol
),
contract_path=contract_path,
gasprice=gasprice,
timeout=timeout
)
Expand Down