CounterpartyXCP / counterparty-core

Counterparty Protocol Reference Implementation
http://counterparty.io
MIT License
284 stars 206 forks source link

Invalid movements_hash on testnet #334

Closed toysrtommy closed 9 years ago

toysrtommy commented 9 years ago

Crashed after the error.

Block: 284985 (0.02s) Block: 284986 (0.01s) Block: 284987 (0.02s) Block: 284988 (0.02s) Block: 284989 (0.02s) Block: 284990 (0.02s) Block: 284991 (0.02s) Block: 284992 (0.02s) Block: 284993 (0.02s) Block: 284994 (0.02s) Block: 284995 (0.02s) Block: 284996 (0.02s) Block: 284997 (0.02s) Block: 284998 (0.02s) Block: 284999 (0.02s) Traceback (most recent call last): File "./counterpartyd.py", line 1131, in blocks.follow(db) File "/home/xcp/counterpartyd/lib/blocks.py", line 1317, in follow parse_block(db, block_index, block_time) File "/home/xcp/counterpartyd/lib/blocks.py", line 162, in parse_block return generate_movement_hash(db, block_index, previous_hash, current_hash) File "/home/xcp/counterpartyd/lib/blocks.py", line 134, in generate_movement_hash raise exceptions.ConsensusError('Invalid movements_hash for block {}'.format(block_index)) lib.exceptions.ConsensusError: Invalid movements_hash for block 285000

ouziel-slama commented 9 years ago

Movements hashes changed with this PR: https://github.com/CounterpartyXCP/counterpartyd/pull/329 You should use a fresh database or clean movements_hash field:

sqlite3 ~/.config/counterpartyd/countepartyd.9.testnet.db
UPDATE blocks SET movements_hash=NULL;
toysrtommy commented 9 years ago

After the sql update, now got this error: Status: Connecting to database. Status: Running v9.43.0 of counterpartyd. Status: Checking version. Status: Connecting to block explorer. Status: Connecting to backend. Status: Resuming parsing. Traceback (most recent call last): File "./counterpartyd.py", line 1131, in blocks.follow(db) File "/home/xcp/counterpartyd/lib/blocks.py", line 1317, in follow parse_block(db, block_index, block_time) File "/home/xcp/counterpartyd/lib/blocks.py", line 162, in parse_block return generate_movement_hash(db, block_index, previous_hash, current_hash) File "/home/xcp/counterpartyd/lib/blocks.py", line 126, in generate_movement_hash movements_hash = util.dhash_string(previous_hash + movements_string) TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

ouziel-slama commented 9 years ago

Sorry forgot to precise that you need to reparse (./counterpartyd --testnet reparse) before relaunch the server.

toysrtommy commented 9 years ago

Sure can do reparse, but the thing is it's just get reparsed after pulling the latest dev branch before I post this issue. Not sure if that another pass would help at all

ouziel-slama commented 9 years ago

Yep that would help I think. Firstly: clean the movements_hash with the query above. Secondly: reparse the database. Thirdly: relaunch the server

toysrtommy commented 9 years ago

Did a reparse and server restart, still exact same prob. I checked the sqlite db and did a select, there's nothing in "blocks" table beyond index 284999.

(fyi - insight is in "finished" status, and bitcoind also has the right block data)

Status: Resuming parsing. Traceback (most recent call last): File "./counterpartyd.py", line 1131, in blocks.follow(db) File "/home/xcp/counterpartyd/lib/blocks.py", line 1317, in follow parse_block(db, block_index, block_time) File "/home/xcp/counterpartyd/lib/blocks.py", line 162, in parse_block return generate_movement_hash(db, block_index, previous_hash, current_hash) File "/home/xcp/counterpartyd/lib/blocks.py", line 134, in generate_movement_hash raise exceptions.ConsensusError('Invalid movements_hash for block {}'.format(block_index)) lib.exceptions.ConsensusError: Invalid movements_hash for block 285000

ouziel-slama commented 9 years ago

hum.. don't understand, I just remove my testnet database and restart the server on a fresh one.. it works well and passed the block 285000 and 290000 without problem. That means checkpoints in config file are corrects. If you have nothing beyond block 284499, worth I think that you make like me: remove the database and relaunch the server.

toysrtommy commented 9 years ago

Ok. Deleted the db, and restarting now. But honestly I don't understand why this is needed, becuz this current db is a clean build like 24 hours ago.

also, the rebuilding db process is really slow. any way to accelerate that? The initial few thousand blocks are pretty fast, then it gets significantly slower and slower, with each block takes tens of seconds.

ghost commented 9 years ago

Look for "bootstrap" on this page http://support.counterparty.io/support/solutions/articles/5000003524-how-do-i-get-started-developing-on (It probably gets slower because early on there were very few transactions and many blocks didn't have any CP transactions in them).

ouziel-slama commented 9 years ago

Theoretically, you don't need to delete the database. Just to clean the movements_hash field in testnet database and make a reparse. I will make a PR today to avoid this step on testnet when there is a protocol change. On mainnet movements_hash will never change (maybe except a modification in the way to calculate the hash, but most probably this will not happen). In your case, I don't understand what happened, delete the database have exactly the same effect than clean the movement_hashes, then reparse, then relaunch the server.

toysrtommy commented 9 years ago

Just spent another 5 hours rebuilding the db. Same prob again..

Block: 284997 (0.02s) Block: 284998 (0.02s) Block: 284999 (0.02s) Traceback (most recent call last): File "./counterpartyd.py", line 1131, in blocks.follow(db) File "/home/xcp/counterpartyd/lib/blocks.py", line 1317, in follow parse_block(db, block_index, block_time) File "/home/xcp/counterpartyd/lib/blocks.py", line 162, in parse_block return generate_movement_hash(db, block_index, previous_hash, current_hash) File "/home/xcp/counterpartyd/lib/blocks.py", line 134, in generate_movement_hash raise exceptions.ConsensusError('Invalid movements_hash for block {}'.format(block_index)) lib.exceptions.ConsensusError: Invalid movements_hash for block 285000

adamkrellenstein commented 9 years ago

@toysrtommy, I just e-mailed you a good DB. I'll re-build a testnet DB from scratch myself to see if I can reproduce the problem. Note: you can always switch databases with --database-file=

We're definitely working on making the DB build faster, in any case.