From a765274aa92780390ad0bb2e1029f09bf1ad1f00 Mon Sep 17 00:00:00 2001 From: Nicholas Evans Date: Wed, 30 Oct 2019 02:15:29 -0500 Subject: [PATCH 1/6] Update all distribution function referenecs Update function naming to remove referece to Keep Remove unused parameters --- implementation/contracts/deposit/DepositRedemption.sol | 2 +- implementation/contracts/deposit/DepositUtils.sol | 2 +- implementation/contracts/external/IBondedECDSAKeep.sol | 4 ++-- implementation/test/contracts/keep/ECDSAKeepStub.sol | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/implementation/contracts/deposit/DepositRedemption.sol b/implementation/contracts/deposit/DepositRedemption.sol index 53eb59f18..e14b549b2 100644 --- a/implementation/contracts/deposit/DepositRedemption.sol +++ b/implementation/contracts/deposit/DepositRedemption.sol @@ -37,7 +37,7 @@ library DepositRedemption { IBondedECDSAKeep _keep = IBondedECDSAKeep(_d.keepAddress); _tbtcToken.approve(_d.keepAddress, DepositUtils.signerFee()); - _keep.distributeERC20ToKeepGroup(_d.keepAddress, _tbtcTokenAddress, DepositUtils.signerFee()); + _keep.distributeERC20ToMembers(_tbtcTokenAddress, DepositUtils.signerFee()); } /// @notice Approves digest for signing by a keep diff --git a/implementation/contracts/deposit/DepositUtils.sol b/implementation/contracts/deposit/DepositUtils.sol index b6b963e6c..03cf5719b 100644 --- a/implementation/contracts/deposit/DepositUtils.sol +++ b/implementation/contracts/deposit/DepositUtils.sol @@ -380,6 +380,6 @@ library DepositUtils { function pushFundsToKeepGroup(Deposit storage _d, uint256 _ethValue) public returns (bool) { require(address(this).balance >= _ethValue, "Not enough funds to send"); IBondedECDSAKeep _keep = IBondedECDSAKeep(_d.keepAddress); - return _keep.distributeEthToKeepGroup.value(_ethValue)(_d.keepAddress); + return _keep.distributeETHToMembers.value(_ethValue)(); } } diff --git a/implementation/contracts/external/IBondedECDSAKeep.sol b/implementation/contracts/external/IBondedECDSAKeep.sol index 0f3494cc6..c660d830a 100644 --- a/implementation/contracts/external/IBondedECDSAKeep.sol +++ b/implementation/contracts/external/IBondedECDSAKeep.sol @@ -18,12 +18,12 @@ interface IBondedECDSAKeep { // Allow sending funds to a keep group // Expected: increment their existing ETH bond - function distributeEthToKeepGroup(address _keepAddress) external payable returns (bool); + function distributeETHToMembers() external payable returns (bool); // Allow sending tokens to a keep group // Useful for sending signers their TBTC // The Keep contract should call transferFrom on the token contract - function distributeERC20ToKeepGroup(address _keepAddress, address _asset, uint256 _value) external returns (bool); + function distributeERC20ToMembers(address _TBTCTokenAddress, uint256 _value) external returns (bool); // returns the amount of the keep's ETH bond in wei function checkBondAmount(address _keepAddress) external view returns (uint256); diff --git a/implementation/test/contracts/keep/ECDSAKeepStub.sol b/implementation/test/contracts/keep/ECDSAKeepStub.sol index 92f16937f..5b809c820 100644 --- a/implementation/test/contracts/keep/ECDSAKeepStub.sol +++ b/implementation/test/contracts/keep/ECDSAKeepStub.sol @@ -59,11 +59,11 @@ contract ECDSAKeepStub is IECDSAKeep, IBondedECDSAKeep { return success; } - function distributeEthToKeepGroup(address _keepAddress) external payable returns (bool){ + function distributeETHToMembers() external payable returns (bool){ return success; } - function distributeERC20ToKeepGroup(address _keepAddress, address _asset, uint256 _value) external returns (bool){ + function distributeERC20ToMembers(address _asset, uint256 _value) external returns (bool){ return success; } From 8fd8bfb82183584222d6f81114d26b4344d7d139 Mon Sep 17 00:00:00 2001 From: Nicholas Evans Date: Wed, 30 Oct 2019 03:41:56 -0500 Subject: [PATCH 2/6] Remove functons implemented in IECDSA Keep --- implementation/contracts/external/IBondedECDSAKeep.sol | 9 --------- 1 file changed, 9 deletions(-) diff --git a/implementation/contracts/external/IBondedECDSAKeep.sol b/implementation/contracts/external/IBondedECDSAKeep.sol index c660d830a..9e063d82c 100644 --- a/implementation/contracts/external/IBondedECDSAKeep.sol +++ b/implementation/contracts/external/IBondedECDSAKeep.sol @@ -16,15 +16,6 @@ interface IBondedECDSAKeep { bytes calldata _preimage ) external returns (bool _isFraud); - // Allow sending funds to a keep group - // Expected: increment their existing ETH bond - function distributeETHToMembers() external payable returns (bool); - - // Allow sending tokens to a keep group - // Useful for sending signers their TBTC - // The Keep contract should call transferFrom on the token contract - function distributeERC20ToMembers(address _TBTCTokenAddress, uint256 _value) external returns (bool); - // returns the amount of the keep's ETH bond in wei function checkBondAmount(address _keepAddress) external view returns (uint256); From 97f6a1c51b317fec869479b17da0d8e2e43b8c01 Mon Sep 17 00:00:00 2001 From: Nicholas Evans Date: Wed, 30 Oct 2019 03:43:28 -0500 Subject: [PATCH 3/6] Swap reference to IECDSAKeep from IBonderECDSAKeep Functions are implemented in IECDSAKeep and no longer need to be imported via stub --- implementation/contracts/deposit/DepositRedemption.sol | 3 +-- implementation/contracts/deposit/DepositUtils.sol | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/implementation/contracts/deposit/DepositRedemption.sol b/implementation/contracts/deposit/DepositRedemption.sol index e14b549b2..2b29b7c00 100644 --- a/implementation/contracts/deposit/DepositRedemption.sol +++ b/implementation/contracts/deposit/DepositRedemption.sol @@ -6,7 +6,6 @@ import {BytesLib} from "@summa-tx/bitcoin-spv-sol/contracts/BytesLib.sol"; import {ValidateSPV} from "@summa-tx/bitcoin-spv-sol/contracts/ValidateSPV.sol"; import {CheckBitcoinSigs} from "@summa-tx/bitcoin-spv-sol/contracts/CheckBitcoinSigs.sol"; import {DepositUtils} from "./DepositUtils.sol"; -import {IBondedECDSAKeep} from "../external/IBondedECDSAKeep.sol"; import {IECDSAKeep} from "@keep-network/keep-ecdsa/contracts/api/IECDSAKeep.sol"; import {DepositStates} from "./DepositStates.sol"; import {OutsourceDepositLogging} from "./OutsourceDepositLogging.sol"; @@ -34,7 +33,7 @@ library DepositRedemption { address _tbtcTokenAddress = _d.TBTCToken; TBTCToken _tbtcToken = TBTCToken(_tbtcTokenAddress); - IBondedECDSAKeep _keep = IBondedECDSAKeep(_d.keepAddress); + IECDSAKeep _keep = IECDSAKeep(_d.keepAddress); _tbtcToken.approve(_d.keepAddress, DepositUtils.signerFee()); _keep.distributeERC20ToMembers(_tbtcTokenAddress, DepositUtils.signerFee()); diff --git a/implementation/contracts/deposit/DepositUtils.sol b/implementation/contracts/deposit/DepositUtils.sol index 03cf5719b..32b9c716d 100644 --- a/implementation/contracts/deposit/DepositUtils.sol +++ b/implementation/contracts/deposit/DepositUtils.sol @@ -7,6 +7,7 @@ import {BytesLib} from "@summa-tx/bitcoin-spv-sol/contracts/BytesLib.sol"; import {TBTCConstants} from "./TBTCConstants.sol"; import {ITBTCSystem} from "../interfaces/ITBTCSystem.sol"; import {IERC721} from "openzeppelin-solidity/contracts/token/ERC721/IERC721.sol"; +import {IECDSAKeep} from "@keep-network/keep-ecdsa/contracts/api/IECDSAKeep.sol"; import {IBondedECDSAKeep} from "../external/IBondedECDSAKeep.sol"; import {TBTCToken} from "../system/TBTCToken.sol"; @@ -379,7 +380,7 @@ library DepositUtils { /// @return true if successful, otherwise revert function pushFundsToKeepGroup(Deposit storage _d, uint256 _ethValue) public returns (bool) { require(address(this).balance >= _ethValue, "Not enough funds to send"); - IBondedECDSAKeep _keep = IBondedECDSAKeep(_d.keepAddress); + IECDSAKeep _keep = IECDSAKeep(_d.keepAddress); return _keep.distributeETHToMembers.value(_ethValue)(); } } From 5f73dadaf6344d1544e67bd35439a4cd5b7ff269 Mon Sep 17 00:00:00 2001 From: Nicholas Evans Date: Wed, 30 Oct 2019 03:44:40 -0500 Subject: [PATCH 4/6] Move implemented functions to appropreate section Move the function up to clarify that they belong in IECDSAKeep interface --- .../test/contracts/keep/ECDSAKeepStub.sol | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/implementation/test/contracts/keep/ECDSAKeepStub.sol b/implementation/test/contracts/keep/ECDSAKeepStub.sol index 5b809c820..f68e325bb 100644 --- a/implementation/test/contracts/keep/ECDSAKeepStub.sol +++ b/implementation/test/contracts/keep/ECDSAKeepStub.sol @@ -46,6 +46,15 @@ contract ECDSAKeepStub is IECDSAKeep, IBondedECDSAKeep { emit SignatureRequested(_digest); } + function distributeETHToMembers() external payable returns (bool){ + return success; + } + + function distributeERC20ToMembers(address _asset, uint256 _value) external returns (bool){ + return success; + } + + // Functions implemented for IBondedECDSAKeep interface. function submitSignatureFraud( @@ -59,14 +68,6 @@ contract ECDSAKeepStub is IECDSAKeep, IBondedECDSAKeep { return success; } - function distributeETHToMembers() external payable returns (bool){ - return success; - } - - function distributeERC20ToMembers(address _asset, uint256 _value) external returns (bool){ - return success; - } - function checkBondAmount(address _keepAddress) external view returns (uint256){ return bondAmount; } From b25dafff2340e582cb7c02294124a2b07c43de1e Mon Sep 17 00:00:00 2001 From: Nicholas Evans Date: Tue, 5 Nov 2019 10:20:08 -0600 Subject: [PATCH 5/6] Update keep-ecdsa dependency version --- implementation/package-lock.json | 6 +++--- implementation/package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/implementation/package-lock.json b/implementation/package-lock.json index 6279dfe8e..e7b318f04 100644 --- a/implementation/package-lock.json +++ b/implementation/package-lock.json @@ -53,9 +53,9 @@ } }, "@keep-network/keep-ecdsa": { - "version": "0.1.1", - "resolved": "https://npm.pkg.github.com/download/@keep-network/keep-ecdsa/0.1.1/4c4c014425154c0796446e21ef8950218200a7d684e1917c377916dc7b279d48", - "integrity": "sha1-83KUz+8FNQc/YZMIJRL/bCMNANU=", + "version": "0.1.2", + "resolved": "https://npm.pkg.github.com/download/@keep-network/keep-ecdsa/0.1.2/2ec5def4b97bcb87dd3378edddfa01233151274380b6b299659b1ecd0fea5068", + "integrity": "sha512-MqXRjmcb1b7gSSoz1ZiMfyX0Ig8RbLnWUx+Qnw1NXv/WxwJXYJuKYihNBImKKGcUCq9KmMl3oXWOogVLruJ79A==", "requires": { "openzeppelin-solidity": "^2.3.0" } diff --git a/implementation/package.json b/implementation/package.json index 419853960..bdf035748 100644 --- a/implementation/package.json +++ b/implementation/package.json @@ -21,7 +21,7 @@ "author": "James Prestwich", "license": "UNLICENSED", "dependencies": { - "@keep-network/keep-ecdsa": "^0.1.1", + "@keep-network/keep-ecdsa": "^0.1.2", "bn-chai": "^1.0.1", "bn.js": "^4.11.8", "@summa-tx/bitcoin-spv-sol": "^2.1.0", From 4f45e9b6cc5d782205de21ba4cdaf41d8d696a36 Mon Sep 17 00:00:00 2001 From: Nicholas Evans Date: Tue, 5 Nov 2019 10:20:57 -0600 Subject: [PATCH 6/6] Update return functionalitty on distribution functions We don't return true or false anymore --- implementation/contracts/deposit/DepositUtils.sol | 3 ++- implementation/test/contracts/keep/ECDSAKeepStub.sol | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/implementation/contracts/deposit/DepositUtils.sol b/implementation/contracts/deposit/DepositUtils.sol index 32b9c716d..4d082362d 100644 --- a/implementation/contracts/deposit/DepositUtils.sol +++ b/implementation/contracts/deposit/DepositUtils.sol @@ -381,6 +381,7 @@ library DepositUtils { function pushFundsToKeepGroup(Deposit storage _d, uint256 _ethValue) public returns (bool) { require(address(this).balance >= _ethValue, "Not enough funds to send"); IECDSAKeep _keep = IECDSAKeep(_d.keepAddress); - return _keep.distributeETHToMembers.value(_ethValue)(); + _keep.distributeETHToMembers.value(_ethValue)(); + return true; } } diff --git a/implementation/test/contracts/keep/ECDSAKeepStub.sol b/implementation/test/contracts/keep/ECDSAKeepStub.sol index f68e325bb..0a5ce7946 100644 --- a/implementation/test/contracts/keep/ECDSAKeepStub.sol +++ b/implementation/test/contracts/keep/ECDSAKeepStub.sol @@ -46,12 +46,12 @@ contract ECDSAKeepStub is IECDSAKeep, IBondedECDSAKeep { emit SignatureRequested(_digest); } - function distributeETHToMembers() external payable returns (bool){ - return success; + function distributeETHToMembers() external payable { + } - function distributeERC20ToMembers(address _asset, uint256 _value) external returns (bool){ - return success; + function distributeERC20ToMembers(address _asset, uint256 _value) external { + }