create account

Tech Support: Polycub double-harvest bug 'fix' by edicted

View this thread on: hive.blogpeakd.comecency.com
· @edicted ·
$41.33
Tech Support: Polycub double-harvest bug 'fix'
![viruscomputerbugcartoonillustration.jpg](https://images.hive.blog/DQmWU7bxwv1bGfZSLnwCDwXKW71buCu22uJH7gi24JwuVau/virus-computer-bug-cartoon-illustration.jpg)

A lot of people have been hit with this bug because it is so easy to trigger.  Basically if you 'harvest' two farms at the same time the contract will bug out and it becomes impossible to claim locked coins.  I've already personally walked 4 people through this bug so I figured I'd just create this quick tutorial in case I need to walk anyone through it again. 

When this bug happens to any particular wallet, that wallet is essentially permanently bugged, and can never claim locked tokens ever again.  The best thing to do if you still want to claim locked tokens in this case is move the LP tokens to another wallet and farm on an unbugged account. 

Of course at this point as yields decline it will be less and less worth it to claim locked tokens, so perhaps this post comes a little late.  Still, many in Discord ask about this bug when it happens, and it's super annoying so it's worth explaining a bit more in detail. 

https://polygonscan.com/address/0xef79881df640b42bda6a84ac9435611ec6bb51a4#readContract

In order to claim some of the tokens manually that are locked behind this bug (after moving LP tokens to a new wallet), go to the above polycub contract and scroll down to #12 and #13:

![image.png](https://images.hive.blog/DQmb74CPnJ3fW9E1wCmwd53qGx2e5rpufxT3wRbEkMvAH1v/image.png)

<code>pendingLength</code> is how we find out how many harvests are locked in the contract.  These harvests seem to be stored on some kind of array starting with an index of <code>0</code> and ending with <code>pendingLength-1</code>

#### Paste your public address into <code>pendingLength</code> to find out how big the array is. 

![image.png](https://images.hive.blog/DQmYHCUMpyrjSTQnh1drjXRaPhmH4DaNs43o9Z496g14EJ4/image.png)

We can see that this wallet has a <code>pendingLength</code> of 5 after we hit the <code>Query</code> button.  This means that the user has harvested 5 times without claiming locked tokens.  In this case the locked tokens can't be claimed, which is exactly what the bug does.  What we are looking for is which harvest is the bugged harvest before we move onto the next step. 

As I said before, these harvests are stored in some kind of array (I don't know how Solidity works but that's irrelevant).  An array of 5 is stored in five indexes: 0, 1, 2, 3, 4 (for a total of five slots).  Non-programmers would ask why a list starts at zero instead of one, but you'll just have to trust me that there are many reasons why it is done this way that are well beyond the scope of this tech support. 

#### Find the bugged harvest.
Move up one section to #12 (<code>pending</code>), input the same public key, and starting at index 0, find the bugged contract.  It will usually be index 1 unless you harvested farms before the bug happened without claiming locked to clear the array. 

![image.png](https://images.hive.blog/DQmbaZ4sQgMgLuUUcgDuCdQWHK9Z1nVWJUqJisdQvjf9md9/image.png)

You'll know you've found the bugged index when you see that the <code>startBlock</code> and <code>endBlock</code> point to the same block.  Something about the way Polygon works makes this particular contract bug out when two harvests are claimed on the same block. 

###### Once you've found the bugged index, click the <code>Write Contract</code> button at the top of the page or click the following link:

https://polygonscan.com/address/0xef79881df640b42bda6a84ac9435611ec6bb51a4#writeContract

![image.png](https://images.hive.blog/DQmPVTxksusD869zv9mo57V6S8MvGWA95KmVaZ8sFe5zyih/image.png)

The first thing we need to do here is turn the red dot green to signal that our wallet is connected to Metamask.  Often times it takes two tries for some reason, and you have to click a disclaimer that this is extremely experimental and potentially dangerous to craft custom operations by hand.   Luckily you shouldn't really have much (if any) liquid funds on this particular wallet so the risk is minimal.  Plus the operation that we are signing is super basic.  It's hard to imagine there being any problems in this particular scenario. 

![image.png](https://images.hive.blog/DQme6f1Cr783acHC8EbcZThNjguCaWcWcYABjqggwqz9VXo/image.png)

![image.png](https://images.hive.blog/DQmPrB5fW7pdkpa3EFRY4z2NH76VLK8EKCNUpsb7kd1TqF6/image.png)

After you get the green light head down to #2 <code>claim</code> and set <code>_claimLocked</code> to <code>true</code> and <code>_limit</code> to whatever the bugged index was we found in the previous step.  Again, in most cases it will be 1, but not always.  Click the <code>Write</code> button.  A custom Metamask operation should appear for you to sign. 

![image.png](https://images.hive.blog/DQmNjkCHS4gzuaKnBKRKeiKHi4UxM18mpACQtHkERZdbNJb/image.png)

If Metamask looks like this you made a mistake and the transaction will fail.  Not only that it will destroy over $1 worth of fees, which is a lot of fees for Polygon.  If Metamask says it will fail, trust that it will.  If everything looks fine, sign the transaction and wait for it to confirm on chain. 

![image.png](https://images.hive.blog/DQmW86JBqeU7ZK3xfbP1otLktL2haWJ84BjdF6HRxqWAxcH/image.png)

Doing it this way only claims one of the indexes.  
In this example we had 5 indexes to claim. 

So you can repeat this exact same transaction 4 times (clicking <code>Write</code> 4 times and signing Metamask) using the same variables of <code>true</code> and <code>1</code> or whatever the bugged index was.  Each time you do this it will decrease the number of indexes in <code>pendingLength</code> by one, until there is only one left (index 0).  The bugged index will remain unclaimable, and you won't get that money until it unlocks in 90 days. 

If you are unsure if you got them all, there is no harm is checking other indexes or repeating the beginning step to see if you got them all.  Metamask will let you know if it's not a valid operation by jacking up the fee to the roof and telling you it will fail.  Do not attempt any such operations.  They will fail and they will eat up all the gas you pump into them. 

#### Conclusion
This is a super annoying bug that's not going to be fixed unless the contracts get redeployed.  There are so many other priorities on the table that I wouldn't expect that to happen.  Luckily, there are a few easy ways to avoid this bug entirely.  The first of which is to always wait for harvests to confirm before harvesting something else, or even better simply use the <code>Harvest all</code> button on the home page.  

![image.png](https://images.hive.blog/DQmYLqaXxYG4kxBwXRuBWKKUFAP9uaYUbLW2fFhStjUCXyS/image.png)


This Harvest all button has been reprogrammed specifically to wait until the current harvest has been confirmed before it moves onto the next one, which will avoid the bug entirely without anyone having to think about it. 


Hopefully this information is useful going forward, although it will be nice when yields decline and it becomes less and less worth it to claim locked tokens in the first place.  I've already personally helped four people through this process, and Khal went over it with me personally as well in Discord, so I figured I could help out a bit on the tech support angle, seeing as how the queue seems to be quite full in that regard. 

Posted Using [LeoFinance <sup>Beta</sup>](https://leofinance.io/@edicted/tech-support-polycub-double-harvest-bug-fix)
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 312 others
properties (23)
authoredicted
permlinktech-support-polycub-double-harvest-bug-fix
categoryhive-167922
json_metadata{"app":"leofinance/0.2","format":"markdown","tags":["proofofbrain","leofinance","vyb","palnet","pcub","cub","polycub","bug"],"canonical_url":"https://leofinance.io/@edicted/tech-support-polycub-double-harvest-bug-fix","links":["https://polygonscan.com/address/0xef79881df640b42bda6a84ac9435611ec6bb51a4#readContract","https://polygonscan.com/address/0xef79881df640b42bda6a84ac9435611ec6bb51a4#writeContract"],"image":["https://images.hive.blog/DQmWU7bxwv1bGfZSLnwCDwXKW71buCu22uJH7gi24JwuVau/virus-computer-bug-cartoon-illustration.jpg","https://images.hive.blog/DQmb74CPnJ3fW9E1wCmwd53qGx2e5rpufxT3wRbEkMvAH1v/image.png","https://images.hive.blog/DQmYHCUMpyrjSTQnh1drjXRaPhmH4DaNs43o9Z496g14EJ4/image.png","https://images.hive.blog/DQmbaZ4sQgMgLuUUcgDuCdQWHK9Z1nVWJUqJisdQvjf9md9/image.png","https://images.hive.blog/DQmPVTxksusD869zv9mo57V6S8MvGWA95KmVaZ8sFe5zyih/image.png","https://images.hive.blog/DQme6f1Cr783acHC8EbcZThNjguCaWcWcYABjqggwqz9VXo/image.png","https://images.hive.blog/DQmPrB5fW7pdkpa3EFRY4z2NH76VLK8EKCNUpsb7kd1TqF6/image.png","https://images.hive.blog/DQmNjkCHS4gzuaKnBKRKeiKHi4UxM18mpACQtHkERZdbNJb/image.png","https://images.hive.blog/DQmW86JBqeU7ZK3xfbP1otLktL2haWJ84BjdF6HRxqWAxcH/image.png","https://images.hive.blog/DQmYLqaXxYG4kxBwXRuBWKKUFAP9uaYUbLW2fFhStjUCXyS/image.png"]}
created2022-03-25 01:21:15
last_update2022-03-25 01:21:15
depth0
children7
last_payout2022-04-01 01:21:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value41.328 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length7,513
author_reputation3,509,368,001,739,760
root_title"Tech Support: Polycub double-harvest bug 'fix'"
beneficiaries
0.
accountedicted
weight10,000
max_accepted_payout1,000,000.000 HBD
percent_hbd0
post_id111,663,986
net_rshares57,462,050,099,324
author_curate_reward""
vote details (376)
@carteritos · (edited)
Thanks but why not just simply shift to the soft which has the features you need? As far as I know the Voiso solutions have historical reporting feature. Here is the link to find out https://voiso.com/historical-reporting
properties (22)
authorcarteritos
permlinkrk0qbe
categoryhive-167922
json_metadata{"app":"hiveblog/0.1","links":["https://voiso.com/historical-reporting"]}
created2022-10-19 20:59:36
last_update2022-10-26 17:52:30
depth1
children0
last_payout2022-10-26 20:59:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length221
author_reputation155,663,696,394
root_title"Tech Support: Polycub double-harvest bug 'fix'"
beneficiaries
0.
accounthiveonboard
weight100
1.
accountocdb
weight100
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id117,609,704
net_rshares0
@jfang003 ·
So this affects anyone farming so I guess I am safe. This information is nice and I will refer anyone I see with it to this post. 

The issue lies with the contracts so does this apply on any Polygon Defi platform or just the ones that didn't realize that this could occur?

Posted Using [LeoFinance <sup>Beta</sup>](https://leofinance.io/@jfang003/re-edicted-71guqx)
properties (22)
authorjfang003
permlinkre-edicted-71guqx
categoryhive-167922
json_metadata{"app":"leofinance/0.2","format":"markdown","tags":["hive-167922","leofinance"],"canonical_url":"https://leofinance.io/@jfang003/re-edicted-71guqx"}
created2022-03-25 04:03:06
last_update2022-03-25 04:03:06
depth1
children0
last_payout2022-04-01 04:03:06
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length367
author_reputation657,755,215,899,514
root_title"Tech Support: Polycub double-harvest bug 'fix'"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id111,667,367
net_rshares0
@khan.dayyanz ·
Thanks, works like a charm.
properties (22)
authorkhan.dayyanz
permlinkre-edicted-r9ft8m
categoryhive-167922
json_metadata{"tags":["hive-167922"],"app":"peakd/2022.03.8"}
created2022-03-28 04:17:12
last_update2022-03-28 04:17:12
depth1
children0
last_payout2022-04-04 04:17:12
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length27
author_reputation19,546,915,550,836
root_title"Tech Support: Polycub double-harvest bug 'fix'"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id111,750,114
net_rshares0
@mikedcrypto ·
$0.08
Great post fellow club member...

>The bugged index will remain unclaimable, and you won't get that money until it unlocks in 90 days.

So this is all irrelevant if you wait 90 days? I don't have this issue anyway, but if I'm understanding properly then the worst case scenario is that someone has to wait 90 days?

That's good because at first I was thinking that worst case scenario is they can never get their pcub.

Posted Using [LeoFinance <sup>Beta</sup>](https://leofinance.io/@mikedcrypto/re-edicted-7326np)
👍  
properties (23)
authormikedcrypto
permlinkre-edicted-7326np
categoryhive-167922
json_metadata{"app":"leofinance/0.2","format":"markdown","tags":["hive-167922","leofinance"],"canonical_url":"https://leofinance.io/@mikedcrypto/re-edicted-7326np"}
created2022-03-25 02:05:06
last_update2022-03-25 02:05:06
depth1
children0
last_payout2022-04-01 02:05:06
cashout_time1969-12-31 23:59:59
total_payout_value0.040 HBD
curator_payout_value0.040 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length515
author_reputation5,238,100,477,892
root_title"Tech Support: Polycub double-harvest bug 'fix'"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id111,664,880
net_rshares57,414,402,028
author_curate_reward""
vote details (1)
@tokenizedsociety ·
I think Khal or someone said this could happen and we should use that magic Harvest All button so I've been harvesting t with that exclusively.

Good to know there is a workaround for the bug though, even if it's a little bit of work.

Posted Using [LeoFinance <sup>Beta</sup>](https://leofinance.io/@tokenizedsociety/re-edicted-mfefe)
properties (22)
authortokenizedsociety
permlinkre-edicted-mfefe
categoryhive-167922
json_metadata{"app":"leofinance/0.2","format":"markdown","tags":["hive-167922","leofinance"],"canonical_url":"https://leofinance.io/@tokenizedsociety/re-edicted-mfefe"}
created2022-03-25 02:00:48
last_update2022-03-25 02:00:48
depth1
children0
last_payout2022-04-01 02:00:48
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length335
author_reputation130,656,781,071,982
root_title"Tech Support: Polycub double-harvest bug 'fix'"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id111,664,767
net_rshares0
@whatsup ·
$0.08
Thank you for writing this, I've heard about it in chat, but I've been really careful.



Posted Using [LeoFinance <sup>Beta</sup>](https://leofinance.io/@whatsup/re-edicted-5vxjvt)
👍  
properties (23)
authorwhatsup
permlinkre-edicted-5vxjvt
categoryhive-167922
json_metadata{"app":"leofinance/0.2","format":"markdown","tags":["hive-167922","leofinance"],"canonical_url":"https://leofinance.io/@whatsup/re-edicted-5vxjvt"}
created2022-03-25 02:09:18
last_update2022-03-25 02:09:18
depth1
children0
last_payout2022-04-01 02:09:18
cashout_time1969-12-31 23:59:59
total_payout_value0.040 HBD
curator_payout_value0.040 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length181
author_reputation519,839,651,581,670
root_title"Tech Support: Polycub double-harvest bug 'fix'"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id111,664,961
net_rshares57,414,042,754
author_curate_reward""
vote details (1)
@yogajill ·
$0.08
Because this stuff wasn't already complicated enough!! Yiiiiiza. Lol     guessing this could help users smarter than me!! 

Posted Using [LeoFinance <sup>Beta</sup>](https://leofinance.io/@yogajill/re-edicted-76bfz8)
👍  
properties (23)
authoryogajill
permlinkre-edicted-76bfz8
categoryhive-167922
json_metadata{"app":"leofinance/0.2","format":"markdown","tags":["hive-167922","leofinance"],"canonical_url":"https://leofinance.io/@yogajill/re-edicted-76bfz8"}
created2022-03-25 03:31:27
last_update2022-03-25 03:31:27
depth1
children0
last_payout2022-04-01 03:31:27
cashout_time1969-12-31 23:59:59
total_payout_value0.040 HBD
curator_payout_value0.040 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length216
author_reputation54,138,244,064,176
root_title"Tech Support: Polycub double-harvest bug 'fix'"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id111,666,752
net_rshares57,420,796,081
author_curate_reward""
vote details (1)