From 47a68cf013df6c59f77ef7f18b15d75b5953688e Mon Sep 17 00:00:00 2001 From: Loredana Date: Thu, 18 Jan 2018 11:14:36 +0100 Subject: [PATCH 1/2] Remove channel_deposit_bugbounty_limit from contract --- contracts/contracts/RaidenMicroTransferChannels.sol | 9 --------- 1 file changed, 9 deletions(-) diff --git a/contracts/contracts/RaidenMicroTransferChannels.sol b/contracts/contracts/RaidenMicroTransferChannels.sol index 4bf26518..888acfab 100644 --- a/contracts/contracts/RaidenMicroTransferChannels.sol +++ b/contracts/contracts/RaidenMicroTransferChannels.sol @@ -22,12 +22,6 @@ contract RaidenMicroTransferChannels { // Contract semantic version string public constant version = '0.1.0'; - // We temporarily limit total token deposits in a channel to 100 tokens with 18 decimals. - // This was calculated just for RDN with its current (as of 30/11/2017) price and should - // not be considered to be the same for other tokens. - // This is just for the bug bounty release, as a safety measure. - uint256 public constant channel_deposit_bugbounty_limit = 10 ** 18 * 100; - Token public token; mapping (bytes32 => Channel) public channels; @@ -568,8 +562,6 @@ contract RaidenMicroTransferChannels { uint192 _deposit) private { - require(_deposit <= channel_deposit_bugbounty_limit); - uint32 open_block_number = uint32(block.number); // Create unique identifier from sender, receiver and current block number @@ -604,7 +596,6 @@ contract RaidenMicroTransferChannels { require(channels[key].open_block_number > 0); require(closing_requests[key].settle_block_number == 0); - require(channels[key].deposit + _added_deposit <= channel_deposit_bugbounty_limit); channels[key].deposit += _added_deposit; assert(channels[key].deposit >= _added_deposit); From 85dd0cb76c27fc7b4640467f0ae50027798de427 Mon Sep 17 00:00:00 2001 From: Loredana Date: Thu, 18 Jan 2018 11:18:22 +0100 Subject: [PATCH 2/2] Fix tests after channel deposit limit removal --- contracts/tests/fixtures.py | 7 -- contracts/tests/test_channel_create.py | 98 ++----------------------- contracts/tests/test_channel_topup.py | 99 -------------------------- contracts/tests/test_uraiden.py | 5 -- 4 files changed, 5 insertions(+), 204 deletions(-) diff --git a/contracts/tests/fixtures.py b/contracts/tests/fixtures.py index 6ae093b6..c2e6f18c 100644 --- a/contracts/tests/fixtures.py +++ b/contracts/tests/fixtures.py @@ -3,18 +3,13 @@ print_the_logs = False - - MAX_UINT256 = 2 ** 256 - 1 MAX_UINT192 = 2 ** 192 - 1 MAX_UINT32 = 2 ** 32 - 1 fake_address = '0x03432' empty_address = '0x0000000000000000000000000000000000000000' passphrase = '0' - -# recheck test_create_token_fallback_uint_conversion when bug bounty limit is removed uraiden_contract_version = '0.1.0' -channel_deposit_bugbounty_limit = 100 * 10 ** 18 challenge_period_min = 500 contract_args = [ { @@ -45,8 +40,6 @@ 'type': '223' } ] - - uraiden_events = { 'created': 'ChannelCreated', 'topup': 'ChannelToppedUp', diff --git a/contracts/tests/test_channel_create.py b/contracts/tests/test_channel_create.py index d46866ba..67e8db0a 100644 --- a/contracts/tests/test_channel_create.py +++ b/contracts/tests/test_channel_create.py @@ -2,7 +2,6 @@ from ethereum import tester from eth_utils import encode_hex from tests.fixtures import ( - channel_deposit_bugbounty_limit, contract_params, channel_params, owner_index, @@ -83,48 +82,6 @@ def test_channel_erc223_create(owner, get_accounts, uraiden_instance, token_inst token_instance.transact({"from": sender}).transfer(uraiden_instance.address, deposit, txdata) -def test_channel_erc223_create_bounty_limit( - get_block, - owner, - get_accounts, - uraiden_instance, - token_instance): - token = token_instance - (sender, receiver, C, D) = get_accounts(4) - txdata = bytes.fromhex(sender[2:] + receiver[2:]) - - # Fund accounts with tokens - token.transact({"from": owner}).transfer(sender, channel_deposit_bugbounty_limit + 1) - - pre_balance = token_instance.call().balanceOf(uraiden_instance.address) - - with pytest.raises(tester.TransactionFailed): - token_instance.transact({"from": sender}).transfer( - uraiden_instance.address, - channel_deposit_bugbounty_limit + 1, - txdata - ) - with pytest.raises(tester.TransactionFailed): - token_instance.transact({"from": sender}).transfer( - uraiden_instance.address, - channel_deposit_bugbounty_limit + 10, - txdata - ) - - txn_hash = token_instance.transact({"from": sender}).transfer( - uraiden_instance.address, - channel_deposit_bugbounty_limit, - txdata - ) - - post_balance = pre_balance + channel_deposit_bugbounty_limit - assert token_instance.call().balanceOf(uraiden_instance.address) == post_balance - open_block_number = get_block(txn_hash) - - channel_data = uraiden_instance.call().getChannelInfo(sender, receiver, open_block_number) - assert channel_data[1] == channel_deposit_bugbounty_limit - - def test_create_token_fallback_uint_conversion( owner, get_accounts, @@ -154,12 +111,11 @@ def test_create_token_fallback_uint_conversion( txdata ) - # TODO - uncomment this after channel_deposit_bugbounty_limit is removed - # txn_hash = token.transact({"from": sender}).transfer( - # uraiden.address, - # MAX_UINT192, - # txdata - # ) + txn_hash = token.transact({"from": sender}).transfer( + uraiden.address, + MAX_UINT192, + txdata + ) def test_channel_erc223_event( @@ -231,50 +187,6 @@ def test_channel_erc20_create(owner, get_accounts, uraiden_instance, token_insta uraiden_instance.transact({"from": sender}).createChannel(receiver, deposit) -def test_channel_erc20_create_bounty_limit( - owner, - get_accounts, - uraiden_instance, - token_instance, - get_block): - token = token_instance - (sender, receiver) = get_accounts(2) - - # Fund accounts with tokens - token.transact({"from": owner}).transfer(sender, channel_deposit_bugbounty_limit + 1) - - # Approve token allowance - token_instance.transact({"from": sender}).approve( - uraiden_instance.address, - channel_deposit_bugbounty_limit + 1 - ) - - pre_balance = token_instance.call().balanceOf(uraiden_instance.address) - - with pytest.raises(tester.TransactionFailed): - uraiden_instance.transact({"from": sender}).createChannel( - receiver, - channel_deposit_bugbounty_limit + 1 - ) - with pytest.raises(tester.TransactionFailed): - uraiden_instance.transact({"from": sender}).createChannel( - receiver, - channel_deposit_bugbounty_limit + 100 - ) - - txn_hash = uraiden_instance.transact({"from": sender}).createChannel( - receiver, - channel_deposit_bugbounty_limit - ) - - post_balance = pre_balance + channel_deposit_bugbounty_limit - assert token_instance.call().balanceOf(uraiden_instance.address) == post_balance - open_block_number = get_block(txn_hash) - - channel_data = uraiden_instance.call().getChannelInfo(sender, receiver, open_block_number) - assert channel_data[1] == channel_deposit_bugbounty_limit - - def test_channel_erc20_event( owner, get_accounts, diff --git a/contracts/tests/test_channel_topup.py b/contracts/tests/test_channel_topup.py index 3afb3603..df8967e9 100644 --- a/contracts/tests/test_channel_topup.py +++ b/contracts/tests/test_channel_topup.py @@ -1,7 +1,6 @@ import pytest from ethereum import tester from tests.fixtures import ( - channel_deposit_bugbounty_limit, contract_params, channel_params, owner_index, @@ -76,55 +75,6 @@ def test_channel_topup_223( ev_handler.check() -def test_channel_topup_223_bounty_limit( - get_accounts, - owner, - uraiden_instance, - token_instance, - get_channel): - token = token_instance - (sender, receiver, A) = get_accounts(3) - channel_deposit = 1 - channel = get_channel(uraiden_instance, token_instance, channel_deposit, sender, receiver)[:3] - (sender, receiver, open_block_number) = channel - - top_up_data = sender[2:] + receiver[2:] + hex(open_block_number)[2:].zfill(8) - top_up_data = bytes.fromhex(top_up_data) - - # See how many tokens we need to reach channel_deposit_bugbounty_limit - added_deposit = channel_deposit_bugbounty_limit - channel_deposit - - # Fund accounts with tokens - token.transact({"from": owner}).transfer(sender, added_deposit + 1) - - pre_balance = token.call().balanceOf(uraiden_instance.address) - - with pytest.raises(tester.TransactionFailed): - token_instance.transact({"from": sender}).transfer( - uraiden_instance.address, - added_deposit + 1, - top_up_data - ) - with pytest.raises(tester.TransactionFailed): - token_instance.transact({"from": sender}).transfer( - uraiden_instance.address, - added_deposit + 20, - top_up_data - ) - - token_instance.transact({"from": sender}).transfer( - uraiden_instance.address, - added_deposit, - top_up_data - ) - - post_balance = pre_balance + added_deposit - assert token_instance.call().balanceOf(uraiden_instance.address) == post_balance - - channel_data = uraiden_instance.call().getChannelInfo(sender, receiver, open_block_number) - assert channel_data[1] == channel_deposit_bugbounty_limit - - def test_channel_topup_20( get_accounts, uraiden_instance, @@ -194,55 +144,6 @@ def test_channel_topup_20( ev_handler.check() -def test_channel_topup_20_bounty_limit( - get_accounts, - owner, - uraiden_instance, - token_instance, - get_channel): - token = token_instance - (sender, receiver, A) = get_accounts(3) - channel_deposit = 1 - channel = get_channel(uraiden_instance, token_instance, channel_deposit, sender, receiver)[:3] - (sender, receiver, open_block_number) = channel - - # See how many tokens we need to reach channel_deposit_bugbounty_limit - added_deposit = channel_deposit_bugbounty_limit - channel_deposit - - # Fund accounts with tokens - token.transact({"from": owner}).transfer(sender, added_deposit + 1) - - # Approve token allowance - txn_hash = token.transact({"from": sender}).approve(uraiden_instance.address, added_deposit + 1) - - pre_balance = token.call().balanceOf(uraiden_instance.address) - - with pytest.raises(tester.TransactionFailed): - uraiden_instance.transact({'from': sender}).topUp( - receiver, - open_block_number, - added_deposit + 1 - ) - with pytest.raises(tester.TransactionFailed): - uraiden_instance.transact({'from': sender}).topUp( - receiver, - open_block_number, - added_deposit + 50 - ) - - uraiden_instance.transact({'from': sender}).topUp( - receiver, - open_block_number, - added_deposit - ) - - post_balance = pre_balance + added_deposit - assert token_instance.call().balanceOf(uraiden_instance.address) == post_balance - - channel_data = uraiden_instance.call().getChannelInfo(sender, receiver, open_block_number) - assert channel_data[1] == channel_deposit_bugbounty_limit - - def test_topup_token_fallback_uint_conversion( contract_params, owner, diff --git a/contracts/tests/test_uraiden.py b/contracts/tests/test_uraiden.py index e5fbd3df..a6901e5c 100644 --- a/contracts/tests/test_uraiden.py +++ b/contracts/tests/test_uraiden.py @@ -2,7 +2,6 @@ from ethereum import tester from eth_utils import encode_hex, is_same_address from tests.fixtures import ( - channel_deposit_bugbounty_limit, uraiden_contract_version, challenge_period_min, contract_params, @@ -72,9 +71,6 @@ def test_uraiden_init( assert token.call().balanceOf(uraiden.address) == 0 assert web3.eth.getBalance(uraiden.address) == 0 - # Temporary limit for the bug bounty release - assert uraiden.call().channel_deposit_bugbounty_limit() == channel_deposit_bugbounty_limit - def test_variable_access(owner, uraiden_contract, token_instance, contract_params): uraiden = uraiden_contract(token_instance) @@ -82,7 +78,6 @@ def test_variable_access(owner, uraiden_contract, token_instance, contract_param assert is_same_address(uraiden.call().token(), token_instance.address) assert uraiden.call().challenge_period() == contract_params['challenge_period'] assert uraiden.call().version() == uraiden_contract_version - assert uraiden.call().channel_deposit_bugbounty_limit() == channel_deposit_bugbounty_limit def test_function_access(