XLNT / gnarly

🤙 A blockchain ETL tool to make your life better. Now that’s fuckin’ gnarly.
https://xlnt.co
Apache License 2.0
119 stars 11 forks source link

erc20 reducer patches failing #48

Open nionis opened 6 years ago

nionis commented 6 years ago

Issue

Sometimes when existing instance (ctrl+c) and we restart, gnarly will fail to apply ERC20 reducer patches.

I suspect this is due to 2 extra operations within the ERC20 reducer, my tests show that if I have only one extra operation it will not have this issue.

Recreate issue

I recreate it by randomly stopping the server and rebooting (with resuming on), once I recreate the issue, then every boot will fail.

ctrl-c that caused the bug:

equelize:pool connection acquired +0ms
  sequelize:sql:pg executing(default) : UPDATE "erc20_balances" SET "balanceStr"='3149499999999999999',"patchId"='78525b54-177e-4373-9494-16c037a19559',"updatedAt"='2018-08-09 10:38:06.083 +00:00' WHERE "id" = '0xe41d2489571d322189246dafa5ebde1f4699f498-0x4969358e80cdC3D74477D7447BFfA3B2e2aCbe92' +1ms
  sequelize:sql:pg executing(default) : UPDATE "erc20_balances" SET "balance"='3149499999999999999',"patchId"='78525b54-177e-4373-9494-16c037a19559',"updatedAt"='2018-08-09 10:38:06.085 +00:00' WHERE "id" = '0xe41d2489571d322189246dafa5ebde1f4699f498-0x4969358e80cdC3D74477D7447BFfA3B2e2aCbe92' +1ms
  sequelize:sql:pg executed(default) : UPDATE "erc20_balances" SET "balance"='174199399999999999999',"patchId"='a4821b9b-81f7-4c48-97a2-c526281845a8',"updatedAt"='2018-08-09 10:38:06.068 +00:00' WHERE "id" = '0xe41d2489571d322189246dafa5ebde1f4699f498-0x4969358e80cdC3D74477D7447BFfA3B2e2aCbe92' +0ms
  sequelize:pool connection released +1ms
  sequelize:sql:pg executed(default) : UPDATE "erc20_balances" SET "balance"='1482159000000000000000',"patchId"='78525b54-177e-4373-9494-16c037a19559',"updatedAt"='2018-08-09 10:38:06.073 +00:00' WHERE "id" = '0xe41d2489571d322189246dafa5ebde1f4699f498-0x1Fc73344279F4D402Bb6eB3f41FD212013b7810c' +1ms
  sequelize:sql:pg executed(default) : UPDATE "erc20_balances" SET "balance"='-171759999999999999999',"patchId"='a4821b9b-81f7-4c48-97a2-c526281845a8',"updatedAt"='2018-08-09 10:38:06.071 +00:00' WHERE "id" = '0xe41d2489571d322189246dafa5ebde1f4699f498-0x0bcd6ed54Df75d2BD2876C2900dfCcB2CA6F848e' +0ms
  sequelize:pool connection released +1ms
  sequelize:pool connection released +0ms
  sequelize:sql:pg executed(default) : UPDATE "erc20_balances" SET "balanceStr"='3149499999999999999',"patchId"='78525b54-177e-4373-9494-16c037a19559',"updatedAt"='2018-08-09 10:38:06.083 +00:00' WHERE "id" = '0xe41d2489571d322189246dafa5ebde1f4699f498-0x4969358e80cdC3D74477D7447BFfA3B2e2aCbe92' +1ms
  sequelize:pool connection released +1ms
  sequelize:sql:pg executed(default) : UPDATE "erc20_balances" SET "balance"='3149499999999999999',"patchId"='78525b54-177e-4373-9494-16c037a19559',"updatedAt"='2018-08-09 10:38:06.085 +00:00' WHERE "id" = '0xe41d2489571d322189246dafa5ebde1f4699f498-0x4969358e80cdC3D74477D7447BFfA3B2e2aCbe92' +2ms
  sequelize:pool connection released +2ms
  sequelize:pool connection acquired +116ms
  sequelize:sql:pg executing(default) : INSERT INTO "transactions" ("id","blockHash","createdAt","updatedAt","reducerId") VALUES ('6e8c01d0-599e-478c-b850-800c3d91f90a','0xb2a7ca9d945d4b2b00eac3ba9ae14088d61615aa6430d2226e4518c3e58e5da7','2018-08-09 10:38:06.219 +00:00','2018-08-09 10:38:06.219 +00:00','events') RETURNING *; +116ms
  sequelize:sql:pg executed(default) : INSERT INTO "transactions" ("id","blockHash","createdAt","updatedAt","reducerId") VALUES ('6e8c01d0-599e-478c-b850-800c3d91f90a','0xb2a7ca9d945d4b2b00eac3ba9ae14088d61615aa6430d2226e4518c3e58e5da7','2018-08-09 10:38:06.219 +00:00','2018-08-09 10:38:06.219 +00:00','events') RETURNING *; +3ms
  sequelize:pool connection released +4ms
  gnarly-core:ourbit:events:notifyPatches txId: 6e8c01d0-599e-478c-b850-800c3d91f90a, patches: [] +3s
  gnarly-core:api [getBlockByNumber] 5547564 0x54a62c +1s
  gnarly-core:api [getBlockByNumber] 5547565 0x54a62d +186ms
  gnarly-core:api [getBlockByNumber] 5547565 0x54a62d +45ms
^C  gnarly Gracefully exiting. Send the signal again to force exit. +0ms
  gnarly-core Gracefully decomposing reducers... +47s

  gnarly-core:blockstream Pending Transactions: 0 +44s
  gnarly-core:blockstream Pending Transactions: 0 +0ms
  gnarly-core:blockstream Pending Transactions: 0 +0ms
  gnarly-core:blockstream Pending Transactions: 0 +0ms
  gnarly-core:blockstream Done! Exiting... +1ms
  gnarly-core:blockstream Done! Exiting... +0ms
  gnarly-core:blockstream Done! Exiting... +0ms
  gnarly-core:blockstream Done! Exiting... +0ms

reboot logs:

  gnarly-core:ourbit:ZRX [applyPatch] d9553a35-7a05-4808-91a0-752d4c4a08f3 3 +219ms
  gnarly-core:ourbit:ZRX [applyPatch] b2c2474a-5e9a-4f96-8d05-429fb018004f 3 +2ms
  gnarly-core:ourbit:ZRX [applyPatch] 4003ad5f-3bbb-42ac-be1c-132259dcfc0b 8 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] 8dcc662a-ed7f-4728-9e4b-d76bd4a442ba 5 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] 8fc40e6e-9fde-4bfd-b15a-8a61e3c3a2f0 7 +1ms
  gnarly-core:ourbit:ZRX [applyPatch] 61b586ac-a32f-457a-b21b-9e4bfc32bafa 10 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] b77b908b-8617-4697-8565-11cc608669d1 2 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] 869b63f4-12f6-4917-a1d4-4fecf9f70773 10 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] 142ddcfe-3d3d-4f67-9a2f-e5c7087a83ea 4 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] 8b082b63-0994-4761-86e6-5b07d54f6d59 16 +1ms
  gnarly-core:ourbit:ZRX [applyPatch] 9069f397-686d-4d47-b0c5-585ca0e31a5a 10 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] f4beaf96-1899-4ed3-81e7-570d0d443385 8 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] f8070bc2-b28f-4a59-952c-24c88f653c2d 3 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] d13f14ee-3c50-4111-bec2-0c34d444cdf1 9 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] 6ac8173a-c3a2-4044-9026-5c73ebf47409 6 +1ms
  gnarly-core:ourbit:ZRX [applyPatch] c00e4b60-ff03-4034-866a-2efb1c09c236 4 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] d7512215-f278-418f-89b9-7e3d55d45581 3 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] 8c767448-b1ff-4f04-8b39-ad3c11a8130a 10 +1ms
  gnarly-core:ourbit:ZRX [applyPatch] b8fd1dfc-fb58-4140-acda-cbec020de84e 4 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] 447b86ad-5c98-4122-9dee-072b623bce63 6 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] c55ad150-2048-468e-8572-edad0f528836 17 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] 1540c607-5b18-4177-9575-d47736b41072 7 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] 1de4d82a-a3a4-4966-bf7c-5e1a5dac743a 8 +1ms
  gnarly-core:ourbit:ZRX [applyPatch] 356a7d8e-9aa3-4049-9365-e140db5f2ea5 3 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] 85b53d22-d9a0-48a7-b081-ae417359eaf5 4 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] f4ff0faf-fd44-4e88-97e7-58433c969857 2 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] 071e4b57-1690-426c-8c54-ba04f3b2f6b2 3 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] 3c0e187a-9b63-4425-ab30-84eb08cc9a6e 2 +1ms
  gnarly-core:ourbit:ZRX [applyPatch] ac9c7b82-8ec6-4098-a04a-e4f9a4bef5f6 2 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] bd6a052e-6033-4a38-8915-305dee4be699 5 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] 0b7a24d8-1e49-45f1-8322-72c9d74c00a5 3 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] d7807b8f-567e-4e8a-8359-f60ccd78bcb3 1 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] 71fd50ea-1368-46f2-b63c-0488b8f73634 2 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] d8021f5f-c2c1-4007-a918-5449403b58fe 2 +1ms
  gnarly-core:ourbit:ZRX [applyPatch] c352951e-1b7d-466e-94f6-090edc93823e 4 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] 823831d2-ad93-406a-922d-9d0363026414 3 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] b338389e-1d6b-4494-9da6-6e50c503ee44 4 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] 4045a3a2-6437-49ef-8304-94bbb556c12c 2 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] 84040fd3-0485-47de-bd38-4a4b0934f107 4 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] 6bbf952a-0cb2-4266-bd15-fe501baa6f5c 3 +1ms
  gnarly-core:ourbit:ZRX [applyPatch] f35ced55-9772-4140-adde-aabc8e0c2b00 2 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] d19061f7-272a-4c98-93a2-f98dc501fce4 3 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] 5dc13587-e2f9-4b3f-b14a-96cd34ec96de 2 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] 99d9180a-1ed2-4157-9b65-704a6e3d3e93 6 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] dca97bbb-1683-44af-be54-b59c78562372 7 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] ca96583c-1a69-46ac-bf9c-48bf8cfb7554 5 +1ms
  gnarly-core:ourbit:ZRX [applyPatch] 150e0d0a-86a1-475e-8180-b21f97755e90 9 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] 65fc6903-0ea7-45dd-9e96-c667c7c8f1c5 2 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] 4c3459b9-bf1c-4c24-8f85-c5f75603f454 2 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] f425bf48-4433-4956-baea-892a23c13fef 4 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] d526793c-b7a0-46bf-bf32-e42d7dfbb750 2 +1ms
  gnarly-core:ourbit:ZRX [applyPatch] 30b81dd5-85ea-4ec3-a927-afc4afcd43bc 2 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] ee299e06-2b8f-4817-a03e-425fc7bfd6e8 2 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] 670a9d5c-0cc3-4eca-ab77-4f03654e2cbb 2 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] 4da7ef97-e9b5-4c1e-be68-c01e3ef0c90a 5 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] ac8de6b8-88c0-4d79-90ae-c11c6e2ec979 4 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] 74e8fcc0-d9aa-452e-81e9-37e93273d8a8 4 +1ms
  gnarly-core:ourbit:ZRX [applyPatch] 29b1972f-fef0-4456-a473-68a8318b6497 4 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] 7e2036cc-de23-45d3-885a-47c05da6c1fd 2 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] ae18fd1e-86e0-4eea-9c58-e33d851e7d27 2 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] a18a87ec-61c7-4ca0-b352-c04f44cfa33e 1 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] 01e63019-e8de-4fa2-9e6f-611a5511dc94 1 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] 6e99b932-9b6c-4e32-9343-a698c1b6c1c0 3 +1ms
  gnarly-core:ourbit:ZRX [applyPatch] 42cb637a-a6d1-4adf-9a20-7f0b5e7f6eaa 2 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] d788e123-f730-452d-aaff-2e0b997803c3 3 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] 61316421-7f78-46ce-81ce-8153a144456e 2 +1ms
  gnarly-core:ourbit:ZRX [applyPatch] e607b94d-4cc0-4d98-a8dd-81b3babc66d5 1 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] e1c0ce0f-bd5f-43ae-9544-f1ac1f5281b1 3 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] 2c82061a-6be1-4d5d-a870-088f42823901 1 +0ms
  gnarly-core:ourbit:ZRX [applyPatch] 3520a38a-3ec7-442b-b1a4-b7cfdba6b8c0 4 +1ms
  gnarly-core:ourbit:ZRX [applyPatch] f4df5c2d-7d12-4d1a-9a48-8214e457613b 5 +0ms
  gnarly-core:runner:ZRX TypeError: Cannot read property 'balanceStr' of undefined
  gnarly-core:runner:ZRX     at Object.replace (/mnt/c/Users/stive/Documents/work/projects/gnarly/node_modules/@xlnt/fast-json-patch/lib/core.js:27:26)
  gnarly-core:runner:ZRX     at applyOperation (/mnt/c/Users/stive/Documents/work/projects/gnarly/node_modules/@xlnt/fast-json-patch/lib/core.js:231:60)
  gnarly-core:runner:ZRX     at Object.applyPatch (/mnt/c/Users/stive/Documents/work/projects/gnarly/node_modules/@xlnt/fast-json-patch/lib/core.js:268:22)
  gnarly-core:runner:ZRX     at txBatch.forEach (/mnt/c/Users/stive/Documents/work/projects/gnarly/packages/gnarly-core/src/ourbit/Ourbit.ts:131:9)
  gnarly-core:runner:ZRX     at Array.forEach (<anonymous>)
  gnarly-core:runner:ZRX     at Ourbit.<anonymous> (/mnt/c/Users/stive/Documents/work/projects/gnarly/packages/gnarly-core/src/ourbit/Ourbit.ts:127:15)
  gnarly-core:runner:ZRX     at Generator.next (<anonymous>)
  gnarly-core:runner:ZRX     at fulfilled (/mnt/c/Users/stive/Documents/work/projects/gnarly/packages/gnarly-core/lib/ourbit/Ourbit.js:4:58)
  gnarly-core:runner:ZRX     at process._tickCallback (internal/process/next_tick.js:68:7) +236ms
error Command failed with exit code 1.
nionis commented 6 years ago

probably the best way to go about this is to implement unit tests because debugging it is really hard atm, also it might have been that I didnt get the error when I was using one operation because I was lucky, so don't let that distract you from exploring other reasons