Syndica / sig

a Solana validator client implementation written in Zig
https://syndica.io/sig
Apache License 2.0
219 stars 34 forks source link

feat(ledger): user-selectable db, hashmapdb fixes, add tests, safer memory management #372

Closed dnut closed 1 week ago

dnut commented 2 weeks ago

I broke up the lmdb pr #352 into two prs: this one and #373. This PR contains all the changes from #352 except for adding support for lmdb. I stripped out lmdb because it has a bug that I'm not sure how to fix yet. I'd like to get these improvements merged before figuring out lmdb.


This adds a build option to customize the database backend, for example:

zig build -Dblockstore-db=lmdb

RocksDB remains the default for now.

For any build, only the necessary dependencies will be compiled. For example, if you specify -Dblockstore-db=hashmap, then rocksdb will not be built.

A few bugs were uncovered in the hashmap db when testing the databases more strictly, so I fixed those in here as well.

I also upgrade the rocksdb library because it had an unsound usage of the allocator interface. I made changes in both rocksdb-zig and sig to make this safer.