Compare commits

...

5 Commits

Author SHA1 Message Date
Aleksandr Bezobchuk
b61f7270b1 Merge branch 'master' into bez/consensus-reactor-internal 2021-06-03 10:14:38 -04:00
Aleksandr Bezobchuk
ab476e89b3 consensus: cl++ 2021-06-03 09:50:26 -04:00
Aleksandr Bezobchuk
58f0a87015 consensus: metrics 2021-06-03 09:48:23 -04:00
Aleksandr Bezobchuk
f8775952c3 consensus: lint++ 2021-06-03 09:33:46 -04:00
Aleksandr Bezobchuk
faea2f20aa consensus: move pkg to internal 2021-06-03 09:30:44 -04:00
35 changed files with 33 additions and 36 deletions

View File

@@ -32,6 +32,9 @@ Friendly reminder: We have a [bug bounty program](https://hackerone.com/tendermi
- P2P Protocol
- Go API
- [consensus] \#6532 Move the `consensus` package to the `internal` package. (@alexanderbez)
- Remove `ConsensusState()` and `ConsensusReactor()` on the `Node` type.
- Move `consensus` metrics to the root `metrics` package.
- [mempool] \#6529 The `Context` field has been removed from the `TxInfo` type. `CheckTx` now requires a `Context` argument. (@alexanderbez)
- [abci/client, proxy] \#5673 `Async` funcs return an error, `Sync` and `Async` funcs accept `context.Context` (@melekes)
- [p2p] Removed unused function `MakePoWTarget`. (@erikgrinaker)

View File

@@ -3,7 +3,7 @@ package commands
import (
"github.com/spf13/cobra"
"github.com/tendermint/tendermint/consensus"
"github.com/tendermint/tendermint/internal/consensus"
)
// ReplayCmd allows replaying of messages from the WAL.

View File

@@ -24,7 +24,7 @@ import (
"github.com/tendermint/tendermint/abci/example/kvstore"
abci "github.com/tendermint/tendermint/abci/types"
cfg "github.com/tendermint/tendermint/config"
cstypes "github.com/tendermint/tendermint/consensus/types"
cstypes "github.com/tendermint/tendermint/internal/consensus/types"
tmsync "github.com/tendermint/tendermint/internal/libs/sync"
"github.com/tendermint/tendermint/internal/test/factory"
tmbytes "github.com/tendermint/tendermint/libs/bytes"

View File

@@ -4,7 +4,7 @@ import (
"errors"
"fmt"
cstypes "github.com/tendermint/tendermint/consensus/types"
cstypes "github.com/tendermint/tendermint/internal/consensus/types"
"github.com/tendermint/tendermint/libs/bits"
tmjson "github.com/tendermint/tendermint/libs/json"
tmmath "github.com/tendermint/tendermint/libs/math"

View File

@@ -11,9 +11,9 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
cstypes "github.com/tendermint/tendermint/consensus/types"
"github.com/tendermint/tendermint/crypto/merkle"
"github.com/tendermint/tendermint/crypto/tmhash"
cstypes "github.com/tendermint/tendermint/internal/consensus/types"
"github.com/tendermint/tendermint/internal/test/factory"
"github.com/tendermint/tendermint/libs/bits"
"github.com/tendermint/tendermint/libs/bytes"

View File

@@ -6,7 +6,7 @@ import (
"sync"
"time"
cstypes "github.com/tendermint/tendermint/consensus/types"
cstypes "github.com/tendermint/tendermint/internal/consensus/types"
tmsync "github.com/tendermint/tendermint/internal/libs/sync"
"github.com/tendermint/tendermint/libs/bits"
tmjson "github.com/tendermint/tendermint/libs/json"

View File

@@ -4,12 +4,13 @@ import (
"fmt"
"time"
cstypes "github.com/tendermint/tendermint/consensus/types"
cstypes "github.com/tendermint/tendermint/internal/consensus/types"
tmsync "github.com/tendermint/tendermint/internal/libs/sync"
"github.com/tendermint/tendermint/libs/bits"
tmevents "github.com/tendermint/tendermint/libs/events"
"github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/libs/service"
csmetrics "github.com/tendermint/tendermint/metrics/consensus"
"github.com/tendermint/tendermint/p2p"
tmcons "github.com/tendermint/tendermint/proto/tendermint/consensus"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
@@ -104,7 +105,7 @@ type Reactor struct {
state *State
eventBus *types.EventBus
Metrics *Metrics
Metrics *csmetrics.Metrics
mtx tmsync.RWMutex
peers map[p2p.NodeID]*PeerState
@@ -144,7 +145,7 @@ func NewReactor(
state: cs,
waitSync: waitSync,
peers: make(map[p2p.NodeID]*PeerState),
Metrics: NopMetrics(),
Metrics: csmetrics.NopMetrics(),
stateCh: stateCh,
dataCh: dataCh,
voteCh: voteCh,
@@ -252,7 +253,7 @@ func (r *Reactor) WaitSync() bool {
}
// ReactorMetrics sets the reactor's metrics as an option function.
func ReactorMetrics(metrics *Metrics) ReactorOption {
func ReactorMetrics(metrics *csmetrics.Metrics) ReactorOption {
return func(r *Reactor) { r.Metrics = metrics }
}

View File

@@ -13,8 +13,8 @@ import (
"github.com/gogo/protobuf/proto"
cfg "github.com/tendermint/tendermint/config"
cstypes "github.com/tendermint/tendermint/consensus/types"
"github.com/tendermint/tendermint/crypto"
cstypes "github.com/tendermint/tendermint/internal/consensus/types"
"github.com/tendermint/tendermint/internal/libs/fail"
tmsync "github.com/tendermint/tendermint/internal/libs/sync"
tmevents "github.com/tendermint/tendermint/libs/events"
@@ -23,6 +23,7 @@ import (
tmmath "github.com/tendermint/tendermint/libs/math"
tmos "github.com/tendermint/tendermint/libs/os"
"github.com/tendermint/tendermint/libs/service"
csmetrics "github.com/tendermint/tendermint/metrics/consensus"
"github.com/tendermint/tendermint/p2p"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
sm "github.com/tendermint/tendermint/state"
@@ -139,7 +140,7 @@ type State struct {
evsw tmevents.EventSwitch
// for reporting metrics
metrics *Metrics
metrics *csmetrics.Metrics
// wait the channel event happening for shutting down the state gracefully
onStopCh chan *cstypes.RoundState
@@ -172,7 +173,7 @@ func NewState(
wal: nilWAL{},
evpool: evpool,
evsw: tmevents.NewEventSwitch(),
metrics: NopMetrics(),
metrics: csmetrics.NopMetrics(),
onStopCh: make(chan *cstypes.RoundState),
}
@@ -211,7 +212,7 @@ func (cs *State) SetEventBus(b *types.EventBus) {
}
// StateMetrics sets the metrics.
func StateMetrics(metrics *Metrics) StateOption {
func StateMetrics(metrics *csmetrics.Metrics) StateOption {
return func(cs *State) { cs.metrics = metrics }
}

View File

@@ -11,8 +11,8 @@ import (
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/abci/example/counter"
cstypes "github.com/tendermint/tendermint/consensus/types"
"github.com/tendermint/tendermint/crypto/tmhash"
cstypes "github.com/tendermint/tendermint/internal/consensus/types"
"github.com/tendermint/tendermint/libs/log"
tmpubsub "github.com/tendermint/tendermint/libs/pubsub"
tmrand "github.com/tendermint/tendermint/libs/rand"

View File

@@ -12,8 +12,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/consensus/types"
"github.com/tendermint/tendermint/crypto/merkle"
"github.com/tendermint/tendermint/internal/consensus/types"
"github.com/tendermint/tendermint/internal/libs/autofile"
"github.com/tendermint/tendermint/libs/log"
tmtypes "github.com/tendermint/tendermint/types"

View File

@@ -18,9 +18,9 @@ import (
_ "github.com/lib/pq" // provide the psql db driver
abci "github.com/tendermint/tendermint/abci/types"
cfg "github.com/tendermint/tendermint/config"
cs "github.com/tendermint/tendermint/consensus"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/evidence"
cs "github.com/tendermint/tendermint/internal/consensus"
tmjson "github.com/tendermint/tendermint/libs/json"
"github.com/tendermint/tendermint/libs/log"
tmnet "github.com/tendermint/tendermint/libs/net"
@@ -29,6 +29,7 @@ import (
"github.com/tendermint/tendermint/libs/strings"
"github.com/tendermint/tendermint/light"
"github.com/tendermint/tendermint/mempool"
csmetrics "github.com/tendermint/tendermint/metrics/consensus"
"github.com/tendermint/tendermint/p2p"
"github.com/tendermint/tendermint/p2p/pex"
"github.com/tendermint/tendermint/privval"
@@ -985,16 +986,6 @@ func (n *Node) BlockStore() *store.BlockStore {
return n.blockStore
}
// ConsensusState returns the Node's ConsensusState.
func (n *Node) ConsensusState() *cs.State {
return n.consensusState
}
// ConsensusReactor returns the Node's ConsensusReactor.
func (n *Node) ConsensusReactor() *cs.Reactor {
return n.consensusReactor
}
// MempoolReactor returns the Node's mempool reactor.
func (n *Node) MempoolReactor() service.Service {
return n.mempoolReactor
@@ -1152,19 +1143,19 @@ func DefaultGenesisDocProviderFunc(config *cfg.Config) GenesisDocProvider {
type Provider func(*cfg.Config, log.Logger) (*Node, error)
// MetricsProvider returns a consensus, p2p and mempool Metrics.
type MetricsProvider func(chainID string) (*cs.Metrics, *p2p.Metrics, *mempool.Metrics, *sm.Metrics)
type MetricsProvider func(chainID string) (*csmetrics.Metrics, *p2p.Metrics, *mempool.Metrics, *sm.Metrics)
// DefaultMetricsProvider returns Metrics build using Prometheus client library
// if Prometheus is enabled. Otherwise, it returns no-op Metrics.
func DefaultMetricsProvider(config *cfg.InstrumentationConfig) MetricsProvider {
return func(chainID string) (*cs.Metrics, *p2p.Metrics, *mempool.Metrics, *sm.Metrics) {
return func(chainID string) (*csmetrics.Metrics, *p2p.Metrics, *mempool.Metrics, *sm.Metrics) {
if config.Prometheus {
return cs.PrometheusMetrics(config.Namespace, "chain_id", chainID),
return csmetrics.PrometheusMetrics(config.Namespace, "chain_id", chainID),
p2p.PrometheusMetrics(config.Namespace, "chain_id", chainID),
mempool.PrometheusMetrics(config.Namespace, "chain_id", chainID),
sm.PrometheusMetrics(config.Namespace, "chain_id", chainID)
}
return cs.NopMetrics(), p2p.NopMetrics(), mempool.NopMetrics(), sm.NopMetrics()
return csmetrics.NopMetrics(), p2p.NopMetrics(), mempool.NopMetrics(), sm.NopMetrics()
}
}

View File

@@ -17,15 +17,16 @@ import (
bcv0 "github.com/tendermint/tendermint/blockchain/v0"
bcv2 "github.com/tendermint/tendermint/blockchain/v2"
cfg "github.com/tendermint/tendermint/config"
cs "github.com/tendermint/tendermint/consensus"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/evidence"
cs "github.com/tendermint/tendermint/internal/consensus"
"github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/libs/service"
tmstrings "github.com/tendermint/tendermint/libs/strings"
"github.com/tendermint/tendermint/mempool"
mempoolv0 "github.com/tendermint/tendermint/mempool/v0"
mempoolv1 "github.com/tendermint/tendermint/mempool/v1"
csmetrics "github.com/tendermint/tendermint/metrics/consensus"
"github.com/tendermint/tendermint/p2p"
"github.com/tendermint/tendermint/p2p/pex"
protop2p "github.com/tendermint/tendermint/proto/tendermint/p2p"
@@ -381,7 +382,7 @@ func createConsensusReactor(
mp mempool.Mempool,
evidencePool *evidence.Pool,
privValidator types.PrivValidator,
csMetrics *cs.Metrics,
csMetrics *csmetrics.Metrics,
waitSync bool,
eventBus *types.EventBus,
peerManager *p2p.PeerManager,

View File

@@ -1,7 +1,7 @@
package core
import (
cm "github.com/tendermint/tendermint/consensus"
cm "github.com/tendermint/tendermint/internal/consensus"
tmmath "github.com/tendermint/tendermint/libs/math"
ctypes "github.com/tendermint/tendermint/rpc/core/types"
rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"

View File

@@ -6,8 +6,8 @@ import (
"time"
cfg "github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/consensus"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/internal/consensus"
tmjson "github.com/tendermint/tendermint/libs/json"
"github.com/tendermint/tendermint/libs/log"
mempl "github.com/tendermint/tendermint/mempool"

View File

@@ -14,7 +14,7 @@ import (
"os"
"strings"
cs "github.com/tendermint/tendermint/consensus"
cs "github.com/tendermint/tendermint/internal/consensus"
tmjson "github.com/tendermint/tendermint/libs/json"
"github.com/tendermint/tendermint/types"
)

View File

@@ -12,7 +12,7 @@ import (
"io"
"os"
cs "github.com/tendermint/tendermint/consensus"
cs "github.com/tendermint/tendermint/internal/consensus"
tmjson "github.com/tendermint/tendermint/libs/json"
)