btcz / bitcoinz

BitcoinZ
https://bitcointalk.org/index.php?topic=3086664.0
Other
125 stars 69 forks source link

Debug.log file Flooding (low impact) #71

Open MarcelusCH opened 1 year ago

MarcelusCH commented 1 year ago

By the node version 2.0.7-10 we added the possibility to add an OP code with an Hex encoded string in the transactions that also give an unexpected output format if it is used. This unexpected output format is OP_RETURN _<HEX-STRING>_.

This was added in the Raw Transaction class: https://github.com/btcz/bitcoinz/blob/977cdc0dce3bb62757e1258b5f9e8a349f4fc637/src/rpc/rawtransaction.cpp#L591

An example of the Raw DATA can be found in this transaction : https://explorer.btcz.app/tx/b8b29ff7f76e40d01990fad1a8d51d830a66c9f533c3b1768f78fcaf26888ef4

Now, when the Insight option is activated, the node try to find the spent index information about this OP_RETURN code that are not existing as the spent amount is zero (0). And this trigger an error in the debug.logfile for each Raw DATA.

Error in the log file for Insight : ERROR: Unable to get spent index information Triggered here: https://github.com/btcz/bitcoinz/blob/977cdc0dce3bb62757e1258b5f9e8a349f4fc637/src/main.cpp#L1641

Also a similar error happen in the wallet functions. Error for the Wallet functions : CWalletTx::GetAmounts: Unknown transaction type found, txid <The_TX_ID> Triggered here: https://github.com/btcz/bitcoinz/blob/977cdc0dce3bb62757e1258b5f9e8a349f4fc637/src/wallet/wallet.cpp#L2485

After some time, the log is flooded by this badly returned error information's !

The solution is to check if the output is encoded as usually, with an OP_DUP OP_HASH160 scriptPubKey, or with an Raw DATA field with OP_RETURN. This should be done before calling the function that trigger the error. A check could also be done just before the error is triggered but I guess this will probably have an affect on the performance.

MarcelusCH commented 1 year ago

The issue in the wallet class can be fixed easely by adding a check : TX_NULL_DATA

In the main class, a check should be added and awoid error return only if the fInsightExplorer param is active. But this will not resolve the log flooding in every case. Also it's needed to find a way to check the OP code.

(See draft PR)

cryptorex commented 1 year ago

@MarcelusCH thanks for the write up - I've yet to test, but hope to get to it this week!

rfsales commented 10 months ago

same issue