From 93b109634e3228a0ce8a139c2cc6e73e8d6aaae3 Mon Sep 17 00:00:00 2001 From: Arbitrage0 Date: Fri, 4 May 2018 01:11:55 +0100 Subject: [PATCH 1/9] Checking if Solc satisfies version requirements Solves #1365 A few things, firstly I'm new to open-source contributions and I've been dabbling with Python for a bit, so I wanted to put my skills to use on Raiden. Please do tell me what I'm doing wrong (or right). Secondly, this relies on the compiler_version() method of _solidity.py in ethereum.tools but I have a feeling that the Regex on line 127 might be a bit messed up, since I tried testing it and it doesn't come out right sometimes. I'll defer to their expertise though, might just be me. I've also imported the inbuilt LooseVersion to save time on developing a version comparison function from scratch. --- raiden/blockchain/abi.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/raiden/blockchain/abi.py b/raiden/blockchain/abi.py index 1e9ae1e580..96fc948f9b 100644 --- a/raiden/blockchain/abi.py +++ b/raiden/blockchain/abi.py @@ -14,6 +14,8 @@ from raiden.utils import get_contract_path from raiden.constants import MIN_REQUIRED_SOLC +from distutils.version import LooseVersion + __all__ = ( 'CONTRACT_MANAGER', @@ -133,7 +135,13 @@ def validate_solc(): "Couldn't find the solc in the current $PATH.\n" "Make sure the solidity compiler is installed and available on your $PATH." ) - + + elif LooseVersion(_solidity.compiler_version()) < LooseVersion(MIN_REQUIRED_SOLC): + raise RuntimeError( + "You are currently using the solidity compiler version {}.\n".format{_solidity.compiler_version()) + "Please upgrade to version {}".format(MIN_REQUIRED_SOLC) + ) + try: _solidity.compile_contract( get_contract_path('HumanStandardToken.sol'), From 574855a052e1cc71bcdc6853af799c6298d09ab2 Mon Sep 17 00:00:00 2001 From: Arbitrage0 Date: Fri, 4 May 2018 01:27:00 +0100 Subject: [PATCH 2/9] Update abi.py --- raiden/blockchain/abi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/raiden/blockchain/abi.py b/raiden/blockchain/abi.py index 96fc948f9b..8912865d24 100644 --- a/raiden/blockchain/abi.py +++ b/raiden/blockchain/abi.py @@ -138,7 +138,7 @@ def validate_solc(): elif LooseVersion(_solidity.compiler_version()) < LooseVersion(MIN_REQUIRED_SOLC): raise RuntimeError( - "You are currently using the solidity compiler version {}.\n".format{_solidity.compiler_version()) + "You are currently using the solidity compiler version {}.\n".format(_solidity.compiler_version()) "Please upgrade to version {}".format(MIN_REQUIRED_SOLC) ) From 1fa2946379f9ec1c9d6110544308d4c9c902ef4a Mon Sep 17 00:00:00 2001 From: Arbitrage0 Date: Fri, 4 May 2018 11:02:56 +0100 Subject: [PATCH 3/9] Update abi.py --- raiden/blockchain/abi.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/raiden/blockchain/abi.py b/raiden/blockchain/abi.py index 8912865d24..3117b19376 100644 --- a/raiden/blockchain/abi.py +++ b/raiden/blockchain/abi.py @@ -135,13 +135,14 @@ def validate_solc(): "Couldn't find the solc in the current $PATH.\n" "Make sure the solidity compiler is installed and available on your $PATH." ) - - elif LooseVersion(_solidity.compiler_version()) < LooseVersion(MIN_REQUIRED_SOLC): + + elif LooseVersion(_solidity.compiler_version()) < LooseVersion(MIN_REQUIRED_SOLC[1:]): raise RuntimeError( - "You are currently using the solidity compiler version {}.\n".format(_solidity.compiler_version()) - "Please upgrade to version {}".format(MIN_REQUIRED_SOLC) + "You are currently using the solidity compiler version {}.\n".format( + _solidity.compiler_version()) + "Please upgrade to version " + MIN_REQUIRED_SOLC ) - + try: _solidity.compile_contract( get_contract_path('HumanStandardToken.sol'), From 485d8f9aefc2d07d7d79ff52bd708404955019bb Mon Sep 17 00:00:00 2001 From: Arbitrage0 Date: Fri, 4 May 2018 11:16:03 +0100 Subject: [PATCH 4/9] Update abi.py --- raiden/blockchain/abi.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/raiden/blockchain/abi.py b/raiden/blockchain/abi.py index 3117b19376..d84f91a6b3 100644 --- a/raiden/blockchain/abi.py +++ b/raiden/blockchain/abi.py @@ -138,9 +138,9 @@ def validate_solc(): elif LooseVersion(_solidity.compiler_version()) < LooseVersion(MIN_REQUIRED_SOLC[1:]): raise RuntimeError( - "You are currently using the solidity compiler version {}.\n".format( + 'You are currently using the solidity compiler version {}.\n'.format( _solidity.compiler_version()) - "Please upgrade to version " + MIN_REQUIRED_SOLC + 'Please upgrade to the compatible version {}.'.format(MIN_REQUIRED_SOLC) ) try: From 2316c6dad599f7a13aa01e4eae9aaa5e721abfab Mon Sep 17 00:00:00 2001 From: Arbitrage0 Date: Fri, 4 May 2018 11:28:52 +0100 Subject: [PATCH 5/9] Update abi.py --- raiden/blockchain/abi.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/raiden/blockchain/abi.py b/raiden/blockchain/abi.py index d84f91a6b3..e100fd5098 100644 --- a/raiden/blockchain/abi.py +++ b/raiden/blockchain/abi.py @@ -138,9 +138,9 @@ def validate_solc(): elif LooseVersion(_solidity.compiler_version()) < LooseVersion(MIN_REQUIRED_SOLC[1:]): raise RuntimeError( - 'You are currently using the solidity compiler version {}.\n'.format( - _solidity.compiler_version()) - 'Please upgrade to the compatible version {}.'.format(MIN_REQUIRED_SOLC) + 'You are currently using the solidity compiler version {0}.\n' + 'Please upgrade to the compatible version {1}.'.format( + _solidity.compiler_version(), MIN_REQUIRED_SOLC) ) try: From eaea0d5db634da4f77b4e052347ab48a308f95d1 Mon Sep 17 00:00:00 2001 From: Arbitrage0 Date: Tue, 8 May 2018 04:05:00 +0100 Subject: [PATCH 6/9] Update abi.py --- raiden/blockchain/abi.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/raiden/blockchain/abi.py b/raiden/blockchain/abi.py index e100fd5098..fe7a78e737 100644 --- a/raiden/blockchain/abi.py +++ b/raiden/blockchain/abi.py @@ -138,8 +138,8 @@ def validate_solc(): elif LooseVersion(_solidity.compiler_version()) < LooseVersion(MIN_REQUIRED_SOLC[1:]): raise RuntimeError( - 'You are currently using the solidity compiler version {0}.\n' - 'Please upgrade to the compatible version {1}.'.format( + 'You are currently using the solidity compiler version {}.\n' + 'Please upgrade to the minimum compatible version {}.'.format( _solidity.compiler_version(), MIN_REQUIRED_SOLC) ) From 7c9d8867b950431e3a2d0206d2258404a57324f1 Mon Sep 17 00:00:00 2001 From: Arbitrage0 Date: Fri, 4 May 2018 01:11:55 +0100 Subject: [PATCH 7/9] Checking if Solc satisfies version requirements Solves #1365 A few things, firstly I'm new to open-source contributions and I've been dabbling with Python for a bit, so I wanted to put my skills to use on Raiden. Please do tell me what I'm doing wrong (or right). Secondly, this relies on the compiler_version() method of _solidity.py in ethereum.tools but I have a feeling that the Regex on line 127 might be a bit messed up, since I tried testing it and it doesn't come out right sometimes. I'll defer to their expertise though, might just be me. I've also imported the inbuilt LooseVersion to save time on developing a version comparison function from scratch. Update abi.py Update abi.py Update abi.py Update abi.py Update abi.py --- raiden/blockchain/abi.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/raiden/blockchain/abi.py b/raiden/blockchain/abi.py index 1e9ae1e580..fe7a78e737 100644 --- a/raiden/blockchain/abi.py +++ b/raiden/blockchain/abi.py @@ -14,6 +14,8 @@ from raiden.utils import get_contract_path from raiden.constants import MIN_REQUIRED_SOLC +from distutils.version import LooseVersion + __all__ = ( 'CONTRACT_MANAGER', @@ -134,6 +136,13 @@ def validate_solc(): "Make sure the solidity compiler is installed and available on your $PATH." ) + elif LooseVersion(_solidity.compiler_version()) < LooseVersion(MIN_REQUIRED_SOLC[1:]): + raise RuntimeError( + 'You are currently using the solidity compiler version {}.\n' + 'Please upgrade to the minimum compatible version {}.'.format( + _solidity.compiler_version(), MIN_REQUIRED_SOLC) + ) + try: _solidity.compile_contract( get_contract_path('HumanStandardToken.sol'), From fef14f635750d32ce7dab215ea0cddc4e4ac7628 Mon Sep 17 00:00:00 2001 From: "Augusto F. Hack" Date: Fri, 27 Apr 2018 22:14:15 -0300 Subject: [PATCH 8/9] removed unused state change ReceiveBalanceProof --- raiden/transfer/mediated_transfer/state.py | 2 +- .../mediated_transfer/state_change.py | 26 ------------------- raiden/transfer/mediated_transfer/target.py | 2 +- 3 files changed, 2 insertions(+), 28 deletions(-) diff --git a/raiden/transfer/mediated_transfer/state.py b/raiden/transfer/mediated_transfer/state.py index 78da6e1181..6f6eaada3b 100644 --- a/raiden/transfer/mediated_transfer/state.py +++ b/raiden/transfer/mediated_transfer/state.py @@ -457,7 +457,7 @@ class MediationPairState(State): 'payer_waiting_close', # ContractSendChannelClose was sent 'payer_waiting_withdraw', # ContractSendWithdraw was sent 'payer_contract_withdraw', # ContractChannelReceiveWithdraw for the above send received - 'payer_balance_proof', # ReceiveBalanceProof was received + 'payer_balance_proof', # ReceiveUnlock was received 'payer_expired', # None of the above happened and the lock expired ) diff --git a/raiden/transfer/mediated_transfer/state_change.py b/raiden/transfer/mediated_transfer/state_change.py index 239f717e7b..91567b62a6 100644 --- a/raiden/transfer/mediated_transfer/state_change.py +++ b/raiden/transfer/mediated_transfer/state_change.py @@ -283,32 +283,6 @@ def __ne__(self, other): return not self.__eq__(other) -class ReceiveBalanceProof(StateChange): - """ A balance proof `identifier` was received. """ - def __init__(self, identifier, node_address, balance_proof): - self.identifier = identifier - self.node_address = node_address - self.balance_proof = balance_proof - - def __repr__(self): - return ''.format( - self.identifier, - pex(self.node_address), - self.balance_proof, - ) - - def __eq__(self, other): - return ( - isinstance(other, ReceiveBalanceProof) and - self.identifier == other.identifier and - self.node_address == other.node_address and - self.balance_proof == other.balance_proof - ) - - def __ne__(self, other): - return not self.__eq__(other) - - class ContractReceiveWithdraw(StateChange): """ A lock was withdrawn via the blockchain. diff --git a/raiden/transfer/mediated_transfer/target.py b/raiden/transfer/mediated_transfer/target.py index 71ddf70b6c..d911f91e5f 100644 --- a/raiden/transfer/mediated_transfer/target.py +++ b/raiden/transfer/mediated_transfer/target.py @@ -127,7 +127,7 @@ def handle_secretreveal(target_state, state_change, channel_state): def handle_unlock(target_state, state_change, channel_state): - """ Handles a ReceiveBalanceProof state change. """ + """ Handles a ReceiveUnlock state change. """ iteration = TransitionResult(target_state, list()) if state_change.balance_proof.sender == target_state.route.node_address: From e3feff2b2d2cf84e253f59fbca4e069d60faae06 Mon Sep 17 00:00:00 2001 From: "Augusto F. Hack" Date: Fri, 27 Apr 2018 22:14:15 -0300 Subject: [PATCH 9/9] removed unused state change ReceiveBalanceProof --- raiden/transfer/mediated_transfer/state.py | 2 +- .../mediated_transfer/state_change.py | 26 ------------------- raiden/transfer/mediated_transfer/target.py | 2 +- 3 files changed, 2 insertions(+), 28 deletions(-) diff --git a/raiden/transfer/mediated_transfer/state.py b/raiden/transfer/mediated_transfer/state.py index 78da6e1181..6f6eaada3b 100644 --- a/raiden/transfer/mediated_transfer/state.py +++ b/raiden/transfer/mediated_transfer/state.py @@ -457,7 +457,7 @@ class MediationPairState(State): 'payer_waiting_close', # ContractSendChannelClose was sent 'payer_waiting_withdraw', # ContractSendWithdraw was sent 'payer_contract_withdraw', # ContractChannelReceiveWithdraw for the above send received - 'payer_balance_proof', # ReceiveBalanceProof was received + 'payer_balance_proof', # ReceiveUnlock was received 'payer_expired', # None of the above happened and the lock expired ) diff --git a/raiden/transfer/mediated_transfer/state_change.py b/raiden/transfer/mediated_transfer/state_change.py index 239f717e7b..91567b62a6 100644 --- a/raiden/transfer/mediated_transfer/state_change.py +++ b/raiden/transfer/mediated_transfer/state_change.py @@ -283,32 +283,6 @@ def __ne__(self, other): return not self.__eq__(other) -class ReceiveBalanceProof(StateChange): - """ A balance proof `identifier` was received. """ - def __init__(self, identifier, node_address, balance_proof): - self.identifier = identifier - self.node_address = node_address - self.balance_proof = balance_proof - - def __repr__(self): - return ''.format( - self.identifier, - pex(self.node_address), - self.balance_proof, - ) - - def __eq__(self, other): - return ( - isinstance(other, ReceiveBalanceProof) and - self.identifier == other.identifier and - self.node_address == other.node_address and - self.balance_proof == other.balance_proof - ) - - def __ne__(self, other): - return not self.__eq__(other) - - class ContractReceiveWithdraw(StateChange): """ A lock was withdrawn via the blockchain. diff --git a/raiden/transfer/mediated_transfer/target.py b/raiden/transfer/mediated_transfer/target.py index 71ddf70b6c..d911f91e5f 100644 --- a/raiden/transfer/mediated_transfer/target.py +++ b/raiden/transfer/mediated_transfer/target.py @@ -127,7 +127,7 @@ def handle_secretreveal(target_state, state_change, channel_state): def handle_unlock(target_state, state_change, channel_state): - """ Handles a ReceiveBalanceProof state change. """ + """ Handles a ReceiveUnlock state change. """ iteration = TransitionResult(target_state, list()) if state_change.balance_proof.sender == target_state.route.node_address: