Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Refactor IKeep/KeepBridge #268

Merged
merged 50 commits into from
Sep 30, 2019
Merged

Refactor IKeep/KeepBridge #268

merged 50 commits into from
Sep 30, 2019

Conversation

nkuba
Copy link
Member

@nkuba nkuba commented Aug 30, 2019

In this PR we move functions implemented in a KeepBridge contract responsible for communication with keep to be directly executed by a deposit.

We pull interfaces from keep-tecdsa to communicate with the contracts deployed as part of keep system.

There still remained IKeep interface which holds functions which are not yet implemented on the keep side. As it's done this interface should be replaced by IECDSAKeep calls.

Closes: #221

@nkuba nkuba force-pushed the refactor-keep-bridge branch from 5f9ecfe to 2431a7f Compare August 30, 2019 11:58
nkuba added 26 commits September 5, 2019 11:15
We install keep-tecdas contracts via npm. This will allow us to remove
interfaces we created before for communication with keeps.
We need to initialize TBTCSystem with Keep Registry address for
communication with keep.
Function was moved as we are getting rid of IKeep interface. We will
call keep registry contract directly from TBTCSystem.
Removed function to get keep public key from IKeep and KeepBridge. We
call keep directly from the deposit.
Moved approveDigest and wasDigestApprovedForSigning from IKeep
interaface and KeepBrdige implementation directly to deposit contrac
where we call Keep and store list of approved digests in deposit.
Keep function approveDigest won't return boolean, we no longer require
it's result to be equal true.
keep-tecdsa exposes interfaces for communication with contracts. Here we
use this interfaces.
We remove Keep Bridge and interact with keep contracts directly.
This interface remains until all functions are implemented properly
within keep and we can communicate directly with the interface exposed
from keep. For now this is just a stub.
Splitet setKeepInfo and getKeepInfo into separate functions to simplify
tests.
Updated name of the function and removed KeepBridge address from it
which is no longer used.
@nkuba nkuba force-pushed the refactor-keep-bridge branch from 5c0ff17 to ed528b0 Compare September 5, 2019 09:15
@nkuba nkuba marked this pull request as ready for review September 5, 2019 09:45
@nkuba nkuba requested a review from NicholasDotSol September 5, 2019 15:05
@nkuba nkuba requested a review from liamzebedee September 22, 2019 10:21
Copy link
Contributor

@liamzebedee liamzebedee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one remaining comment unresolved from me!

@pdyraga
Copy link
Member

pdyraga commented Sep 26, 2019

Hey, what's the status here? If we resolve conflicts are we ready to merge?

@liamzebedee
Copy link
Contributor

Yep @nkuba, all okay my end!

@nkuba nkuba force-pushed the refactor-keep-bridge branch from e6a27c3 to b51bffe Compare September 26, 2019 19:47
@nkuba nkuba requested a review from liamzebedee September 26, 2019 19:56
@nkuba
Copy link
Member Author

nkuba commented Sep 26, 2019

Done, the merge was painfull but I sorted it out. Waiting for final approvals.

Contracts we use from keep-tecdsa project are now published to github
package registry. Here we update dependency to use it.
We also update .npmrc to point to github registry to be able to download
dependencies from there.
@nkuba nkuba force-pushed the refactor-keep-bridge branch 3 times, most recently from 5f1a088 to 467a944 Compare September 29, 2019 15:35
We need to access private packages from Github Package Registry, here we
set it up for Circle CI with a GITHUB_TOKEN.
@nkuba nkuba force-pushed the refactor-keep-bridge branch from 467a944 to eb5fc4b Compare September 29, 2019 15:36
@nkuba nkuba force-pushed the refactor-keep-bridge branch from 93777c3 to d9cf615 Compare September 29, 2019 15:52
Copy link
Contributor

@NicholasDotSol NicholasDotSol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, super minor comment.

/// @dev calls out to the keep contract, storing a 256bit int costs the same as a bool
/// @param _digest the digest to check approval time for
/// @return the time it was approved. 0 if unapproved
/// @notice Gets timestamp of digest approval for signing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix up formatting :)

/// Returns 0 if the digest was not recorded for signing for the given keep.
function wasDigestApprovedForSigning(address _keepAddress, bytes32 _digest) external view returns (uint256);

// TODO: This is a contract holding functions which are required to be implemented
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment is a little confusing, what about:

// TODO: This is an interface holding functions which are required to be implemented on keep side

@@ -63,10 +55,11 @@ library DepositFunding {
) public returns (bool) {
require(_d.inStart(), "Deposit setup already requested");

IKeep _keep = IKeep(_d.KeepBridge);

// TODO: Whole value is forwarded to TBTC System, but should be partially
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

value is partially forwarded to TBTC System and partially stored as funder bond in the deposit https://github.com/keep-network/tbtc/issues/279.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually currently it's stored in deposit as funder bond but we need to transfer part of it to the keep as per #297. I've updated the comment.

@pdyraga pdyraga dismissed liamzebedee’s stale review September 30, 2019 10:40

Approved in the comment, all questions addressed.

@pdyraga pdyraga merged commit bc7384a into master Sep 30, 2019
@pdyraga pdyraga deleted the refactor-keep-bridge branch September 30, 2019 10:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor IKeep/KeepBridge
5 participants