HorizenOfficial / zen

Horizen
https://www.horizen.io
Other
264 stars 120 forks source link

Transaction details cannot be found in some blocks #639

Closed isReset728 closed 8 months ago

isReset728 commented 8 months ago

Describe the issue

Version: v5.0.1 There are two transactions at block height 1514975. The transaction hash is 33982dca2254854f64e6cb3072f3194700222ed45ccce510cc038ef369ebad8b cannot be found. The other transaction hash is f1ed745e64bd37566d633132268c0e66c96f28795abce5d93adccd0c559337f7 can be found. Had the same problem at block height 1514974.

curl -u test:test 'http://127.0.0.1:8231' -H'Content-Type: application/json' -d '{"jsonrpc": "2.0", "method": "getrawtransaction", "params": ["33982dca2254854f64e6cb3072f3194700222ed45ccce510cc038ef369ebad8b",2]}'

{"result":null,"error":{"code":-5,"message":"No information available about transaction"},"id":null}

image

Can you reliably reproduce the issue?

No response

Expected behavior

No response

Actual behavior and errors

No response

The full version of zend you are using

en Daemon version v5.0.1

Machine specs

Any extra information that might be useful in the debugging process

No response

Do you have a back-up of ~/.zen directory and/or a VM snapshot?

No response

ptagl commented 8 months ago

This is expected behavior as also confirmed by the RPC command help message:

NOTE: By default this function only works sometimes. This is when the tx is in the mempool or there is an unspent output in the utxo for this transaction. To make it always work, you need to maintain a transaction index, using the -txindex command line option."

So, if you want to make getrawtransaction work on any input at any time, you need to run zend with the startup argument -txindex, so that it can store information about any transaction in the database. Please, note that switching -txindex from enabled to disabled and vice-versa requires a new synchronization of blocks from scratch or a reindex, otherwise zend would immediately stop with an error message. The recommendation, in general, is to perform the reindex with the -reindexfast startup argument.

Let us know if you have any other questions or doubts!