iquidus / explorer

An open source block explorer
BSD 3-Clause "New" or "Revised" License
747 stars 1.33k forks source link

Exception at a specific block height during sync. #464

Closed gdiscord closed 3 years ago

gdiscord commented 3 years ago

Am hitting the exception below consistently at a specific block height as sync.js runs. I have tried it about 10 times and consistently hit the exception, and always at that height.

Tracing the code on the line explorer.js:503:74 it appears it's relating to an address in the blockchain? But not sure which address and whether it is fetching it from setting.json.

Please advise.

TypeError: Cannot read property '0' of undefined at explorer/lib/explorer.js:503:74 at Object.next (explorer/lib/explorer.js:360:18) at Object.syncLoop (explorer/lib/explorer.js:376:10) at Object.prepare_vout (explorer/lib/explorer.js:497:20) at explorer/lib/database.js:117:13 at explorer/lib/explorer.js:605:14 at Object.next (explorer/lib/explorer.js:365:24) at explorer/lib/explorer.js:596:22 at Object.convert_to_satoshi (explorer/lib/explorer.js:40:12) at explorer/lib/explorer.js:594:30 at explorer/lib/explorer.js:476:14 at Object.next (explorer/lib/explorer.js:348:19) at explorer/lib/explorer.js:471:14 at Object.next (explorer/lib/explorer.js:360:18) at Object.syncLoop (explorer/lib/explorer.js:376:10) at Object.is_unique (explorer/lib/explorer.js:465:20) at explorer/lib/explorer.js:587:26 at explorer/lib/explorer.js:571:20 at Object.next (explorer/lib/explorer.js:348:19) at explorer/lib/explorer.js:565:22 at Object.next (explorer/lib/explorer.js:360:18) at explorer/lib/explorer.js:568:20

joeuhren commented 3 years ago

Approximately which block is it failing on? Also, which coin are you trying to sync? My guess is that block is using some kind of non-standard blockchain feature which isn't supported by iquidus, but difficult to say exactly what's going on until we can see the raw block data.

gdiscord commented 3 years ago

the coin is oasis, and it has been running on another explorer for years now. https://oasis.ccore.online.

The exact block it's failing on is 6070 (i.e after 6069 loads the error is triggered)

A little bit more data:

6068: 03803a98b630f02823730efc33b0a8583baeb72623ea265fff2df942d75e7711 6069: cef0aabbaeeee7298b23b93ce51e27b0ba8a037d0d36a8425e9ab6ad1216225e 6069: 3e484a4c294d59011f051e49caa8c515f835897bd48298fa806420e969b80de9 explorer/node_modules/bluebird/js/release/async.js:49 fn = function () { throw arg; }; ^

TypeError: Cannot read property '0' of undefined at explorer/lib/explorer.js:503:74 at Object.next (explorer/lib/explorer.js:360:18) at Object.syncLoop (explorer/lib/explorer.js:376:10) at Object.prepare_vout (explorer/lib/explorer.js:497:20)

joeuhren commented 3 years ago

Thanks for the sample block data and existing explorer link, that really helped to diagnose the problem quickly. The issue is that the 3rd transaction in block 6069 is using a zerocoin privacy feature which is not supported in iquidus at this time: https://oasis.ccore.online/transaction/7d38b3e2ce68b4956420c3a232cff60fd026d31c2d1d2d4d7e26faf5879b1781

Unfortunately, if you want to use iquidus as a block explorer for this coin you will either need to add your own implementation for handling zerocoin transactions or else maybe you can get lucky and find another custom iquidus explorer floating around online that has already done this, but I don't know of one to recommend.

gdiscord commented 3 years ago

I see. Thanks for the quick answer.

The main reason I wanted to use Iquidus is because I'd like to query the blockchain to get all addresses with a positive balance. Is there another approach I can use to achieve same?

gdiscord commented 3 years ago

Found a fix for the exception.

changing the following line in explorer.js: from -> if (vout[i].scriptPubKey.type != 'nonstandard' && vout[i].scriptPubKey.type != 'nulldata') { to ->

if (vout[i].scriptPubKey.type != 'nonstandard' && vout[i].scriptPubKey.type != 'nulldata' && vout[i].scriptPubKey.hasOwnProperty("addresses")) {

https://github.com/iquidus/explorer/issues/56

Hopefully it helps someone else.

joeuhren commented 3 years ago

That's probably the best workaround for your situation where you simply skip over the obfuscated addresses during syncing like you have demonstrated. Please note that the private data is being discarded in this case and not being handled properly, so I want to be clear that this is NOT a proper fix for zerocoin. It will work for your use-case however since you wouldn't be able to figure out the private balances anyway and so discarding that data shouldn't matter for your purpose.

I hope that makes sense.

gdiscord commented 3 years ago

I think I get your point. Zerocoin has been in maintenance mode in this coin for a couple of years or more, and now making effort to completely nuke it from the coin codebase. So yes, zerocoin balances are of no interested in my particular usecase - only interested in getting all public addresses with a positive balance.

gdiscord commented 3 years ago

Another exception encountered after block height 334604 is loaded.


explorer/node_modules/bluebird/js/release/async.js:49 fn = function () { throw arg; }; ^

TypeError: Cannot read property 'length' of undefined at explorer/lib/explorer.js:557:43 at explorer/lib/explorer.js:207:16 at Client. (explorer/lib/explorer.js:27:16) at Client.tryCatcher (explorer/node_modules/bluebird/js/release/util.js:16:23) at Promise.successAdapter (explorer/node_modules/bluebird/js/release/nodeify.js:23:30) at Promise._settlePromise (explorer/node_modules/bluebird/js/release/promise.js:601:21) at Promise._settlePromise0 (explorer/node_modules/bluebird/js/release/promise.js:649:10) at Promise._settlePromises (explorer/node_modules/bluebird/js/release/promise.js:729:18) at Promise._fulfill (explorer/node_modules/bluebird/js/release/promise.js:673:18)

gdiscord commented 3 years ago

Fix from a comment in the same link posted earlier: https://github.com/iquidus/explorer/issues/56#issuecomment-660524440