Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User acceptance tests of redemptions veto mechanism (TIP-072) #782

Closed
2 tasks done
lukasz-zimnoch opened this issue Feb 5, 2024 · 3 comments
Closed
2 tasks done
Assignees
Labels
⛓️ solidity Solidity contracts

Comments

@lukasz-zimnoch
Copy link
Member

lukasz-zimnoch commented Feb 5, 2024

Depends on: #781

The scope of this issue includes the design and execution of the user acceptance tests for the redemptions veto mechanism specified in TIP-072: Optimistic redemptions and developed as part of #781. UATs should be executed on Sepolia testnet once necessary contract upgrades are deployed there.

Tasks

Preview Give feedback
@michalinacienciala
Copy link
Contributor

michalinacienciala commented Feb 8, 2024

Scenarios

This task is about testing the new redemption veto mechanism by executing UAT scenarios mentioned below. UATs should be executed on Sepolia testnet once necessary contract upgrades are deployed there.

The tests were written with the assumption that just for testing we modify the default values of governable parameters:

  • redemption request period is 2 hours 10 min
  • redemption request period after one veto gets extended to 8 hours 30 min
  • redemption request period after two vetos gets extended to 24 hours 1 hour
  • freeze time upon veto is 1 month 2 hours

The value of the governable parameters may get modified on the testnet in order to make testing faster.

Scenario 1

Checking regular redemption without objections.

Step Expected result Test execution / result
Trigger a redemption of a deposit (at T0). Do not object the redemption. Redemption of 0.015 tBTC requested from account 0x58C6A45AcFCc1fD0E5A103Cab2caE00b0B188EC5 to BTC address 2NCUkcBRrTXBoNSfG4GiZit9PBGZSNpJ2mZ at 14:56 (T0). Unmint tx.
Wait till T1=T0+10min. The redemption should start being executed in the first coordination window after T1. Once redemption is processed, the BTC should be returned to the requested BTC address (returned amount of BTC should equal to the amount of TBTC minus Threshold Network fee). T1=15:06. First coordination window after T1 was at 15:31. Redemption started execution at 2024-02-23 15:31:14.155 (starting action execution). BTC tx: 16:01. Redeem tx: 19:49. Returned amount: 0.01499163 (= 0.015 - 0.0000075 treasury fee - 1/2*0.00000174 transaction fee).

Scenario 2

Checking redemption with one objection.

Step Expected result Test execution / result
Trigger a redemption of a deposit (at T0). Redemption of 0.01 tBTC requested from account 0x58C6A45AcFCc1fD0E5A103Cab2caE00b0B188EC5 to BTC address 2N2pcxHzH44cEBB5kZy7iHtV7yiZmXyfpcU at 13:51 (T0). Unmint tx.
Some time later (<T0+10min, at T1) make one Guardian object to the redemption. Objection raised at 13:57 (T1). Objection tx.
Wait till T2=T0+30min. The redemption should start being executed in the first coordination window after T2. Once redemption is processed, the BTC should be returned to the requested BTC address (returned amount of BTC should equal to the amount of TBTC minus Threshold Network fee). T2=14:27. First coordination window after T1 was at 15:31. Redemption started execution at 2024-02-23 15:31:14.155 (starting action execution). BTC tx: 16:01. Redeem tx: 19:49. Returned amount: 0.00999413 (= 0.01 - 0.000005 treasury fee - 1/2*0.00000174 transaction fee)

Scenario 3

Checking redemption with two objections. Making sure the redemption does not get vetoed and requester is not added to the list of banned users.

Step Expected result Test execution / result
Trigger a redemption of a deposit (at T0). Make sure requested redeem amount (X) is at least 0.015 tBTC smaller that the max redeem amount (Y). Redemption of 0.012 tBTC requested from account 0x58C6A45AcFCc1fD0E5A103Cab2caE00b0B188EC5 to BTC address 2NEhkxqSXogWoABEXF2JVxF8qZMdu7nVKgH at 10:21 (T0). Unmint tx.
Some time later (<T0+10min, at T1) make one Guardian object to the redemption. 1st objection raised at 10:25 (T1). Objection tx.
Some time later (<T0+30min, at T2) make another Guardian object to the redemption. 2nd objection raised at 10:36 (T1). Objection tx.
Wait till T3=T0+1h. The redemption should start being executed in the first coordination window after T3. Once redemption is processed, the BTC should be returned to the requested BTC address (returned amount of BTC should equal to the amount of TBTC minus Threshold Network fee). T3=11:21. First coordination window after T1 was at 11:44. Redemption started execution at 2024-02-28 11:44:49.914 (starting action execution). BTC tx: 12:11 . Redeem tx: 15:17 . Returned amount: 0.01199258 (= 0.012 - 0.000006 treasury fee - 0.00000142 transaction fee)
Some time later (<T3+2h, at T4) make another redemption request Redemption should be requested. Redemption requested successfully at 11:26. Unmint tx.

Scenario 4

Checking redemption with three objections. Making sure each objection extends the redemption request period. Ensuring redemption gets vetoed. Checking if vetoed redeemer cannot redeem again. Making sure the vetoed redeemer can finalize the redeem once the freeze period elapses.

Step Expected result Test execution / result
Trigger a redemption of a deposit (at T0). Make sure requested redeem amount (X) is at least 0.015 tBTC smaller that the max redeem amount (Y). Redemption of 0.02 tBTC requested from account 0x27343E0410acd8Cf711d079C57811fe8c0666DF2 to BTC address 2MsVTbZFh5GJykznjNQrqZbuSGLt4Qjx4yZ at 13:58 (T0). Unmint tx.
Some time later (<T0+10min, at T1) make one Guardian object to the redemption. 1st objection raised at 14:03 (T1). Objection tx.
Some time later (<T0+30min, at T2; T2>T1+10min) make another Guardian object to the redemption. 2nd objection raised at 14:18 (T2). Objection tx.
Some time later (<T0+1h, at T3, T3>T2+30min) make another Guardian object to the redemption. At T3 the redemption veto freeze period should start. Once veto is processed, the amount of tBTC belonging to the redemption requester should decrease by penalty_factor of the requested redemption amount. 3rd objection raised at 14:52 (T3). Objection tx.
Some time later (<T3+2h, at T4) using the same redeemer try to request another redemption. Redemption should not be possible. At 15:43 (T4) tried redeeming 0.01 to 2N5CZ2BoSfog6VF8MxeLAi9gy3wdeYMj7z7 using the account 0x27343E0410acd8Cf711d079C57811fe8c0666DF2. Got error: Redemption request rejected by the watchtower.
Soon after try to retrieve the vetoed funds. Retrieval should not be possible. Tried to retrieve funds at 15:57. Transaction failed with the Freeze period not expired error. Retrieve tx.
Wait till T5>T3+2h. Try to retrieve the vetoed funds. The funds (decreased by penalty_factor of the requested redemption amount) should be retrieved as a TBTC Bank balance. Tried to retrieve funds at 16:55 (T5). Transaction succeeded. Bank balance of retriever after transaction was increased by 1900000 (95% of 2000000). Retrieve tx. No BTC was returned.

Scenario 5

Making sure that the vetoed redeemer can be removed from the list of banned users.

Step Expected result Test execution / result
Remove vetoed redeemed (e.g. redeemer from Scenario 4) from the list of banned users. Removed 0x27343E0410acd8Cf711d079C57811fe8c0666DF2 (vetoed in Scenario 4) from the list of banned users. Unban tx.
Request redemption from that user's account. Redemption should be requested. Redemption requested successfully. Unmint tx.

Scenario 6

Making sure that freeze window is specific to a given redemption and does not get extended when another redemption gets vetoed (or does not end when other redemption freeze window ends).

Step Expected result Test execution / result
Requests two redemptions (R1, R2) using the same account, one after another. Redemption R1 of 0.03 tBTC requested from account 0x58C6A45AcFCc1fD0E5A103Cab2caE00b0B188EC5 to BTC address 2N5DQFioPM5kvd1CJbuuXybcUe6vAFBKBBP at 14:28. Unmint tx. Redemption R2 of 0.04 tBTC requested from account 0x58C6A45AcFCc1fD0E5A103Cab2caE00b0B188EC5 to BTC address 2MsFY8Eo2P3U9SFZiUbpY2KnVaPE1nRhCbs at 14:32. Unmint tx.
Make three objections to both redemptions, triggering veto for both of them. Let T1 be the time of the veto of the R1, T2 - of R2. 1st objection for R1. 2nd objection for R1. 3rd objection for R1, at 14:40 (T1). 1st objection for R2. 2nd objection for R2. 3rd objection for R2, at 15:04 (T2).
At T3, where T1+2h<T3<T2+2h try to retrieve funds from the R2. Retrieval should not be possible. Tried to retrieve funds at 16:43 (T3). Transaction failed with the Freeze period not expired error. Retrieve tx.
At T4, where T1+2h<T4<T2+2h try to retrieve funds from the R1. The funds (decreased by penalty_factor of the requested redemption amount) should be retrieved as a TBTC Bank balance. Tried to retrieve funds at 16:48 (T4). Transaction succeeded. Bank balance of the retriever after transaction was increased by 2850000 (95% of 3000000). Retrieve tx. No BTC was returned.
At T5, where T5>T2+2h try to redeem R2. The funds (decreased by penalty_factor of the requested redemption amount) should be retrieved as a TBTC Bank balance. Tried to retrieve funds at 17:09 (T5). Transaction succeeded. Bank balance of the retriever after transaction was increased by 3800000 (95% of 4000000). Retrieve tx. No BTC was returned.

@michalinacienciala
Copy link
Contributor

michalinacienciala commented Mar 1, 2024

We're also executing Scenario 4 again, this time with the value of governable parameters almost the same as the default ones:

  • redemption request period is 2 hours
  • redemption request period after one veto gets extended to 8 hours
  • redemption request period after two vetos gets extended to 24 hours
  • freeze time upon veto is 1 month 24 hours

Additionally a waivedAmountLimit parameter was configured to 0.02 value (redemptions smaller than this value cannot be vetoed).

Scenario 4 (in progress)

Step Expected result Test execution / result
Trigger a redemption of a deposit (at T0). Make sure requested redeem amount (X) is at least 0.015 tBTC smaller that the max redeem amount (Y). Redemption of 0.02 tBTC requested from account 0x58C6A45AcFCc1fD0E5A103Cab2caE00b0B188EC5 to BTC address 2MtV6cMaMgrvNudeWjpqvJECfKNyL3TfL3V at Mar 1, 9:57 (T0). Unmint tx.
Some time later (<T0+2h, at T1) make one Guardian object to the redemption. 1st objection raised at Mar 1, 10:01 (T1). Objection tx.
Some time later (<T0+8h, at T2; T2>T1+2h) make another Guardian object to the redemption. 2nd objection raised at Mar 1, 12:04 (T2). Objection tx.
Some time later (<T0+24h, at T3, T3>T2+8h) make another Guardian object to the redemption. At T3 the redemption veto freeze period should start. 3rd objection raised at Mar 1, 20:52 (T3). Objection tx.
Some time later (<T3+24h, at T4) using the same redeemer try to request another redemption. Redemption should not be possible. At Mar 1, 20:56 (T4) tried redeeming 0.02 tBTC to 2N5VSdnbwQhDuHhEJBUixze8Gkz5EQ7cRzb using the account 0x58C6A45AcFCc1fD0E5A103Cab2caE00b0B188EC5. Got error: Redemption request rejected by the watchtower.
Soon after try to retrieve the vetoed funds. Retrieval should not be possible. Tried to retrieve funds at Mar 1, 21:00. Transaction failed with the Freeze period not expired error. Retrieve tx.
Wait till T5>T3+24h. Try to retrieve the vetoed funds. The funds (decreased by penalty_factor of the requested redemption amount) should be retrieved as a TBTC Bank balance. Tried to retrieve funds at Mar 3, 16:54 (T5). Transaction succeeded. Bank balance of retriever after transaction was increased by 1900000 (95% of 2000000). Retrieve tx. No BTC was returned.

We're also executing a new scenario that makes sure the redemptions for amount smaller than waivedAmountLimit (0.02) cannot be objected (in Scenario 4 we tested that redemptions for waivedAmountLimit can be objected):

Scenario 7

Step Expected result Test execution / result
Trigger a redemption of <0.02 tBTC (at T0). Redemption of 0.01999 tBTC requested from account 0x58C6A45AcFCc1fD0E5A103Cab2caE00b0B188EC5 to BTC address 2Mzj8kkULAUHojVKYBH9SFc8vX3PUCqRWZW at Mar 1, 10:12 (T0). Unmint tx.
Some time later (<T0+2h, at T1) try to object to the redemption. Objection should not be successfull. Tried to object to the redemption at Mar 1, 10:13 (T1). Transaction failed with error Redemption veto delay period expired. Objection tx.

@michalinacienciala
Copy link
Contributor

All tests have passed.
@lukasz-zimnoch, you can change the freeze time upon veto param back to 1 month.

@lukasz-zimnoch lukasz-zimnoch added the ⛓️ solidity Solidity contracts label Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⛓️ solidity Solidity contracts
Projects
None yet
Development

No branches or pull requests

2 participants