bitcoinjs / indexd

An external bitcoind index management service module
ISC License
53 stars 23 forks source link

Choking on testnet transaction 22e08a53aff6cb0680758036e09f792dac56e4813de81c9be1b4b1ae3cda0ab0 #40

Closed asoltys closed 6 years ago

asoltys commented 6 years ago

Running indexd master (7c0c12526ae6ed9a6874878138cbec16dfe671c5) against testnet:

indexd:rpc getblock [ '00000000003ba174fd77250a04eba0e15134da0b4edfb9996bfedffdd235f97c',
  2 ] RangeError [ERR_INVALID_OPT_VALUE]: The value "250000" is invalid for option "value"
    at checkInt (buffer.js:1275:11)
    at Buffer.writeUInt16LE (buffer.js:1337:7)
    at Object.encode (/home/adam/indexd/node_modules/varstruct/lib/numbers.js:27:11)
    at Object.encode (/home/adam/indexd/node_modules/varstruct/lib/varbuffer.js:22:18)
    at /home/adam/indexd/node_modules/varstruct/lib/object.js:36:19
    at Array.forEach (<anonymous>)
    at Object.encode (/home/adam/indexd/node_modules/varstruct/lib/object.js:33:13)
    at ChainedBatch.put (/home/adam/indexd/dbwrapper.js:42:35)
    at outs.forEach (/home/adam/indexd/indexes/txo.js:52:14)
    at Array.forEach (<anonymous>) +43ms
  service RangeError [ERR_INVALID_OPT_VALUE]: The value "250000" is invalid for option "value"
  service     at checkInt (buffer.js:1275:11)
  service     at Buffer.writeUInt16LE (buffer.js:1337:7)
  service     at Object.encode (/home/adam/indexd/node_modules/varstruct/lib/numbers.js:27:11)
  service     at Object.encode (/home/adam/indexd/node_modules/varstruct/lib/varbuffer.js:22:18)
  service     at /home/adam/indexd/node_modules/varstruct/lib/object.js:36:19
  service     at Array.forEach (<anonymous>)
  service     at Object.encode (/home/adam/indexd/node_modules/varstruct/lib/object.js:33:13)
  service     at ChainedBatch.put (/home/adam/indexd/dbwrapper.js:42:35)
  service     at outs.forEach (/home/adam/indexd/indexes/txo.js:52:14)
  service     at Array.forEach (<anonymous>) +1m

I think it's choking on tx 22e08a53aff6cb0680758036e09f792dac56e4813de81c9be1b4b1ae3cda0ab0 which seems to be some sort of crazy non-standard tx. I couldn't decode it with bitcoin-cli

dcousens commented 6 years ago

@asoltys interesting! This module relies on the RPC, so if the RPC can't decode that TX, we can't either. Have you reported this to https://github.com/bitcoin/bitcoin ?

dcousens commented 6 years ago

Wow, it is a 500KiB transaction.

dcousens commented 6 years ago
{
  "txId": "22e08a53aff6cb0680758036e09f792dac56e4813de81c9be1b4b1ae3cda0ab0",
  "txHex": "01000000015300a4bd8000a2b1bf083c72fc65b74e1699da78904451fc9f01626135c1775e010000006b48304502200cc2be5c057d81a78d1eb880aa0c76ada27c52e900adbb8c99a12dc36b97613402210095b3a9d662dc8ce6acac336ff0e17ef82c1e7fc38cf3978444dc1351897ef230012102dfeb96b4296fadef124dfdbe898c50f27126219fa0151e9ea90dc9f1affd659affffffff010000000000000000fe90d00300ffffffff... snipped 499986*f  ...ffffff00000000",
  "blockId": "00000000003ba174fd77250a04eba0e15134da0b4edfb9996bfedffdd235f97c",
  "blockHeight": 54504
}
dcousens commented 6 years ago

OK, the RPC isn't choking here, we are.

dcousens commented 6 years ago

I made an assumption that has backfired.

https://github.com/bitcoinjs/indexd/blob/7c0c12526ae6ed9a6874878138cbec16dfe671c5/indexes/txo.js#L23

Specifically, I thought 16-bits would be enough for the size of the script. Apparently not!

asoltys commented 6 years ago

Ah ha :) and yeah sorry I had just mispasted the raw transaction hex into bitcoin-cli, too big for my clipboard or terminal I guess

dcousens commented 6 years ago

Added 3e37c1e and then 49372a3, this problem should resolve. I hadn't released this version yet, but thanks for testing!

I'll add a script to https://github.com/bitcoinjs/private-bitcoin which you can use to drop the tip for the TXO index which should mean it re-syncs. Alternatively, wipe your indexd data directory...

dcousens commented 6 years ago

@asoltys see https://github.com/bitcoinjs/private-bitcoin/blob/87fcf554c316cbb4d71ca12e4712ca8c748ea989/scripts/drop.js#L1-L23

dcousens commented 6 years ago

Closing as fixed :+1: (re-open if not)

asoltys commented 6 years ago

Thanks for the quick fix! Drop script worked like a charm. Indexing now.