Skip to content

Commit

Permalink
Enforce limitless TNs after limit removal in TNR
Browse files Browse the repository at this point in the history
We want the limit removal to be completely done once we do it. When new
TN are deployed afterwards, they must be deployed without limits.

Closes #1416
  • Loading branch information
karlb authored and palango committed Jul 29, 2021
1 parent f2d4049 commit 7f9201d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
7 changes: 7 additions & 0 deletions raiden_contracts/data/source/raiden/TokenNetworkRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ contract TokenNetworkRegistry is Utils {
canCreateTokenNetwork
returns (address token_network_address)
{
// After the limits have been removed, new token networks must be created without limits
// See https://github.com/raiden-network/raiden-contracts/issues/1416
if (max_token_networks == MAX_INT) {
require(_channel_participant_deposit_limit == MAX_INT, "Limits must be set to MAX_INT");
require(_token_network_deposit_limit == MAX_INT, "Limits must be set to MAX_INT");
}

require(token_to_token_networks[_token_address] == address(0x0));

// We limit the number of token networks to 1 for the Bug Bounty release
Expand Down
14 changes: 11 additions & 3 deletions raiden_contracts/tests/test_contract_limits.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
ParticipantInfoIndex,
)
from raiden_contracts.tests.utils import call_and_transact
from raiden_contracts.tests.utils.constants import DEPLOYER_ADDRESS
from raiden_contracts.tests.utils.constants import DEPLOYER_ADDRESS, UINT256_MAX


def test_register_three_but_not_four(
Expand Down Expand Up @@ -69,11 +69,19 @@ def test_register_three_but_not_four(

# Now remove the limit and try again
call_and_transact(token_network_registry.functions.removeLimits(), {"from": DEPLOYER_ADDRESS})
with pytest.raises(TransactionFailed, match="Limits must be set to MAX_INT"):
call_and_transact(
token_network_registry.functions.createERC20TokenNetwork(
token4.address,
channel_participant_deposit_limit,
token_network_deposit_limit,
)
)
call_and_transact(
token_network_registry.functions.createERC20TokenNetwork(
token4.address,
channel_participant_deposit_limit,
token_network_deposit_limit,
UINT256_MAX,
UINT256_MAX,
)
)

Expand Down

0 comments on commit 7f9201d

Please sign in to comment.