diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b0691b..62f6bdb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +## Unreleased +This release contains a dependency upgrade for [classic-terra/core](https://github.com/classic-terra/core)@v2.1.2 with AppHash fix caused by legacy wasm codec + +## [v2.1.1](https://github.com/classic-terra/mantlemint/tree/v2.1.1) (2023-06-11) +This release contains a dependency upgrade for [classic-terra/core](https://github.com/classic-terra/core)@v2.1.1 + +## [v2.0.2](https://github.com/classic-terra/mantlemint/tree/v2.1.1) (2023-05-12) +This release contains a dependency upgrade for [classic-terra/core](https://github.com/classic-terra/core)@v2.0.2 + +## [v1.1.0] +This release contains a dependency upgrade for [classic-terra/core](https://github.com/classic-terra/core)@v1.1.0 + +## [v1.0.5] +This release contains a dependency upgrade for [classic-terra/core](https://github.com/classic-terra/core)@v1.0.5 + ## [v0.1.2](https://github.com/terra-money/mantlemint/tree/v0.1.2) (2022-04-14) This release contains a depencency upgrade for [core](https://github.com/terra-money/core)@0.5.17...@0.5.18. Apart from the dependency bump all functionalities should be exactly the same as v0.1.1. diff --git a/Dockerfile b/Dockerfile index e1288e3..42c571e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,30 +1,22 @@ -ARG GO_VERSION="1.20" -ARG ALPINE_VERSION="3.16" +# docker build . -t cosmwasm/wasmd:latest +# docker run --rm -it cosmwasm/wasmd:latest /bin/sh +FROM golang:1.18-alpine3.17 AS go-builder ARG BUILDPLATFORM=linux/amd64 -ARG BASE_IMAGE="golang:${GO_VERSION}-alpine${ALPINE_VERSION}" -FROM --platform=${BUILDPLATFORM} ${BASE_IMAGE} as base - -############################################################################### -# Builder -############################################################################### -FROM base as builder-stage-1 - -ARG BUILDPLATFORM # NOTE: add libusb-dev to run with LEDGER_ENABLED=true RUN set -eux &&\ + apk update &&\ apk add --no-cache \ - linux-headers \ ca-certificates \ + linux-headers \ build-base \ cmake \ git -WORKDIR /go/src/mimalloc - # use mimalloc for musl +WORKDIR ${GOPATH}/src/mimalloc RUN set -eux &&\ - git clone --depth 1 --branch v2.0.9 \ + git clone --depth 1 \ https://github.com/microsoft/mimalloc . &&\ mkdir -p build &&\ cd build &&\ @@ -32,11 +24,10 @@ RUN set -eux &&\ make -j$(nproc) &&\ make install -WORKDIR /go/src/mantlemint -COPY . . +WORKDIR /code +COPY . /code/ -# Cosmwasm - Download correct libwasmvm version -# See https://github.com/CosmWasm/wasmvm/releases +# Cosmwasm - Download correct libwasmvm version and verify checksum RUN set -eux &&\ WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | cut -d ' ' -f 2) && \ WASMVM_DOWNLOADS="https://github.com/CosmWasm/wasmvm/releases/download/${WASMVM_VERSION}"; \ @@ -52,44 +43,29 @@ RUN set -eux &&\ wget ${WASMVM_URL} -O /lib/libwasmvm_muslc.a; \ CHECKSUM=`sha256sum /lib/libwasmvm_muslc.a | cut -d" " -f1`; \ grep ${CHECKSUM} /tmp/checksums.txt; \ - rm /tmp/checksums.txt + rm /tmp/checksums.txt # force it to use static lib (from above) not standard libgo_cosmwasm.so file -RUN set -eux &&\ - LEDGER_ENABLED=false \ - go build -work \ - -tags muslc,linux \ +RUN LEDGER_ENABLED=false \ + go build \ -mod=readonly \ - -ldflags="-extldflags '-L/go/src/mimalloc/build -lmimalloc -static'" \ - -o /go/bin/mantlemint \ - ./sync.go + -tags "muslc,linux" \ + -ldflags " \ + -w -s -linkmode=external -extldflags \ + '-L/go/src/mimalloc/build -lmimalloc -Wl,-z,muldefs -static' \ + " \ + -trimpath \ + -o build/mantlemint ./sync.go -############################################################################### -FROM alpine:${ALPINE_VERSION} as terra-core +FROM alpine:3.17 WORKDIR /root -COPY --from=builder-stage-1 /go/bin/mantlemint /usr/local/bin/mantlemint - -ENV CHAIN_ID="localterra" \ - MANTLEMINT_HOME="/app" \ - ## db paths relative to MANTLEMINT_HOME - INDEXER_DB="/data/indexer" \ - MANTLEMINT_DB="/data/mantlemint" \ - GENESIS_PATH="/app/config/genesis.json" \ - DISABLE_SYNC="false" \ - RUST_BACKTRACE="full" \ - ENABLE_EXPORT_MODULE="false" \ - RICHLIST_LENGTH="100" \ - RICHLIST_THRESHOLD="0uluna" \ - ACCOUNT_ADDRESS_PREFIX="terra" \ - BOND_DENOM="uluna" \ - LCD_ENDPOINTS="http://localhost:1317" \ - RPC_ENDPOINTS="http://localhost:26657" \ - WS_ENDPOINTS="ws://localhost:26657/websocket" +COPY --from=go-builder /code/build/mantlemint /usr/local/bin/mantlemint -# lcd & grpc ports +# rest server EXPOSE 1317 +# grpc EXPOSE 9090 CMD ["/usr/local/bin/mantlemint"] diff --git a/Makefile b/Makefile index 9bf4430..ebdabbb 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,6 @@ #!/usr/bin/make -f BUILDDIR ?= $(CURDIR)/build -DOCKER := $(shell which docker) -SHA256_CMD = sha256sum -GO_VERSION ?= "1.20" - -ifeq (,$(VERSION)) - VERSION := $(shell git describe --tags) - # if VERSION is empty, then populate it with branch's name and raw commit hash - ifeq (,$(VERSION)) - VERSION := $(BRANCH)-$(COMMIT) - endif -endif build: go.sum ifeq ($(OS),Windows_NT) @@ -20,54 +9,28 @@ else go build -mod=readonly $(BUILD_FLAGS) -o build/mantlemint ./sync.go endif +lint: + golangci-lint run --out-format=tab + +lint-fix: + golangci-lint run --fix --out-format=tab --issues-exit-code=0 + +lint-strict: + find . -path './_build' -prune -o -type f -name '*.go' -exec gofumpt -w -l {} + build-static: mkdir -p $(BUILDDIR) - $(DOCKER) buildx build --tag terramoney/mantlemint ./ - $(DOCKER) create --name temp terramoney/mantlemint:latest - $(DOCKER) cp temp:/usr/local/bin/mantlemint $(BUILDDIR)/ - $(DOCKER) rm temp + docker buildx build --tag terramoney/mantlemint ./ + docker create --name temp terramoney/mantlemint:latest + docker cp temp:/usr/local/bin/mantlemint $(BUILDDIR)/ + docker rm temp install: go.sum go install -mod=readonly $(BUILD_FLAGS) ./ +go.sum: go.mod + @echo "--> Ensure dependencies have not been modified" + @go mod verify -build-release-amd64: go.sum $(BUILDDIR)/ - $(DOCKER) buildx create --name mantlemint-builder || true - $(DOCKER) buildx use mantlemint-builder - $(DOCKER) buildx build \ - --build-arg GO_VERSION=$(GO_VERSION) \ - --build-arg GIT_VERSION=$(VERSION) \ - --build-arg GIT_COMMIT=$(COMMIT) \ - --build-arg BUILDPLATFORM=linux/amd64 \ - --build-arg GOOS=linux \ - --build-arg GOARCH=amd64 \ - -t mantlemint:local-amd64 \ - --load \ - -f Dockerfile . - $(DOCKER) rm -f mantlemint-builder || true - $(DOCKER) create -ti --name mantlemint-builder mantlemint:local-amd64 - $(DOCKER) cp mantlemint-builder:/usr/local/bin/mantlemint $(BUILDDIR)/release/mantlemint - tar -czvf $(BUILDDIR)/release/mantlemint_$(VERSION)_Linux_x86_64.tar.gz -C $(BUILDDIR)/release/ mantlemint - rm $(BUILDDIR)/release/mantlemint - $(DOCKER) rm -f mantlemint-builder - -build-release-arm64: go.sum $(BUILDDIR)/ - $(DOCKER) buildx create --name mantlemint-builder || true - $(DOCKER) buildx use mantlemint-builder - $(DOCKER) buildx build \ - --build-arg GO_VERSION=$(GO_VERSION) \ - --build-arg GIT_VERSION=$(VERSION) \ - --build-arg GIT_COMMIT=$(COMMIT) \ - --build-arg BUILDPLATFORM=linux/arm64 \ - --build-arg GOOS=linux \ - --build-arg GOARCH=arm64 \ - -t mantlemint:local-arm64 \ - --load \ - -f Dockerfile . - $(DOCKER) rm -f mantlemint-builder || true - $(DOCKER) create -ti --name mantlemint-builder mantlemint:local-arm64 - $(DOCKER) cp mantlemint-builder:/usr/local/bin/mantlemint $(BUILDDIR)/release/mantlemint - tar -czvf $(BUILDDIR)/release/mantlemint_$(VERSION)_Linux_aarch64.tar.gz -C $(BUILDDIR)/release/ mantlemint - rm $(BUILDDIR)/release/mantlemint - $(DOCKER) rm -f mantlemint-builder \ No newline at end of file +clean: + rm -rf $(BUILDDIR)/ diff --git a/README.md b/README.md index af0bfc8..c463e45 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# terra-money/mantlemint +# classic-terra/mantlemint ## What is Mantlemint? @@ -9,8 +9,8 @@ Native query performance on RPC is slow and is not suitable for massive query ha If you are looking to serve any kind of public node accepting varying degrees of end-user queries, it is recommended that you run a mantlemint instance alongside of your RPC. While mantlemint is indeed faster at resolving queries, due to the absence of IAVL tree and native tendermint, it cannot join p2p network by itself. Rather, you would have to relay finalized blocks to mantlemint, using RPC's websocket. -## Currently supported terra-money/core versions -- columbus-5 | terra-money/core@0.5.x | tendermint v0.34.x +## Currently supported classic-terra/core versions +- columbus-5 | classic-terra/core@2.1.x | tendermint v0.34.x ## Features @@ -24,7 +24,7 @@ If you are looking to serve any kind of public node accepting varying degrees of ## Installation -This specific directory contains mantlemint implementation for [@terra-money/core@0.5.x](https://github.com/terra-money/core) (compatible with [tendermint@0.34.x](https://github.com/tendermint/tendermint)). +This specific directory contains mantlemint implementation for [@classic-terra/core@2.1.x](https://github.com/terra-money/core) (compatible with [tendermint@0.34.x](https://github.com/tendermint/tendermint)). Go v1.17+ is recommended for this project. @@ -47,7 +47,7 @@ $ make install # results in $GOPATH/bin/mantlemint Since mantlemint cannot join p2p network by itself, it depends on RPC to receive recently proposed blocks. -Any [Terra node](https://github.com/terra-money/core) with port 26657 enabled can be used for this. +Any [Terra node](https://github.com/classic-terra/core) with port 26657 enabled can be used for this. #### 2. `config/app.toml`, a genesis file @@ -94,12 +94,12 @@ INDEXER_DB=indexer \ # Flag to enable/disable mantlemint sync, mainly for debugging DISABLE_SYNC=false \ -# Run sync binary -sync +# Run mantlemint binary +mantlemint # Optional: crisis module's invariant check is known to take hours. # You can skip it by providing --x-crisis-skip-assert-invariants flag -sync --x-crisis-skip-assert-invariants +mantlemint --x-crisis-skip-assert-invariants ``` ### Adjusting smart contract memory cache size @@ -138,14 +138,14 @@ Please note that mantlemint still is able to serve queries while `/health` retur - `/index/tx/by_height/{height}`: List all transactions and their responses in a block. Equivalent to `tendermint/block?height=xxx`, with tx responses base64-decoded for better usability. - `/index/tx/by_hash/{txHash}`: Get transaction and its response by hash. Equivalent to `lcd/txs/{hash}`, but without hitting RPC. -## Notable Differences from [core](https://github.com/terra-money/core) +## Notable Differences from [core](https://github.com/classic-terra/core) - Uses a forked [tendermint/tm-db](https://github.com/terra-money/tm-db/commit/c71e8b6e9f20d7f5be32527db4a92ae19ac0d2b2): Disables unncessary mutexes in `prefixdb` methods - Replaces ABCIClient with [NewConcurrentQueryClient](https://github.com/terra-money/mantlemint/blob/main/mantlemint/client.go#L110): Removal of mutexes allow better concurrency, even during block injection - Uses single batch-protected db: All state changes are flushed at once, making it safe to read from db during block injection - Automatic failover: In case of block injection failure, mantlemint reverts back to the previous known state and retry - Strictly no `tendermint`; some parameters in app.toml would not affect `mantlemint` -- Following endpoints are not implemented +- Following endpoints are not implemented - `GET /blocks/` - `GET /blocks/latest` - `GET /txs/{hash}` @@ -156,7 +156,7 @@ Please note that mantlemint still is able to serve queries while `/health` retur ## FAQ -### Q1. Can I use public RPC (http://public-node.terra.dev:26657) as RPC and WS endpoints? +### Q1. Can I use public RPC and WS endpoints? While you can, we do NOT recommend doing so. We only expose public node as a seed node for p2p, and its http/ws connection may not be stable. It is safer to have your own RPC diff --git a/block_feed/aggregate.go b/block_feed/aggregate.go index 7706d6b..4014b76 100644 --- a/block_feed/aggregate.go +++ b/block_feed/aggregate.go @@ -25,13 +25,13 @@ func NewAggregateBlockFeed( rpcEndpoints []string, wsEndpoints []string, ) *AggregateSubscription { - var rpc, rpcErr = NewRpcSubscription(rpcEndpoints) + rpc, rpcErr := NewRpcSubscription(rpcEndpoints) if rpcErr != nil { panic(rpcErr) } // ws starts with 1st occurrence of ws endpoints - var ws, wsErr = NewWSSubscription(wsEndpoints) + ws, wsErr := NewWSSubscription(wsEndpoints) if wsErr != nil { panic(wsErr) } diff --git a/block_feed/rpc.go b/block_feed/rpc.go index d7c21ee..3d089fc 100644 --- a/block_feed/rpc.go +++ b/block_feed/rpc.go @@ -2,7 +2,7 @@ package block_feed import ( "fmt" - "io/ioutil" + "io" "log" "net/http" ) @@ -11,18 +11,18 @@ var _ BlockFeed = (*RPCSubscription)(nil) type RPCSubscription struct { rpcEndpoints []string - cSub chan *BlockResult + cSub chan *BlockResult } func NewRpcSubscription(rpcEndpoints []string) (*RPCSubscription, error) { return &RPCSubscription{ rpcEndpoints: rpcEndpoints, - cSub: make(chan *BlockResult), + cSub: make(chan *BlockResult), }, nil } func (rpc *RPCSubscription) SyncFromUntil(from int64, to int64, rpcIndex int) { - var cSub = rpc.cSub + cSub := rpc.cSub log.Printf("[block_feed/rpc] subscription started, from=%d, to=%d\n", from, to) @@ -35,7 +35,7 @@ func (rpc *RPCSubscription) SyncFromUntil(from int64, to int64, rpcIndex int) { log.Fatalf("block request failed, %v", err) } - resBytes, err := ioutil.ReadAll(res.Body) + resBytes, err := io.ReadAll(res.Body) if err != nil { log.Fatalf("block request failed, %v", err) } diff --git a/block_feed/websocket.go b/block_feed/websocket.go index 9d427d5..8b000e0 100644 --- a/block_feed/websocket.go +++ b/block_feed/websocket.go @@ -2,8 +2,9 @@ package block_feed import ( "encoding/json" - "github.com/gorilla/websocket" "log" + + "github.com/gorilla/websocket" ) var _ BlockFeed = (*WSSubscription)(nil) @@ -34,7 +35,6 @@ func NewWSSubscription(wsEndpoints []string) (*WSSubscription, error) { func (ws *WSSubscription) Subscribe(rpcIndex int) (chan *BlockResult, error) { socket, _, err := websocket.DefaultDialer.Dial(ws.wsEndpoints[rpcIndex], nil) - // return err, handle failures gracefully if err != nil { return nil, err @@ -42,7 +42,7 @@ func (ws *WSSubscription) Subscribe(rpcIndex int) (chan *BlockResult, error) { ws.ws = socket - var request = &handshake{ + request := &handshake{ JSONRPC: "2.0", Method: "subscribe", ID: 0, @@ -85,7 +85,6 @@ func (ws *WSSubscription) Close() error { // "data" field present func handleInitialHandhake(ws *websocket.Conn) error { _, _, err := ws.ReadMessage() - if err != nil { return err } @@ -98,7 +97,6 @@ func receiveBlockEvents(ws *websocket.Conn, c chan *BlockResult) { defer close(c) for { _, message, err := ws.ReadMessage() - // if read message failed, // scrap the whole ws thing if err != nil { diff --git a/db/heleveldb/leveldb_batch.go b/db/heleveldb/leveldb_batch.go index 2506c0d..ade3011 100644 --- a/db/heleveldb/leveldb_batch.go +++ b/db/heleveldb/leveldb_batch.go @@ -8,8 +8,10 @@ import ( "github.com/terra-money/mantlemint/db/rollbackable" ) -var _ hld.HeightLimitEnabledBatch = (*LevelBatch)(nil) -var _ rollbackable.HasRollbackBatch = (*LevelBatch)(nil) +var ( + _ hld.HeightLimitEnabledBatch = (*LevelBatch)(nil) + _ rollbackable.HasRollbackBatch = (*LevelBatch)(nil) +) type LevelBatch struct { height int64 diff --git a/db/heleveldb/leveldb_driver.go b/db/heleveldb/leveldb_driver.go index ac3420a..26be950 100644 --- a/db/heleveldb/leveldb_driver.go +++ b/db/heleveldb/leveldb_driver.go @@ -40,8 +40,8 @@ func (d *Driver) Get(maxHeight int64, key []byte) ([]byte, error) { if maxHeight == 0 { return d.session.Get(prefixCurrentDataKey(key)) } - var requestHeight = hld.Height(maxHeight).CurrentOrLatest().ToInt64() - var requestHeightMin = hld.Height(0).CurrentOrNever().ToInt64() + requestHeight := hld.Height(maxHeight).CurrentOrLatest().ToInt64() + requestHeightMin := hld.Height(0).CurrentOrNever().ToInt64() // check if requestHeightMin is if requestHeightMin > requestHeight { @@ -74,8 +74,8 @@ func (d *Driver) Has(maxHeight int64, key []byte) (bool, error) { if maxHeight == 0 { return d.session.Has(prefixCurrentDataKey(key)) } - var requestHeight = hld.Height(maxHeight).CurrentOrLatest().ToInt64() - var requestHeightMin = hld.Height(0).CurrentOrNever().ToInt64() + requestHeight := hld.Height(maxHeight).CurrentOrLatest().ToInt64() + requestHeightMin := hld.Height(0).CurrentOrNever().ToInt64() // check if requestHeightMin is if requestHeightMin > requestHeight { diff --git a/db/heleveldb/leveldb_iterator.go b/db/heleveldb/leveldb_iterator.go index 2b770f7..4d92b20 100644 --- a/db/heleveldb/leveldb_iterator.go +++ b/db/heleveldb/leveldb_iterator.go @@ -39,6 +39,7 @@ func NewLevelDBIterator(d *Driver, maxHeight int64, start, end []byte) (*Iterato end: end, }, nil } + func NewLevelDBReverseIterator(d *Driver, maxHeight int64, start, end []byte) (*Iterator, error) { pdb := tmdb.NewPrefixDB(d.session, cKeysForIteratorPrefix) iter, err := pdb.ReverseIterator(start, end) @@ -77,7 +78,6 @@ func (i *Iterator) Valid() bool { } } return false - } func (i *Iterator) Value() (value []byte) { diff --git a/db/hld/height_limited_db.go b/db/hld/height_limited_db.go index 6436b4f..8feb8a6 100644 --- a/db/hld/height_limited_db.go +++ b/db/hld/height_limited_db.go @@ -21,11 +21,9 @@ const ( debugKeyGetResult ) -var HeightLimitedDelimiter = []byte{'@'} -var LatestHeightBuf = []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff} - var ( - errInvalidWriteHeight = "invalid operation: writeHeight is not set" + HeightLimitedDelimiter = []byte{'@'} + LatestHeightBuf = []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff} ) var _ HLD = (*HeightLimitedDB)(nil) @@ -65,8 +63,8 @@ func (hld *HeightLimitedDB) BranchHeightLimitedDB(height int64) *HeightLimitedDB // SetReadHeight sets a target read height in the db driver. // It acts differently if the db mode is writer or reader: -// - Reader uses readHeight as the max height at which the retrieved key/value pair is limited to, -// allowing full block snapshot history +// - Reader uses readHeight as the max height at which the retrieved key/value pair is limited to, +// allowing full block snapshot history func (hld *HeightLimitedDB) SetReadHeight(height int64) { hld.readHeight = height } @@ -222,7 +220,7 @@ func (hld *HeightLimitedDB) Debug(debugType int, key []byte, value []byte) { } var actualKeyHeight int64 - if bytes.Compare(keyHeight, LatestHeightBuf) == 0 { + if bytes.Equal(keyHeight, LatestHeightBuf) { actualKeyHeight = -1 } else { actualKeyHeight = int64(lib.BigEndianToUint(keyHeight)) diff --git a/db/safe_batch/safe_batch.go b/db/safe_batch/safe_batch.go index 8979be9..faa5ba2 100644 --- a/db/safe_batch/safe_batch.go +++ b/db/safe_batch/safe_batch.go @@ -7,8 +7,10 @@ import ( "github.com/terra-money/mantlemint/db/rollbackable" ) -var _ tmdb.DB = (*SafeBatchDB)(nil) -var _ SafeBatchDBCloser = (*SafeBatchDB)(nil) +var ( + _ tmdb.DB = (*SafeBatchDB)(nil) + _ SafeBatchDBCloser = (*SafeBatchDB)(nil) +) type SafeBatchDBCloser interface { tmdb.DB diff --git a/db/snappy/snappy_db.go b/db/snappy/snappy_db.go index b76030c..45676cb 100644 --- a/db/snappy/snappy_db.go +++ b/db/snappy/snappy_db.go @@ -2,10 +2,11 @@ package snappy import ( "encoding/json" + "sync" + "github.com/golang/snappy" "github.com/pkg/errors" tmdb "github.com/tendermint/tm-db" - "sync" ) const ( diff --git a/db/snappy/snappy_db_test.go b/db/snappy/snappy_db_test.go index 1ea4c09..dcc586e 100644 --- a/db/snappy/snappy_db_test.go +++ b/db/snappy/snappy_db_test.go @@ -1,13 +1,14 @@ package snappy import ( + "io" + "os" + "testing" + "github.com/stretchr/testify/assert" tmjson "github.com/tendermint/tendermint/libs/json" tendermint "github.com/tendermint/tendermint/types" db "github.com/tendermint/tm-db" - "io/ioutil" - "os" - "testing" ) func TestSnappyDB(t *testing.T) { @@ -52,6 +53,7 @@ func TestSnappyDB(t *testing.T) { v, err = snappy.Get([]byte("key")) assert.Equal(t, []byte("batchedValue"), v) + assert.Nil(t, err) batch = snappy.NewBatch() assert.Nil(t, batch.Delete([]byte("key"))) @@ -83,7 +85,7 @@ func TestSnappyDBCompat(t *testing.T) { func indexSampleTx(mdb db.DB, key []byte) { block := &tendermint.Block{} blockFile, _ := os.Open("../../indexer/fixtures/block_4814775.json") - blockJSON, _ := ioutil.ReadAll(blockFile) + blockJSON, _ := io.ReadAll(blockFile) if err := tmjson.Unmarshal(blockJSON, block); err != nil { panic(err) } diff --git a/db/types.go b/db/types.go index 4154f08..d68252b 100644 --- a/db/types.go +++ b/db/types.go @@ -1,4 +1,3 @@ - package db // DB defines mantlemint specific db interface, based off tm-db@0.6.4. @@ -94,13 +93,14 @@ type Batch interface { // var itr Iterator = ... // defer itr.Close() // -// for ; itr.Valid(); itr.Next() { -// k, v := itr.Key(); itr.Value() -// ... -// } -// if err := itr.Error(); err != nil { -// ... -// } +// for ; itr.Valid(); itr.Next() { +// k, v := itr.Key(); itr.Value() +// ... +// } +// +// if err := itr.Error(); err != nil { +// ... +// } type Iterator interface { // Domain returns the start (inclusive) and end (exclusive) limits of the iterator. // CONTRACT: start, end readonly []byte diff --git a/go.mod b/go.mod index 3db76b0..ef14c86 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/CosmWasm/wasmd v0.30.0 - github.com/classic-terra/core/v2 v2.1.1 + github.com/classic-terra/core/v2 v2.1.3-0.20230901180431-a52a1682d43d github.com/cosmos/cosmos-sdk v0.45.14 github.com/cosmos/iavl v0.19.5 github.com/gogo/protobuf v1.3.3 @@ -15,7 +15,7 @@ require ( github.com/pkg/errors v0.9.1 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.14.0 - github.com/stretchr/testify v1.8.1 + github.com/stretchr/testify v1.8.4 github.com/tendermint/tendermint v0.34.24 github.com/tendermint/tm-db v0.6.7 ) @@ -37,7 +37,7 @@ require ( github.com/cosmos/btcutil v1.0.4 // indirect github.com/cosmos/cosmos-proto v1.0.0-alpha8 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect - github.com/cosmos/gogoproto v1.4.4 // indirect + github.com/cosmos/gogoproto v1.4.10 // indirect github.com/cosmos/gorocksdb v1.2.0 // indirect github.com/cosmos/ibc-go/v4 v4.3.1 // indirect github.com/cosmos/ledger-cosmos-go v0.12.2 // indirect @@ -49,7 +49,7 @@ require ( github.com/dgraph-io/badger/v2 v2.2007.4 // indirect github.com/dgraph-io/ristretto v0.1.0 // indirect github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect - github.com/docker/distribution v2.8.1+incompatible // indirect + github.com/docker/distribution v2.8.2+incompatible // indirect github.com/dustin/go-humanize v1.0.0 // indirect github.com/dvsekhvalnov/jose2go v1.5.0 // indirect github.com/felixge/httpsnoop v1.0.2 // indirect @@ -61,8 +61,9 @@ require ( github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gogo/gateway v1.1.0 // indirect github.com/golang/glog v1.0.0 // indirect - github.com/golang/protobuf v1.5.2 // indirect + github.com/golang/protobuf v1.5.3 // indirect github.com/google/btree v1.1.2 // indirect + github.com/google/go-cmp v0.5.9 // indirect github.com/google/gofuzz v1.2.0 // indirect github.com/google/orderedcode v0.0.1 // indirect github.com/gorilla/handlers v1.5.1 // indirect @@ -104,12 +105,11 @@ require ( github.com/rakyll/statik v0.1.7 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/regen-network/cosmos-proto v0.3.1 // indirect - github.com/rogpeppe/go-internal v1.9.0 // indirect github.com/rs/cors v1.8.2 // indirect github.com/rs/zerolog v1.27.0 // indirect github.com/sasha-s/go-deadlock v0.3.1 // indirect github.com/spf13/afero v1.9.2 // indirect - github.com/spf13/cast v1.5.0 // indirect + github.com/spf13/cast v1.5.1 // indirect github.com/spf13/cobra v1.6.1 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/subosito/gotenv v1.4.1 // indirect @@ -119,14 +119,14 @@ require ( github.com/zondax/hid v0.9.1 // indirect go.etcd.io/bbolt v1.3.6 // indirect golang.org/x/crypto v0.5.0 // indirect - golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect - golang.org/x/net v0.7.0 // indirect - golang.org/x/sys v0.5.0 // indirect - golang.org/x/term v0.5.0 // indirect - golang.org/x/text v0.7.0 // indirect - google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6 // indirect - google.golang.org/grpc v1.52.3 // indirect - google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8 // indirect + golang.org/x/exp v0.0.0-20230131160201-f062dba9d201 // indirect + golang.org/x/net v0.9.0 // indirect + golang.org/x/sys v0.7.0 // indirect + golang.org/x/term v0.7.0 // indirect + golang.org/x/text v0.9.0 // indirect + google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect + google.golang.org/grpc v1.55.0 // indirect + google.golang.org/protobuf v1.30.0 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect @@ -137,10 +137,10 @@ require ( replace ( github.com/99designs/keyring => github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76 github.com/CosmWasm/wasmd => github.com/classic-terra/wasmd v0.30.0-terra.2 - github.com/cosmos/cosmos-sdk => github.com/classic-terra/cosmos-sdk v0.45.14-classic + github.com/cosmos/cosmos-sdk => github.com/classic-terra/cosmos-sdk v0.45.14-classic.0.20230908022309-061c8ec559bf github.com/cosmos/ledger-cosmos-go => github.com/terra-money/ledger-terra-go v0.11.2 github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 github.com/tendermint/tendermint => github.com/classic-terra/tendermint v0.34.24-terra.0 - github.com/tendermint/tm-db => github.com/terra-money/tm-db v0.6.4-performance.7 + github.com/tendermint/tm-db => github.com/terra-money/tm-db v0.6.7-performance.3 google.golang.org/grpc => google.golang.org/grpc v1.33.2 ) diff --git a/go.sum b/go.sum index 77280fd..6dd1bb0 100644 --- a/go.sum +++ b/go.sum @@ -141,10 +141,10 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5P github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= -github.com/classic-terra/core/v2 v2.1.1 h1:INAxDYZkdabuvz47IFnsa9mc3Hx7qXeTuDf5FOvVbxA= -github.com/classic-terra/core/v2 v2.1.1/go.mod h1:eFcGtA69MzqowaXsvY3H/fccj8lwdzIXnHo46we1t5c= -github.com/classic-terra/cosmos-sdk v0.45.14-classic h1:R3WBEoqnBDGef3LCCq0uTWEqFO8pwwqkIv3nQWv5Z+E= -github.com/classic-terra/cosmos-sdk v0.45.14-classic/go.mod h1:KaUwQKijD7mOiKnPa/7JOJoGfDt4Mq+1CGlODMHPmfM= +github.com/classic-terra/core/v2 v2.1.3-0.20230901180431-a52a1682d43d h1:jkMwA0RZjw0/9Vgb7RlC0UWLgvSK2Zj5WWZtYNsVACo= +github.com/classic-terra/core/v2 v2.1.3-0.20230901180431-a52a1682d43d/go.mod h1:H0G4z6fp1pDGsX5K5quawTNYmaKj3Xu2hYiMNx4hwME= +github.com/classic-terra/cosmos-sdk v0.45.14-classic.0.20230908022309-061c8ec559bf h1:VPTM3x5gLx7/FgMVynYfNvKhtdKE/pSkodT6flOpHL0= +github.com/classic-terra/cosmos-sdk v0.45.14-classic.0.20230908022309-061c8ec559bf/go.mod h1:KaUwQKijD7mOiKnPa/7JOJoGfDt4Mq+1CGlODMHPmfM= github.com/classic-terra/tendermint v0.34.24-terra.0 h1:ZGaJpmKfxjlmmLO80t03jlK2SBQfJKlLsF+ItDbXtko= github.com/classic-terra/tendermint v0.34.24-terra.0/go.mod h1:rXVrl4OYzmIa1I91av3iLv2HS0fGSiucyW9J4aMTpKI= github.com/classic-terra/wasmd v0.30.0-terra.2 h1:qaZx4mloPU6xaJP7TAd3CNzN4iziJ47ClOEkJV5de/Q= @@ -172,8 +172,8 @@ github.com/cosmos/cosmos-proto v1.0.0-alpha8/go.mod h1:6/p+Bc4O8JKeZqe0VqUGTX31e github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= -github.com/cosmos/gogoproto v1.4.4 h1:nVAsgLlAf5jeN0fV7hRlkZvf768zU+dy4pG+hxc2P34= -github.com/cosmos/gogoproto v1.4.4/go.mod h1:/yl6/nLwsZcZ2JY3OrqjRqvqCG9InUMcXRfRjQiF9DU= +github.com/cosmos/gogoproto v1.4.10 h1:QH/yT8X+c0F4ZDacDv3z+xE3WU1P1Z3wQoLMBRJoKuI= +github.com/cosmos/gogoproto v1.4.10/go.mod h1:3aAZzeRWpAwr+SS/LLkICX2/kDFyaYVzckBDzygIxek= github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4Y= github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw= github.com/cosmos/iavl v0.19.5 h1:rGA3hOrgNxgRM5wYcSCxgQBap7fW82WZgY78V9po/iY= @@ -215,8 +215,8 @@ github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WA github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/dlclark/regexp2 v1.2.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= -github.com/docker/distribution v2.8.1+incompatible h1:Q50tZOPR6T/hjNsyc9g8/syEs6bk8XXApsHjKukMl68= -github.com/docker/distribution v2.8.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= +github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= +github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/docker v1.4.2-0.20180625184442-8e610b2b55bf/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= @@ -249,7 +249,7 @@ github.com/fjl/memsize v0.0.0-20180418122429-ca190fb6ffbc/go.mod h1:VvhXpOYNQvB+ github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= -github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= +github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= @@ -333,8 +333,9 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +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.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.3-0.20201103224600-674baa8c7fc3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= @@ -356,6 +357,7 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -503,7 +505,7 @@ github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFB github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 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= @@ -699,7 +701,6 @@ github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6So github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= -github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rs/cors v0.0.0-20160617231935-a62a804a8a00/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/rs/cors v1.8.2 h1:KCooALfAYGs415Cwu5ABvv9n9509fSiG5SQJn/AQo4U= @@ -735,8 +736,8 @@ github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B github.com/spf13/afero v1.9.2 h1:j49Hj62F0n+DaZ1dDCvhABaPNSGNkt32oRFxI33IEMw= github.com/spf13/afero v1.9.2/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= -github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= +github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA= +github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA= @@ -762,7 +763,6 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -771,8 +771,8 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +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/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs= github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca/go.mod h1:u2MKkTVTVJWe5D1rCvame8WqhBd88EuIwODJZ1VHCPM= @@ -782,8 +782,8 @@ github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2l github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= github.com/terra-money/ledger-terra-go v0.11.2 h1:BVXZl+OhJOri6vFNjjVaTabRLApw9MuG7mxWL4V718c= github.com/terra-money/ledger-terra-go v0.11.2/go.mod h1:ClJ2XMj1ptcnONzKH+GhVPi7Y8pXIT+UzJ0TNt0tfZE= -github.com/terra-money/tm-db v0.6.4-performance.7 h1:eS7qNoUf+a0A0nWRieFg1iNneBaf80TMkShPLE8onnM= -github.com/terra-money/tm-db v0.6.4-performance.7/go.mod h1:K6twQf1PGDxC6K6V+G2l0nrYsQAxsypb4PpbJnyzwJw= +github.com/terra-money/tm-db v0.6.7-performance.3 h1:7d2lsU67QNwIPcsqaEzGJe1jpQEFIWpXdH3yCRwdx38= +github.com/terra-money/tm-db v0.6.7-performance.3/go.mod h1:K6twQf1PGDxC6K6V+G2l0nrYsQAxsypb4PpbJnyzwJw= github.com/tidwall/btree v1.5.0 h1:iV0yVY/frd7r6qGBXfEYs7DH0gTDgrKTrDjS7xt/IyQ= github.com/tidwall/btree v1.5.0/go.mod h1:LGm8L/DZjPLmeWGjv5kFrY8dL4uVhMmzmmLYmsObdKE= github.com/tidwall/gjson v1.6.7/go.mod h1:zeFuBCIqD4sN/gmqBzZ4j7Jd6UcA2Fc56x7QFsv+8fI= @@ -869,8 +869,8 @@ golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= -golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA= -golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA= +golang.org/x/exp v0.0.0-20230131160201-f062dba9d201 h1:BEABXpNXLEz0WxtA+6CQIz2xkg80e+1zrhWyMcq8VzE= +golang.org/x/exp v0.0.0-20230131160201-f062dba9d201/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= @@ -895,7 +895,7 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0 h1:b9gGHsz9/HhJ3HF5DHQytPpuwocVTChQJK3AvoLRD5I= +golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -944,8 +944,8 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM= +golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1042,12 +1042,12 @@ golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU= +golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.7.0 h1:BEvjmm5fURWqcfbSKTdpkDXYBrUS1c0m8agp14W48vQ= +golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1057,8 +1057,8 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1118,7 +1118,7 @@ golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= -golang.org/x/tools v0.2.0 h1:G6AHpWxTMGY1KyEYoAQ5WTtIekUUvDNjan3ugu60JvE= +golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1192,8 +1192,8 @@ google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210126160654-44e461bb6506/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6 h1:a2S6M0+660BgMNl++4JPlcAO/CjkqYItDEZwkoDQK7c= -google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= +google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 h1:DdoeryqhaXp1LtT/emMP1BRJPHHKFi5akj/nbx/zNTA= +google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4/go.mod h1:NWraEVixdDnqcqQ30jipen1STv2r/n24Wb7twVTGR4s= google.golang.org/grpc v1.33.2 h1:EQyQC3sa8M+p6Ulc8yy9SWSS2GVwyRc83gAbG8lrl4o= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= @@ -1208,8 +1208,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8 h1:KR8+MyP7/qOlV+8Af01LtjL04bu7on42eVsxT4EyBQk= -google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= +google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/indexer/block/block.go b/indexer/block/block.go index 6d6ec0f..139c7af 100644 --- a/indexer/block/block.go +++ b/indexer/block/block.go @@ -2,6 +2,7 @@ package block import ( "fmt" + tmjson "github.com/tendermint/tendermint/libs/json" tm "github.com/tendermint/tendermint/types" tmdb "github.com/tendermint/tm-db" diff --git a/indexer/block/block_test.go b/indexer/block/block_test.go index b0f6d05..8bc770d 100644 --- a/indexer/block/block_test.go +++ b/indexer/block/block_test.go @@ -2,18 +2,19 @@ package block import ( "fmt" + "io" + "os" + "testing" + "github.com/stretchr/testify/assert" tmjson "github.com/tendermint/tendermint/libs/json" tmdb "github.com/tendermint/tm-db" - "io/ioutil" - "os" - "testing" ) func TestIndexBlock(t *testing.T) { db := tmdb.NewMemDB() blockFile, _ := os.Open("../fixtures/block_4724005_raw.json") - blockJSON, _ := ioutil.ReadAll(blockFile) + blockJSON, _ := io.ReadAll(blockFile) record := BlockRecord{} _ = tmjson.Unmarshal(blockJSON, &record) diff --git a/indexer/block/client.go b/indexer/block/client.go index a4b4563..98e8a21 100644 --- a/indexer/block/client.go +++ b/indexer/block/client.go @@ -3,18 +3,17 @@ package block import ( "encoding/json" "fmt" - "github.com/pkg/errors" "net/http" "strconv" + "github.com/pkg/errors" + "github.com/gorilla/mux" tmdb "github.com/tendermint/tm-db" "github.com/terra-money/mantlemint/indexer" ) -var ( - EndpointGETBlocksHeight = "/index/blocks/{height}" -) +var EndpointGETBlocksHeight = "/index/blocks/{height}" var ( ErrorInvalidHeight = func(height string) string { return fmt.Sprintf("invalid height %s", height) } diff --git a/indexer/block/types.go b/indexer/block/types.go index 4fb02fb..e133b32 100644 --- a/indexer/block/types.go +++ b/indexer/block/types.go @@ -5,12 +5,14 @@ import ( "github.com/terra-money/mantlemint/lib" ) -var prefix = []byte("block/height:") -var getKey = func(height uint64) []byte { - return lib.ConcatBytes(prefix, lib.UintToBigEndian(height)) -} +var ( + prefix = []byte("block/height:") + getKey = func(height uint64) []byte { + return lib.ConcatBytes(prefix, lib.UintToBigEndian(height)) + } +) type BlockRecord struct { - BlockID *tm.BlockID `json:"block_id""` + BlockID *tm.BlockID `json:"block_id"` Block *tm.Block `json:"block"` } diff --git a/indexer/height/client.go b/indexer/height/client.go index d44ccfc..025617c 100644 --- a/indexer/height/client.go +++ b/indexer/height/client.go @@ -1,3 +1 @@ package height - - diff --git a/indexer/height/height.go b/indexer/height/height.go index d6a8d98..6f16572 100644 --- a/indexer/height/height.go +++ b/indexer/height/height.go @@ -2,6 +2,7 @@ package height import ( "fmt" + tmjson "github.com/tendermint/tendermint/libs/json" tm "github.com/tendermint/tendermint/types" tmdb "github.com/tendermint/tm-db" diff --git a/indexer/height/types.go b/indexer/height/types.go index ca0ef09..adb7cd2 100644 --- a/indexer/height/types.go +++ b/indexer/height/types.go @@ -1,12 +1,12 @@ package height -var key = []byte("lastKnownHeight") -var getKey = func() []byte { - return key -} +var ( + key = []byte("lastKnownHeight") + getKey = func() []byte { + return key + } +) type HeightRecord struct { Height uint64 `json:"height"` } - - diff --git a/indexer/indexer.go b/indexer/indexer.go index 7cfbc25..a00b40b 100644 --- a/indexer/indexer.go +++ b/indexer/indexer.go @@ -2,12 +2,13 @@ package indexer import ( "fmt" + "time" + "github.com/gorilla/mux" tm "github.com/tendermint/tendermint/types" tmdb "github.com/tendermint/tm-db" "github.com/terra-money/mantlemint/db/snappy" "github.com/terra-money/mantlemint/mantlemint" - "time" ) type Indexer struct { diff --git a/indexer/tx/client.go b/indexer/tx/client.go index bcb4cd5..ace8186 100644 --- a/indexer/tx/client.go +++ b/indexer/tx/client.go @@ -2,10 +2,11 @@ package tx import ( "fmt" - "github.com/pkg/errors" "net/http" "strconv" + "github.com/pkg/errors" + "github.com/gorilla/mux" tmdb "github.com/tendermint/tm-db" "github.com/terra-money/mantlemint/indexer" diff --git a/indexer/tx/tx_test.go b/indexer/tx/tx_test.go index 01bbf46..845f1b2 100644 --- a/indexer/tx/tx_test.go +++ b/indexer/tx/tx_test.go @@ -2,27 +2,28 @@ package tx import ( "fmt" + "io" + "os" + "testing" + "github.com/stretchr/testify/assert" tmjson "github.com/tendermint/tendermint/libs/json" tendermint "github.com/tendermint/tendermint/types" tmdb "github.com/tendermint/tm-db" "github.com/terra-money/mantlemint/mantlemint" - "io/ioutil" - "os" - "testing" ) func TestIndexTx(t *testing.T) { db := tmdb.NewMemDB() block := &tendermint.Block{} blockFile, _ := os.Open("../fixtures/block_4814775.json") - blockJSON, _ := ioutil.ReadAll(blockFile) + blockJSON, _ := io.ReadAll(blockFile) if err := tmjson.Unmarshal(blockJSON, block); err != nil { t.Fail() } eventFile, _ := os.Open("../fixtures/response_4814775.json") - eventJSON, _ := ioutil.ReadAll(eventFile) + eventJSON, _ := io.ReadAll(eventFile) evc := mantlemint.NewMantlemintEventCollector() event := tendermint.EventDataTx{} if err := tmjson.Unmarshal(eventJSON, &event.Result); err != nil { diff --git a/indexer/tx/types.go b/indexer/tx/types.go index ab95543..2c58116 100644 --- a/indexer/tx/types.go +++ b/indexer/tx/types.go @@ -2,9 +2,10 @@ package tx import ( "encoding/json" + "time" + abci "github.com/tendermint/tendermint/abci/types" "github.com/terra-money/mantlemint/lib" - "time" ) type TxRecord struct { @@ -25,15 +26,19 @@ type TxByHeightRecord struct { Tx json.RawMessage `json:"tx"` } -var txPrefix = []byte("tx/hash:") -var getKey = func(hash string) []byte { - return lib.ConcatBytes(txPrefix, []byte(hash)) -} +var ( + txPrefix = []byte("tx/hash:") + getKey = func(hash string) []byte { + return lib.ConcatBytes(txPrefix, []byte(hash)) + } +) -var byHeightPrefix = []byte("tx/height:") -var getByHeightKey = func(height uint64) []byte { - return lib.ConcatBytes(byHeightPrefix, lib.UintToBigEndian(height)) -} +var ( + byHeightPrefix = []byte("tx/height:") + getByHeightKey = func(height uint64) []byte { + return lib.ConcatBytes(byHeightPrefix, lib.UintToBigEndian(height)) + } +) type ResponseDeliverTx struct { Code uint32 `json:"code"` diff --git a/indexer/types.go b/indexer/types.go index bcaeb69..3448900 100644 --- a/indexer/types.go +++ b/indexer/types.go @@ -1,18 +1,21 @@ package indexer import ( + "log" + "net/http" + "runtime" + "github.com/gorilla/mux" tm "github.com/tendermint/tendermint/types" tmdb "github.com/tendermint/tm-db" "github.com/terra-money/mantlemint/mantlemint" - "log" - "net/http" - "runtime" ) -type IndexFunc func(indexerDB tmdb.Batch, block *tm.Block, blockId *tm.BlockID, evc *mantlemint.EventCollector) error -type ClientHandler func(w http.ResponseWriter, r *http.Request) error -type RESTRouteRegisterer func(router *mux.Router, indexerDB tmdb.DB) +type ( + IndexFunc func(indexerDB tmdb.Batch, block *tm.Block, blockId *tm.BlockID, evc *mantlemint.EventCollector) error + ClientHandler func(w http.ResponseWriter, r *http.Request) error + RESTRouteRegisterer func(router *mux.Router, indexerDB tmdb.DB) +) func CreateIndexer(idf IndexFunc) IndexFunc { return idf @@ -22,16 +25,14 @@ func CreateRESTRoute(registerer RESTRouteRegisterer) RESTRouteRegisterer { return registerer } -var ( - ErrorInternal = func(err error) string { - _, fn, fl, ok := runtime.Caller(1) - - if !ok { - // ... - } else { - log.Printf("ErrorInternal[%s:%d] %v\n", fn, fl, err.Error()) - } +var ErrorInternal = func(err error) string { + _, fn, fl, ok := runtime.Caller(1) - return "internal server error" + if !ok { + // ... + } else { + log.Printf("ErrorInternal[%s:%d] %v\n", fn, fl, err.Error()) } -) + + return "internal server error" +} diff --git a/lib/bytes.go b/lib/bytes.go index 04e3cf7..9ba1a1f 100644 --- a/lib/bytes.go +++ b/lib/bytes.go @@ -14,7 +14,7 @@ func ConcatBytes(items ...[]byte) []byte { } func UintToBigEndian(n uint64) []byte { - var buf = make([]byte, 8) + buf := make([]byte, 8) binary.BigEndian.PutUint64(buf, n) return buf diff --git a/mantlemint/appcreator.go b/mantlemint/appcreator.go index aba7d22..0e63ba3 100644 --- a/mantlemint/appcreator.go +++ b/mantlemint/appcreator.go @@ -21,4 +21,4 @@ func NewConcurrentQueryClientCreator(app types.Application) proxy.ClientCreator func (l *localClientCreator) NewABCIClient() (abcicli.Client, error) { return NewConcurrentQueryClient(l.mtx, l.app), nil -} \ No newline at end of file +} diff --git a/mantlemint/client.go b/mantlemint/client.go index 4005769..ac60875 100644 --- a/mantlemint/client.go +++ b/mantlemint/client.go @@ -299,7 +299,8 @@ func (app *localClient) OfferSnapshotSync(req types.RequestOfferSnapshot) (*type } func (app *localClient) LoadSnapshotChunkSync( - req types.RequestLoadSnapshotChunk) (*types.ResponseLoadSnapshotChunk, error) { + req types.RequestLoadSnapshotChunk, +) (*types.ResponseLoadSnapshotChunk, error) { app.mtx.Lock() defer app.mtx.Unlock() @@ -308,7 +309,8 @@ func (app *localClient) LoadSnapshotChunkSync( } func (app *localClient) ApplySnapshotChunkSync( - req types.RequestApplySnapshotChunk) (*types.ResponseApplySnapshotChunk, error) { + req types.RequestApplySnapshotChunk, +) (*types.ResponseApplySnapshotChunk, error) { app.mtx.Lock() defer app.mtx.Unlock() diff --git a/mantlemint/executor.go b/mantlemint/executor.go index b33b4f7..d315ec7 100644 --- a/mantlemint/executor.go +++ b/mantlemint/executor.go @@ -1,12 +1,13 @@ package mantlemint import ( + "os" + "github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/mempool/mock" "github.com/tendermint/tendermint/proxy" "github.com/tendermint/tendermint/state" tmdb "github.com/tendermint/tm-db" - "os" ) // NewMantlemintExecutor creates stock tendermint block executor, with stubbed mempool and evidence pool diff --git a/mantlemint/reactor.go b/mantlemint/reactor.go index 58bf6c6..5a912aa 100644 --- a/mantlemint/reactor.go +++ b/mantlemint/reactor.go @@ -1,28 +1,21 @@ package mantlemint import ( - // "fmt" - // abcicli "github.com/tendermint/tendermint/abci/client" - // abci "github.com/tendermint/tendermint/abci/types" + "log" + "sync" + "github.com/tendermint/tendermint/consensus" "github.com/tendermint/tendermint/crypto/merkle" "github.com/tendermint/tendermint/proxy" "github.com/tendermint/tendermint/state" "github.com/tendermint/tendermint/store" - "log" - "sync" - tendermint "github.com/tendermint/tendermint/types" tmdb "github.com/tendermint/tm-db" ) var _ Mantlemint = (*Instance)(nil) -var ( - errNoBlock = "block is never injected" -) - type Instance struct { executor Executor conn proxy.AppConns @@ -50,14 +43,12 @@ func NewMantlemint( runBefore MantlemintCallbackBefore, runAfter MantlemintCallbackAfter, ) Mantlemint { - // here we go! - var stateStore = state.NewStore(db, state.StoreOptions{ + stateStore := state.NewStore(db, state.StoreOptions{ DiscardABCIResponses: false, }) - var blockStore = store.NewBlockStore(db) - var lastState, err = stateStore.Load() - + blockStore := store.NewBlockStore(db) + lastState, err := stateStore.Load() if err != nil { panic(err) } @@ -125,8 +116,8 @@ func (mm *Instance) LoadInitialState() error { } func (mm *Instance) Inject(block *tendermint.Block) error { - var currentState = mm.lastState - var blockID = tendermint.BlockID{ + currentState := mm.lastState + blockID := tendermint.BlockID{ Hash: block.Hash(), PartSetHeader: block.MakePartSet(tendermint.BlockPartSizeBytes).Header(), } diff --git a/mantlemint/types.go b/mantlemint/types.go index a88bcfd..e9422d3 100644 --- a/mantlemint/types.go +++ b/mantlemint/types.go @@ -21,7 +21,9 @@ type Executor interface { SetEventBus(publisher tendermint.BlockEventPublisher) } -type MantlemintCallbackBefore func(block *tendermint.Block) error -type MantlemintCallbackAfter func(block *tendermint.Block, events *EventCollector) error +type ( + MantlemintCallbackBefore func(block *tendermint.Block) error + MantlemintCallbackAfter func(block *tendermint.Block, events *EventCollector) error +) // --- internal types diff --git a/rpc/cache.go b/rpc/cache.go index 32aa0f5..93ac0a6 100644 --- a/rpc/cache.go +++ b/rpc/cache.go @@ -51,7 +51,7 @@ func (cb *CacheBackend) Set(cacheKey string, status int, body []byte) *ResponseC status: status, body: body, } - if evicted := cb.lru.Add(cacheKey, response); evicted != false { + if evicted := cb.lru.Add(cacheKey, response); evicted { cb.evictionCount++ } diff --git a/rpc/cache_test.go b/rpc/cache_test.go index e8aceaf..480f980 100644 --- a/rpc/cache_test.go +++ b/rpc/cache_test.go @@ -28,7 +28,7 @@ func TestCacheBackend(t *testing.T) { nil, ) testRes := httptest.NewRecorder() - var callCount = 0 + callCount := 0 handler := http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) { callCount++ @@ -59,5 +59,4 @@ func TestCacheBackend(t *testing.T) { fmt.Println(callCount) assert.Equal(t, callCount, 1) - } diff --git a/rpc/client.go b/rpc/client.go index 7cfbe4d..af9d4b0 100644 --- a/rpc/client.go +++ b/rpc/client.go @@ -2,7 +2,6 @@ package rpc import ( "context" - "fmt" abcicli "github.com/tendermint/tendermint/abci/client" abci "github.com/tendermint/tendermint/abci/types" @@ -156,9 +155,6 @@ func (m *MantlemintRPCClient) Health(ctx context.Context) (*coretypes.ResultHeal func (m *MantlemintRPCClient) Block(ctx context.Context, height *int64) (*coretypes.ResultBlock, error) { return core.Block(nil, height) - fmt.Println("is it you") - - panic("implement me") } func (m *MantlemintRPCClient) BlockByHash(ctx context.Context, hash []byte) (*coretypes.ResultBlock, error) { diff --git a/rpc/register.go b/rpc/register.go index 6ad3427..ff5a1cd 100644 --- a/rpc/register.go +++ b/rpc/register.go @@ -2,7 +2,7 @@ package rpc import ( "fmt" - "io/ioutil" + "io" "net/http" "strconv" "time" @@ -65,7 +65,7 @@ func StartRPC( }() // start new api server - apiSrv := api.New(context, tmlog.NewTMLogger(ioutil.Discard)) + apiSrv := api.New(context, tmlog.NewTMLogger(io.Discard)) // register custom routes to default api server registerCustomRoutes(apiSrv.Router) diff --git a/store/rootmulti/dbadapter.go b/store/rootmulti/dbadapter.go index 47a3f0d..21d4749 100644 --- a/store/rootmulti/dbadapter.go +++ b/store/rootmulti/dbadapter.go @@ -39,7 +39,7 @@ func (cdsa commitDBStoreAdapter) SetPruning(_ types.PruningOptions) {} func (cdsa commitDBStoreAdapter) GetPruning() types.PruningOptions { return types.PruningOptions{} } func (cdsa *commitDBStoreAdapter) BranchStoreWithHeightLimitedDB(hldb dbm.DB) types.CommitKVStore { - var db = dbm.NewPrefixDB(hldb, cdsa.prefix) + db := dbm.NewPrefixDB(hldb, cdsa.prefix) return commitDBStoreAdapter{Store: dbadapter.Store{DB: db}, prefix: cdsa.prefix} } diff --git a/store/rootmulti/store.go b/store/rootmulti/store.go index 61f4b30..5f00078 100644 --- a/store/rootmulti/store.go +++ b/store/rootmulti/store.go @@ -33,21 +33,14 @@ const ( latestVersionKey = "s/latest" pruneHeightsKey = "s/pruneheights" commitInfoKeyFmt = "s/%d" // s/ - - // Do not change chunk size without new snapshot format (must be uniform across nodes) - snapshotChunkSize = uint64(10e6) - snapshotBufferSize = int(snapshotChunkSize) - snapshotMaxItemSize = int(64e6) // SDK has no key/value size limit, so we set an arbitrary limit ) -const iavlDisablefastNodeDefault = true - // Store is composed of many CommitStores. Name contrasts with // cacheMultiStore which is used for branching other MultiStores. It implements // the CommitMultiStore interface. type Store struct { - db dbm.DB - logger log.Logger + db dbm.DB + logger log.Logger hldb *hld.HeightLimitedDB lastCommitInfo *types.CommitInfo pruningOpts types.PruningOptions @@ -60,12 +53,12 @@ type Store struct { pruneHeights []int64 initialVersion int64 - traceWriter io.Writer - traceContext types.TraceContext + traceWriter io.Writer + traceContext types.TraceContext - interBlockCache types.MultiStorePersistentCache + interBlockCache types.MultiStorePersistentCache - listeners map[types.StoreKey][]types.WriteListener + listeners map[types.StoreKey][]types.WriteListener } var ( @@ -80,7 +73,7 @@ var ( func NewStore(db dbm.DB, logger log.Logger, hldb *hld.HeightLimitedDB) *Store { return &Store{ db: db, - logger: logger, + logger: logger, hldb: hldb, pruningOpts: types.PruneNothing, iavlCacheSize: iavl.DefaultIAVLCacheSize, @@ -205,7 +198,7 @@ func (rs *Store) loadVersion(ver int64, upgrades *types.StoreUpgrades) error { } // load each Store (note this doesn't panic on unmounted keys now) - var newStores = make(map[types.StoreKey]types.CommitKVStore) + newStores := make(map[types.StoreKey]types.CommitKVStore) storesKeys := make([]types.StoreKey, 0, len(rs.storesParams)) @@ -383,7 +376,6 @@ func (rs *Store) Commit() types.CommitID { // This case means that no commit has been made in the store, we // start from initialVersion. version = rs.initialVersion - } else { // This case can means two things: // - either there was already a previous commit in the store, in which @@ -477,7 +469,7 @@ func (rs *Store) CacheMultiStore() types.CacheMultiStore { // any store cannot be loaded. This should only be used for querying and // iterating at past heights. func (rs *Store) CacheMultiStoreWithVersion(version int64) (types.CacheMultiStore, error) { - var hldb = rs.hldb.BranchHeightLimitedDB(version) + hldb := rs.hldb.BranchHeightLimitedDB(version) cachedStores := make(map[types.StoreKey]types.CacheWrapper) for key, store := range rs.stores { @@ -551,8 +543,6 @@ func (rs *Store) GetKVStore(key types.StoreKey) types.KVStore { return store } - - // GetStoreByName performs a lookup of a StoreKey given a store name typically // provided in a path. The StoreKey is then used to perform a lookup and return // a Store. If the Store is wrapped in an inter-block cache, it will be unwrapped diff --git a/sync.go b/sync.go index 5652d50..c2c9cf6 100644 --- a/sync.go +++ b/sync.go @@ -4,7 +4,6 @@ import ( "crypto/sha1" "encoding/hex" "fmt" - "io/ioutil" "log" "os" "runtime/debug" @@ -57,7 +56,7 @@ func main() { panic(ldbErr) } - var hldb = hld.ApplyHeightLimitedDB( + hldb := hld.ApplyHeightLimitedDB( ldb, &hld.HeightLimitedDBConfig{ Debug: true, @@ -74,7 +73,7 @@ func main() { vpr := viper.GetViper() var wasmOpts []wasm.Option - var app = terra.NewTerraApp( + app := terra.NewTerraApp( logger, batched, nil, @@ -92,7 +91,7 @@ func main() { ) // create app... - var appCreator = mantlemint.NewConcurrentQueryClientCreator(app) + appCreator := mantlemint.NewConcurrentQueryClientCreator(app) appConns := proxy.NewAppConns(appCreator) appConns.SetLogger(logger) if startErr := appConns.OnStart(); startErr != nil { @@ -104,8 +103,8 @@ func main() { fmt.Println(a) }() - var executor = mantlemint.NewMantlemintExecutor(batched, appConns.Consensus()) - var mm = mantlemint.NewMantlemint( + executor := mantlemint.NewMantlemintExecutor(batched, appConns.Consensus()) + mm := mantlemint.NewMantlemint( batched, appConns, executor, @@ -253,12 +252,12 @@ func fauxMerkleModeOpt(app *baseapp.BaseApp) { } func getGenesisDoc(genesisPath string) *tendermint.GenesisDoc { - jsonBlob, _ := ioutil.ReadFile(genesisPath) + jsonBlob, _ := os.ReadFile(genesisPath) shasum := sha1.New() shasum.Write(jsonBlob) sum := hex.EncodeToString(shasum.Sum(nil)) - log.Printf("[v0.34.x/sync] genesis shasum=%s", sum) + log.Printf("[sync] genesis shasum=%s", sum) if genesis, genesisErr := tendermint.GenesisDocFromFile(genesisPath); genesisErr != nil { panic(genesisErr)