diff --git a/.github/workflows/gnovm.yml b/.github/workflows/gnovm.yml index 79bff34866e..0fce8292816 100644 --- a/.github/workflows/gnovm.yml +++ b/.github/workflows/gnovm.yml @@ -23,10 +23,14 @@ jobs: strategy: fail-fast: false matrix: - go-version: [ "1.19.x", "1.20.x" ] - goarch: [ "amd64" ] - goos: [ "linux" ] - program: [ "gno" ] + go-version: # two latest versions + - "1.19.x" + - "1.20.x" + goenv: # TODO: replace with pairs, so it's easier to read in the GH interface. + - "GOARCH=amd64 GOOS=linux" + - "GOARCH=wasm GOOS=js" + program: + - "gno" runs-on: ubuntu-latest timeout-minutes: 5 steps: @@ -36,7 +40,7 @@ jobs: - uses: actions/checkout@v3 - name: go install working-directory: gnovm - run: GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go install ./cmd/${{ matrix.program }} + run: ${{ matrix.goenv }} go install ./cmd/${{ matrix.program }} test: strategy: diff --git a/go.mod b/go.mod index 9042d49acfa..eefa2f91115 100644 --- a/go.mod +++ b/go.mod @@ -12,6 +12,7 @@ require ( github.com/fortytw2/leaktest v1.3.0 github.com/gdamore/tcell/v2 v2.1.0 github.com/gnolang/cors v1.8.1 + github.com/gnolang/goleveldb v0.0.9 github.com/gnolang/overflow v0.0.0-20170615021017-4d914c927216 github.com/golang/protobuf v1.5.3 github.com/google/gofuzz v1.2.0 @@ -27,7 +28,6 @@ require ( github.com/peterbourgon/ff/v3 v3.4.0 github.com/pmezard/go-difflib v1.0.0 github.com/stretchr/testify v1.8.4 - github.com/syndtr/goleveldb v1.0.0 github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c go.etcd.io/bbolt v1.3.7 go.uber.org/multierr v1.9.0 @@ -52,7 +52,7 @@ require ( github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 // indirect - github.com/golang/snappy v0.0.3 // indirect + github.com/golang/snappy v0.0.4 // indirect github.com/google/flatbuffers v1.12.1 // indirect github.com/gorilla/securecookie v1.1.1 // indirect github.com/gorilla/sessions v1.2.1 // indirect diff --git a/go.sum b/go.sum index 85e172493fa..94404e246da 100644 --- a/go.sum +++ b/go.sum @@ -67,6 +67,8 @@ github.com/gdamore/tcell/v2 v2.1.0 h1:UnSmozHgBkQi2PGsFr+rpdXuAPRRucMegpQp3Z3kDr github.com/gdamore/tcell/v2 v2.1.0/go.mod h1:vSVL/GV5mCSlPC6thFP5kfOFdM9MGZcalipmpTxTgQA= github.com/gnolang/cors v1.8.1 h1:D3y1DMoWcgGpCefHwD4UHjy1w1163sfczZyy7b5wH8o= github.com/gnolang/cors v1.8.1/go.mod h1:g7HJhHH+N1r+oRrb7ckR2J6xp5es4EizpAP0JpfgVgU= +github.com/gnolang/goleveldb v0.0.9 h1:Q7rGko9oXMKtQA+Apeeed5a3sjba/mcDhzJGoTVLCKE= +github.com/gnolang/goleveldb v0.0.9/go.mod h1:Dz6p9bmpy/FBESTgduiThZt5mToVDipcHGzj/zUOo8E= github.com/gnolang/overflow v0.0.0-20170615021017-4d914c927216 h1:GKvsK3oLWG9B1GL7WP/VqwM6C92j5tIvB844oggL9Lk= github.com/gnolang/overflow v0.0.0-20170615021017-4d914c927216/go.mod h1:xJhtEL7ahjM1WJipt89gel8tHzfIl/LyMY+lCYh38d8= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= @@ -87,9 +89,9 @@ github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= +github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/flatbuffers v1.12.1 h1:MVlul7pQNoDzWRLTw5imwYsl+usrS1TXG2H4jg6ImGw= github.com/google/flatbuffers v1.12.1/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -187,8 +189,6 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE= -github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ= github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c h1:g+WoO5jjkqGAzHWCjJB1zZfXPIAaDpzXIEJ0eS6B5Ok= github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= diff --git a/misc/deployments/staging.gno.land/overlay/config.toml b/misc/deployments/staging.gno.land/overlay/config.toml index a580ed7db7f..a02bb45bbb7 100644 --- a/misc/deployments/staging.gno.land/overlay/config.toml +++ b/misc/deployments/staging.gno.land/overlay/config.toml @@ -16,7 +16,7 @@ moniker = "45-79-178-97" fast_sync = true # Database backend: goleveldb | cleveldb | boltdb -# * goleveldb (github.com/syndtr/goleveldb - most popular implementation) +# * goleveldb (github.com/gnolang/goleveldb, fork of github.com/syndtr/goleveldb) - most popular implementation) # - pure go # - stable # * cleveldb (uses levigo wrapper) diff --git a/misc/deployments/test2.gno.land/overlay/config.toml b/misc/deployments/test2.gno.land/overlay/config.toml index 465e39b474f..edf04ba4431 100644 --- a/misc/deployments/test2.gno.land/overlay/config.toml +++ b/misc/deployments/test2.gno.land/overlay/config.toml @@ -16,7 +16,7 @@ moniker = "45-79-178-97" fast_sync = true # Database backend: goleveldb | cleveldb | boltdb -# * goleveldb (github.com/syndtr/goleveldb - most popular implementation) +# * goleveldb (github.com/gnolang/goleveldb - most popular implementation) # - pure go # - stable # * cleveldb (uses levigo wrapper) diff --git a/misc/deployments/test3.gno.land/overlay/config.toml b/misc/deployments/test3.gno.land/overlay/config.toml index 465e39b474f..edf04ba4431 100644 --- a/misc/deployments/test3.gno.land/overlay/config.toml +++ b/misc/deployments/test3.gno.land/overlay/config.toml @@ -16,7 +16,7 @@ moniker = "45-79-178-97" fast_sync = true # Database backend: goleveldb | cleveldb | boltdb -# * goleveldb (github.com/syndtr/goleveldb - most popular implementation) +# * goleveldb (github.com/gnolang/goleveldb - most popular implementation) # - pure go # - stable # * cleveldb (uses levigo wrapper) diff --git a/tm2/pkg/autofile/autofile.go b/tm2/pkg/autofile/autofile.go index 205554a7644..b81e4368e8c 100644 --- a/tm2/pkg/autofile/autofile.go +++ b/tm2/pkg/autofile/autofile.go @@ -2,9 +2,7 @@ package autofile import ( "os" - "os/signal" "sync" - "syscall" "time" "github.com/gnolang/gno/tm2/pkg/random" @@ -63,19 +61,16 @@ func OpenAutoFile(path string) (*AutoFile, error) { closeTicker: time.NewTicker(autoFileClosePeriod), closeTickerStopc: make(chan struct{}), } + if err := af.openFile(); err != nil { af.Close() return nil, err } - // Close file on SIGHUP. - af.hupc = make(chan os.Signal, 1) - signal.Notify(af.hupc, syscall.SIGHUP) - go func() { - for range af.hupc { - af.closeFile() - } - }() + // see autofile_*.go implementations, following different build constraints. + if err := af.setupCloseHandler(); err != nil { + return nil, err + } go af.closeFileRoutine() @@ -158,10 +153,10 @@ func (af *AutoFile) openFile() error { } // fileInfo, err := file.Stat() // if err != nil { - // return err + // return err // } // if fileInfo.Mode() != autoFilePerms { - // return errors.NewErrPermissionsChanged(file.Name(), fileInfo.Mode(), autoFilePerms) + // return errors.NewErrPermissionsChanged(file.Name(), fileInfo.Mode(), autoFilePerms) // } af.file = file return nil diff --git a/tm2/pkg/autofile/autofile_unix.go b/tm2/pkg/autofile/autofile_unix.go new file mode 100644 index 00000000000..4bf6c15d4f7 --- /dev/null +++ b/tm2/pkg/autofile/autofile_unix.go @@ -0,0 +1,22 @@ +//go:build !js && !wasm +// +build !js,!wasm + +package autofile + +import ( + "os" + "os/signal" + "syscall" +) + +func (af *AutoFile) setupCloseHandler() error { + // Close file on SIGHUP. + af.hupc = make(chan os.Signal, 1) + signal.Notify(af.hupc, syscall.SIGHUP) + go func() { + for range af.hupc { + af.closeFile() + } + }() + return nil +} diff --git a/tm2/pkg/autofile/autofile_wasm.go b/tm2/pkg/autofile/autofile_wasm.go new file mode 100644 index 00000000000..3d328ef9992 --- /dev/null +++ b/tm2/pkg/autofile/autofile_wasm.go @@ -0,0 +1,8 @@ +//go:build js && wasm +// +build js,wasm + +package autofile + +func (af *AutoFile) setupCloseHandler() error { + return nil +} diff --git a/tm2/pkg/bft/abci/example/kvstore/persistent_kvstore.go b/tm2/pkg/bft/abci/example/kvstore/persistent_kvstore.go index 09c827d1433..2e0adb5656f 100644 --- a/tm2/pkg/bft/abci/example/kvstore/persistent_kvstore.go +++ b/tm2/pkg/bft/abci/example/kvstore/persistent_kvstore.go @@ -10,7 +10,7 @@ import ( "github.com/gnolang/gno/tm2/pkg/bft/abci/example/errors" abci "github.com/gnolang/gno/tm2/pkg/bft/abci/types" "github.com/gnolang/gno/tm2/pkg/crypto" - dbm "github.com/gnolang/gno/tm2/pkg/db" + "github.com/gnolang/gno/tm2/pkg/db" "github.com/gnolang/gno/tm2/pkg/log" ) @@ -19,6 +19,8 @@ const ( ValidatorKeyPrefix string = "/val/" ) +const dbBackend = db.GoLevelDBBackend + // ----------------------------------------- var _ abci.Application = (*PersistentKVStoreApplication)(nil) @@ -34,7 +36,7 @@ type PersistentKVStoreApplication struct { func NewPersistentKVStoreApplication(dbDir string) *PersistentKVStoreApplication { name := "kvstore" - db, err := dbm.NewGoLevelDB(name, dbDir) + db, err := db.NewDB(name, dbBackend, dbDir) if err != nil { panic(err) } diff --git a/tm2/pkg/bft/config/config.go b/tm2/pkg/bft/config/config.go index 576bf0ff76f..6f148c3b5c1 100644 --- a/tm2/pkg/bft/config/config.go +++ b/tm2/pkg/bft/config/config.go @@ -174,7 +174,7 @@ type BaseConfig struct { FastSyncMode bool `toml:"fast_sync"` // Database backend: goleveldb | cleveldb | boltdb - // * goleveldb (github.com/syndtr/goleveldb - most popular implementation) + // * goleveldb (github.com/gnolang/goleveldb - most popular implementation) // - pure go // - stable // * cleveldb (uses levigo wrapper) diff --git a/tm2/pkg/bft/config/toml.go b/tm2/pkg/bft/config/toml.go index abb2ab33e17..a35e5674631 100644 --- a/tm2/pkg/bft/config/toml.go +++ b/tm2/pkg/bft/config/toml.go @@ -70,7 +70,7 @@ moniker = "{{ .BaseConfig.Moniker }}" fast_sync = {{ .BaseConfig.FastSyncMode }} # Database backend: goleveldb | cleveldb | boltdb -# * goleveldb (github.com/syndtr/goleveldb - most popular implementation) +# * goleveldb (github.com/gnolang/goleveldb - most popular implementation) # - pure go # - stable # * cleveldb (uses levigo wrapper) diff --git a/tm2/pkg/crypto/keys/lazy_keybase.go b/tm2/pkg/crypto/keys/lazy_keybase.go index 2b2719bfdba..f7f9e229980 100644 --- a/tm2/pkg/crypto/keys/lazy_keybase.go +++ b/tm2/pkg/crypto/keys/lazy_keybase.go @@ -5,10 +5,12 @@ import ( "github.com/gnolang/gno/tm2/pkg/crypto" "github.com/gnolang/gno/tm2/pkg/crypto/hd" - dbm "github.com/gnolang/gno/tm2/pkg/db" + "github.com/gnolang/gno/tm2/pkg/db" "github.com/gnolang/gno/tm2/pkg/os" ) +const dbBackend = db.GoLevelDBBackend + var _ Keybase = lazyKeybase{} type lazyKeybase struct { @@ -26,7 +28,7 @@ func NewLazyDBKeybase(name, dir string) Keybase { } func (lkb lazyKeybase) List() ([]Info, error) { - db, err := dbm.NewGoLevelDB(lkb.name, lkb.dir) + db, err := db.NewDB(lkb.name, dbBackend, lkb.dir) if err != nil { return nil, err } @@ -36,7 +38,7 @@ func (lkb lazyKeybase) List() ([]Info, error) { } func (lkb lazyKeybase) GetByNameOrAddress(nameOrBech32 string) (Info, error) { - db, err := dbm.NewGoLevelDB(lkb.name, lkb.dir) + db, err := db.NewDB(lkb.name, dbBackend, lkb.dir) if err != nil { return nil, err } @@ -46,7 +48,7 @@ func (lkb lazyKeybase) GetByNameOrAddress(nameOrBech32 string) (Info, error) { } func (lkb lazyKeybase) GetByName(name string) (Info, error) { - db, err := dbm.NewGoLevelDB(lkb.name, lkb.dir) + db, err := db.NewDB(lkb.name, dbBackend, lkb.dir) if err != nil { return nil, err } @@ -56,7 +58,7 @@ func (lkb lazyKeybase) GetByName(name string) (Info, error) { } func (lkb lazyKeybase) GetByAddress(address crypto.Address) (Info, error) { - db, err := dbm.NewGoLevelDB(lkb.name, lkb.dir) + db, err := db.NewDB(lkb.name, dbBackend, lkb.dir) if err != nil { return nil, err } @@ -66,7 +68,7 @@ func (lkb lazyKeybase) GetByAddress(address crypto.Address) (Info, error) { } func (lkb lazyKeybase) Delete(name, passphrase string, skipPass bool) error { - db, err := dbm.NewGoLevelDB(lkb.name, lkb.dir) + db, err := db.NewDB(lkb.name, dbBackend, lkb.dir) if err != nil { return err } @@ -76,7 +78,7 @@ func (lkb lazyKeybase) Delete(name, passphrase string, skipPass bool) error { } func (lkb lazyKeybase) Sign(name, passphrase string, msg []byte) ([]byte, crypto.PubKey, error) { - db, err := dbm.NewGoLevelDB(lkb.name, lkb.dir) + db, err := db.NewDB(lkb.name, dbBackend, lkb.dir) if err != nil { return nil, nil, err } @@ -86,7 +88,7 @@ func (lkb lazyKeybase) Sign(name, passphrase string, msg []byte) ([]byte, crypto } func (lkb lazyKeybase) Verify(name string, msg, sig []byte) error { - db, err := dbm.NewGoLevelDB(lkb.name, lkb.dir) + db, err := db.NewDB(lkb.name, dbBackend, lkb.dir) if err != nil { return err } @@ -96,7 +98,7 @@ func (lkb lazyKeybase) Verify(name string, msg, sig []byte) error { } func (lkb lazyKeybase) CreateAccount(name, mnemonic, bip39Passwd, encryptPasswd string, account uint32, index uint32) (Info, error) { - db, err := dbm.NewGoLevelDB(lkb.name, lkb.dir) + db, err := db.NewDB(lkb.name, dbBackend, lkb.dir) if err != nil { return nil, err } @@ -106,7 +108,7 @@ func (lkb lazyKeybase) CreateAccount(name, mnemonic, bip39Passwd, encryptPasswd } func (lkb lazyKeybase) CreateAccountBip44(name, mnemonic, bip39Passwd, encryptPasswd string, params hd.BIP44Params) (Info, error) { - db, err := dbm.NewGoLevelDB(lkb.name, lkb.dir) + db, err := db.NewDB(lkb.name, dbBackend, lkb.dir) if err != nil { return nil, err } @@ -116,7 +118,7 @@ func (lkb lazyKeybase) CreateAccountBip44(name, mnemonic, bip39Passwd, encryptPa } func (lkb lazyKeybase) CreateLedger(name string, algo SigningAlgo, hrp string, account, index uint32) (info Info, err error) { - db, err := dbm.NewGoLevelDB(lkb.name, lkb.dir) + db, err := db.NewDB(lkb.name, dbBackend, lkb.dir) if err != nil { return nil, err } @@ -126,7 +128,7 @@ func (lkb lazyKeybase) CreateLedger(name string, algo SigningAlgo, hrp string, a } func (lkb lazyKeybase) CreateOffline(name string, pubkey crypto.PubKey) (info Info, err error) { - db, err := dbm.NewGoLevelDB(lkb.name, lkb.dir) + db, err := db.NewDB(lkb.name, dbBackend, lkb.dir) if err != nil { return nil, err } @@ -136,7 +138,7 @@ func (lkb lazyKeybase) CreateOffline(name string, pubkey crypto.PubKey) (info In } func (lkb lazyKeybase) CreateMulti(name string, pubkey crypto.PubKey) (info Info, err error) { - db, err := dbm.NewGoLevelDB(lkb.name, lkb.dir) + db, err := db.NewDB(lkb.name, dbBackend, lkb.dir) if err != nil { return nil, err } @@ -146,7 +148,7 @@ func (lkb lazyKeybase) CreateMulti(name string, pubkey crypto.PubKey) (info Info } func (lkb lazyKeybase) Update(name, oldpass string, getNewpass func() (string, error)) error { - db, err := dbm.NewGoLevelDB(lkb.name, lkb.dir) + db, err := db.NewDB(lkb.name, dbBackend, lkb.dir) if err != nil { return err } @@ -156,7 +158,7 @@ func (lkb lazyKeybase) Update(name, oldpass string, getNewpass func() (string, e } func (lkb lazyKeybase) Import(name string, armor string) (err error) { - db, err := dbm.NewGoLevelDB(lkb.name, lkb.dir) + db, err := db.NewDB(lkb.name, dbBackend, lkb.dir) if err != nil { return err } @@ -171,7 +173,7 @@ func (lkb lazyKeybase) ImportPrivKey( decryptPassphrase, encryptPassphrase string, ) error { - db, err := dbm.NewGoLevelDB(lkb.name, lkb.dir) + db, err := db.NewDB(lkb.name, dbBackend, lkb.dir) if err != nil { return err } @@ -185,7 +187,7 @@ func (lkb lazyKeybase) ImportPrivKeyUnsafe( armor string, encryptPassphrase string, ) error { - db, err := dbm.NewGoLevelDB(lkb.name, lkb.dir) + db, err := db.NewDB(lkb.name, dbBackend, lkb.dir) if err != nil { return err } @@ -195,7 +197,7 @@ func (lkb lazyKeybase) ImportPrivKeyUnsafe( } func (lkb lazyKeybase) ImportPubKey(name string, armor string) (err error) { - db, err := dbm.NewGoLevelDB(lkb.name, lkb.dir) + db, err := db.NewDB(lkb.name, dbBackend, lkb.dir) if err != nil { return err } @@ -205,7 +207,7 @@ func (lkb lazyKeybase) ImportPubKey(name string, armor string) (err error) { } func (lkb lazyKeybase) Export(name string) (armor string, err error) { - db, err := dbm.NewGoLevelDB(lkb.name, lkb.dir) + db, err := db.NewDB(lkb.name, dbBackend, lkb.dir) if err != nil { return "", err } @@ -215,7 +217,7 @@ func (lkb lazyKeybase) Export(name string) (armor string, err error) { } func (lkb lazyKeybase) ExportPubKey(name string) (armor string, err error) { - db, err := dbm.NewGoLevelDB(lkb.name, lkb.dir) + db, err := db.NewDB(lkb.name, dbBackend, lkb.dir) if err != nil { return "", err } @@ -225,7 +227,7 @@ func (lkb lazyKeybase) ExportPubKey(name string) (armor string, err error) { } func (lkb lazyKeybase) ExportPrivateKeyObject(name string, passphrase string) (crypto.PrivKey, error) { - db, err := dbm.NewGoLevelDB(lkb.name, lkb.dir) + db, err := db.NewDB(lkb.name, dbBackend, lkb.dir) if err != nil { return nil, err } @@ -237,7 +239,7 @@ func (lkb lazyKeybase) ExportPrivateKeyObject(name string, passphrase string) (c func (lkb lazyKeybase) ExportPrivKey(name string, decryptPassphrase string, encryptPassphrase string, ) (armor string, err error) { - db, err := dbm.NewGoLevelDB(lkb.name, lkb.dir) + db, err := db.NewDB(lkb.name, dbBackend, lkb.dir) if err != nil { return "", err } @@ -247,7 +249,7 @@ func (lkb lazyKeybase) ExportPrivKey(name string, decryptPassphrase string, } func (lkb lazyKeybase) ExportPrivKeyUnsafe(name string, decryptPassphrase string) (string, error) { - db, err := dbm.NewGoLevelDB(lkb.name, lkb.dir) + db, err := db.NewDB(lkb.name, dbBackend, lkb.dir) if err != nil { return "", err } diff --git a/tm2/pkg/db/db.go b/tm2/pkg/db/db.go index 228072fba55..6ffa7bf2eb1 100644 --- a/tm2/pkg/db/db.go +++ b/tm2/pkg/db/db.go @@ -9,9 +9,8 @@ type BackendType string // These are valid backend types. const ( - // GoLevelDBBackend represents goleveldb (github.com/syndtr/goleveldb - most + // GoLevelDBBackend represents goleveldb (github.com/gnolang/goleveldb - most // popular implementation) - // - pure go // - stable GoLevelDBBackend BackendType = "goleveldb" // CLevelDBBackend represents cleveldb (uses levigo wrapper) @@ -19,11 +18,11 @@ const ( // - requires gcc // - use cleveldb build tag (go build -tags cleveldb) CLevelDBBackend BackendType = "cleveldb" - // MemDBBackend represents in-memoty key value store, which is mostly used + // MemDBBackend represents in-memory key value store, which is mostly used // for testing. MemDBBackend BackendType = "memdb" // FSDBBackend represents filesystem database - // - EXPERIMENTAL + // - EXPERIMENTAL // - slow FSDBBackend BackendType = "fsdb" // BoltDBBackend represents bolt (uses etcd's fork of bolt - diff --git a/tm2/pkg/db/go_level_db.go b/tm2/pkg/db/go_level_db.go index 80e1e5f5c1e..e269e5a9f8c 100644 --- a/tm2/pkg/db/go_level_db.go +++ b/tm2/pkg/db/go_level_db.go @@ -6,10 +6,10 @@ import ( "fmt" "path/filepath" - "github.com/syndtr/goleveldb/leveldb" - "github.com/syndtr/goleveldb/leveldb/errors" - "github.com/syndtr/goleveldb/leveldb/iterator" - "github.com/syndtr/goleveldb/leveldb/opt" + "github.com/gnolang/goleveldb/leveldb" + "github.com/gnolang/goleveldb/leveldb/errors" + "github.com/gnolang/goleveldb/leveldb/iterator" + "github.com/gnolang/goleveldb/leveldb/opt" ) func init() { @@ -289,7 +289,7 @@ func (itr *goLevelDBIterator) Valid() bool { // Implements Iterator. func (itr *goLevelDBIterator) Key() []byte { // Key returns a copy of the current key. - // See https://github.com/syndtr/goleveldb/blob/52c212e6c196a1404ea59592d3f1c227c9f034b2/leveldb/iterator/iter.go#L88 + // See https://github.com/gnolang/goleveldb/blob/52c212e6c196a1404ea59592d3f1c227c9f034b2/leveldb/iterator/iter.go#L88 itr.assertNoError() itr.assertIsValid() return cp(itr.source.Key()) @@ -298,7 +298,7 @@ func (itr *goLevelDBIterator) Key() []byte { // Implements Iterator. func (itr *goLevelDBIterator) Value() []byte { // Value returns a copy of the current value. - // See https://github.com/syndtr/goleveldb/blob/52c212e6c196a1404ea59592d3f1c227c9f034b2/leveldb/iterator/iter.go#L88 + // See https://github.com/gnolang/goleveldb/blob/52c212e6c196a1404ea59592d3f1c227c9f034b2/leveldb/iterator/iter.go#L88 itr.assertNoError() itr.assertIsValid() return cp(itr.source.Value()) diff --git a/tm2/pkg/db/go_level_db_test.go b/tm2/pkg/db/go_level_db_test.go index 6eb7c5ab2c6..a85bb6e8713 100644 --- a/tm2/pkg/db/go_level_db_test.go +++ b/tm2/pkg/db/go_level_db_test.go @@ -4,8 +4,8 @@ import ( "fmt" "testing" + "github.com/gnolang/goleveldb/leveldb/opt" "github.com/stretchr/testify/require" - "github.com/syndtr/goleveldb/leveldb/opt" ) func TestGoLevelDBNewGoLevelDB(t *testing.T) { diff --git a/tm2/pkg/iavl/nodedb.go b/tm2/pkg/iavl/nodedb.go index 4c8e41a30b0..3e59b3480e9 100644 --- a/tm2/pkg/iavl/nodedb.go +++ b/tm2/pkg/iavl/nodedb.go @@ -117,14 +117,6 @@ func (ndb *nodeDB) SaveNode(node *Node) { // Has checks if a hash exists in the database. func (ndb *nodeDB) Has(hash []byte) bool { key := ndb.nodeKey(hash) - - if ldb, ok := ndb.db.(*dbm.GoLevelDB); ok { - exists, err := ldb.DB().Has(key, nil) - if err != nil { - panic("Got error from leveldb: " + err.Error()) - } - return exists - } return ndb.db.Get(key) != nil }