Skip to content

Commit

Permalink
cosmossdk.io/log
Browse files Browse the repository at this point in the history
  • Loading branch information
hieuvubk committed Nov 14, 2023
1 parent 747830c commit ae63edb
Show file tree
Hide file tree
Showing 87 changed files with 138 additions and 118 deletions.
2 changes: 1 addition & 1 deletion baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"sort"
"strings"

"cosmossdk.io/log"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/crypto/tmhash"
"github.com/cometbft/cometbft/libs/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/gogoproto/proto"
Expand Down
2 changes: 1 addition & 1 deletion baseapp/baseapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"testing"
"time"

"cosmossdk.io/log"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
dbm "github.com/cosmos/cosmos-db"
"github.com/stretchr/testify/require"
Expand Down
2 changes: 1 addition & 1 deletion baseapp/block_gas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"math"
"testing"

"cosmossdk.io/log"
abci "github.com/cometbft/cometbft/abci/types"
tmjson "github.com/cometbft/cometbft/libs/json"
"github.com/cometbft/cometbft/libs/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
dbm "github.com/cosmos/cosmos-db"
"github.com/stretchr/testify/require"
Expand Down
2 changes: 1 addition & 1 deletion baseapp/grpcrouter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"sync"
"testing"

"github.com/cometbft/cometbft/libs/log"
"cosmossdk.io/log"
dbm "github.com/cosmos/cosmos-db"
"github.com/stretchr/testify/require"

Expand Down
2 changes: 1 addition & 1 deletion baseapp/msg_service_router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"os"
"testing"

"cosmossdk.io/log"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
dbm "github.com/cosmos/cosmos-db"
"github.com/stretchr/testify/require"
Expand Down
2 changes: 1 addition & 1 deletion baseapp/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
txconfigv1 "cosmossdk.io/api/cosmos/tx/config/v1"
"cosmossdk.io/core/appconfig"
"cosmossdk.io/depinject"
"github.com/cometbft/cometbft/libs/log"
"cosmossdk.io/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
tmtypes "github.com/cometbft/cometbft/types"
dbm "github.com/cosmos/cosmos-db"
Expand Down
2 changes: 1 addition & 1 deletion client/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"context"
"testing"

"cosmossdk.io/log"
abci "github.com/cometbft/cometbft/abci/types"
tmjson "github.com/cometbft/cometbft/libs/json"
"github.com/cometbft/cometbft/libs/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
dbm "github.com/cosmos/cosmos-db"
"github.com/stretchr/testify/suite"
Expand Down
2 changes: 1 addition & 1 deletion client/pruning/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"

"github.com/cometbft/cometbft/libs/log"
"cosmossdk.io/log"
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/server"
Expand Down
2 changes: 1 addition & 1 deletion runtime/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"io"

"github.com/cometbft/cometbft/libs/log"
"cosmossdk.io/log"
dbm "github.com/cosmos/cosmos-db"

"github.com/cosmos/cosmos-sdk/baseapp"
Expand Down
2 changes: 1 addition & 1 deletion server/api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"sync"
"time"

"github.com/cometbft/cometbft/libs/log"
"cosmossdk.io/log"
tmrpcserver "github.com/cometbft/cometbft/rpc/jsonrpc/server"
gateway "github.com/cosmos/gogogateway"
"github.com/gorilla/handlers"
Expand Down
2 changes: 1 addition & 1 deletion server/log/cmt_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package server

import (
"cosmossdk.io/log"
cmtlog "github.com/cometbft/cometbft/libs/log"
cmtlog "cosmossdk.io/log"
)

var _ cmtlog.Logger = (*CometLoggerWrapper)(nil)
Expand Down
4 changes: 2 additions & 2 deletions server/mock/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (
"fmt"
"path/filepath"

db "github.com/cometbft/cometbft-db"
"cosmossdk.io/log"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/log"
"github.com/cometbft/cometbft/types"
db "github.com/cosmos/cosmos-db"
"google.golang.org/grpc"

bam "github.com/cosmos/cosmos-sdk/baseapp"
Expand Down
2 changes: 1 addition & 1 deletion server/mock/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"os"
"testing"

tmlog "cosmossdk.io/log"
abci "github.com/cometbft/cometbft/abci/types"
tmlog "github.com/cometbft/cometbft/libs/log"
)

// SetupApp returns an application as well as a clean-up function to be used to
Expand Down
1 change: 0 additions & 1 deletion server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ const (
FlagMinRetainBlocks = "min-retain-blocks"
FlagIAVLCacheSize = "iavl-cache-size"
FlagDisableIAVLFastNode = "iavl-disable-fastnode"
FlagIAVLLazyLoading = "iavl-lazy-loading"

// state sync-related flags
FlagStateSyncSnapshotInterval = "state-sync.snapshot-interval"
Expand Down
2 changes: 1 addition & 1 deletion server/types/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"io"
"time"

"cosmossdk.io/log"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
tmtypes "github.com/cometbft/cometbft/types"
dbm "github.com/cosmos/cosmos-db"
Expand Down
2 changes: 1 addition & 1 deletion server/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import (
"github.com/spf13/viper"

"cosmossdk.io/log"
tmlog "cosmossdk.io/log"
tmcmd "github.com/cometbft/cometbft/cmd/cometbft/commands"
tmcfg "github.com/cometbft/cometbft/config"
tmlog "github.com/cometbft/cometbft/libs/log"
tmtypes "github.com/cometbft/cometbft/types"
dbm "github.com/cosmos/cosmos-db"

Expand Down
2 changes: 1 addition & 1 deletion simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (

autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
"cosmossdk.io/log"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/log"
dbm "github.com/cosmos/cosmos-db"
"github.com/spf13/cast"

Expand Down
2 changes: 1 addition & 1 deletion simapp/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"os"
"testing"

"cosmossdk.io/log"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
dbm "github.com/cosmos/cosmos-db"
"github.com/golang/mock/gomock"
Expand Down
2 changes: 1 addition & 1 deletion simapp/app_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"os"
"path/filepath"

"github.com/cometbft/cometbft/libs/log"
"cosmossdk.io/log"
dbm "github.com/cosmos/cosmos-db"

"cosmossdk.io/depinject"
Expand Down
2 changes: 1 addition & 1 deletion simapp/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"strings"
"testing"

"cosmossdk.io/log"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
dbm "github.com/cosmos/cosmos-db"
"github.com/stretchr/testify/require"
Expand Down
2 changes: 1 addition & 1 deletion simapp/simd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (

rosettaCmd "cosmossdk.io/tools/rosetta/cmd"

"cosmossdk.io/log"
tmcfg "github.com/cometbft/cometbft/config"
"github.com/cometbft/cometbft/libs/log"
dbm "github.com/cosmos/cosmos-db"
"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand Down
2 changes: 1 addition & 1 deletion simapp/simd/cmd/testnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"testing"

"github.com/cometbft/cometbft/libs/log"
"cosmossdk.io/log"
"github.com/spf13/viper"
"github.com/stretchr/testify/require"

Expand Down
2 changes: 1 addition & 1 deletion simapp/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"os"
"testing"

"cosmossdk.io/log"
abci "github.com/cometbft/cometbft/abci/types"
tmjson "github.com/cometbft/cometbft/libs/json"
"github.com/cometbft/cometbft/libs/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
tmtypes "github.com/cometbft/cometbft/types"
dbm "github.com/cosmos/cosmos-db"
Expand Down
2 changes: 1 addition & 1 deletion snapshots/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"sort"
"sync"

"github.com/cometbft/cometbft/libs/log"
"cosmossdk.io/log"

"github.com/cosmos/cosmos-sdk/snapshots/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
Expand Down
4 changes: 2 additions & 2 deletions store/cachekv/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
fmt "fmt"
"testing"

dbm "github.com/cosmos/cosmos-db"
"github.com/cometbft/cometbft/libs/log"
"cosmossdk.io/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/store"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down
39 changes: 38 additions & 1 deletion store/pruning/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"
"sync"

"github.com/cometbft/cometbft/libs/log"
"cosmossdk.io/log"
dbm "github.com/cosmos/cosmos-db"

"github.com/cosmos/cosmos-sdk/store/pruning/types"
Expand Down Expand Up @@ -212,6 +212,43 @@ func (m *Manager) LoadPruningHeights(db dbm.DB) error {
return nil
}

// GetPruningHeight returns the height which can prune upto if it is able to prune at the given height.
func (m *Manager) GetPruningHeight(height int64) int64 {
if m.opts.GetPruningStrategy() == types.PruningNothing {
return 0
}
if m.opts.Interval <= 0 {
return 0
}

if height%int64(m.opts.Interval) != 0 || height <= int64(m.opts.KeepRecent) {
return 0
}

// Consider the snapshot height
pruneHeight := height - 1 - int64(m.opts.KeepRecent) // we should keep the current height at least

m.pruneSnapshotHeightsMx.RLock()

Check failure on line 231 in store/pruning/manager.go

View workflow job for this annotation

GitHub Actions / tests (02)

m.pruneSnapshotHeightsMx.RLock undefined (type sync.Mutex has no field or method RLock)

Check failure on line 231 in store/pruning/manager.go

View workflow job for this annotation

GitHub Actions / tests (01)

m.pruneSnapshotHeightsMx.RLock undefined (type sync.Mutex has no field or method RLock)

Check failure on line 231 in store/pruning/manager.go

View workflow job for this annotation

GitHub Actions / tests (03)

m.pruneSnapshotHeightsMx.RLock undefined (type sync.Mutex has no field or method RLock)

Check failure on line 231 in store/pruning/manager.go

View workflow job for this annotation

GitHub Actions / tests (00)

m.pruneSnapshotHeightsMx.RLock undefined (type sync.Mutex has no field or method RLock)
defer m.pruneSnapshotHeightsMx.RUnlock()

Check failure on line 232 in store/pruning/manager.go

View workflow job for this annotation

GitHub Actions / tests (02)

m.pruneSnapshotHeightsMx.RUnlock undefined (type sync.Mutex has no field or method RUnlock)

Check failure on line 232 in store/pruning/manager.go

View workflow job for this annotation

GitHub Actions / tests (01)

m.pruneSnapshotHeightsMx.RUnlock undefined (type sync.Mutex has no field or method RUnlock)

Check failure on line 232 in store/pruning/manager.go

View workflow job for this annotation

GitHub Actions / tests (03)

m.pruneSnapshotHeightsMx.RUnlock undefined (type sync.Mutex has no field or method RUnlock)

Check failure on line 232 in store/pruning/manager.go

View workflow job for this annotation

GitHub Actions / tests (00)

m.pruneSnapshotHeightsMx.RUnlock undefined (type sync.Mutex has no field or method RUnlock)

// snapshotInterval is zero, indicating that all heights can be pruned
if m.snapshotInterval <= 0 {
return pruneHeight
}

if len(m.pruneSnapshotHeights) == 0 { // the length should be greater than zero

Check failure on line 239 in store/pruning/manager.go

View workflow job for this annotation

GitHub Actions / tests (02)

invalid argument: m.pruneSnapshotHeights (variable of type *list.List) for len

Check failure on line 239 in store/pruning/manager.go

View workflow job for this annotation

GitHub Actions / tests (01)

invalid argument: m.pruneSnapshotHeights (variable of type *list.List) for len

Check failure on line 239 in store/pruning/manager.go

View workflow job for this annotation

GitHub Actions / tests (03)

invalid argument: m.pruneSnapshotHeights (variable of type *list.List) for len

Check failure on line 239 in store/pruning/manager.go

View workflow job for this annotation

GitHub Actions / tests (00)

invalid argument: m.pruneSnapshotHeights (variable of type *list.List) for len
return 0
}

// the snapshot `m.pruneSnapshotHeights[0]` is already operated,
// so we can prune upto `m.pruneSnapshotHeights[0] + int64(m.snapshotInterval) - 1`
snHeight := m.pruneSnapshotHeights[0] + int64(m.snapshotInterval) - 1

Check failure on line 245 in store/pruning/manager.go

View workflow job for this annotation

GitHub Actions / tests (02)

invalid operation: cannot index m.pruneSnapshotHeights (variable of type *list.List)

Check failure on line 245 in store/pruning/manager.go

View workflow job for this annotation

GitHub Actions / tests (01)

invalid operation: cannot index m.pruneSnapshotHeights (variable of type *list.List)

Check failure on line 245 in store/pruning/manager.go

View workflow job for this annotation

GitHub Actions / tests (03)

invalid operation: cannot index m.pruneSnapshotHeights (variable of type *list.List)

Check failure on line 245 in store/pruning/manager.go

View workflow job for this annotation

GitHub Actions / tests (00)

invalid operation: cannot index m.pruneSnapshotHeights (variable of type *list.List)
if snHeight < pruneHeight {
return snHeight
}
return pruneHeight
}

func loadPruningHeights(db dbm.DB) ([]int64, error) {
bz, err := db.Get(pruneHeightsKey)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion store/pruning/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"
"testing"

"github.com/cometbft/cometbft/libs/log"
"cosmossdk.io/log"
db "github.com/cosmos/cosmos-db"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"
Expand Down
2 changes: 1 addition & 1 deletion store/rootmulti/proof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package rootmulti
import (
"testing"

"cosmossdk.io/log"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/log"
dbm "github.com/cosmos/cosmos-db"
"github.com/stretchr/testify/require"

Expand Down
2 changes: 1 addition & 1 deletion store/rootmulti/snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/cometbft/cometbft/libs/log"
"cosmossdk.io/log"
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/snapshots"
snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types"
Expand Down
Loading

0 comments on commit ae63edb

Please sign in to comment.