Skip to content

Commit

Permalink
Merge PR: add pruning log and invalidTxs log (#1189)
Browse files Browse the repository at this point in the history
* add pruning log

* add invalidTxs log

* fix ut

Co-authored-by: Zhong Qiu <[email protected]>
  • Loading branch information
xiangjianmeng and zhongqiuwood authored Nov 12, 2021
1 parent a017e10 commit fa0cc6c
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/elapse_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,12 @@ func (e *ElapsedTimeInfos) Dump(logger log.Logger) {
}
}

info := fmt.Sprintf("%s<%s>, %s<%s>, %s<%s>, %s[%s]",
info := fmt.Sprintf("%s<%s>, %s<%s>, %s<%s>, %s[%s], %s<%s>",
trace.Height, e.infoMap[trace.Height],
trace.Tx, e.infoMap[trace.Tx],
trace.GasUsed, e.infoMap[trace.GasUsed],
trace.RunTx, e.infoMap[trace.RunTx],
trace.InvalidTxs, e.infoMap[trace.InvalidTxs],
)

if len(detailInfo) > 0 {
Expand Down
1 change: 1 addition & 0 deletions libs/cosmos-sdk/baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ func NewBaseApp(
if app.interBlockCache != nil {
app.cms.SetInterBlockCache(app.interBlockCache)
}
app.cms.SetLogger(app.logger)

app.parallelTxManage.workgroup.Start()

Expand Down
5 changes: 5 additions & 0 deletions libs/cosmos-sdk/server/mock/store.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package mock

import (
"github.com/okex/exchain/libs/tendermint/libs/log"
"io"

dbm "github.com/tendermint/tm-db"
Expand Down Expand Up @@ -187,3 +188,7 @@ func NewCommitMultiStore() sdk.CommitMultiStore {
func (ms multiStore) StopStore() {
panic("not implemented")
}

func (ms multiStore) SetLogger(log log.Logger) {
panic("not implemented")
}
19 changes: 18 additions & 1 deletion libs/cosmos-sdk/store/rootmulti/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
abci "github.com/okex/exchain/libs/tendermint/abci/types"
"github.com/okex/exchain/libs/tendermint/crypto/merkle"
"github.com/okex/exchain/libs/tendermint/crypto/tmhash"
tmlog "github.com/okex/exchain/libs/tendermint/libs/log"
tmtypes "github.com/okex/exchain/libs/tendermint/types"
"github.com/pkg/errors"
dbm "github.com/tendermint/tm-db"
Expand Down Expand Up @@ -49,6 +50,8 @@ type Store struct {
traceContext types.TraceContext

interBlockCache types.MultiStorePersistentCache

logger tmlog.Logger
}

var (
Expand Down Expand Up @@ -377,10 +380,20 @@ func (rs *Store) Commit() types.CommitID {
// pruneStores will batch delete a list of heights from each mounted sub-store.
// Afterwards, pruneHeights is reset.
func (rs *Store) pruneStores() {
if len(rs.pruneHeights) == 0 {
pruneCnt := len(rs.pruneHeights)
if pruneCnt == 0 {
return
}

if rs.logger != nil {
rs.logger.Info("pruning start", "pruning-count", pruneCnt, "curr-height", rs.lastCommitInfo.Version+1)
rs.logger.Debug("pruning", "pruning-heights", rs.pruneHeights)
}
defer func() {
if rs.logger != nil {
rs.logger.Info("pruning end")
}
}()
for key, store := range rs.stores {
if store.GetStoreType() == types.StoreTypeIAVL {
// If the store is wrapped with an inter-block cache, we must first unwrap
Expand Down Expand Up @@ -1047,3 +1060,7 @@ func (rs *Store) StopStore() {
}

}

func (rs *Store) SetLogger(log tmlog.Logger) {
rs.logger = log.With("module", "root-multi")
}
2 changes: 1 addition & 1 deletion libs/cosmos-sdk/store/rootmulti/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"math"
"testing"

"github.com/stretchr/testify/require"
abci "github.com/okex/exchain/libs/tendermint/abci/types"
"github.com/okex/exchain/libs/tendermint/crypto/merkle"
"github.com/stretchr/testify/require"
dbm "github.com/tendermint/tm-db"

"github.com/okex/exchain/libs/cosmos-sdk/store/iavl"
Expand Down
3 changes: 3 additions & 0 deletions libs/cosmos-sdk/store/types/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package types

import (
"fmt"
"github.com/okex/exchain/libs/tendermint/libs/log"
"io"

abci "github.com/okex/exchain/libs/tendermint/abci/types"
Expand Down Expand Up @@ -179,6 +180,8 @@ type CommitMultiStore interface {
SetInterBlockCache(MultiStorePersistentCache)

StopStore()

SetLogger(log log.Logger)
}

//---------subsp-------------------------------
Expand Down
1 change: 1 addition & 0 deletions libs/tendermint/state/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ func execBlockOnProxyApp(
}

logger.Info("Executed block", "height", block.Height, "validTxs", validTxs, "invalidTxs", invalidTxs)
trace.GetElapsedInfo().AddInfo(trace.InvalidTxs, fmt.Sprintf("%d", invalidTxs))

return abciResponses, nil
}
Expand Down
3 changes: 3 additions & 0 deletions libs/tendermint/state/execution_parallel.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package state

import (
"fmt"
abci "github.com/okex/exchain/libs/tendermint/abci/types"
"github.com/okex/exchain/libs/tendermint/libs/log"
"github.com/okex/exchain/libs/tendermint/proxy"
"github.com/okex/exchain/libs/tendermint/trace"
"github.com/okex/exchain/libs/tendermint/types"
dbm "github.com/tendermint/tm-db"
)
Expand Down Expand Up @@ -54,6 +56,7 @@ func execBlockOnProxyAppAsync(
}

logger.Info("Executed block", "height", block.Height, "validTxs", validTxs, "invalidTxs", invalidTxs)
trace.GetElapsedInfo().AddInfo(trace.InvalidTxs, fmt.Sprintf("%d", invalidTxs))

return abciResponses, nil
}
1 change: 1 addition & 0 deletions libs/tendermint/trace/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const (


Abci = "abci"
InvalidTxs = "InvalidTxs"
SaveResp = "saveResp"
Persist = "persist"
SaveState = "saveState"
Expand Down

0 comments on commit fa0cc6c

Please sign in to comment.