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

Update to SolC 0.8.6 #1517

Merged
merged 3 commits into from
Aug 12, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion raiden_contracts/contract_source_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from raiden_contracts.contract_manager import ContractManager, contracts_data_path

_BASE = Path(__file__).parent
SOLC_VERSION = "0.7.6"
SOLC_VERSION = "0.8.6"


class ContractSourceManagerCompilationError(RuntimeError):
Expand Down
182 changes: 91 additions & 91 deletions raiden_contracts/data/contracts.json

Large diffs are not rendered by default.

64 changes: 32 additions & 32 deletions raiden_contracts/data/gas.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
{
"CustomToken.approve": 45996,
"CustomToken.mint": 50543,
"CustomToken.transfer": 36269,
"CustomToken.transferFrom": 28799,
"MonitoringService.claimReward": 45679,
"MonitoringService.monitor": 227988,
"OneToN.bulkClaim 1 ious": 107199,
"OneToN.bulkClaim 6 ious": 167010,
"OneToN.claim": 104092,
"SecretRegistry.registerSecret": 46295,
"SecretRegistry.registerSecretBatch1": 46808,
"SecretRegistry.registerSecretBatch2": 71620,
"SecretRegistry.registerSecretBatch3": 96432,
"ServiceRegistry.deposit": 491725,
"ServiceRegistry.setURL": 47137,
"TokenNetwork DEPLOYMENT": 3852243,
"TokenNetwork.closeChannel": 120706,
"TokenNetwork.cooperativeSettle": 113805,
"TokenNetwork.openChannel": 113256,
"TokenNetwork.openChannelWithDeposit": 149245,
"TokenNetwork.setTotalDeposit": 55830,
"TokenNetwork.setTotalWithdraw": 117009,
"TokenNetwork.settleChannel": 108347,
"TokenNetwork.unlock 1 locks": 38536,
"TokenNetwork.unlock 6 locks": 53219,
"TokenNetwork.updateNonClosingBalanceProof": 92886,
"TokenNetworkRegistry DEPLOYMENT": 4607854,
"TokenNetworkRegistry createERC20TokenNetwork": 3630206,
"UserDeposit.deposit": 97821,
"UserDeposit.deposit (increase balance)": 33621,
"UserDeposit.planWithdraw": 69680,
"UserDeposit.withdraw": 48896
"CustomToken.approve": 46118,
"CustomToken.mint": 50776,
"CustomToken.transfer": 36556,
"CustomToken.transferFrom": 29060,
"MonitoringService.claimReward": 45683,
"MonitoringService.monitor": 228082,
"OneToN.bulkClaim 1 ious": 107282,
"OneToN.bulkClaim 6 ious": 166866,
"OneToN.claim": 103900,
"SecretRegistry.registerSecret": 46205,
"SecretRegistry.registerSecretBatch1": 46799,
"SecretRegistry.registerSecretBatch2": 71627,
"SecretRegistry.registerSecretBatch3": 96455,
"ServiceRegistry.deposit": 478020,
"ServiceRegistry.setURL": 47165,
"TokenNetwork DEPLOYMENT": 3920887,
"TokenNetwork.closeChannel": 120676,
"TokenNetwork.cooperativeSettle": 114948,
"TokenNetwork.openChannel": 113388,
"TokenNetwork.openChannelWithDeposit": 149798,
"TokenNetwork.setTotalDeposit": 56274,
"TokenNetwork.setTotalWithdraw": 117471,
"TokenNetwork.settleChannel": 108628,
"TokenNetwork.unlock 1 locks": 38869,
"TokenNetwork.unlock 6 locks": 54090,
"TokenNetwork.updateNonClosingBalanceProof": 92745,
"TokenNetworkRegistry DEPLOYMENT": 4639695,
"TokenNetworkRegistry createERC20TokenNetwork": 3695803,
"UserDeposit.deposit": 98819,
"UserDeposit.deposit (increase balance)": 34619,
"UserDeposit.planWithdraw": 69778,
"UserDeposit.withdraw": 49317
}
2 changes: 1 addition & 1 deletion raiden_contracts/data/source/lib/ECVerify.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT
/* solium-disable error-reason */
pragma solidity 0.7.6;
pragma solidity 0.8.6;
pragma abicoder v2;

library ECVerify {
Expand Down
2 changes: 1 addition & 1 deletion raiden_contracts/data/source/lib/MessageType.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT
/* solium-disable error-reason */
pragma solidity 0.7.6;
pragma solidity 0.8.6;
pragma abicoder v2;

library MessageType {
Expand Down
2 changes: 1 addition & 1 deletion raiden_contracts/data/source/raiden/Controllable.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.7.6;
pragma solidity 0.8.6;
pragma abicoder v2;

contract Controllable {
Expand Down
2 changes: 1 addition & 1 deletion raiden_contracts/data/source/raiden/SecretRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.7.6;
pragma solidity 0.8.6;
pragma abicoder v2;

/// @title SecretRegistry
Expand Down
2 changes: 1 addition & 1 deletion raiden_contracts/data/source/raiden/Token.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.7.6;
pragma solidity 0.8.6;
pragma abicoder v2;

interface Token {
Expand Down
44 changes: 23 additions & 21 deletions raiden_contracts/data/source/raiden/TokenNetwork.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT
/* solium-disable indentation */
pragma solidity 0.7.6;
pragma solidity 0.8.6;
pragma abicoder v2;

import "lib/ECVerify.sol";
Expand Down Expand Up @@ -1186,32 +1186,34 @@ contract TokenNetwork is Utils, Controllable {
Participant storage participant_state = channel.participants[participant];
Participant storage partner_state = channel.participants[partner];

// Calculate the actual amount of tokens that will be transferred
added_deposit = total_deposit - participant_state.deposit;
unchecked {
// Calculate the actual amount of tokens that will be transferred
added_deposit = total_deposit - participant_state.deposit;

// The actual amount of tokens that will be transferred must be > 0
require(added_deposit > 0, "TN/deposit: no deposit added");
// The actual amount of tokens that will be transferred must be > 0
require(added_deposit > 0, "TN/deposit: no deposit added");

// Underflow check; we use <= because added_deposit == total_deposit for the first deposit
require(added_deposit <= total_deposit, "TN/deposit: deposit underflow");
// Underflow check; we use <= because added_deposit == total_deposit for the first deposit
require(added_deposit <= total_deposit, "TN/deposit: deposit underflow");

// This should never fail at this point. Added check for security, because we directly set
// the participant_state.deposit = total_deposit, while we transfer `added_deposit` tokens
assert(participant_state.deposit + added_deposit == total_deposit);
// This should never fail at this point. Added check for security, because we directly set
// the participant_state.deposit = total_deposit, while we transfer `added_deposit` tokens
assert(participant_state.deposit + added_deposit == total_deposit);

// Red Eyes release token network limit
require(
token.balanceOf(address(this)) + added_deposit <= token_network_deposit_limit,
"TN/deposit: network limit reached"
);
// Red Eyes release token network limit
require(
token.balanceOf(address(this)) + added_deposit <= token_network_deposit_limit,
"TN/deposit: network limit reached"
);

// Update the participant's channel deposit
participant_state.deposit = total_deposit;
// Update the participant's channel deposit
participant_state.deposit = total_deposit;

// Calculate the entire channel deposit, to avoid overflow
channel_deposit = participant_state.deposit + partner_state.deposit;
// Overflow check
require(channel_deposit >= participant_state.deposit, "TN/deposit: deposit overflow");
// Calculate the entire channel deposit, to avoid overflow
channel_deposit = participant_state.deposit + partner_state.deposit;
// Overflow check
require(channel_deposit >= participant_state.deposit, "TN/deposit: deposit overflow");
}

emit ChannelNewDeposit(
channel_identifier,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT
/* solium-disable error-reason */
pragma solidity 0.7.6;
pragma solidity 0.8.6;
pragma abicoder v2;

import "raiden/Utils.sol";
Expand Down
12 changes: 8 additions & 4 deletions raiden_contracts/data/source/raiden/Utils.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.7.6;
pragma solidity 0.8.6;
pragma abicoder v2;

/// @title Utils
Expand Down Expand Up @@ -45,7 +45,9 @@ contract Utils {
pure
returns (uint256, uint256)
{
return a > b ? (a - b, b) : (0, a);
unchecked {
return a > b ? (a - b, b) : (0, a);
}
}

/// @dev Special addition function that does not fail when overflowing.
Expand All @@ -58,7 +60,9 @@ contract Utils {
pure
returns (uint256)
{
uint256 sum = a + b;
return sum >= a ? sum : MAX_SAFE_UINT256;
unchecked {
uint256 sum = a + b;
return sum >= a ? sum : MAX_SAFE_UINT256;
}
}
}
8 changes: 4 additions & 4 deletions raiden_contracts/data/source/services/MonitoringService.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.7.6;
pragma solidity 0.8.6;
pragma abicoder v2;

import "lib/ECVerify.sol";
Expand Down Expand Up @@ -296,9 +296,9 @@ contract MonitoringService is Utils {

// Offset for this specific MS within the range
uint256 ms_offset = (
uint256(participant1) +
uint256(participant2) +
uint256(monitoring_service_address)
uint256(uint160(participant1)) +
uint256(uint160(participant2)) +
uint256(uint160(monitoring_service_address))
) % range_length;

return best_case_block + ms_offset;
Expand Down
2 changes: 1 addition & 1 deletion raiden_contracts/data/source/services/OneToN.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.7.6;
pragma solidity 0.8.6;
pragma abicoder v2;

import "lib/ECVerify.sol";
Expand Down
6 changes: 4 additions & 2 deletions raiden_contracts/data/source/services/ServiceRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
/* solium-disable indentation */
/* solium-disable security/no-block-members */
pragma solidity 0.7.6;
pragma solidity 0.8.6;
pragma abicoder v2;

import "raiden/Token.sol";
Expand Down Expand Up @@ -280,7 +280,9 @@ contract ServiceRegistry is Utils, ServiceRegistryConfigurableParameters {
valid_till = block.timestamp;
}
// Check against overflow.
require(valid_till < valid_till + registration_duration, "overflow during extending the registration");
unchecked {
require(valid_till < valid_till + registration_duration, "overflow during extending the registration");
}
valid_till = valid_till + registration_duration;
assert(valid_till > service_valid_till[msg.sender]);
service_valid_till[msg.sender] = valid_till;
Expand Down
2 changes: 1 addition & 1 deletion raiden_contracts/data/source/services/UserDeposit.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.7.6;
pragma solidity 0.8.6;
pragma abicoder v2;

import "raiden/Token.sol";
Expand Down
4 changes: 2 additions & 2 deletions raiden_contracts/data/source/test/CustomToken.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT
/* solium-disable error-reason */
pragma solidity 0.7.6;
pragma solidity 0.8.6;

/*
This Token Contract implements the standard token functionality (https://github.com/ethereum/EIPs/issues/20), the ERC223 functionality (https://github.com/ethereum/EIPs/issues/223) as well as the following OPTIONAL extras intended for use by humans.
Expand Down Expand Up @@ -60,7 +60,7 @@ contract CustomToken is StandardToken {
symbol = token_symbol;

// Initial supply is assigned to the owner
owner_address = msg.sender;
owner_address = payable(msg.sender);
balances[owner_address] = initial_supply;
_total_supply = initial_supply;
}
Expand Down
2 changes: 1 addition & 1 deletion raiden_contracts/data/source/test/HumanStandardToken.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT
/* solium-disable */
pragma solidity 0.7.6;
pragma solidity 0.8.6;

import "test/StandardToken.sol";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.7.6;
pragma solidity 0.8.6;

import "services/MonitoringService.sol";

Expand Down
2 changes: 1 addition & 1 deletion raiden_contracts/data/source/test/OneToNInternalsTest.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.7.6;
pragma solidity 0.8.6;

import "services/OneToN.sol";

Expand Down
2 changes: 1 addition & 1 deletion raiden_contracts/data/source/test/SignatureVerifyTest.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.7.6;
pragma solidity 0.8.6;

/*
* This is a contract used for testing the ECVerify library and ecrecover behaviour.
Expand Down
2 changes: 1 addition & 1 deletion raiden_contracts/data/source/test/StandardToken.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT
/* solium-disable */
pragma solidity 0.7.6;
pragma solidity 0.8.6;

import "raiden/Token.sol";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.7.6;
pragma solidity 0.8.6;
pragma experimental ABIEncoderV2;

import "lib/MessageType.sol";
Expand Down Expand Up @@ -267,6 +267,6 @@ contract TokenNetworkUtilsTest is TokenNetwork {
}

function get_max_safe_uint256() public pure returns (uint256) {
return uint256(0 - 1);
return MAX_SAFE_UINT256;
}
}
2 changes: 1 addition & 1 deletion raiden_contracts/data/source/test/UDCTransfer.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.7.6;
pragma solidity 0.8.6;

import "services/UserDeposit.sol";

Expand Down