leapdao / leap-sandbox

Local Leap Network / Integration Tests
3 stars 3 forks source link

Add challenge exit tests #47

Open troggy opened 5 years ago

troggy commented 5 years ago

Bounty

This is a critical functionality and we should be testing it with integration tests.

Scope

Deliverables

Gain for the project

peace of mind, automatically catch regressions in challenge code

gitcoinbot commented 4 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


This issue now has a funding of 363.0 DAI (363.0 USD @ $1.0/DAI) attached to it as part of the https://github.com/leapdao fund.

simonweniger commented 4 years ago

Hey @mul1sh , thanks for starting to work on the bounty. LeapDAO is a Decentralized Autonomous Organisation creating the Leap Network, a scalable second layer solution for the Ethereum Blockchain. The holacratic DAO has over 20 active members world-wide developing and maintaining the network. Its mission is to enable scalable Dapps to operate securely on layer-2 of Ethereum as well as widening the scope of possible Dapps in the Ethereum ecosystem.

If you're intrested to join LeapDAO and contribute to the project long term feel free to join our slack and check all available bountys

greetings Simon Weniger DEV Link at LeapDAO

mul1sh commented 4 years ago

@simonweniger awesome thanks for the invitation 🙂.

Joining slack now too, I've started working on this bounty and will definitely reach out if im stuck.

mul1sh commented 4 years ago

hi @troggy @simonweniger I'm still working on this and I had a few questions.

Thanks

simonweniger commented 4 years ago

@johannbarbie, @troggy can you help ?

troggy commented 4 years ago

i'm writing tests targeting the challengeExit function in the ExitHandler.sol contract, correct?

correct.

where I can get its implementation, from the solidity code I fairly understand how the function works but an implementation would help me figure out all its working for the test cases.

I'm not sure what do you call an "implementation" here? 🤔If you are looking for a usage example, take a look at this script for challengeExit.

Finally, are there any other docs I can access about the workings of leapdao other than https://docs.leapdao.org/, because I also need clarification about other terms used i.e. color tokens e.t.c

@simonweniger can help you with general questions. Otherwise, I would prefer to have a call — it is faster. I'm @kosta on LeapDAO Slack, ping me and we'll schedule a call.

mul1sh commented 4 years ago

@troggy thanks for the awesome feedback 🙂 , I've reached out in slack.

gitcoinbot commented 4 years ago

@mul1sh Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

mul1sh commented 4 years ago

@gitcoinbot yep almost done :)

simonweniger commented 4 years ago

Hey @mul1sh , how is it going ? Do you need any help ?

mul1sh commented 4 years ago

Finally doing 1 last test and then I submit in a few hours :)

troggy commented 4 years ago

@mul1sh Unfortunately, we will have to un-assign you from this bounty.

if you have problems implementing the task — just say so, please and ask for assistance. There is nothing bad about this. We are here to help, but we need your cooperation as well.

/cc @simonweniger

mul1sh commented 4 years ago

Hey @troggy I'm submitting today no more delays promise 🙂. Yes I had a few issues understanding the whole flow, I definitely should have asked for help but I also wanted to learn more about the contracts by breaking it down and putting it back together hence why I have taken this long, but sorry for this I realize this was an oversight on my end.

Nonetheless expect the tests fully working in the next few hours, in fact i'm wrapping them up now.

troggy commented 4 years ago

hence why I have taken this long

from my point of view, there is no problem with task taking too long — that's fine, we are not in a hurry. The problem is in poor communication

mul1sh commented 4 years ago

I agree, I'll be more proactive in communicating my progress and also ask questions frequently in case i'm stuck going forward.

troggy commented 4 years ago

a good first step to improve the situation IMO is to push your work in progress into PR. Takes only a minute, the code doesn't have to be working

Sprimage commented 4 years ago

I noticed he abandoned this bounty

Technical-Vairix commented 4 years ago

@troggy Hey, how are you? pls ping me when you can talk about the bounty https://gitcoin.co/issue/leapdao/leap-sandbox/47/3832, I have some questions before start to work on this.

troggy commented 4 years ago

@Technical-Vairix post your questions here pls

gitcoinbot commented 4 years ago

@sprimage Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

Sprimage commented 4 years ago

Trying to write the challengeExit function, I see the other tests have actions. Is this a requirement for the test? I need to write an action for the challengeExit too no?

troggy commented 4 years ago

I see the other tests have actions

what do you mean by that?

This is an example of "test": https://github.com/leapdao/leap-sandbox/blob/master/tests/1_depositTransferExit.js . This just one of those, other "tests" are no different in structure.

The assignment is to create a new "test" which will use challengeExit function (and other as specified in this bounty). You don't need to implement challengeExit function, it is already implemented and your "test" will need to check this function is working as expected.

troggy commented 4 years ago

Each "test" is basically a script that is being run against a working network (this is handled by leap-sandbox already). All the data you need to interact with network/environment is passed to the "test" in arguments (see any of the "tests" for example). Then you just interact with the network to test desired conditions. For now we can start with "success tests" only — the tests checking the success path for the function. For example, for challengeExit that could be a successful challenge for an attempt to exit utxo which was already spent.

Sprimage commented 4 years ago

Thanks @troggy, I have some more questions. Can you explain what the _proof and _prevProof parameters represent when challenging an exit. In the contracts test here https://github.com/leapdao/leap-contracts/blob/eecdc8ee88c812724177f5a61e182e4f46e4c1a3/test/exitHandler.js#L351 I noticed they were generated from the Tx object and submitNewPeriod function. How can I access these data points on the sandbox environment?

troggy commented 4 years ago

both of these are cryptographic proofs of tx inclusion in a chain. Plasma contracts know nothing about blocks, they only have period roots (period root is basically a root of merkle tree. See here: https://github.com/leapdao/leap-core/blob/master/lib/period.js#L95). So to prove to Plasma contracts the given tx was indeed included in a given period, you need merkle proof like this.

Both _proof and _prevProof are the same structures, just proving inclusion for different txs. Refer to my plasma explanation I gave you in Slack the other day.

to generate proof, you can use getProof helper from leap-core library. Check the implementation if you are curious to know what it does under the hood: https://github.com/leapdao/leap-core/blob/master/lib/helpers.js#L219.

Look for usage examples in leap-sandbox. For instance, here https://github.com/leapdao/leap-sandbox/blob/master/tests/actions/exitUnspent.js#L69

gitcoinbot commented 4 years ago

@sprimage Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

Sprimage commented 4 years ago

Yeah I'm here @gitcoinbot still working

gitcoinbot commented 4 years ago

@sprimage Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

Sprimage commented 4 years ago

Still working...we discuss in slack channel, thanks

gitcoinbot commented 4 years ago

@sprimage Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

Sprimage commented 4 years ago

Yes still here