Bitcoin Forum
May 05, 2024, 02:54:23 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: The Uncommanded Fork Problem  (Read 733 times)
Snowfire (OP)
Full Member
***
Offline Offline

Activity: 122
Merit: 100


View Profile
March 12, 2013, 10:11:57 PM
 #1

Most of you have probably heard about the shenanigans in the Bitcoin block chain recently, where an incompatibility in client versions briefly forced an uncommanded fork in the block chain. The situation seems contained, but questions remain. Since most of the alts use a very similar block chain, and their clients are near copies of Bitcoin's, how vulnerable are they to this same problem, and what could realistically be done about it?

BTC:1Ca1YU6rCqCHniNj6BvypHbaHYp32t2ubp XRP: rpVbjBotUFCoi9xPu3BqYXZhTLpgZbQpoZ
LTC:LRNTGhyymtNQ7uWeMQXdoEfP5Mryx2c62i :FC: 6qzaJCrowtyepN5LgdpQaTy94JuxmKmdF7
1714877663
Hero Member
*
Offline Offline

Posts: 1714877663

View Profile Personal Message (Offline)

Ignore
1714877663
Reply with quote  #2

1714877663
Report to moderator
"There should not be any signed int. If you've found a signed int somewhere, please tell me (within the next 25 years please) and I'll change it to unsigned int." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714877663
Hero Member
*
Offline Offline

Posts: 1714877663

View Profile Personal Message (Offline)

Ignore
1714877663
Reply with quote  #2

1714877663
Report to moderator
1714877663
Hero Member
*
Offline Offline

Posts: 1714877663

View Profile Personal Message (Offline)

Ignore
1714877663
Reply with quote  #2

1714877663
Report to moderator
Sunny King
Legendary
*
Offline Offline

Activity: 1205
Merit: 1010



View Profile WWW
March 13, 2013, 02:14:17 AM
 #2

Most of you have probably heard about the shenanigans in the Bitcoin block chain recently, where an incompatibility in client versions briefly forced an uncommanded fork in the block chain. The situation seems contained, but questions remain. Since most of the alts use a very similar block chain, and their clients are near copies of Bitcoin's, how vulnerable are they to this same problem, and what could realistically be done about it?

I am following the bitcoin issue since yesterday it looks like the problem is with pre 0.8 clients that uses berkeley db. I think almost all altcoins are still based on bitcoin 0.7 or earlier, except for terracoin, so yes we are probably affected. I am monitoring the situation closely right now and will give updates as I get a better handle of the problem. Stay tuned as I don't exclude the possibility of emergency patches for miners if there is immediate threat on block chain.
2112
Legendary
*
Offline Offline

Activity: 2128
Merit: 1065



View Profile
March 13, 2013, 02:20:44 AM
 #3

Stay tuned as I don't exclude the possibility of emergency patches for miners if there is immediate threat on block chain.
Chillax, dude. Your emergency patch is already available:
Just create the file named "DB_CONFIG" in the ".bitcoin" or "AppData/Roaming/Bitcoin" directory that contains the following:
Code:
set_lg_dir database
set_lk_max_locks 40000
The default was 10000. You can monitor the lock usage using "db_stat -e". I've tested it on an old laptop with 0.3.24 and 0.5.0. Obviously it will work with alt-coins based on the Bitcoin & BDB code. The same file should go into the respective "testnet" subdirectories.

Please don't omit the "set_lg_dir database" line. Without it you may corrupt the "_db.00?" and/or "log.*" files if you are unlucky and run the Berkeley DB utilities like "db_stat". With this line you will at worst get the error message from those utilities.

Good luck.

Edit: Oh, I forgot about the most obvious or non-obvious: restart the bitcoind/bitcoin-qt.

Please comment, critique, criticize or ridicule BIP 2112: https://bitcointalk.org/index.php?topic=54382.0
Long-term mining prognosis: https://bitcointalk.org/index.php?topic=91101.0
Sunny King
Legendary
*
Offline Offline

Activity: 1205
Merit: 1010



View Profile WWW
March 13, 2013, 02:29:57 AM
 #4

Thanks for the tips, although this is probably not enough as it may cause chain fork again unless all nodes take the workaround?

Just create the file named "DB_CONFIG" in the ".bitcoin" or "AppData/Roaming/Bitcoin" directory that contains the following:
Code:
set_lg_dir database
set_lk_max_locks 40000
The default was 10000. You can monitor the lock usage using "db_stat -e". I've tested it on an old laptop with 0.3.24 and 0.5.0. Obviously it will work with alt-coins based on the Bitcoin & BDB code. The same file should go into the respective "testnet" subdirectories.

Please don't omit the "set_lg_dir database" line. Without it you may corrupt the "_db.00?" and/or "log.*" files if you are unlucky and run the Berkeley DB utilities like "db_stat". With this line you will at worst get the error message from those utilities.

Good luck.

Edit: Oh, I forgot about the most obvious or non-obvious: restart the bitcoind/bitcoin-qt.
markm
Legendary
*
Offline Offline

Activity: 2940
Merit: 1090



View Profile WWW
March 13, 2013, 02:44:12 AM
 #5

Look in db.cpp

There are three settings related to locks, see

http://www.stanford.edu/class/cs276a/projects/docs/berkeleydb/ref/lock/max.html

If increasing one of them to 40,000 from 10,000 is it really okay to leave the other two unchanged?

-MarkM-

Browser-launched Crossfire client now online (select CrossCiv server for Galactic  Milieu)
Free website hosting with PHP, MySQL etc: http://hosting.knotwork.com/
Sunny King
Legendary
*
Offline Offline

Activity: 1205
Merit: 1010



View Profile WWW
March 13, 2013, 02:59:09 AM
 #6

It appears this problem depends on the size of transaction index.
Thanks Mark for the pointer.

Quote
The maximum number of lock objects needed can be estimated as follows:

    For Btree and Recno access methods, you will need one lock object per level of the database tree, at a minimum. (Unless keys are quite large with respect to the page size, neither Recno nor Btree database trees should ever be deeper than five levels.) Then, you will need one lock object for each leaf page of the database tree that will be simultaneously accessed.
    For the Queue access method, you will need one lock object per record that is simultaneously accessed. To this, add one lock object per page that will be simultaneously accessed. (Because the Queue access method uses fixed-length records and the database page size is known, it is possible to calculate the number of pages -- and, therefore, the lock objects -- required.) Deleted records skipped by a DB_NEXT or DB_PREV operation do not require a separate lock object. Further, if your application is using transactions, no database operation will ever use more than three lock objects at any time.
    For the Hash access method, you only need a single lock object.

For all access methods, you should then add an additional lock object per database for the database's metadata page.

The maximum number of locks required by an application cannot be easily estimated. It is possible to calculate a maximum number of locks by multiplying the maximum number of lockers, times the maximum number of lock objects, times two (two for the two possible lock modes for each object, read and write). However, this is a pessimal value, and real applications are unlikely to actually need that many locks. Reviewing the Lock subsystem statistics is the best way to determine this value.
2112
Legendary
*
Offline Offline

Activity: 2128
Merit: 1065



View Profile
March 13, 2013, 05:09:43 AM
 #7

Whatever you do, just leave the "set_lg_dir database" line in the DB_CONFIG file. Otherwise you will not be able to use "db_stat" and other Berkeley DB utilities to debug the problems in the future. And then you will be back to being like the Bitcoin core development group: debugging blindly at the lowest level and trying to run the utils will corrupt the DB environment because log files were inaccessible.

Or man up and move the log files up one level from the "database" directory. Then the utilities will work correctly without the configuration file.

Have fun.

Please comment, critique, criticize or ridicule BIP 2112: https://bitcointalk.org/index.php?topic=54382.0
Long-term mining prognosis: https://bitcointalk.org/index.php?topic=91101.0
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!