Welcome to the Dash Forum!

Please sign up to discuss the most innovative cryptocurrency!

Why BDB is still a requirement?

Discussion in 'Development Tech Discussion' started by dashvolution, Oct 7, 2017.

  1. dashvolution

    dashvolution New Member

    Joined:
    Oct 5, 2017
    Messages:
    5
    Likes Received:
    1
    Trophy Points:
    3
    Hi,

    I've been compiling Dash from sources and I saw that Berkeley DB is still a requirement in the Makefile. Why is that? I thought that Dash (and Bitcoin) migrated from BDB to LevelDB years ago. Actually in the file dbwrapper.cpp I can see references to LevelDB and not to BDB.

    Any idea why BDB is still part of the hard requirements to build?

    Cheers
     
    • Useful Useful x 1
  2. UdjinM6

    UdjinM6 Official Dash Dev
    Dash Core Team Moderator

    Joined:
    May 20, 2014
    Messages:
    3,637
    Likes Received:
    3,536
    Trophy Points:
    1,183
    LevelDB is used for block index and chainstate DBs. Wallet still uses BDB.
     
    • Informative Informative x 2
  3. dashvolution

    dashvolution New Member

    Joined:
    Oct 5, 2017
    Messages:
    5
    Likes Received:
    1
    Trophy Points:
    3
    Thank you!
    Can you point me to the code where BDB is used to parse the wallet? I guess it's being used to parse the .dat files when you back up the wallet data right?

    Thank you!
     
  4. UdjinM6

    UdjinM6 Official Dash Dev
    Dash Core Team Moderator

    Joined:
    May 20, 2014
    Messages:
    3,637
    Likes Received:
    3,536
    Trophy Points:
    1,183
    src/wallet/db.* src/wallet/walletdb.*
     
  5. codablock

    codablock Member
    Core Developer

    Joined:
    Mar 29, 2017
    Messages:
    98
    Likes Received:
    149
    Trophy Points:
    83
    The discussion of LevelDB vs BDB has a long history in Bitcoin. There are many arguments why BDB should not be used anymore for the wallet code, but there is also one single argument why it can't be removed that simply: Compatibility. The Bitcoin devs fear that the upgrade from of the wallet.dat from BDB to anything else is too dangerous, as people would actually loose money if it goes wrong in any case. It goes so far, that they even fear upgrading the BDB version to a newer one as it would immediately make the existing wallet.dat incompatible with older versions of the software, making a downgrade impossible. Also, many devs seem to believe that a key/value store is in general the wrong choice, and thus changing BDB to LevelDB would just replace one bad solution with another bad solution.

    The plan is to eventually use and migrate to a custom append-only wallet format. Code for this is already available, but as far as I know not merged yet. IMHO what they plan is a good solution to the problem, because it solves many problems and may avoid many future problems.

    As Dash is based on Bitcoin, we suffer from the same problems with BDB. We also can't simply upgrade or migrate to something different, without taking many things into consideration. Luckily, sticking to the old BDB version does not harm users that much atm. It's mainly a burden for developers, but they should be able to live with it with some effort and slight pain. We are going to backport a lot of stuff from Bitcoin after the release of Dash 12.2. After that, we can reevaluate the situation with BDB and either take the fixes from Bitcoin (if they are ready by that time) or think about going our own way.
     
    • Like Like x 1
    • Agree Agree x 1
    • Informative Informative x 1