Skip to content

Commit

Permalink
Allow removal of balance limits in TokenNetwork
Browse files Browse the repository at this point in the history
See #1481
  • Loading branch information
karlb authored and palango committed Jul 29, 2021
1 parent bc7d429 commit 5346cf6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
14 changes: 13 additions & 1 deletion raiden_contracts/data/source/raiden/TokenNetwork.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import "raiden/Token.sol";
import "raiden/Utils.sol";
import "raiden/SecretRegistry.sol";

uint256 constant MAX_INT = 2**256 - 1;

/// @title TokenNetwork
/// @notice Stores and manages all the Raiden Network channels that use the
/// token specified in this TokenNetwork contract.
Expand Down Expand Up @@ -201,7 +203,7 @@ contract TokenNetwork is Utils {
);

modifier onlyDeprecationExecutor() {
require(msg.sender == deprecation_executor);
require(msg.sender == deprecation_executor, "Can only be called by deprecation_executor");
_;
}

Expand Down Expand Up @@ -1553,4 +1555,14 @@ contract TokenNetwork is Utils {
pair_hash = getParticipantsHash(participant1, participant2);
delete participants_hash_to_channel_identifier[pair_hash];
}

/// @notice Removes the balance limits.
/// Can only be called by the deprecation_executor.
function removeLimits()
external
onlyDeprecationExecutor
{
channel_participant_deposit_limit = MAX_INT;
token_network_deposit_limit = MAX_INT;
}
}
2 changes: 0 additions & 2 deletions raiden_contracts/data/source/raiden/TokenNetworkRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import "raiden/Utils.sol";
import "raiden/Token.sol";
import "raiden/TokenNetwork.sol";

uint256 constant MAX_INT = 2**256 - 1;

/// @title TokenNetworkRegistry
/// @notice The TokenNetwork Registry deploys new TokenNetwork contracts for the
/// Raiden Network protocol.
Expand Down
12 changes: 12 additions & 0 deletions raiden_contracts/tests/test_contract_limits.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,14 @@ def test_participant_deposit_limit(
{"from": B},
)

# Now disable the limits and try again
with pytest.raises(TransactionFailed, match="Can only be called by"):
call_and_transact(token_network.functions.removeLimits())
call_and_transact(token_network.functions.removeLimits(), {"from": DEPLOYER_ADDRESS})
token_network.functions.setTotalDeposit(
channel_identifier, B, MAX_ETH_CHANNEL_PARTICIPANT + 1, A
).call({"from": B})


@pytest.mark.skip(reason="Only for local testing, otherwise it takes too much time to run.")
def test_network_deposit_limit(
Expand Down Expand Up @@ -243,3 +251,7 @@ def send_remaining(
D = create_account()
with pytest.raises(TransactionFailed):
create_channel(C, D)

# Now disable the limits and try again
call_and_transact(token_network.functions.removeLimits(), {"from": DEPLOYER_ADDRESS})
token_network.functions.setTotalDeposit(channel_identifier, A, 1, B).call({"from": A})

0 comments on commit 5346cf6

Please sign in to comment.