thecointech / thecoin

Mono-repo for TheCoin project
https://thecoin.io
GNU Affero General Public License v3.0
4 stars 1 forks source link

Fix/fetch history limit #337

Closed FrozenKiwi closed 2 years ago

FrozenKiwi commented 2 years ago

Tiny job, massive fix.

After moving our smart contract to polygon, the existing getLog we were using would not search spans of more than 10K blocks. Unfortunately, because Polygon moves so fast, that range was exhausted in a few days.

Polygon is built on etherscan though so, which has special-purpose methods for scanning blocks. Solution, switch provider from Infura to use Etherscan and connect directly.

However, the built-in Etherscan provider didn't work with Mumbai. Luckily, 3rd party plugin provided that ability. Unfortunately, it required a slightly newer version of Ethers. No worries, we upgrade our version of ethers. Unfortunately, this then conflicted with older versions of ethers used by IDX. I went to update IDX, and found that all my existing tools had been deprecated, and the whole system switched to a new set in the last few months. Tried to revert, unfortunately, the mix of new & old ethers was now breaking the devLive configuration. Threw up hands in despair, upgraded to the new version of IDX (is a lot more dev-friendly, would rather waste cycles going forward than backwards. After everything was working, tested the system vs devlive. Unfortunately, the new versions of ethers changed the getLogs we were using to communicate with devlive. The fix to this mismatch was included in the alpha version of ganache 7.

At this point, I threw up my hands. Created my own provider, wrote bypass code to use the old version of getLogs in devlive, and then re-wrote the transaction fetch code to run using etherscans fancy new apis. Then back-ported the new api's to work using the old logs to get devLIve going.

Then, cause it was so much fun, I backported the whole system to dev, so can run the website (with transactions) without devLive

God I hate crypto...

FrozenKiwi commented 2 years ago

@MarieTheCoin If you feel like reviewing this, I would definitely value your input

I'm going to merge it in now though because I need to deploy the fixes in here. I'll re-review it myself tomorrow if you don't see this/get around to it.