diff --git a/.github/dependabot.yml b/.github/dependabot.yml index f5f686570e2..6a2a2966370 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -28,11 +28,6 @@ updates: everything-else: patterns: - "*" - exclude-patterns: - # NOTE: grocksdb should be updated manually, to match the version - # available on Ubuntu's latest LTS release; and updated in conjunction - # with the ubuntu version on .github/workflows/db-tests.yml - - "github.com/linxGnu/grocksdb" open-pull-requests-limit: 10 pull-request-branch-name: separator: "-" diff --git a/.github/workflows/db-tests.yml b/.github/workflows/db-tests.yml deleted file mode 100644 index 133c3bcb982..00000000000 --- a/.github/workflows/db-tests.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: db-tests - -on: - pull_request: - paths: - - "tm2/pkg/db/**.go" - - "go.sum" - - ".github/workflows/db-tests.yml" - push: - branches: [ "master" ] - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - test: - # NOTE: this job uses a specific version of ubuntu as the version of grocksb - # we use is related to the version of RocksDB in ubuntu's repositories. - # If updating this to a later ubuntu release, update the grocksdb version - # accordingly: - # https://github.com/linxGnu/grocksdb/releases - # https://pkgs.org/search/?q=rocksdb-dev - runs-on: ubuntu-22.04 - timeout-minutes: 5 - strategy: - fail-fast: false - matrix: - goversion: - - "1.20.x" - - "1.21.x" - steps: - - uses: actions/checkout@v4 - - # golang - - uses: actions/setup-go@v4 - with: - go-version: ${{ matrix.goversion }} - - - name: install database dependencies - run: sudo apt-get install -y libleveldb-dev librocksdb-dev - - - name: Set environment variables for debug mode - if: env.ACTIONS_STEP_DEBUG == 'true' - run: | - export LOG_PATH_DIR=${{ runner.temp }}/logs - mkdir -p $LOG_PATH_DIR - - echo "LOG_LEVEL=debug" >> $GITHUB_ENV - echo "LOG_PATH_DIR=$LOG_PATH_DIR" >> $GITHUB_ENV - - # test ./pkgs/db - - name: test ./tm2/pkg/db - run: go test -v ./tm2/pkg/db/... diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d93ea6ad656..082eebb6726 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -24,7 +24,7 @@ jobs: - name: Lint uses: golangci/golangci-lint-action@v3 env: - # Don't attempt to compile/resolve C packages (grocksdb, cleveldb). + # Don't attempt to compile/resolve C packages. CGO_ENABLED: 0 with: # sync with misc/devdeps/go.mod diff --git a/.github/workflows/tm2.yml b/.github/workflows/tm2.yml index 539029b540e..7edee813e51 100644 --- a/.github/workflows/tm2.yml +++ b/.github/workflows/tm2.yml @@ -55,7 +55,7 @@ jobs: - _test.pkg.amino - _test.pkg.bft - _test.pkg.others - # _test.pkg.db needs special dependencies -- see db-tests. + - _test.pkg.db runs-on: ubuntu-latest timeout-minutes: 21 steps: diff --git a/contribs/gnodev/go.sum b/contribs/gnodev/go.sum index 7c4c812d541..d5e2f112e02 100644 --- a/contribs/gnodev/go.sum +++ b/contribs/gnodev/go.sum @@ -84,7 +84,6 @@ github.com/jaekwon/testify v1.6.1 h1:4AtAJcR9GzXN5W4DdY7ie74iCPiJV1JJUJL90t2ZUyw github.com/jaekwon/testify v1.6.1/go.mod h1:Oun0RXIHI7osufabQ60i4Lqkj0GXLbqI1I7kgzBNm1U= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= @@ -95,7 +94,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw= github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= -github.com/linxGnu/grocksdb v1.6.20 h1:C0SNv12/OBr/zOdGw6reXS+mKpIdQGb/AkZWjHYnO64= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.11 h1:8feyoE3OzPrcshW5/MJ4sGESc5cqmGkGCWlco4l0bqY= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -130,7 +128,6 @@ github.com/zondax/hid v0.9.2 h1:WCJFnEDMiqGF64nlZz28E9qLVZ0KSJ7xpc5DLEyma2U= github.com/zondax/hid v0.9.2/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= github.com/zondax/ledger-go v0.14.3 h1:wEpJt2CEcBJ428md/5MgSLsXLBos98sBOyxNmCjfUCw= github.com/zondax/ledger-go v0.14.3/go.mod h1:IKKaoxupuB43g4NxeQmbLXv7T9AlQyie1UpHb342ycI= -go.etcd.io/bbolt v1.3.8 h1:xs88BrvEv273UsB79e0hcVrlUWmS0a8upikMFhSyAtA= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= diff --git a/contribs/gnokeykc/go.sum b/contribs/gnokeykc/go.sum index d8f2a0be5fb..275612dcfd1 100644 --- a/contribs/gnokeykc/go.sum +++ b/contribs/gnokeykc/go.sum @@ -76,7 +76,6 @@ github.com/jaekwon/testify v1.6.1 h1:4AtAJcR9GzXN5W4DdY7ie74iCPiJV1JJUJL90t2ZUyw github.com/jaekwon/testify v1.6.1/go.mod h1:Oun0RXIHI7osufabQ60i4Lqkj0GXLbqI1I7kgzBNm1U= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= @@ -86,7 +85,6 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= -github.com/linxGnu/grocksdb v1.6.20 h1:C0SNv12/OBr/zOdGw6reXS+mKpIdQGb/AkZWjHYnO64= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.11 h1:8feyoE3OzPrcshW5/MJ4sGESc5cqmGkGCWlco4l0bqY= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -122,7 +120,6 @@ github.com/zondax/hid v0.9.2 h1:WCJFnEDMiqGF64nlZz28E9qLVZ0KSJ7xpc5DLEyma2U= github.com/zondax/hid v0.9.2/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= github.com/zondax/ledger-go v0.14.3 h1:wEpJt2CEcBJ428md/5MgSLsXLBos98sBOyxNmCjfUCw= github.com/zondax/ledger-go v0.14.3/go.mod h1:IKKaoxupuB43g4NxeQmbLXv7T9AlQyie1UpHb342ycI= -go.etcd.io/bbolt v1.3.8 h1:xs88BrvEv273UsB79e0hcVrlUWmS0a8upikMFhSyAtA= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= diff --git a/go.mod b/go.mod index d704a24cbd2..03420534d25 100644 --- a/go.mod +++ b/go.mod @@ -18,9 +18,7 @@ require ( github.com/gorilla/websocket v1.5.1 github.com/gotuna/gotuna v0.6.0 github.com/jaekwon/testify v1.6.1 - github.com/jmhodges/levigo v1.0.0 github.com/libp2p/go-buffer-pool v0.1.0 - github.com/linxGnu/grocksdb v1.6.20 github.com/mattn/go-runewidth v0.0.15 github.com/pelletier/go-toml v1.9.5 github.com/peterbourgon/ff/v3 v3.4.0 @@ -28,7 +26,6 @@ require ( github.com/rogpeppe/go-internal v1.11.0 github.com/rs/cors v1.10.1 github.com/stretchr/testify v1.8.4 - go.etcd.io/bbolt v1.3.8 go.uber.org/multierr v1.10.0 go.uber.org/zap v1.24.0 go.uber.org/zap/exp v0.1.0 diff --git a/go.sum b/go.sum index 4d7fac2f2ce..6a812e0adca 100644 --- a/go.sum +++ b/go.sum @@ -41,12 +41,6 @@ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeC github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= -github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c h1:8ISkoahWXwZR41ois5lSJBSVw4D0OV19Ht/JSTzvSv0= -github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64= -github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A= -github.com/facebookgo/stack v0.0.0-20160209184415-751773369052/go.mod h1:UbMTZqLaRiH3MsBH8va0n7s1pQYcu3uTb8G4tygF4Zg= -github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 h1:7HZCaLC5+BZpmbhCOZJ293Lz68O7PYrF2EzeiFMwCLk= -github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= @@ -97,8 +91,6 @@ github.com/jaekwon/testify v1.6.1 h1:4AtAJcR9GzXN5W4DdY7ie74iCPiJV1JJUJL90t2ZUyw github.com/jaekwon/testify v1.6.1/go.mod h1:Oun0RXIHI7osufabQ60i4Lqkj0GXLbqI1I7kgzBNm1U= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U= -github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= @@ -110,8 +102,6 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw= github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= -github.com/linxGnu/grocksdb v1.6.20 h1:C0SNv12/OBr/zOdGw6reXS+mKpIdQGb/AkZWjHYnO64= -github.com/linxGnu/grocksdb v1.6.20/go.mod h1:IbTMGpmWg/1pg2hcG9LlxkqyqiJymdCweaUrzsLRFmg= github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= @@ -146,7 +136,6 @@ github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUz github.com/rs/cors v1.10.1 h1:L0uuZVXIKlI1SShY2nhFfo44TYvDPQ1w4oFkUJNfhyo= github.com/rs/cors v1.10.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= @@ -157,8 +146,6 @@ github.com/zondax/hid v0.9.2 h1:WCJFnEDMiqGF64nlZz28E9qLVZ0KSJ7xpc5DLEyma2U= github.com/zondax/hid v0.9.2/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= github.com/zondax/ledger-go v0.14.3 h1:wEpJt2CEcBJ428md/5MgSLsXLBos98sBOyxNmCjfUCw= github.com/zondax/ledger-go v0.14.3/go.mod h1:IKKaoxupuB43g4NxeQmbLXv7T9AlQyie1UpHb342ycI= -go.etcd.io/bbolt v1.3.8 h1:xs88BrvEv273UsB79e0hcVrlUWmS0a8upikMFhSyAtA= -go.etcd.io/bbolt v1.3.8/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= @@ -251,7 +238,6 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= diff --git a/misc/loop/go.sum b/misc/loop/go.sum index 392700c001d..dccce72d524 100644 --- a/misc/loop/go.sum +++ b/misc/loop/go.sum @@ -71,7 +71,6 @@ github.com/jaekwon/testify v1.6.1 h1:4AtAJcR9GzXN5W4DdY7ie74iCPiJV1JJUJL90t2ZUyw github.com/jaekwon/testify v1.6.1/go.mod h1:Oun0RXIHI7osufabQ60i4Lqkj0GXLbqI1I7kgzBNm1U= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= @@ -79,7 +78,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw= github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= -github.com/linxGnu/grocksdb v1.8.4 h1:ZMsBpPpJNtRLHiKKp0mI7gW+NT4s7UgfD5xHxx1jVRo= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.11 h1:8feyoE3OzPrcshW5/MJ4sGESc5cqmGkGCWlco4l0bqY= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -110,7 +108,6 @@ github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXl github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= github.com/zondax/hid v0.9.2 h1:WCJFnEDMiqGF64nlZz28E9qLVZ0KSJ7xpc5DLEyma2U= github.com/zondax/ledger-go v0.14.3 h1:wEpJt2CEcBJ428md/5MgSLsXLBos98sBOyxNmCjfUCw= -go.etcd.io/bbolt v1.3.8 h1:xs88BrvEv273UsB79e0hcVrlUWmS0a8upikMFhSyAtA= go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ= go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= diff --git a/tm2/Makefile b/tm2/Makefile index b08101a15a6..87fb84d0d98 100644 --- a/tm2/Makefile +++ b/tm2/Makefile @@ -50,8 +50,4 @@ GOTEST_FLAGS ?= -v -p 1 -timeout=30m _test.pkg.others:; go test $(GOTEST_FLAGS) `go list ./pkg/... | grep -Ev 'pkg/(amino|bft|db|iavl/benchmarks)(/|$$)'` _test.pkg.amino:; go test $(GOTEST_FLAGS) ./pkg/amino/... _test.pkg.bft:; go test $(GOTEST_FLAGS) ./pkg/bft/... - -CGO_ENABLED ?= 0 -_test.pkg.db: - @[ -z "$$CGO_ENABLED" ] && echo 'Disabling cgo for database tests. Use CGO_ENABLED=1 to enable it if you have the correct libs' || true - CGO_ENABLED=$(CGO_ENABLED) go test $(GOTEST_FLAGS) ./pkg/db/... ./pkg/iavl/benchmarks/... +_test.pkg.db:; go test $(GOTEST_FLAGS) ./pkg/db/... ./pkg/iavl/benchmarks/... diff --git a/tm2/pkg/bft/config/config.go b/tm2/pkg/bft/config/config.go index 3cf6afc147b..0afc97979bf 100644 --- a/tm2/pkg/bft/config/config.go +++ b/tm2/pkg/bft/config/config.go @@ -31,9 +31,7 @@ var ( ) const ( - levelDBName = "goleveldb" - clevelDBName = "cleveldb" - boltDBName = "boltdb" + levelDBName = "goleveldb" ) const ( @@ -243,19 +241,11 @@ type BaseConfig struct { // and verifying their commits FastSyncMode bool `toml:"fast_sync" comment:"If this node is many blocks behind the tip of the chain, FastSync\n allows them to catchup quickly by downloading blocks in parallel\n and verifying their commits"` - // Database backend: goleveldb | cleveldb | boltdb + // Database backend: goleveldb // * goleveldb (github.com/gnolang/goleveldb - most popular implementation) // - pure go // - stable - // * cleveldb (uses levigo wrapper) - // - fast - // - requires gcc - // - use cleveldb build tag (go build -tags cleveldb) - // * boltdb (uses etcd's fork of bolt - go.etcd.io/bbolt) - // - EXPERIMENTAL - // - may be faster is some use-cases (random reads - indexer) - // - use boltdb build tag (go build -tags boltdb) - DBBackend string `toml:"db_backend" comment:"Database backend: goleveldb | cleveldb | boltdb\n * goleveldb (github.com/gnolang/goleveldb - most popular implementation)\n - pure go\n - stable\n * cleveldb (uses levigo wrapper)\n - fast\n - requires gcc\n - use cleveldb build tag (go build -tags cleveldb)\n * boltdb (uses etcd's fork of bolt - go.etcd.io/bbolt)\n - EXPERIMENTAL\n - may be faster is some use-cases (random reads - indexer)\n - use boltdb build tag (go build -tags boltdb)"` + DBBackend string `toml:"db_backend" comment:"Database backend: goleveldb\n * goleveldb (github.com/gnolang/goleveldb - most popular implementation)\n - pure go\n - stable"` // Database directory DBPath string `toml:"db_dir" comment:"Database directory"` @@ -365,9 +355,7 @@ func (cfg BaseConfig) ValidateBasic() error { } // Verify the DB backend - if cfg.DBBackend != levelDBName && - cfg.DBBackend != clevelDBName && - cfg.DBBackend != boltDBName { + if cfg.DBBackend != levelDBName { return errInvalidDBBackend } diff --git a/tm2/pkg/db/_all/all.go b/tm2/pkg/db/_all/all.go index f654efd53c7..fe526c383d6 100644 --- a/tm2/pkg/db/_all/all.go +++ b/tm2/pkg/db/_all/all.go @@ -1,13 +1,7 @@ // Package all imports all available databases. It is useful mostly in tests. -// -// cgo databases (rocksdb, cleveldb) will be excluded if CGO_ENABLED=0. package all import ( - // Keep in sync with list of non-cgo backends. - // Add cgo backends in all_cgo.go. - _ "github.com/gnolang/gno/tm2/pkg/db/boltdb" - _ "github.com/gnolang/gno/tm2/pkg/db/fsdb" _ "github.com/gnolang/gno/tm2/pkg/db/goleveldb" _ "github.com/gnolang/gno/tm2/pkg/db/memdb" ) diff --git a/tm2/pkg/db/_all/all_cgo.go b/tm2/pkg/db/_all/all_cgo.go deleted file mode 100644 index 293361de713..00000000000 --- a/tm2/pkg/db/_all/all_cgo.go +++ /dev/null @@ -1,10 +0,0 @@ -//go:build cgo - -package all - -import ( - // Keep in sync with list of cgo backends. - // Add non-cgo backends in all.go. - _ "github.com/gnolang/gno/tm2/pkg/db/cleveldb" - _ "github.com/gnolang/gno/tm2/pkg/db/rocksdb" -) diff --git a/tm2/pkg/db/_tags/boltdb.go b/tm2/pkg/db/_tags/boltdb.go deleted file mode 100644 index c9a74ee700c..00000000000 --- a/tm2/pkg/db/_tags/boltdb.go +++ /dev/null @@ -1,5 +0,0 @@ -//go:build boltdb - -package tags - -import _ "github.com/gnolang/gno/tm2/pkg/db/boltdb" diff --git a/tm2/pkg/db/_tags/cleveldb.go b/tm2/pkg/db/_tags/cleveldb.go deleted file mode 100644 index cd4f4fc2521..00000000000 --- a/tm2/pkg/db/_tags/cleveldb.go +++ /dev/null @@ -1,5 +0,0 @@ -//go:build cleveldb - -package tags - -import _ "github.com/gnolang/gno/tm2/pkg/db/cleveldb" diff --git a/tm2/pkg/db/_tags/fsdb.go b/tm2/pkg/db/_tags/fsdb.go deleted file mode 100644 index 134a831010b..00000000000 --- a/tm2/pkg/db/_tags/fsdb.go +++ /dev/null @@ -1,5 +0,0 @@ -//go:build fsdb - -package tags - -import _ "github.com/gnolang/gno/tm2/pkg/db/fsdb" diff --git a/tm2/pkg/db/_tags/rocksdb.go b/tm2/pkg/db/_tags/rocksdb.go deleted file mode 100644 index f1e19ef31c9..00000000000 --- a/tm2/pkg/db/_tags/rocksdb.go +++ /dev/null @@ -1,5 +0,0 @@ -//go:build rocksdb - -package tags - -import _ "github.com/gnolang/gno/tm2/pkg/db/rocksdb" diff --git a/tm2/pkg/db/boltdb/boltdb.go b/tm2/pkg/db/boltdb/boltdb.go deleted file mode 100644 index c35e3bb00e1..00000000000 --- a/tm2/pkg/db/boltdb/boltdb.go +++ /dev/null @@ -1,353 +0,0 @@ -package boltdb - -import ( - "bytes" - "errors" - "fmt" - "os" - "path/filepath" - - "github.com/gnolang/gno/tm2/pkg/db" - "github.com/gnolang/gno/tm2/pkg/db/internal" - "go.etcd.io/bbolt" -) - -var bucket = []byte("tm") - -func init() { - db.InternalRegisterDBCreator(db.BoltDBBackend, func(name, dir string) (db.DB, error) { - return New(name, dir) - }, false) -} - -// BoltDB is a wrapper around etcd's fork of bolt -// (https://go.etcd.io/bbolt). -// -// NOTE: All operations (including Set, Delete) are synchronous by default. One -// can globally turn it off by using NoSync config option (not recommended). -// -// A single bucket ([]byte("tm")) is used per a database instance. This could -// lead to performance issues when/if there will be lots of keys. -type BoltDB struct { - db *bbolt.DB -} - -// New returns a BoltDB with default options. -func New(name, dir string) (db.DB, error) { - return NewWithOptions(name, dir, bbolt.DefaultOptions) -} - -// NewWithOptions allows you to supply *bbolt.Options. ReadOnly: true is not -// supported because NewWithOptions creates a global bucket. -func NewWithOptions(name string, dir string, opts *bbolt.Options) (db.DB, error) { - if opts.ReadOnly { - return nil, errors.New("ReadOnly: true is not supported") - } - - if err := os.MkdirAll(dir, 0o700); err != nil { - return nil, fmt.Errorf("error creating dir: %w", err) - } - - dbPath := filepath.Join(dir, name+".db") - db, err := bbolt.Open(dbPath, os.ModePerm, opts) - if err != nil { - return nil, err - } - - // create a global bucket - err = db.Update(func(tx *bbolt.Tx) error { - _, err := tx.CreateBucketIfNotExists(bucket) - return err - }) - if err != nil { - return nil, err - } - - return &BoltDB{db: db}, nil -} - -func (bdb *BoltDB) Get(key []byte) (value []byte) { - key = nonEmptyKey(internal.NonNilBytes(key)) - err := bdb.db.View(func(tx *bbolt.Tx) error { - b := tx.Bucket(bucket) - if v := b.Get(key); v != nil { - value = append([]byte{}, v...) - } - return nil - }) - if err != nil { - panic(err) - } - return -} - -func (bdb *BoltDB) Has(key []byte) bool { - return bdb.Get(key) != nil -} - -func (bdb *BoltDB) Set(key, value []byte) { - key = nonEmptyKey(internal.NonNilBytes(key)) - value = internal.NonNilBytes(value) - err := bdb.db.Update(func(tx *bbolt.Tx) error { - b := tx.Bucket(bucket) - return b.Put(key, value) - }) - if err != nil { - panic(err) - } -} - -func (bdb *BoltDB) SetSync(key, value []byte) { - bdb.Set(key, value) -} - -func (bdb *BoltDB) Delete(key []byte) { - key = nonEmptyKey(internal.NonNilBytes(key)) - err := bdb.db.Update(func(tx *bbolt.Tx) error { - return tx.Bucket(bucket).Delete(key) - }) - if err != nil { - panic(err) - } -} - -func (bdb *BoltDB) DeleteSync(key []byte) { - bdb.Delete(key) -} - -func (bdb *BoltDB) Close() { - bdb.db.Close() -} - -func (bdb *BoltDB) Print() { - stats := bdb.db.Stats() - fmt.Printf("%v\n", stats) - - err := bdb.db.View(func(tx *bbolt.Tx) error { - tx.Bucket(bucket).ForEach(func(k, v []byte) error { - fmt.Printf("[%X]:\t[%X]\n", k, v) - return nil - }) - return nil - }) - if err != nil { - panic(err) - } -} - -func (bdb *BoltDB) Stats() map[string]string { - stats := bdb.db.Stats() - m := make(map[string]string) - - // Freelist stats - m["FreePageN"] = fmt.Sprintf("%v", stats.FreePageN) - m["PendingPageN"] = fmt.Sprintf("%v", stats.PendingPageN) - m["FreeAlloc"] = fmt.Sprintf("%v", stats.FreeAlloc) - m["FreelistInuse"] = fmt.Sprintf("%v", stats.FreelistInuse) - - // Transaction stats - m["TxN"] = fmt.Sprintf("%v", stats.TxN) - m["OpenTxN"] = fmt.Sprintf("%v", stats.OpenTxN) - - return m -} - -// boltDBBatch stores key values in sync.Map and dumps them to the underlying -// DB upon Write call. -type boltDBBatch struct { - db *BoltDB - ops []internal.Operation -} - -// NewBatch returns a new batch. -func (bdb *BoltDB) NewBatch() db.Batch { - return &boltDBBatch{ - ops: nil, - db: bdb, - } -} - -// It is safe to modify the contents of the argument after Set returns but not -// before. -func (bdb *boltDBBatch) Set(key, value []byte) { - bdb.ops = append(bdb.ops, internal.Operation{internal.OpTypeSet, key, value}) -} - -// It is safe to modify the contents of the argument after Delete returns but -// not before. -func (bdb *boltDBBatch) Delete(key []byte) { - bdb.ops = append(bdb.ops, internal.Operation{internal.OpTypeDelete, key, nil}) -} - -// NOTE: the operation is synchronous (see BoltDB for reasons) -func (bdb *boltDBBatch) Write() { - err := bdb.db.db.Batch(func(tx *bbolt.Tx) error { - b := tx.Bucket(bucket) - for _, op := range bdb.ops { - key := nonEmptyKey(internal.NonNilBytes(op.Key)) - switch op.OpType { - case internal.OpTypeSet: - if putErr := b.Put(key, op.Value); putErr != nil { - return putErr - } - case internal.OpTypeDelete: - if delErr := b.Delete(key); delErr != nil { - return delErr - } - } - } - return nil - }) - if err != nil { - panic(err) - } -} - -func (bdb *boltDBBatch) WriteSync() { - bdb.Write() -} - -func (bdb *boltDBBatch) Close() {} - -// WARNING: Any concurrent writes or reads will block until the iterator is -// closed. -func (bdb *BoltDB) Iterator(start, end []byte) db.Iterator { - tx, err := bdb.db.Begin(false) - if err != nil { - panic(err) - } - return newBoltDBIterator(tx, start, end, false) -} - -// WARNING: Any concurrent writes or reads will block until the iterator is -// closed. -func (bdb *BoltDB) ReverseIterator(start, end []byte) db.Iterator { - tx, err := bdb.db.Begin(false) - if err != nil { - panic(err) - } - return newBoltDBIterator(tx, start, end, true) -} - -// boltDBIterator allows you to iterate on range of keys/values given some -// start / end keys (nil & nil will result in doing full scan). -type boltDBIterator struct { - tx *bbolt.Tx - - itr *bbolt.Cursor - start []byte - end []byte - - currentKey []byte - currentValue []byte - - isInvalid bool - isReverse bool -} - -func newBoltDBIterator(tx *bbolt.Tx, start, end []byte, isReverse bool) *boltDBIterator { - itr := tx.Bucket(bucket).Cursor() - - var ck, cv []byte - if isReverse { - if end == nil { - ck, cv = itr.Last() - } else { - _, _ = itr.Seek(end) // after key - ck, cv = itr.Prev() // return to end key - } - } else { - if start == nil { - ck, cv = itr.First() - } else { - ck, cv = itr.Seek(start) - } - } - - return &boltDBIterator{ - tx: tx, - itr: itr, - start: start, - end: end, - currentKey: ck, - currentValue: cv, - isReverse: isReverse, - isInvalid: false, - } -} - -func (itr *boltDBIterator) Domain() ([]byte, []byte) { - return itr.start, itr.end -} - -func (itr *boltDBIterator) Valid() bool { - if itr.isInvalid { - return false - } - - // iterated to the end of the cursor - if len(itr.currentKey) == 0 { - itr.isInvalid = true - return false - } - - if itr.isReverse { - if itr.start != nil && bytes.Compare(itr.currentKey, itr.start) < 0 { - itr.isInvalid = true - return false - } - } else { - if itr.end != nil && bytes.Compare(itr.end, itr.currentKey) <= 0 { - itr.isInvalid = true - return false - } - } - - // Valid - return true -} - -func (itr *boltDBIterator) Next() { - itr.assertIsValid() - if itr.isReverse { - itr.currentKey, itr.currentValue = itr.itr.Prev() - } else { - itr.currentKey, itr.currentValue = itr.itr.Next() - } -} - -func (itr *boltDBIterator) Key() []byte { - itr.assertIsValid() - return append([]byte{}, itr.currentKey...) -} - -func (itr *boltDBIterator) Value() []byte { - itr.assertIsValid() - var value []byte - if itr.currentValue != nil { - value = append([]byte{}, itr.currentValue...) - } - return value -} - -func (itr *boltDBIterator) Close() { - err := itr.tx.Rollback() - if err != nil { - panic(err) - } -} - -func (itr *boltDBIterator) assertIsValid() { - if !itr.Valid() { - panic("Boltdb-iterator is invalid") - } -} - -// nonEmptyKey returns a []byte("nil") if key is empty. -// WARNING: this may collude with "nil" user key! -func nonEmptyKey(key []byte) []byte { - if len(key) == 0 { - return []byte("nil") - } - return key -} diff --git a/tm2/pkg/db/boltdb/boltdb_test.go b/tm2/pkg/db/boltdb/boltdb_test.go deleted file mode 100644 index 617ed5e7e0b..00000000000 --- a/tm2/pkg/db/boltdb/boltdb_test.go +++ /dev/null @@ -1,34 +0,0 @@ -package boltdb - -import ( - "fmt" - "testing" - - "github.com/gnolang/gno/tm2/pkg/db/internal" - "github.com/stretchr/testify/require" -) - -func TestBoltDBNew(t *testing.T) { - t.Parallel() - - name := fmt.Sprintf("test_%x", internal.RandStr(12)) - - db, err := New(name, t.TempDir()) - require.NoError(t, err) - db.Close() -} - -func BenchmarkBoltDBRandomReadsWrites(b *testing.B) { - if testing.Short() { - b.Skip("skipping testing in short mode") - } - - name := fmt.Sprintf("test_%x", internal.RandStr(12)) - db, err := New(name, b.TempDir()) - if err != nil { - b.Fatal(err) - } - defer db.Close() - - internal.BenchmarkRandomReadsWrites(b, db) -} diff --git a/tm2/pkg/db/cleveldb/c_level_db.go b/tm2/pkg/db/cleveldb/c_level_db.go deleted file mode 100644 index 51d567b2628..00000000000 --- a/tm2/pkg/db/cleveldb/c_level_db.go +++ /dev/null @@ -1,326 +0,0 @@ -//go:build cgo - -package cleveldb - -import ( - "bytes" - "fmt" - "path/filepath" - - "github.com/gnolang/gno/tm2/pkg/db" - "github.com/gnolang/gno/tm2/pkg/db/internal" - "github.com/jmhodges/levigo" -) - -func init() { - dbCreator := func(name string, dir string) (db.DB, error) { - return NewCLevelDB(name, dir) - } - db.InternalRegisterDBCreator(db.CLevelDBBackend, dbCreator, false) -} - -var _ db.DB = (*CLevelDB)(nil) - -type CLevelDB struct { - db *levigo.DB - ro *levigo.ReadOptions - wo *levigo.WriteOptions - woSync *levigo.WriteOptions -} - -func NewCLevelDB(name string, dir string) (*CLevelDB, error) { - dbPath := filepath.Join(dir, name+".db") - - opts := levigo.NewOptions() - opts.SetCache(levigo.NewLRUCache(1 << 30)) - opts.SetCreateIfMissing(true) - db, err := levigo.Open(dbPath, opts) - if err != nil { - return nil, err - } - ro := levigo.NewReadOptions() - wo := levigo.NewWriteOptions() - woSync := levigo.NewWriteOptions() - woSync.SetSync(true) - database := &CLevelDB{ - db: db, - ro: ro, - wo: wo, - woSync: woSync, - } - return database, nil -} - -// Implements DB. -func (db *CLevelDB) Get(key []byte) []byte { - key = internal.NonNilBytes(key) - res, err := db.db.Get(db.ro, key) - if err != nil { - panic(err) - } - return res -} - -// Implements DB. -func (db *CLevelDB) Has(key []byte) bool { - return db.Get(key) != nil -} - -// Implements DB. -func (db *CLevelDB) Set(key []byte, value []byte) { - key = internal.NonNilBytes(key) - value = internal.NonNilBytes(value) - err := db.db.Put(db.wo, key, value) - if err != nil { - panic(err) - } -} - -// Implements DB. -func (db *CLevelDB) SetSync(key []byte, value []byte) { - key = internal.NonNilBytes(key) - value = internal.NonNilBytes(value) - err := db.db.Put(db.woSync, key, value) - if err != nil { - panic(err) - } -} - -// Implements DB. -func (db *CLevelDB) Delete(key []byte) { - key = internal.NonNilBytes(key) - err := db.db.Delete(db.wo, key) - if err != nil { - panic(err) - } -} - -// Implements DB. -func (db *CLevelDB) DeleteSync(key []byte) { - key = internal.NonNilBytes(key) - err := db.db.Delete(db.woSync, key) - if err != nil { - panic(err) - } -} - -func (db *CLevelDB) DB() *levigo.DB { - return db.db -} - -// Implements DB. -func (db *CLevelDB) Close() { - db.db.Close() - db.ro.Close() - db.wo.Close() - db.woSync.Close() -} - -// Implements DB. -func (db *CLevelDB) Print() { - itr := db.Iterator(nil, nil) - defer itr.Close() - for ; itr.Valid(); itr.Next() { - key := itr.Key() - value := itr.Value() - fmt.Printf("[%X]:\t[%X]\n", key, value) - } -} - -// Implements DB. -func (db *CLevelDB) Stats() map[string]string { - keys := []string{ - "leveldb.aliveiters", - "leveldb.alivesnaps", - "leveldb.blockpool", - "leveldb.cachedblock", - "leveldb.num-files-at-level{n}", - "leveldb.openedtables", - "leveldb.sstables", - "leveldb.stats", - } - - stats := make(map[string]string, len(keys)) - for _, key := range keys { - str := db.db.PropertyValue(key) - stats[key] = str - } - return stats -} - -//---------------------------------------- -// Batch - -// Implements DB. -func (db *CLevelDB) NewBatch() db.Batch { - batch := levigo.NewWriteBatch() - return &cLevelDBBatch{db, batch} -} - -type cLevelDBBatch struct { - db *CLevelDB - batch *levigo.WriteBatch -} - -// Implements Batch. -func (mBatch *cLevelDBBatch) Set(key, value []byte) { - mBatch.batch.Put(key, value) -} - -// Implements Batch. -func (mBatch *cLevelDBBatch) Delete(key []byte) { - mBatch.batch.Delete(key) -} - -// Implements Batch. -func (mBatch *cLevelDBBatch) Write() { - err := mBatch.db.db.Write(mBatch.db.wo, mBatch.batch) - if err != nil { - panic(err) - } -} - -// Implements Batch. -func (mBatch *cLevelDBBatch) WriteSync() { - err := mBatch.db.db.Write(mBatch.db.woSync, mBatch.batch) - if err != nil { - panic(err) - } -} - -// Implements Batch. -func (mBatch *cLevelDBBatch) Close() { - mBatch.batch.Close() -} - -//---------------------------------------- -// Iterator -// NOTE This is almost identical to db/go_level_db.Iterator -// Before creating a third version, refactor. - -func (db *CLevelDB) Iterator(start, end []byte) db.Iterator { - itr := db.db.NewIterator(db.ro) - return newCLevelDBIterator(itr, start, end, false) -} - -func (db *CLevelDB) ReverseIterator(start, end []byte) db.Iterator { - itr := db.db.NewIterator(db.ro) - return newCLevelDBIterator(itr, start, end, true) -} - -var _ db.Iterator = (*cLevelDBIterator)(nil) - -type cLevelDBIterator struct { - source *levigo.Iterator - start, end []byte - isReverse bool - isInvalid bool -} - -func newCLevelDBIterator(source *levigo.Iterator, start, end []byte, isReverse bool) *cLevelDBIterator { - if isReverse { - if end == nil { - source.SeekToLast() - } else { - source.Seek(end) - if source.Valid() { - eoakey := source.Key() // end or after key - if bytes.Compare(end, eoakey) <= 0 { - source.Prev() - } - } else { - source.SeekToLast() - } - } - } else { - if start == nil { - source.SeekToFirst() - } else { - source.Seek(start) - } - } - return &cLevelDBIterator{ - source: source, - start: start, - end: end, - isReverse: isReverse, - isInvalid: false, - } -} - -func (itr cLevelDBIterator) Domain() ([]byte, []byte) { - return itr.start, itr.end -} - -func (itr cLevelDBIterator) Valid() bool { - // Once invalid, forever invalid. - if itr.isInvalid { - return false - } - - // Panic on DB error. No way to recover. - itr.assertNoError() - - // If source is invalid, invalid. - if !itr.source.Valid() { - itr.isInvalid = true - return false - } - - // If key is end or past it, invalid. - start := itr.start - end := itr.end - key := itr.source.Key() - if itr.isReverse { - if start != nil && bytes.Compare(key, start) < 0 { - itr.isInvalid = true - return false - } - } else { - if end != nil && bytes.Compare(end, key) <= 0 { - itr.isInvalid = true - return false - } - } - - // It's valid. - return true -} - -func (itr cLevelDBIterator) Key() []byte { - itr.assertNoError() - itr.assertIsValid() - return itr.source.Key() -} - -func (itr cLevelDBIterator) Value() []byte { - itr.assertNoError() - itr.assertIsValid() - return itr.source.Value() -} - -func (itr cLevelDBIterator) Next() { - itr.assertNoError() - itr.assertIsValid() - if itr.isReverse { - itr.source.Prev() - } else { - itr.source.Next() - } -} - -func (itr cLevelDBIterator) Close() { - itr.source.Close() -} - -func (itr cLevelDBIterator) assertNoError() { - if err := itr.source.GetError(); err != nil { - panic(err) - } -} - -func (itr cLevelDBIterator) assertIsValid() { - if !itr.Valid() { - panic("cLevelDBIterator is invalid") - } -} diff --git a/tm2/pkg/db/cleveldb/c_level_db_test.go b/tm2/pkg/db/cleveldb/c_level_db_test.go deleted file mode 100644 index d72e5397325..00000000000 --- a/tm2/pkg/db/cleveldb/c_level_db_test.go +++ /dev/null @@ -1,112 +0,0 @@ -//go:build cgo - -package cleveldb - -import ( - "bytes" - "encoding/binary" - "fmt" - "math/rand" - "testing" - - "github.com/gnolang/gno/tm2/pkg/db" - "github.com/gnolang/gno/tm2/pkg/db/internal" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func BenchmarkRandomReadsWrites2(b *testing.B) { - b.StopTimer() - - numItems := int64(1000000) - mrand := map[int64]int64{} - for i := 0; i < int(numItems); i++ { - mrand[int64(i)] = int64(0) - } - db, err := NewCLevelDB(fmt.Sprintf("test_%x", internal.RandStr(12)), "") - if err != nil { - b.Fatal(err.Error()) - return - } - - fmt.Println("ok, starting") - b.StartTimer() - - for i := 0; i < b.N; i++ { - // Write something - { - idx := (int64(rand.Int()) % numItems) - mrand[idx]++ - val := mrand[idx] - idxBytes := int642Bytes(int64(idx)) - valBytes := int642Bytes(int64(val)) - // fmt.Printf("Set %X -> %X\n", idxBytes, valBytes) - db.Set( - idxBytes, - valBytes, - ) - } - // Read something - { - idx := (int64(rand.Int()) % numItems) - val := mrand[idx] - idxBytes := int642Bytes(int64(idx)) - valBytes := db.Get(idxBytes) - // fmt.Printf("Get %X -> %X\n", idxBytes, valBytes) - if val == 0 { - if !bytes.Equal(valBytes, nil) { - b.Errorf("Expected %v for %v, got %X", - nil, idx, valBytes) - break - } - } else { - if len(valBytes) != 8 { - b.Errorf("Expected length 8 for %v, got %X", - idx, valBytes) - break - } - valGot := bytes2Int64(valBytes) - if val != valGot { - b.Errorf("Expected %v for %v, got %v", - val, idx, valGot) - break - } - } - } - } - - db.Close() -} - -func int642Bytes(i int64) []byte { - buf := make([]byte, 8) - binary.BigEndian.PutUint64(buf, uint64(i)) - return buf -} - -func bytes2Int64(buf []byte) int64 { - return int64(binary.BigEndian.Uint64(buf)) -} - -func TestCLevelDBBackend(t *testing.T) { - t.Parallel() - - name := fmt.Sprintf("test_%x", internal.RandStr(12)) - // Can't use "" (current directory) or "./" here because levigo.Open returns: - // "Error initializing DB: IO error: test_XXX.db: Invalid argument" - db, err := db.NewDB(name, db.CLevelDBBackend, t.TempDir()) - require.NoError(t, err) - - _, ok := db.(*CLevelDB) - assert.True(t, ok) -} - -func TestCLevelDBStats(t *testing.T) { - t.Parallel() - - name := fmt.Sprintf("test_%x", internal.RandStr(12)) - db, err := db.NewDB(name, db.CLevelDBBackend, t.TempDir()) - require.NoError(t, err) - - assert.NotEmpty(t, db.Stats()) -} diff --git a/tm2/pkg/db/cleveldb/no_cgo_test.go b/tm2/pkg/db/cleveldb/no_cgo_test.go deleted file mode 100644 index 71c1b83bf18..00000000000 --- a/tm2/pkg/db/cleveldb/no_cgo_test.go +++ /dev/null @@ -1,9 +0,0 @@ -//go:build !cgo - -package rocksdb - -import "testing" - -func TestSkip(t *testing.T) { - t.Skip("This package requires cgo to compile and test") -} diff --git a/tm2/pkg/db/db.go b/tm2/pkg/db/db.go index 211d9357a50..0dc90345f0d 100644 --- a/tm2/pkg/db/db.go +++ b/tm2/pkg/db/db.go @@ -35,26 +35,9 @@ const ( // popular implementation) // - stable GoLevelDBBackend BackendType = "goleveldb" - // CLevelDBBackend represents cleveldb (uses levigo wrapper) - // - fast - // - requires gcc - CLevelDBBackend BackendType = "cleveldb" // MemDBBackend represents in-memory key value store, which is mostly used // for testing. MemDBBackend BackendType = "memdb" - // FSDBBackend represents filesystem database - // - EXPERIMENTAL - // - slow - FSDBBackend BackendType = "fsdb" - // BoltDBBackend represents bolt (uses etcd's fork of bolt - - // go.etcd.io/bbolt) - // - EXPERIMENTAL - // - may be faster is some use-cases (random reads - indexer) - BoltDBBackend BackendType = "boltdb" - // RocksDBBackend represents rocksdb (uses github.com/linuxGnu/grocksdb) - // - EXPERIMENTAL - // - requires gcc - RocksDBBackend BackendType = "rocksdb" ) type dbCreator func(name string, dir string) (DB, error) diff --git a/tm2/pkg/db/fsdb/fsdb.go b/tm2/pkg/db/fsdb/fsdb.go deleted file mode 100644 index ddb2439b0f6..00000000000 --- a/tm2/pkg/db/fsdb/fsdb.go +++ /dev/null @@ -1,276 +0,0 @@ -package fsdb - -import ( - "fmt" - "io" - "net/url" - "os" - "path/filepath" - "sort" - "sync" - - "github.com/gnolang/gno/tm2/pkg/db" - "github.com/gnolang/gno/tm2/pkg/db/internal" - "github.com/gnolang/gno/tm2/pkg/errors" -) - -const ( - keyPerm = os.FileMode(0o600) - dirPerm = os.FileMode(0o700) -) - -func init() { - db.InternalRegisterDBCreator(db.FSDBBackend, func(name, dir string) (db.DB, error) { - dbPath := filepath.Join(dir, name+".db") - return NewFSDB(dbPath), nil - }, false) -} - -var _ db.DB = (*FSDB)(nil) - -// It's slow. -type FSDB struct { - mtx sync.Mutex - dir string -} - -func NewFSDB(dir string) *FSDB { - err := os.MkdirAll(dir, dirPerm) - if err != nil { - panic(errors.Wrap(err, "Creating FSDB dir "+dir)) - } - database := &FSDB{ - dir: dir, - } - return database -} - -func (db *FSDB) Get(key []byte) []byte { - db.mtx.Lock() - defer db.mtx.Unlock() - key = escapeKey(key) - - path := db.nameToPath(key) - value, err := read(path) - if os.IsNotExist(err) { - return nil - } else if err != nil { - panic(errors.Wrap(err, "Getting key %s (0x%X)", string(key), key)) - } - return value -} - -func (db *FSDB) Has(key []byte) bool { - db.mtx.Lock() - defer db.mtx.Unlock() - key = escapeKey(key) - - path := db.nameToPath(key) - return fileExists(path) -} - -func fileExists(filePath string) bool { - _, err := os.Stat(filePath) - return !os.IsNotExist(err) -} - -func (db *FSDB) Set(key []byte, value []byte) { - db.mtx.Lock() - defer db.mtx.Unlock() - - db.SetNoLock(key, value) -} - -func (db *FSDB) SetSync(key []byte, value []byte) { - db.mtx.Lock() - defer db.mtx.Unlock() - - db.SetNoLock(key, value) -} - -// NOTE: Implements atomicSetDeleter. -func (db *FSDB) SetNoLock(key []byte, value []byte) { - key = escapeKey(key) - value = internal.NonNilBytes(value) - path := db.nameToPath(key) - err := write(path, value) - if err != nil { - panic(errors.Wrap(err, "Setting key %s (0x%X)", string(key), key)) - } -} - -func (db *FSDB) Delete(key []byte) { - db.mtx.Lock() - defer db.mtx.Unlock() - - db.DeleteNoLock(key) -} - -func (db *FSDB) DeleteSync(key []byte) { - db.mtx.Lock() - defer db.mtx.Unlock() - - db.DeleteNoLock(key) -} - -// NOTE: Implements atomicSetDeleter. -func (db *FSDB) DeleteNoLock(key []byte) { - key = escapeKey(key) - path := db.nameToPath(key) - err := remove(path) - if os.IsNotExist(err) { - return - } else if err != nil { - panic(errors.Wrap(err, "Removing key %s (0x%X)", string(key), key)) - } -} - -func (db *FSDB) Close() { - // Nothing to do. -} - -func (db *FSDB) Print() { - db.mtx.Lock() - defer db.mtx.Unlock() - - panic("FSDB.Print not yet implemented") -} - -func (db *FSDB) Stats() map[string]string { - db.mtx.Lock() - defer db.mtx.Unlock() - - panic("FSDB.Stats not yet implemented") -} - -func (db *FSDB) NewBatch() db.Batch { - db.mtx.Lock() - defer db.mtx.Unlock() - - // Not sure we would ever want to try... - // It doesn't seem easy for general filesystems. - panic("FSDB.NewBatch not yet implemented") -} - -func (db *FSDB) Mutex() *sync.Mutex { - return &(db.mtx) -} - -func (db *FSDB) Iterator(start, end []byte) db.Iterator { - return db.MakeIterator(start, end, false) -} - -func (db *FSDB) MakeIterator(start, end []byte, isReversed bool) db.Iterator { - db.mtx.Lock() - defer db.mtx.Unlock() - - // We need a copy of all of the keys. - // Not the best, but probably not a bottleneck depending. - keys, err := list(db.dir, start, end) - if err != nil { - panic(errors.Wrap(err, "Listing keys in %s", db.dir)) - } - if isReversed { - sort.Sort(sort.Reverse(sort.StringSlice(keys))) - } else { - sort.Strings(keys) - } - return internal.NewMemIterator(db, keys, start, end) -} - -func (db *FSDB) ReverseIterator(start, end []byte) db.Iterator { - return db.MakeIterator(start, end, true) -} - -func (db *FSDB) nameToPath(name []byte) string { - n := url.PathEscape(string(name)) - return filepath.Join(db.dir, n) -} - -// Read some bytes to a file. -// CONTRACT: returns os errors directly without wrapping. -func read(path string) ([]byte, error) { - f, err := os.Open(path) - if err != nil { - return nil, err - } - defer f.Close() - - d, err := io.ReadAll(f) - if err != nil { - return nil, err - } - return d, nil -} - -// Write some bytes from a file. -// CONTRACT: returns os errors directly without wrapping. -func write(path string, d []byte) error { - f, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY, keyPerm) - if err != nil { - return err - } - defer f.Close() - // fInfo, err := f.Stat() - // if err != nil { - // return err - // } - // if fInfo.Mode() != keyPerm { - // return tmerrors.NewErrPermissionsChanged(f.Name(), keyPerm, fInfo.Mode()) - // } - _, err = f.Write(d) - if err != nil { - return err - } - err = f.Sync() - return err -} - -// Remove a file. -// CONTRACT: returns os errors directly without wrapping. -func remove(path string) error { - return os.Remove(path) -} - -// List keys in a directory, stripping of escape sequences and dir portions. -// CONTRACT: returns os errors directly without wrapping. -func list(dirPath string, start, end []byte) ([]string, error) { - dir, err := os.Open(dirPath) - if err != nil { - return nil, err - } - defer dir.Close() - - names, err := dir.Readdirnames(0) - if err != nil { - return nil, err - } - var keys []string - for _, name := range names { - n, err := url.PathUnescape(name) - if err != nil { - return nil, fmt.Errorf("failed to unescape %s while listing", name) - } - key := unescapeKey([]byte(n)) - if db.IsKeyInDomain(key, start, end) { - keys = append(keys, string(key)) - } - } - return keys, nil -} - -// To support empty or nil keys, while the file system doesn't allow empty -// filenames. -func escapeKey(key []byte) []byte { - return []byte("k_" + string(key)) -} - -func unescapeKey(escKey []byte) []byte { - if len(escKey) < 2 { - panic(fmt.Sprintf("Invalid esc key: %x", escKey)) - } - if string(escKey[:2]) != "k_" { - panic(fmt.Sprintf("Invalid esc key: %x", escKey)) - } - return escKey[2:] -} diff --git a/tm2/pkg/db/goleveldb/go_level_db_test.go b/tm2/pkg/db/goleveldb/go_level_db_test.go index a83c5dd2280..0df9ce3b620 100644 --- a/tm2/pkg/db/goleveldb/go_level_db_test.go +++ b/tm2/pkg/db/goleveldb/go_level_db_test.go @@ -8,7 +8,7 @@ import ( "github.com/gnolang/gno/tm2/pkg/db/internal" "github.com/gnolang/goleveldb/leveldb/opt" "github.com/jaekwon/testify/assert" - "github.com/stretchr/testify/require" + "github.com/jaekwon/testify/require" ) func TestGoLevelDBNewGoLevelDB(t *testing.T) { diff --git a/tm2/pkg/db/rocksdb/grocks_db.go b/tm2/pkg/db/rocksdb/grocks_db.go deleted file mode 100644 index 4733c0ba8d9..00000000000 --- a/tm2/pkg/db/rocksdb/grocks_db.go +++ /dev/null @@ -1,342 +0,0 @@ -//go:build cgo - -package rocksdb - -import ( - "bytes" - "fmt" - "path/filepath" - "runtime" - - "github.com/gnolang/gno/tm2/pkg/db" - "github.com/gnolang/gno/tm2/pkg/db/internal" - "github.com/linxGnu/grocksdb" -) - -func init() { - dbCreator := func(name string, dir string) (db.DB, error) { - return NewRocksDB(name, dir) - } - db.InternalRegisterDBCreator(db.RocksDBBackend, dbCreator, false) -} - -var _ db.DB = (*RocksDB)(nil) - -type RocksDB struct { - db *grocksdb.DB - ro *grocksdb.ReadOptions - wo *grocksdb.WriteOptions - woSync *grocksdb.WriteOptions -} - -func NewRocksDB(name string, dir string) (*RocksDB, error) { - // default rocksdb option, good enough for most cases, including heavy workloads. - // 1GB table cache, 512MB write buffer(may use 50% more on heavy workloads). - // compression: snappy as default, need to -lsnappy to enable. - bbto := grocksdb.NewDefaultBlockBasedTableOptions() - bbto.SetBlockCache(grocksdb.NewLRUCache(1 << 30)) - bbto.SetFilterPolicy(grocksdb.NewBloomFilter(10)) - - opts := grocksdb.NewDefaultOptions() - opts.SetBlockBasedTableFactory(bbto) - opts.SetCreateIfMissing(true) - opts.IncreaseParallelism(runtime.NumCPU()) - // 1.5GB maximum memory use for writebuffer. - opts.OptimizeLevelStyleCompaction(512 * 1024 * 1024) - return NewRocksDBWithOptions(name, dir, opts) -} - -func NewRocksDBWithOptions(name string, dir string, opts *grocksdb.Options) (*RocksDB, error) { - dbPath := filepath.Join(dir, name+".db") - db, err := grocksdb.OpenDb(opts, dbPath) - if err != nil { - return nil, err - } - ro := grocksdb.NewDefaultReadOptions() - wo := grocksdb.NewDefaultWriteOptions() - woSync := grocksdb.NewDefaultWriteOptions() - woSync.SetSync(true) - database := &RocksDB{ - db: db, - ro: ro, - wo: wo, - woSync: woSync, - } - return database, nil -} - -// Implements DB. -func (db *RocksDB) Get(key []byte) []byte { - key = internal.NonNilBytes(key) - res, err := db.db.Get(db.ro, key) - if err != nil { - panic(err) - } - return moveSliceToBytes(res) -} - -// Implements DB. -func (db *RocksDB) Has(key []byte) bool { - return db.Get(key) != nil -} - -// Implements DB. -func (db *RocksDB) Set(key []byte, value []byte) { - key = internal.NonNilBytes(key) - value = internal.NonNilBytes(value) - err := db.db.Put(db.wo, key, value) - if err != nil { - panic(err) - } -} - -// Implements DB. -func (db *RocksDB) SetSync(key []byte, value []byte) { - key = internal.NonNilBytes(key) - value = internal.NonNilBytes(value) - err := db.db.Put(db.woSync, key, value) - if err != nil { - panic(err) - } -} - -// Implements DB. -func (db *RocksDB) Delete(key []byte) { - key = internal.NonNilBytes(key) - err := db.db.Delete(db.wo, key) - if err != nil { - panic(err) - } -} - -// Implements DB. -func (db *RocksDB) DeleteSync(key []byte) { - key = internal.NonNilBytes(key) - err := db.db.Delete(db.woSync, key) - if err != nil { - panic(err) - } -} - -func (db *RocksDB) DB() *grocksdb.DB { - return db.db -} - -// Implements DB. -func (db *RocksDB) Close() { - db.ro.Destroy() - db.wo.Destroy() - db.woSync.Destroy() - db.db.Close() -} - -// Implements DB. -func (db *RocksDB) Print() { - itr := db.Iterator(nil, nil) - defer itr.Close() - for ; itr.Valid(); itr.Next() { - key := itr.Key() - value := itr.Value() - fmt.Printf("[%X]:\t[%X]\n", key, value) - } -} - -// Implements DB. -func (db *RocksDB) Stats() map[string]string { - keys := []string{"rocksdb.stats"} - stats := make(map[string]string, len(keys)) - for _, key := range keys { - stats[key] = db.db.GetProperty(key) - } - return stats -} - -//---------------------------------------- -// Batch - -// Implements DB. -func (db *RocksDB) NewBatch() db.Batch { - batch := grocksdb.NewWriteBatch() - return &rocksDBBatch{db, batch} -} - -type rocksDBBatch struct { - db *RocksDB - batch *grocksdb.WriteBatch -} - -// Implements Batch. -func (mBatch *rocksDBBatch) Set(key, value []byte) { - mBatch.batch.Put(key, value) -} - -// Implements Batch. -func (mBatch *rocksDBBatch) Delete(key []byte) { - mBatch.batch.Delete(key) -} - -// Implements Batch. -func (mBatch *rocksDBBatch) Write() { - err := mBatch.db.db.Write(mBatch.db.wo, mBatch.batch) - if err != nil { - panic(err) - } -} - -// Implements Batch. -func (mBatch *rocksDBBatch) WriteSync() { - err := mBatch.db.db.Write(mBatch.db.woSync, mBatch.batch) - if err != nil { - panic(err) - } -} - -// Implements Batch. -func (mBatch *rocksDBBatch) Close() { - mBatch.batch.Destroy() -} - -//---------------------------------------- -// Iterator -// NOTE This is almost identical to db/go_level_db.Iterator -// Before creating a third version, refactor. - -func (db *RocksDB) Iterator(start, end []byte) db.Iterator { - itr := db.db.NewIterator(db.ro) - return newRocksDBIterator(itr, start, end, false) -} - -func (db *RocksDB) ReverseIterator(start, end []byte) db.Iterator { - itr := db.db.NewIterator(db.ro) - return newRocksDBIterator(itr, start, end, true) -} - -var _ db.Iterator = (*rocksDBIterator)(nil) - -type rocksDBIterator struct { - source *grocksdb.Iterator - start, end []byte - isReverse bool - isInvalid bool -} - -func newRocksDBIterator(source *grocksdb.Iterator, start, end []byte, isReverse bool) *rocksDBIterator { - if isReverse { - if end == nil { - source.SeekToLast() - } else { - source.Seek(end) - if source.Valid() { - eoakey := moveSliceToBytes(source.Key()) // end or after key - if bytes.Compare(end, eoakey) <= 0 { - source.Prev() - } - } else { - source.SeekToLast() - } - } - } else { - if start == nil { - source.SeekToFirst() - } else { - source.Seek(start) - } - } - return &rocksDBIterator{ - source: source, - start: start, - end: end, - isReverse: isReverse, - isInvalid: false, - } -} - -func (itr rocksDBIterator) Domain() ([]byte, []byte) { - return itr.start, itr.end -} - -func (itr rocksDBIterator) Valid() bool { - // Once invalid, forever invalid. - if itr.isInvalid { - return false - } - - // Panic on DB error. No way to recover. - itr.assertNoError() - - // If source is invalid, invalid. - if !itr.source.Valid() { - itr.isInvalid = true - return false - } - - // If key is end or past it, invalid. - start := itr.start - end := itr.end - key := moveSliceToBytes(itr.source.Key()) - if itr.isReverse { - if start != nil && bytes.Compare(key, start) < 0 { - itr.isInvalid = true - return false - } - } else { - if end != nil && bytes.Compare(end, key) <= 0 { - itr.isInvalid = true - return false - } - } - - // It's valid. - return true -} - -func (itr rocksDBIterator) Key() []byte { - itr.assertNoError() - itr.assertIsValid() - return moveSliceToBytes(itr.source.Key()) -} - -func (itr rocksDBIterator) Value() []byte { - itr.assertNoError() - itr.assertIsValid() - return moveSliceToBytes(itr.source.Value()) -} - -func (itr rocksDBIterator) Next() { - itr.assertNoError() - itr.assertIsValid() - if itr.isReverse { - itr.source.Prev() - } else { - itr.source.Next() - } -} - -func (itr rocksDBIterator) Close() { - itr.source.Close() -} - -func (itr rocksDBIterator) assertNoError() { - if err := itr.source.Err(); err != nil { - panic(err) - } -} - -func (itr rocksDBIterator) assertIsValid() { - if !itr.Valid() { - panic("rocksDBIterator is invalid") - } -} - -// moveSliceToBytes will free the slice and copy out a go []byte -// This function can be applied on *Slice returned from Key() and Value() -// of an Iterator, because they are marked as freed. -func moveSliceToBytes(s *grocksdb.Slice) []byte { - defer s.Free() - if !s.Exists() { - return nil - } - v := make([]byte, len(s.Data())) - copy(v, s.Data()) - return v -} diff --git a/tm2/pkg/db/rocksdb/grocks_db_test.go b/tm2/pkg/db/rocksdb/grocks_db_test.go deleted file mode 100644 index 8dfb7e4b528..00000000000 --- a/tm2/pkg/db/rocksdb/grocks_db_test.go +++ /dev/null @@ -1,34 +0,0 @@ -//go:build cgo - -package rocksdb - -import ( - "fmt" - "testing" - - "github.com/gnolang/gno/tm2/pkg/db" - "github.com/gnolang/gno/tm2/pkg/db/internal" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestGRocksDBBackend(t *testing.T) { - t.Parallel() - - name := fmt.Sprintf("test_%x", internal.RandStr(12)) - db, err := db.NewDB(name, db.RocksDBBackend, t.TempDir()) - require.NoError(t, err) - - _, ok := db.(*RocksDB) - assert.True(t, ok) -} - -func TestGRocksDBStats(t *testing.T) { - t.Parallel() - - name := fmt.Sprintf("test_%x", internal.RandStr(12)) - db, err := db.NewDB(name, db.RocksDBBackend, t.TempDir()) - require.NoError(t, err) - - assert.NotEmpty(t, db.Stats()) -} diff --git a/tm2/pkg/db/rocksdb/no_cgo_test.go b/tm2/pkg/db/rocksdb/no_cgo_test.go deleted file mode 100644 index 71c1b83bf18..00000000000 --- a/tm2/pkg/db/rocksdb/no_cgo_test.go +++ /dev/null @@ -1,9 +0,0 @@ -//go:build !cgo - -package rocksdb - -import "testing" - -func TestSkip(t *testing.T) { - t.Skip("This package requires cgo to compile and test") -} diff --git a/tm2/pkg/db/util_test.go b/tm2/pkg/db/util_test.go index 0248eda63b9..66531537545 100644 --- a/tm2/pkg/db/util_test.go +++ b/tm2/pkg/db/util_test.go @@ -28,11 +28,6 @@ func TestPrefixIteratorNoMatch1(t *testing.T) { t.Parallel() for _, backend := range db.BackendList() { - if backend == db.BoltDBBackend { - t.Log("bolt does not support concurrent writes while iterating") - continue - } - t.Run(fmt.Sprintf("Prefix w/ backend %s", backend), func(t *testing.T) { t.Parallel() diff --git a/tm2/pkg/iavl/benchmarks/bench_test.go b/tm2/pkg/iavl/benchmarks/bench_test.go index 18af8bb4b2e..2298e738771 100644 --- a/tm2/pkg/iavl/benchmarks/bench_test.go +++ b/tm2/pkg/iavl/benchmarks/bench_test.go @@ -5,7 +5,6 @@ import ( "math/rand" "os" "runtime" - "slices" "testing" "github.com/jaekwon/testify/require" @@ -152,15 +151,8 @@ type benchmark struct { keyLen, dataLen int } -func backendList() []db.BackendType { - return slices.DeleteFunc(db.BackendList(), func(s db.BackendType) bool { - // fsdb doesn't support batch ops, and it's slow anyways, so let's skip. - return s == db.FSDBBackend - }) -} - func BenchmarkSmall(b *testing.B) { - ls := backendList() + ls := db.BackendList() bs := make([]benchmark, 0, len(ls)) for _, backend := range ls { bs = append(bs, benchmark{backend, 1_000, 100, 16, 40}) @@ -169,7 +161,7 @@ func BenchmarkSmall(b *testing.B) { } func BenchmarkMedium(b *testing.B) { - ls := backendList() + ls := db.BackendList() bs := make([]benchmark, 0, len(ls)) for _, backend := range ls { bs = append(bs, benchmark{backend, 100_000, 100, 16, 40}) @@ -178,7 +170,7 @@ func BenchmarkMedium(b *testing.B) { } func BenchmarkLarge(b *testing.B) { - ls := backendList() + ls := db.BackendList() bs := make([]benchmark, 0, len(ls)) for _, backend := range ls { bs = append(bs, benchmark{backend, 1_000_000, 100, 16, 40}) diff --git a/tm2/pkg/iavl/with_gcc_test.go b/tm2/pkg/iavl/with_gcc_test.go deleted file mode 100644 index 83ffea740ba..00000000000 --- a/tm2/pkg/iavl/with_gcc_test.go +++ /dev/null @@ -1,19 +0,0 @@ -//go:build gcc - -// This file exists because some of the DBs e.g CLevelDB -// require gcc as the compiler before they can ran otherwise -// we'll encounter crashes such as in https://github.com/tendermint/merkleeyes/issues/39 - -package iavl - -import ( - "testing" - - "github.com/gnolang/gno/tm2/pkg/db" - _ "github.com/gnolang/gno/tm2/pkg/db/cleveldb" -) - -func BenchmarkImmutableAvlTreeCLevelDB(b *testing.B) { - db := db.NewDB("test", db.CLevelDBBackendStr, "./") - benchmarkImmutableAvlTreeWithDB(b, db) -}