BlockPo / BlockPo-to-Tradelayer

Incubation Repo for the TradeLayer protocol, 0.2.0
http://www.tradelayer.org
Other
8 stars 8 forks source link

Wallet Corruption relating to Trade Channel Balance updates #422

Closed patrickdugan closed 3 years ago

patrickdugan commented 3 years ago

On Jan. 4th while running the TradeChannel .js scripts to test trade channels, the following error occurred fatally on a local instance:


EXCEPTION: St13runtime_error CDB: Error -30974, can't open database wallet.dat litecoin in scheduler

terminate called after throwing an instance of 'std::runtime_error' what(): CDB: Error -30974, can't open database wallet.dat Aborted (core dumped) valiopld@DESKTOP-QUANSNR:~/BlockPo-to-Tradelayer/src$ ./litecoind Error: wallet.dat corrupt, salvage failed

Attempt to reindex resulted in:

valiopld@DESKTOP-QUANSNR:~/BlockPo-to-Tradelayer/src$ ./litecoind -reindex Error: Error loading wallet.dat: Wallet corrupted

The tradelayer.log shows this output at the time of the crash:


2021-01-04T19:12:33Z parseTransaction(block=1753516, 2021-01-04 idx= 2); txid: 4f90a9bf4b6e905405d9496e35055ce98f37b3162440843c1098337b20f1242e 2021-01-04T19:12:33Z FillTxInputCache(): coin.IsSpent() == true, nCacheHits: 367 2021-01-04T19:12:33Z FillTxInputCache(): newcoin = removedCoins->find(txIn.prevout)->second 2021-01-04T19:12:33Z FillTxInputCache(): nCacheHits: 367, nCacheMiss: 3598, nCacheSize: 500000 2021-01-04T19:12:33Z parseTransaction(): strSender: QbbqvDj2bJkeZAu4yWBuQejDd86bWHtbXh 2021-01-04T19:12:33Z logicMath_Withdrawal_FromChannel(): amount_to_withdraw : 1000000000, totalAmount in channel: 10000000000 2021-01-04T19:12:33Z checking wthd element : address: QbbqvDj2bJkeZAu4yWBuQejDd86bWHtbXh, deadline: 1753523, propertyId: 7, amount: 1000000000 2021-01-04T19:12:33Z ____ 2021-01-04T19:12:33Z parseTransaction(block=1753516, 2021-01-04 idx= 3); txid: 39ea8f941e50445efe0524f6f3cd25ede62b7ac1ea02801d66747119ca952030 2021-01-04T19:12:33Z FillTxInputCache(): coin.IsSpent() == true, nCacheHits: 367 2021-01-04T19:12:33Z FillTxInputCache(): newcoin = removedCoins->find(txIn.prevout)->second 2021-01-04T19:12:33Z FillTxInputCache(): nCacheHits: 367, nCacheMiss: 3599, nCacheSize: 500000 2021-01-04T19:12:33Z parseTransaction(): strSender: QbbqvDj2bJkeZAu4yWBuQejDd86bWHtbXh 2021-01-04T19:12:33Z logicMath_Withdrawal_FromChannel(): amount_to_withdraw : 1000000000, totalAmount in channel: 1000000000 2021-01-04T19:12:33Z checking wthd element : address: QbbqvDj2bJkeZAu4yWBuQejDd86bWHtbXh, deadline: 1753523, propertyId: 7, amount: 1000000000 2021-01-04T19:12:33Z ____ 2021-01-04T19:12:33Z parseTransaction(block=1753516, 2021-01-04 idx= 4); txid: 85c323e6d3f9eca920a30c3fb8babde48942b37b6545d3bc2973b6f199b8608c 2021-01-04T19:12:33Z FillTxInputCache(): coin.IsSpent() == false, nCacheHits: 367 2021-01-04T19:12:33Z parseTransaction(): strSender: QbbqvDj2bJkeZAu4yWBuQejDd86bWHtbXh 2021-01-04T19:12:33Z logicMath_Withdrawal_FromChannel(): amount_to_withdraw : 1000000000, totalAmount in channel: 1000000000 2021-01-04T19:12:33Z checking wthd element : address: QbbqvDj2bJkeZAu4yWBuQejDd86bWHtbXh, deadline: 1753523, propertyId: 7, amount: 1000000000 2021-01-04T19:14:35Z Initializing Trade Layer 2021-01-04T19:14:35Z Startup time: 2021-01-04 2021-01-04T19:14:35Z Loading smart property database: OK 2021-01-04T19:14:35Z Loading persistent state: NONE (no usable previous state found) 2021-01-04T19:14:35Z Loading feature activations from levelDB 2021-01-04T19:14:35Z Trade Layer initialization completed 2021-01-04T19:14:36Z Trade Layer shutdown completed

Multiple withdrawal tx for 1 token, then a 2 minute time out and the client attempts to reinitialize given some kind of fatal timeout. Perhaps there is a 120 second timeout in the client in case attempts to update state given a parsing fail, we've seen this in more serious crashes.

The crash didn't take down the testnet, and notably the block height shows the date at which the withdrawals were published were 5 days ago. (~Friday Jan 1st). The fix to the last, channel expiration-related bug was deployed.

Possibly what is happening here is the wallet.dat's meta-data about state in TradeLayer is getting confused about balances and this corrupted the .dat.

patrickdugan commented 3 years ago

We've been running clean since the update 2 weeks ago we can close this right?

santos177 commented 3 years ago

Closing for now.