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

WIP: Refactor + Exit NFT #16

Merged
merged 36 commits into from
Sep 3, 2018
Merged

WIP: Refactor + Exit NFT #16

merged 36 commits into from
Sep 3, 2018

Conversation

jdkanani
Copy link
Contributor

@jdkanani jdkanani commented Aug 18, 2018

  • Use open-zeppelin for ERC contracts
  • Break down RootChain contract into pieces for better readability
  • Add NFT for the exit for plasma. Create NFT on exit and burn on actual withdraw or on the challenge
  • Add burn withdraw for reusable account
  • Exit without burn (this will make account un-usable)
  • Re-use of the account once exited without the burn
  • Only one exit is allowed per account
  • Add deposit withdraw
  • Add challenges for all types of exits
  • Add test-cases for each case

@jdkanani
Copy link
Contributor Author

@ashishrp @shogochiai @vaibhavchellani would love your review. It's WIP!

@jdkanani jdkanani changed the title Refactor + Exit NFT WIP: Refactor + Exit NFT Aug 18, 2018
@jdkanani jdkanani added this to To do in Matic v1 via automation Aug 18, 2018
* @param a uint256 number
* @param b uint256 number
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I will add. Missed it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added in new commit 9d65877

@jdkanani
Copy link
Contributor Author

Added LogDecoder to decode nested logs

For more info, check trufflesuite/truffle#555

);

// withdraw
_withdraw(
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. This _withdraw() function is called by both burnProofWithdrawal-logic and exitWithdrawal-logic
  2. This function appends withdrawal to priorityQueue finally
  3. burnProofWithdrawal must call WETH.withdrawal or ERC20.transfer rather than _withdraw

Is this statement correct? @jdkanani

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. burnProofWithdrawal will also call _withdraw() as operator can just create coins out of thin air, then burn it and create checkpoint without providing data - data unavailability issue.

So, if you burn then you can reuse your account. But if you don't burn and start exit without it, anyone can come and challenge if you reuse your account.

Reuse account == make transaction on Matic chain after exit

Copy link
Contributor

Choose a reason for hiding this comment

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

as operator can just create coins out of thin air, then burn it and create checkpoint without providing data - data unavailability issue.

make sense :)

if you don't burn and start exit without it, anyone can come and challenge if you reuse your account.

Additionally anyone can cause state transition (e.g. balance addition) and the exit will be malicious.
So this exit function must be either "burnt exit" or "last resort"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes!

}

// withdraw tokens
function withdrawTokens(
Copy link
Contributor

Choose a reason for hiding this comment

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

This function was used in withdrawal-bridge, but the w-bridger is deprecated. So this function must be removed for the sake of readability.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function is to withdraw without burn (last resort). When user is done with Matic and Matic chain is no longer functional (extreme case)

We will update withdrawal-bridge once this pull request is done.

Copy link
Contributor

Choose a reason for hiding this comment

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

make sense :)

// If an exit was successfully challenged, owner would be address(0).
address exitOwner = ExitNFT(exitNFTContract).ownerOf(utxoPos);
if (exitOwner != address(0)) {
if (_token == wethToken) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This condition scope had better to be separated function because possibly called from withdrawal() function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't get what you saying.

Copy link
Contributor

Choose a reason for hiding this comment

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

never mind, question solved by other answer.

@@ -147,7 +147,7 @@ contract WithdrawManager is DepositManager {
}

// withdraw tokens
function withdraw(
function withdrawBurntTokens(
Copy link
Contributor

Choose a reason for hiding this comment

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

Q. How long does it take until child-chain burnProof confirmed?
Asm. ~=3600sec, until committed to rootchain @jdkanani

@jdkanani jdkanani mentioned this pull request Aug 25, 2018
@jdkanani jdkanani moved this from To do to In progress in Matic v1 Aug 25, 2018
@jdkanani
Copy link
Contributor Author

@syuhei176 can you take a look at the structure? I will create a diagram to explain in more details.

@jdkanani
Copy link
Contributor Author

jdkanani commented Sep 3, 2018

This pull request is getting really getting big. We will merge this and keep working on other issues.

@vaibhavchellani
Copy link
Contributor

yes makes sense

@jdkanani jdkanani merged commit e59e3fb into master Sep 3, 2018
Matic v1 automation moved this from In progress to Done Sep 3, 2018
@jdkanani jdkanani deleted the fast-exit branch September 3, 2018 20:22
0xAshish pushed a commit to 0xAshish/contracts that referenced this pull request Apr 27, 2019
Add Exit NFT for faster exit and refactor
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
No open projects
Matic v1
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants