diff --git a/nucypher/blockchain/eth/sol/__conf__.py b/nucypher/blockchain/eth/sol/__conf__.py index 2223629fd..ce1421e02 100644 --- a/nucypher/blockchain/eth/sol/__conf__.py +++ b/nucypher/blockchain/eth/sol/__conf__.py @@ -15,4 +15,4 @@ You should have received a copy of the GNU Affero General Public License along with nucypher. If not, see . """ -SOLIDITY_COMPILER_VERSION = 'v0.6.7' +SOLIDITY_COMPILER_VERSION = 'v0.6.9' diff --git a/nucypher/blockchain/eth/sol/source/aragon/interfaces/IERC900History.sol b/nucypher/blockchain/eth/sol/source/aragon/interfaces/IERC900History.sol index 5a693402f..2f038d802 100644 --- a/nucypher/blockchain/eth/sol/source/aragon/interfaces/IERC900History.sol +++ b/nucypher/blockchain/eth/sol/source/aragon/interfaces/IERC900History.sol @@ -1,5 +1,8 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + pragma solidity ^0.6.5; + // Minimum interface to interact with Aragon's Aggregator interface IERC900History { function totalStakedForAt(address addr, uint256 blockNumber) external view returns (uint256); diff --git a/nucypher/blockchain/eth/sol/source/contracts/Adjudicator.sol b/nucypher/blockchain/eth/sol/source/contracts/Adjudicator.sol index 7bac55bb4..60942a2e3 100644 --- a/nucypher/blockchain/eth/sol/source/contracts/Adjudicator.sol +++ b/nucypher/blockchain/eth/sol/source/contracts/Adjudicator.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + pragma solidity ^0.6.5; import "contracts/lib/ReEncryptionValidator.sol"; diff --git a/nucypher/blockchain/eth/sol/source/contracts/Issuer.sol b/nucypher/blockchain/eth/sol/source/contracts/Issuer.sol index 7f27519c2..7670b376d 100644 --- a/nucypher/blockchain/eth/sol/source/contracts/Issuer.sol +++ b/nucypher/blockchain/eth/sol/source/contracts/Issuer.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + pragma solidity ^0.6.5; diff --git a/nucypher/blockchain/eth/sol/source/contracts/MultiSig.sol b/nucypher/blockchain/eth/sol/source/contracts/MultiSig.sol index c79661deb..25feb2f52 100644 --- a/nucypher/blockchain/eth/sol/source/contracts/MultiSig.sol +++ b/nucypher/blockchain/eth/sol/source/contracts/MultiSig.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + pragma solidity ^0.6.1; @@ -30,9 +32,7 @@ contract MultiSig { _; } - // TODO #1809 -// receive() external payable {} - fallback() external payable {} + receive() external payable {} /** * @param _required Number of required signings diff --git a/nucypher/blockchain/eth/sol/source/contracts/NuCypherToken.sol b/nucypher/blockchain/eth/sol/source/contracts/NuCypherToken.sol index ef08a2cb0..f61d66dfe 100644 --- a/nucypher/blockchain/eth/sol/source/contracts/NuCypherToken.sol +++ b/nucypher/blockchain/eth/sol/source/contracts/NuCypherToken.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + pragma solidity ^0.6.1; diff --git a/nucypher/blockchain/eth/sol/source/contracts/PolicyManager.sol b/nucypher/blockchain/eth/sol/source/contracts/PolicyManager.sol index 3cdfe7211..41b397813 100644 --- a/nucypher/blockchain/eth/sol/source/contracts/PolicyManager.sol +++ b/nucypher/blockchain/eth/sol/source/contracts/PolicyManager.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + pragma solidity ^0.6.5; diff --git a/nucypher/blockchain/eth/sol/source/contracts/StakingEscrow.sol b/nucypher/blockchain/eth/sol/source/contracts/StakingEscrow.sol index 13e880e86..3c409b65e 100644 --- a/nucypher/blockchain/eth/sol/source/contracts/StakingEscrow.sol +++ b/nucypher/blockchain/eth/sol/source/contracts/StakingEscrow.sol @@ -1,5 +1,8 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + pragma solidity ^0.6.5; + import "aragon/interfaces/IERC900History.sol"; import "contracts/Issuer.sol"; import "contracts/lib/Bits.sol"; diff --git a/nucypher/blockchain/eth/sol/source/contracts/WorkLock.sol b/nucypher/blockchain/eth/sol/source/contracts/WorkLock.sol index 628d52d0c..2453e0dcc 100644 --- a/nucypher/blockchain/eth/sol/source/contracts/WorkLock.sol +++ b/nucypher/blockchain/eth/sol/source/contracts/WorkLock.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + pragma solidity ^0.6.5; diff --git a/nucypher/blockchain/eth/sol/source/contracts/lib/AdditionalMath.sol b/nucypher/blockchain/eth/sol/source/contracts/lib/AdditionalMath.sol index ac3ffc482..e5675efc9 100644 --- a/nucypher/blockchain/eth/sol/source/contracts/lib/AdditionalMath.sol +++ b/nucypher/blockchain/eth/sol/source/contracts/lib/AdditionalMath.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + pragma solidity ^0.6.1; diff --git a/nucypher/blockchain/eth/sol/source/contracts/lib/Bits.sol b/nucypher/blockchain/eth/sol/source/contracts/lib/Bits.sol index 06707fd8e..18f6222ca 100644 --- a/nucypher/blockchain/eth/sol/source/contracts/lib/Bits.sol +++ b/nucypher/blockchain/eth/sol/source/contracts/lib/Bits.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + pragma solidity ^0.6.1; /** diff --git a/nucypher/blockchain/eth/sol/source/contracts/lib/ReEncryptionValidator.sol b/nucypher/blockchain/eth/sol/source/contracts/lib/ReEncryptionValidator.sol index 39a764aaa..17ea63b4e 100644 --- a/nucypher/blockchain/eth/sol/source/contracts/lib/ReEncryptionValidator.sol +++ b/nucypher/blockchain/eth/sol/source/contracts/lib/ReEncryptionValidator.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + pragma solidity ^0.6.1; import "contracts/lib/UmbralDeserializer.sol"; @@ -11,9 +13,9 @@ library ReEncryptionValidator { using UmbralDeserializer for bytes; - ////////////////////////////////// + //------------------------------// // Umbral-specific constants // - ////////////////////////////////// + //------------------------------// // See parameter `u` of `UmbralParameters` class in pyUmbral // https://github.com/nucypher/pyUmbral/blob/master/umbral/params.py @@ -22,9 +24,9 @@ library ReEncryptionValidator { uint256 public constant UMBRAL_PARAMETER_U_YCOORD = 0x7880ed56962d7c0ae44d6f14bb53b5fe64b31ea44a41d0316f3a598778f0f936; - ////////////////////////////////// + //------------------------------// // SECP256K1-specific constants // - ////////////////////////////////// + //------------------------------// // Base field order uint256 constant FIELD_ORDER = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F; diff --git a/nucypher/blockchain/eth/sol/source/contracts/lib/SignatureVerifier.sol b/nucypher/blockchain/eth/sol/source/contracts/lib/SignatureVerifier.sol index deaf09a55..005efdd28 100644 --- a/nucypher/blockchain/eth/sol/source/contracts/lib/SignatureVerifier.sol +++ b/nucypher/blockchain/eth/sol/source/contracts/lib/SignatureVerifier.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + pragma solidity ^0.6.1; diff --git a/nucypher/blockchain/eth/sol/source/contracts/lib/Snapshot.sol b/nucypher/blockchain/eth/sol/source/contracts/lib/Snapshot.sol index 41755f801..598d554b7 100644 --- a/nucypher/blockchain/eth/sol/source/contracts/lib/Snapshot.sol +++ b/nucypher/blockchain/eth/sol/source/contracts/lib/Snapshot.sol @@ -1,5 +1,8 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + pragma solidity ^0.6.5; + /** * @title Snapshot * @notice Manages snapshots of size 128 bits (32 bits for timestamp, 96 bits for value) diff --git a/nucypher/blockchain/eth/sol/source/contracts/lib/UmbralDeserializer.sol b/nucypher/blockchain/eth/sol/source/contracts/lib/UmbralDeserializer.sol index 817f90908..63d77f982 100644 --- a/nucypher/blockchain/eth/sol/source/contracts/lib/UmbralDeserializer.sol +++ b/nucypher/blockchain/eth/sol/source/contracts/lib/UmbralDeserializer.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + pragma solidity ^0.6.1; diff --git a/nucypher/blockchain/eth/sol/source/contracts/proxy/Dispatcher.sol b/nucypher/blockchain/eth/sol/source/contracts/proxy/Dispatcher.sol index 0fc48fc1b..ea685dd8c 100644 --- a/nucypher/blockchain/eth/sol/source/contracts/proxy/Dispatcher.sol +++ b/nucypher/blockchain/eth/sol/source/contracts/proxy/Dispatcher.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + pragma solidity ^0.6.1; @@ -131,7 +133,19 @@ contract Dispatcher is Upgradeable, ERCProxy { function finishUpgrade(address) public override {} /** - * @dev Fallback function send all requests to the target contract + * @dev Receive function sends empty request to the target contract + */ + receive() external payable { + assert(target.isContract()); + // execute receive function from target contract using storage of the dispatcher + (bool callSuccess,) = target.delegatecall(""); + if (!callSuccess) { + revert(); + } + } + + /** + * @dev Fallback function sends all requests to the target contract */ fallback() external payable { assert(target.isContract()); diff --git a/nucypher/blockchain/eth/sol/source/contracts/proxy/Upgradeable.sol b/nucypher/blockchain/eth/sol/source/contracts/proxy/Upgradeable.sol index f11596db9..92fe2167e 100644 --- a/nucypher/blockchain/eth/sol/source/contracts/proxy/Upgradeable.sol +++ b/nucypher/blockchain/eth/sol/source/contracts/proxy/Upgradeable.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + pragma solidity ^0.6.1; @@ -37,7 +39,9 @@ abstract contract Upgradeable is Ownable { */ uint256 stubSlot; - /** Constants for `isUpgrade` field **/ + /** + * @dev Constants for `isUpgrade` field + */ uint8 constant UPGRADE_FALSE = 1; uint8 constant UPGRADE_TRUE = 2; diff --git a/nucypher/blockchain/eth/sol/source/contracts/staking_contracts/AbstractStakingContract.sol b/nucypher/blockchain/eth/sol/source/contracts/staking_contracts/AbstractStakingContract.sol index acc987e7c..0c3b8ec39 100644 --- a/nucypher/blockchain/eth/sol/source/contracts/staking_contracts/AbstractStakingContract.sol +++ b/nucypher/blockchain/eth/sol/source/contracts/staking_contracts/AbstractStakingContract.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + pragma solidity ^0.6.5; @@ -71,15 +73,12 @@ abstract contract AbstractStakingContract { */ function withdrawETH() public virtual; + receive() external payable {} + /** * @dev Function sends all requests to the target contract */ - // TODO #1809 fallback() external payable { - if (msg.data.length == 0) { - return; - } - require(isFallbackAllowed()); address target = address(router.target()); require(target.isContract()); diff --git a/nucypher/blockchain/eth/sol/source/contracts/staking_contracts/PreallocationEscrow.sol b/nucypher/blockchain/eth/sol/source/contracts/staking_contracts/PreallocationEscrow.sol index fbc1c2bea..6c236b561 100644 --- a/nucypher/blockchain/eth/sol/source/contracts/staking_contracts/PreallocationEscrow.sol +++ b/nucypher/blockchain/eth/sol/source/contracts/staking_contracts/PreallocationEscrow.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + pragma solidity ^0.6.5; diff --git a/nucypher/blockchain/eth/sol/source/contracts/staking_contracts/StakingInterface.sol b/nucypher/blockchain/eth/sol/source/contracts/staking_contracts/StakingInterface.sol index 449b98157..fcaa496fd 100644 --- a/nucypher/blockchain/eth/sol/source/contracts/staking_contracts/StakingInterface.sol +++ b/nucypher/blockchain/eth/sol/source/contracts/staking_contracts/StakingInterface.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + pragma solidity ^0.6.5; diff --git a/nucypher/blockchain/eth/sol/source/zeppelin/math/Math.sol b/nucypher/blockchain/eth/sol/source/zeppelin/math/Math.sol index fd6b525c0..dd8c42894 100644 --- a/nucypher/blockchain/eth/sol/source/zeppelin/math/Math.sol +++ b/nucypher/blockchain/eth/sol/source/zeppelin/math/Math.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: MIT + pragma solidity ^0.6.1; diff --git a/nucypher/blockchain/eth/sol/source/zeppelin/math/SafeMath.sol b/nucypher/blockchain/eth/sol/source/zeppelin/math/SafeMath.sol index 815e560e5..44be38185 100644 --- a/nucypher/blockchain/eth/sol/source/zeppelin/math/SafeMath.sol +++ b/nucypher/blockchain/eth/sol/source/zeppelin/math/SafeMath.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: MIT + pragma solidity ^0.6.1; diff --git a/nucypher/blockchain/eth/sol/source/zeppelin/ownership/Ownable.sol b/nucypher/blockchain/eth/sol/source/zeppelin/ownership/Ownable.sol index 5b67c531c..d5587c89f 100644 --- a/nucypher/blockchain/eth/sol/source/zeppelin/ownership/Ownable.sol +++ b/nucypher/blockchain/eth/sol/source/zeppelin/ownership/Ownable.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: MIT + pragma solidity ^0.6.1; diff --git a/nucypher/blockchain/eth/sol/source/zeppelin/token/ERC20/ERC20.sol b/nucypher/blockchain/eth/sol/source/zeppelin/token/ERC20/ERC20.sol index 74ba34e10..443f9593c 100644 --- a/nucypher/blockchain/eth/sol/source/zeppelin/token/ERC20/ERC20.sol +++ b/nucypher/blockchain/eth/sol/source/zeppelin/token/ERC20/ERC20.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: MIT + pragma solidity ^0.6.1; diff --git a/nucypher/blockchain/eth/sol/source/zeppelin/token/ERC20/ERC20Detailed.sol b/nucypher/blockchain/eth/sol/source/zeppelin/token/ERC20/ERC20Detailed.sol index a7b9a22b7..28b26c5dd 100644 --- a/nucypher/blockchain/eth/sol/source/zeppelin/token/ERC20/ERC20Detailed.sol +++ b/nucypher/blockchain/eth/sol/source/zeppelin/token/ERC20/ERC20Detailed.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: MIT + pragma solidity ^0.6.1; diff --git a/nucypher/blockchain/eth/sol/source/zeppelin/token/ERC20/IERC20.sol b/nucypher/blockchain/eth/sol/source/zeppelin/token/ERC20/IERC20.sol index 415e4bc75..0c21dc185 100644 --- a/nucypher/blockchain/eth/sol/source/zeppelin/token/ERC20/IERC20.sol +++ b/nucypher/blockchain/eth/sol/source/zeppelin/token/ERC20/IERC20.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: MIT + pragma solidity ^0.6.1; diff --git a/nucypher/blockchain/eth/sol/source/zeppelin/token/ERC20/SafeERC20.sol b/nucypher/blockchain/eth/sol/source/zeppelin/token/ERC20/SafeERC20.sol index ec80ed5ce..aa2b624a9 100644 --- a/nucypher/blockchain/eth/sol/source/zeppelin/token/ERC20/SafeERC20.sol +++ b/nucypher/blockchain/eth/sol/source/zeppelin/token/ERC20/SafeERC20.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: MIT + pragma solidity ^0.6.1; diff --git a/nucypher/blockchain/eth/sol/source/zeppelin/utils/Address.sol b/nucypher/blockchain/eth/sol/source/zeppelin/utils/Address.sol index a16079f46..1301dc551 100644 --- a/nucypher/blockchain/eth/sol/source/zeppelin/utils/Address.sol +++ b/nucypher/blockchain/eth/sol/source/zeppelin/utils/Address.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: MIT + pragma solidity ^0.6.1; /** diff --git a/tests/acceptance/blockchain/interfaces/contracts/multiversion/v1/VersionTest.sol b/tests/acceptance/blockchain/interfaces/contracts/multiversion/v1/VersionTest.sol index 520ca0bed..b52d072e3 100644 --- a/tests/acceptance/blockchain/interfaces/contracts/multiversion/v1/VersionTest.sol +++ b/tests/acceptance/blockchain/interfaces/contracts/multiversion/v1/VersionTest.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + pragma solidity ^0.6.1; diff --git a/tests/acceptance/blockchain/interfaces/contracts/multiversion/v2/VersionTest.sol b/tests/acceptance/blockchain/interfaces/contracts/multiversion/v2/VersionTest.sol index d7089c188..41e80f02e 100644 --- a/tests/acceptance/blockchain/interfaces/contracts/multiversion/v2/VersionTest.sol +++ b/tests/acceptance/blockchain/interfaces/contracts/multiversion/v2/VersionTest.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + pragma solidity ^0.6.1; diff --git a/tests/contracts/base/test_dispatcher.py b/tests/contracts/base/test_dispatcher.py index 3e7b812ff..42f292c42 100644 --- a/tests/contracts/base/test_dispatcher.py +++ b/tests/contracts/base/test_dispatcher.py @@ -561,3 +561,56 @@ def test_selfdestruct(testerchain, deploy_contract): testerchain.wait_for_receipt(tx) assert 26 == contract_instance.functions.constructorValue().call() assert 34 == contract_instance.functions.functionValue().call() + + +@pytest.mark.slow +def test_receive_fallback(testerchain, deploy_contract): + # Deploy first contract + no_fallback_lib, _ = deploy_contract('NoFallback') + dispatcher, _ = deploy_contract('Dispatcher', no_fallback_lib.address) + contract_instance = testerchain.client.get_contract( + abi=no_fallback_lib.abi, + address=dispatcher.address, + ContractFactoryClass=Contract) + + # Can't transfer ETH to this version of contract + value = 10000 + with pytest.raises((TransactionFailed, ValueError)): + tx = testerchain.client.send_transaction( + {'from': testerchain.client.coinbase, 'to': contract_instance.address, 'value': value}) + testerchain.wait_for_receipt(tx) + assert testerchain.client.get_balance(contract_instance.address) == 0 + + # Upgrade to other contract + receive_lib, _ = deploy_contract('OnlyReceive') + tx = dispatcher.functions.upgrade(receive_lib.address).transact() + testerchain.wait_for_receipt(tx) + contract_instance = testerchain.client.get_contract( + abi=receive_lib.abi, + address=dispatcher.address, + ContractFactoryClass=Contract) + + # Transfer ETH and check which function was executed + tx = testerchain.client.send_transaction( + {'from': testerchain.client.coinbase, 'to': contract_instance.address, 'value': value}) + testerchain.wait_for_receipt(tx) + assert contract_instance.functions.value().call() == value + assert contract_instance.functions.receiveRequests().call() == 1 + assert testerchain.client.get_balance(contract_instance.address) == value + + # Upgrade to other contract and transfer ETH again + receive_fallback_lib, _ = deploy_contract('ReceiveFallback') + tx = dispatcher.functions.upgrade(receive_fallback_lib.address).transact() + testerchain.wait_for_receipt(tx) + contract_instance = testerchain.client.get_contract( + abi=receive_fallback_lib.abi, + address=dispatcher.address, + ContractFactoryClass=Contract) + + tx = testerchain.client.send_transaction( + {'from': testerchain.client.coinbase, 'to': contract_instance.address, 'value': value}) + testerchain.wait_for_receipt(tx) + assert contract_instance.functions.receiveRequests().call() == 2 + assert contract_instance.functions.value().call() == 2 * value + assert contract_instance.functions.fallbackRequests().call() == 0 + assert testerchain.client.get_balance(contract_instance.address) == 2 * value diff --git a/tests/contracts/contracts/AdjudicatorTestSet.sol b/tests/contracts/contracts/AdjudicatorTestSet.sol index 7ec066b90..b9cb63ea2 100644 --- a/tests/contracts/contracts/AdjudicatorTestSet.sol +++ b/tests/contracts/contracts/AdjudicatorTestSet.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + pragma solidity ^0.6.5; diff --git a/tests/contracts/contracts/IssuerTestSet.sol b/tests/contracts/contracts/IssuerTestSet.sol index e31eb601f..e04305ea3 100644 --- a/tests/contracts/contracts/IssuerTestSet.sol +++ b/tests/contracts/contracts/IssuerTestSet.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + pragma solidity ^0.6.5; diff --git a/tests/contracts/contracts/LibTestSet.sol b/tests/contracts/contracts/LibTestSet.sol index c40d9b01e..5a1d1d86f 100644 --- a/tests/contracts/contracts/LibTestSet.sol +++ b/tests/contracts/contracts/LibTestSet.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + pragma solidity ^0.6.1; diff --git a/tests/contracts/contracts/PolicyManagerTestSet.sol b/tests/contracts/contracts/PolicyManagerTestSet.sol index 9ae734ebc..358f05989 100644 --- a/tests/contracts/contracts/PolicyManagerTestSet.sol +++ b/tests/contracts/contracts/PolicyManagerTestSet.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + pragma solidity ^0.6.5; diff --git a/tests/contracts/contracts/ReceiveApprovalMethodMock.sol b/tests/contracts/contracts/ReceiveApprovalMethodMock.sol index d8d624ff9..f85b0527f 100644 --- a/tests/contracts/contracts/ReceiveApprovalMethodMock.sol +++ b/tests/contracts/contracts/ReceiveApprovalMethodMock.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + pragma solidity ^0.6.1; diff --git a/tests/contracts/contracts/ReentrancyTest.sol b/tests/contracts/contracts/ReentrancyTest.sol index f87506965..a24a6fdbd 100644 --- a/tests/contracts/contracts/ReentrancyTest.sol +++ b/tests/contracts/contracts/ReentrancyTest.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + pragma solidity ^0.6.1; @@ -19,9 +21,7 @@ contract ReentrancyTest { data = _data; } - // TODO #1809 -// receive() external payable { - fallback() external payable { + receive() external payable { // call no more than maxDepth times if (lockCounter >= maxDepth) { return; diff --git a/tests/contracts/contracts/StakingContractsTestSet.sol b/tests/contracts/contracts/StakingContractsTestSet.sol index 0da7aa50a..7555c9378 100644 --- a/tests/contracts/contracts/StakingContractsTestSet.sol +++ b/tests/contracts/contracts/StakingContractsTestSet.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + pragma solidity ^0.6.5; @@ -112,9 +114,7 @@ contract PolicyManagerForStakingContractMock { minFeeRate = _minFeeRate; } - // TODO #1809 -// receive() external payable {} - fallback() external payable {} + receive() external payable {} } @@ -193,12 +193,7 @@ contract StakingInterfaceMockV2 { address public immutable token = address(1); address public immutable escrow = address(1); - // TODO #1809 -// receive() external payable {} - fallback() external payable { - // can only use with ETH - require(msg.value > 0); - } + receive() external payable {} function firstMethod(uint256) public pure {} diff --git a/tests/contracts/contracts/StakingEscrowTestSet.sol b/tests/contracts/contracts/StakingEscrowTestSet.sol index a57e5cc94..bc91fd4c6 100644 --- a/tests/contracts/contracts/StakingEscrowTestSet.sol +++ b/tests/contracts/contracts/StakingEscrowTestSet.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + pragma solidity ^0.6.5; diff --git a/tests/contracts/contracts/WorkLockTestSet.sol b/tests/contracts/contracts/WorkLockTestSet.sol index ecb556715..56fb5a082 100644 --- a/tests/contracts/contracts/WorkLockTestSet.sol +++ b/tests/contracts/contracts/WorkLockTestSet.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + pragma solidity ^0.6.5; diff --git a/tests/contracts/contracts/proxy/BadContracts.sol b/tests/contracts/contracts/proxy/BadContracts.sol index deba591ca..a73ad67d8 100644 --- a/tests/contracts/contracts/proxy/BadContracts.sol +++ b/tests/contracts/contracts/proxy/BadContracts.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + pragma solidity ^0.6.1; diff --git a/tests/contracts/contracts/proxy/ContractV1.sol b/tests/contracts/contracts/proxy/ContractV1.sol index f95a0b95c..6dfcb9b21 100644 --- a/tests/contracts/contracts/proxy/ContractV1.sol +++ b/tests/contracts/contracts/proxy/ContractV1.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + pragma solidity ^0.6.1; diff --git a/tests/contracts/contracts/proxy/ContractV2.sol b/tests/contracts/contracts/proxy/ContractV2.sol index 160a22a07..ad37ca5b5 100644 --- a/tests/contracts/contracts/proxy/ContractV2.sol +++ b/tests/contracts/contracts/proxy/ContractV2.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + pragma solidity ^0.6.1; diff --git a/tests/contracts/contracts/proxy/ContractV3.sol b/tests/contracts/contracts/proxy/ContractV3.sol index f4e82e832..c58c66f57 100644 --- a/tests/contracts/contracts/proxy/ContractV3.sol +++ b/tests/contracts/contracts/proxy/ContractV3.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + pragma solidity ^0.6.1; diff --git a/tests/contracts/contracts/proxy/ContractV4.sol b/tests/contracts/contracts/proxy/ContractV4.sol index 97f2b8b78..e992958c5 100644 --- a/tests/contracts/contracts/proxy/ContractV4.sol +++ b/tests/contracts/contracts/proxy/ContractV4.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + pragma solidity ^0.6.1; @@ -14,22 +16,22 @@ import "contracts/proxy/Upgradeable.sol"; contract ContractV4 is Upgradeable { // slot allocation costs nothing - /// uint256 public storageValue; + // uint256 public storageValue; uint256 reservedSlot4; - /// string public dynamicallySizedValue; + // string public dynamicallySizedValue; uint256 reservedSlot5; - /// uint256[] public arrayValues; + // uint256[] public arrayValues; uint256 reservedSlot6; - /// mapping (uint256 => uint256) public mappingValues; + // mapping (uint256 => uint256) public mappingValues; uint256 reservedSlot7; - /// uint256[] public mappingIndices; + // uint256[] public mappingIndices; uint256 reservedSlot8; struct Structure1 { uint256 value; uint256[] arrayValues; } - /// Structure1[] public arrayStructures; + // Structure1[] public arrayStructures; uint256 reservedSlot9; struct Structure2 { @@ -37,12 +39,12 @@ contract ContractV4 is Upgradeable { uint256[] arrayValues; uint256 valueToCheck; } - /// mapping (uint256 => Structure2) public mappingStructures; + // mapping (uint256 => Structure2) public mappingStructures; uint256 reservedSlot10; - /// uint256 public mappingStructuresLength; + // uint256 public mappingStructuresLength; uint256 reservedSlot11; - /// uint256 public storageValueToCheck; + // uint256 public storageValueToCheck; uint256 reservedSlot12; uint256 public anotherStorageValue; diff --git a/tests/contracts/contracts/proxy/Destroyable.sol b/tests/contracts/contracts/proxy/Destroyable.sol index 0d18c821e..ba1b6ae4a 100644 --- a/tests/contracts/contracts/proxy/Destroyable.sol +++ b/tests/contracts/contracts/proxy/Destroyable.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + pragma solidity ^0.6.1; diff --git a/tests/contracts/contracts/proxy/ReceiveFallbackTestSet.sol b/tests/contracts/contracts/proxy/ReceiveFallbackTestSet.sol new file mode 100644 index 000000000..9a85131fd --- /dev/null +++ b/tests/contracts/contracts/proxy/ReceiveFallbackTestSet.sol @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + +pragma solidity ^0.6.1; + + +import "contracts/proxy/Upgradeable.sol"; + + +/** +* @dev Contract can't handle 'receive' and 'fallback' requests +*/ +contract NoFallback is Upgradeable {} + + +/** +* @dev Contract can handle only 'receive' requests +*/ +contract OnlyReceive is NoFallback { + + uint256 public receiveRequests; + uint256 public value; + + receive() external payable { + receiveRequests += 1; + value += msg.value; + } + +} + + +/** +* @dev Contract can handle 'receive' and 'fallback' requests +*/ +contract ReceiveFallback is OnlyReceive { + + uint256 public fallbackRequests; + + fallback() external payable { + fallbackRequests += 1; + value += msg.value; + } + +}