Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/v0.8-dev' into backport-0.7-to-0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
lklimek committed Feb 15, 2022
2 parents 1cdda70 + 1dd7819 commit 009ced9
Show file tree
Hide file tree
Showing 66 changed files with 243 additions and 348 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ jobs:
**/**.go
go.mod
go.sum
- name: post-setup go 1.17
run: |
sudo mv /bin/go /bin/go-old
sudo ln -s "$GOROOT/bin/go" /bin/go
- name: install
run: sudo make install
if: env.GIT_DIFF != ''
- name: build
run: GOOS=linux GOARCH=${{ matrix.goarch }} make build
if: matrix.goarch == 'amd64' && env.GIT_DIFF != ''
Expand Down
5 changes: 1 addition & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ linters:
- govet
- ineffassign
# - interfacer
- lll
# - lll
# - maligned
- misspell
- nakedret
Expand All @@ -46,9 +46,6 @@ issues:
- path: _test\.go
linters:
- gosec
- linters:
- lll
source: "https://"
max-same-issues: 50

linters-settings:
Expand Down
2 changes: 1 addition & 1 deletion abci/example/kvstore/persistent_kvstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"strconv"
"strings"

"github.com/gogo/protobuf/proto"
dbm "github.com/tendermint/tm-db"

"github.com/gogo/protobuf/proto"
"github.com/tendermint/tendermint/abci/example/code"
"github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto"
Expand Down
2 changes: 1 addition & 1 deletion cmd/tenderdash/commands/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/tendermint/tendermint/types"
)

// InitFilesCmd initialises a fresh Tendermint Core instance.
// InitFilesCmd initializes a fresh Tendermint Core instance.
var InitFilesCmd = &cobra.Command{
Use: "init [full|validator|seed|single]",
Short: "Initializes a Tenderdash node",
Expand Down
8 changes: 4 additions & 4 deletions crypto/xchacha20poly1305/xchachapoly_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ func TestRandom(t *testing.T) {
plaintext := make([]byte, pl)
_, err := crand.Read(key[:])
if err != nil {
t.Errorf("error on read: %w", err)
t.Errorf("error on read: %v", err)
}
_, err = crand.Read(nonce[:])
if err != nil {
t.Errorf("error on read: %w", err)
t.Errorf("error on read: %v", err)
}
_, err = crand.Read(ad)
if err != nil {
t.Errorf("error on read: %w", err)
t.Errorf("error on read: %v", err)
}
_, err = crand.Read(plaintext)
if err != nil {
t.Errorf("error on read: %w", err)
t.Errorf("error on read: %v", err)
}

aead, err := New(key[:])
Expand Down
5 changes: 3 additions & 2 deletions dash/quorum/validator_conn_executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
dbm "github.com/tendermint/tm-db"

abciclient "github.com/tendermint/tendermint/abci/client"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto"
Expand All @@ -22,7 +24,6 @@ import (
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
"github.com/tendermint/tendermint/types"
dbm "github.com/tendermint/tm-db"
)

const (
Expand Down Expand Up @@ -358,7 +359,7 @@ func TestEndBlock(t *testing.T) {
defer proxyApp.Stop() //nolint:errcheck // ignore for tests

state, stateDB, _ := makeState(3, 1)
nodeProTxHash := &state.Validators.Validators[0].ProTxHash
nodeProTxHash := state.Validators.Validators[0].ProTxHash
stateStore := sm.NewStore(stateDB)
blockStore := store.NewBlockStore(dbm.NewMemDB())

Expand Down
6 changes: 3 additions & 3 deletions internal/blocksync/v0/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package v0

import (
"fmt"
"github.com/tendermint/tendermint/crypto"
"runtime/debug"
"sync"
"time"

"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/internal/blocksync"
"github.com/tendermint/tendermint/internal/consensus"
"github.com/tendermint/tendermint/internal/p2p"
Expand Down Expand Up @@ -112,7 +112,7 @@ type Reactor struct {

syncStartTime time.Time

nodeProTxHash *types.ProTxHash
nodeProTxHash types.ProTxHash
}

// NewReactor returns new reactor instance.
Expand All @@ -121,7 +121,7 @@ func NewReactor(
state sm.State,
blockExec *sm.BlockExecutor,
store *store.BlockStore,
nodeProTxHash *crypto.ProTxHash,
nodeProTxHash crypto.ProTxHash,
consReactor consensusReactor,
blockSyncCh *p2p.Channel,
peerUpdates *p2p.PeerUpdates,
Expand Down
4 changes: 2 additions & 2 deletions internal/blocksync/v2/processor_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ type processorContext interface {

type pContext struct {
store blockStore
nodeProTxHash *crypto.ProTxHash
nodeProTxHash crypto.ProTxHash
applier blockApplier
state state.State
metrics *consensus.Metrics
}

func newProcessorContext(st blockStore, nodeProTxHash *crypto.ProTxHash, ex blockApplier, s state.State, m *consensus.Metrics) *pContext {
func newProcessorContext(st blockStore, nodeProTxHash crypto.ProTxHash, ex blockApplier, s state.State, m *consensus.Metrics) *pContext {
return &pContext{
store: st,
nodeProTxHash: nodeProTxHash,
Expand Down
6 changes: 3 additions & 3 deletions internal/blocksync/v2/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ type BlockchainReactor struct {
type blockApplier interface {
ApplyBlock(
state state.State,
nodeProTxHash *crypto.ProTxHash,
nodeProTxHash crypto.ProTxHash,
blockID types.BlockID,
block *types.Block,
) (state.State, error)
}

// XXX: unify naming in this package around tmState
func newReactor(state state.State, nodeProTxHash *crypto.ProTxHash, store blockStore, reporter behavior.Reporter,
func newReactor(state state.State, nodeProTxHash crypto.ProTxHash, store blockStore, reporter behavior.Reporter,
blockApplier blockApplier, blockSync bool, metrics *consensus.Metrics) *BlockchainReactor {
initHeight := state.LastBlockHeight + 1
if initHeight == 1 {
Expand Down Expand Up @@ -96,7 +96,7 @@ func NewBlockchainReactor(
state state.State,
blockApplier blockApplier,
store blockStore,
nodeProTxHash *crypto.ProTxHash,
nodeProTxHash crypto.ProTxHash,
blockSync bool,
metrics *consensus.Metrics) *BlockchainReactor {
reporter := behavior.NewMockReporter()
Expand Down
6 changes: 3 additions & 3 deletions internal/blocksync/v2/reactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ type mockBlockApplier struct {

// XXX: Add whitelist/blacklist?
func (mba *mockBlockApplier) ApplyBlock(
state sm.State, nodeProTxHash *crypto.ProTxHash, blockID types.BlockID, block *types.Block,
state sm.State, nodeProTxHash crypto.ProTxHash, blockID types.BlockID, block *types.Block,
) (sm.State, error) {
state.LastBlockHeight++
return state, nil
Expand Down Expand Up @@ -177,7 +177,7 @@ func newTestReactor(t *testing.T, p testReactorParams) *BlockchainReactor {
require.NoError(t, err)
}
proTxHash := crypto.RandProTxHash()
r := newReactor(state, &proTxHash, store, reporter, appl, true, consensus.NopMetrics())
r := newReactor(state, proTxHash, store, reporter, appl, true, consensus.NopMetrics())
logger := log.TestingLogger()
r.SetLogger(logger.With("module", "blockchain"))

Expand Down Expand Up @@ -531,7 +531,7 @@ func newReactorStore(
proTxHash, err := privVals[0].GetProTxHash(context.Background())
require.NoError(t, err)

state, err = blockExec.ApplyBlock(state, &proTxHash, blockID, thisBlock)
state, err = blockExec.ApplyBlock(state, proTxHash, blockID, thisBlock)
require.NoError(t, err)

blockStore.SaveBlock(thisBlock, thisParts, lastCommit)
Expand Down
26 changes: 3 additions & 23 deletions internal/consensus/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
"bytes"
"context"
"fmt"
abcicli "github.com/tendermint/tendermint/abci/client"
"github.com/tendermint/tendermint/internal/p2p"
"io"
"io/ioutil"
"os"
Expand All @@ -18,16 +16,15 @@ import (
"time"

"github.com/dashevo/dashd-go/btcjson"

"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/bls12381"

"github.com/stretchr/testify/require"
dbm "github.com/tendermint/tm-db"

abcicli "github.com/tendermint/tendermint/abci/client"
"github.com/tendermint/tendermint/abci/example/kvstore"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/bls12381"
cstypes "github.com/tendermint/tendermint/internal/consensus/types"
tmsync "github.com/tendermint/tendermint/internal/libs/sync"
mempoolv0 "github.com/tendermint/tendermint/internal/mempool/v0"
Expand Down Expand Up @@ -1033,15 +1030,6 @@ func randConsensusNetWithPeers(
}
}

func getSwitchIndex(switches []*p2p.Switch, peer p2p.Peer) int {
for i, s := range switches {
if peer.NodeInfo().ID() == s.NodeInfo().ID() {
return i
}
}
panic("didnt find peer in switches")
}

//-------------------------------------------------------------------------------
// genesis

Expand Down Expand Up @@ -1096,14 +1084,6 @@ func (m *mockTicker) Chan() <-chan timeoutInfo {

func (*mockTicker) SetLogger(log.Logger) {}

func newPersistentKVStore() abci.Application {
dir, err := ioutil.TempDir("", "persistent-kvstore")
if err != nil {
panic(err)
}
return kvstore.NewPersistentKVStoreApplication(dir)
}

func newKVStore() abci.Application {
return kvstore.NewApplication()
}
Expand Down
5 changes: 2 additions & 3 deletions internal/consensus/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ import (
"testing"
"time"

"github.com/tendermint/tendermint/crypto"

"github.com/gogo/protobuf/proto"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/merkle"
"github.com/tendermint/tendermint/crypto/tmhash"
cstypes "github.com/tendermint/tendermint/internal/consensus/types"
Expand Down Expand Up @@ -81,7 +80,7 @@ func TestMsgToProto(t *testing.T) {
2,
types.BlockID{},
types.StateID{},
)
)
require.NoError(t, err)
pbVote := vote.ToProto()

Expand Down
11 changes: 10 additions & 1 deletion internal/consensus/peer_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,15 @@ func (ps *PeerState) SetHasCommit(commit *types.Commit) {
ps.mtx.Lock()
defer ps.mtx.Unlock()

ps.logger.
With(
"height", commit.Height,
"round", commit.Round,
"peer_height", ps.PRS.Height,
"peer_round", ps.PRS.Round,
).
Debug("setHasCommit")

ps.setHasCommit(commit.Height, commit.Round)

if ps.PRS.Height < commit.Height || (ps.PRS.Height == commit.Height && ps.PRS.Round < commit.Round) {
Expand Down Expand Up @@ -480,7 +489,7 @@ func (ps *PeerState) ApplyNewRoundStepMessage(msg *NewRoundStepMessage) {
// shift Precommits to LastCommit
if psHeight+1 == msg.Height && psRound == msg.LastCommitRound {
ps.PRS.LastCommitRound = msg.LastCommitRound
ps.PRS.LastPrecommits = ps.PRS.Precommits
ps.PRS.LastPrecommits = ps.PRS.Precommits.Copy()
} else {
ps.PRS.LastCommitRound = msg.LastCommitRound
ps.PRS.LastPrecommits = nil
Expand Down
39 changes: 12 additions & 27 deletions internal/consensus/reactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"time"

"github.com/fortytw2/leaktest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
dbm "github.com/tendermint/tm-db"
Expand Down Expand Up @@ -603,7 +604,7 @@ func TestReactorValidatorSetChanges(t *testing.T) {
// it includes the commit for block 4, which should have the updated validator set
waitForBlockWithUpdatedValsAndValidateIt(t, nPeers, addOneVal.quorumHash, blocksSubs, states)

validate(states)
validate(t, states)

waitForAndValidateBlock(t, nPeers, activeVals, blocksSubs, states, addTwoVals.txs...)
waitForAndValidateBlockWithTx(t, nPeers, activeVals, blocksSubs, states, addTwoVals.txs...)
Expand All @@ -614,15 +615,15 @@ func TestReactorValidatorSetChanges(t *testing.T) {

waitForBlockWithUpdatedValsAndValidateIt(t, nPeers, addTwoVals.quorumHash, blocksSubs, states)

validate(states)
validate(t, states)

waitForAndValidateBlock(t, nPeers, activeVals, blocksSubs, states, removeTwoVals.txs...)
waitForAndValidateBlockWithTx(t, nPeers, activeVals, blocksSubs, states, removeTwoVals.txs...)
waitForAndValidateBlock(t, nPeers, activeVals, blocksSubs, states)

waitForBlockWithUpdatedValsAndValidateIt(t, nPeers, removeTwoVals.quorumHash, blocksSubs, states)

validate(states)
validate(t, states)
}

func makeProTxHashMap(proTxHashes []crypto.ProTxHash) map[string]struct{} {
Expand Down Expand Up @@ -754,31 +755,15 @@ func generatePrivValUpdate(proTxHashes []crypto.ProTxHash) (*privValUpdate, erro
return &privVal, nil
}

func validate(states []*State) {
currValidatorCount := len(states[0].Validators.Validators)
currValidators := states[0].Validators
currHeight, _ := states[0].GetValidators()
height, validators := states[0].GetValidatorSet()
if height != currHeight {
panic("they should all have the same heights")
}
if len(validators.Validators) != currValidatorCount {
panic("they should all have the same initial validator count")
}
if !currValidators.Equals(validators) {
panic("all validators should be the same")
}
func validate(t *testing.T, states []*State) {

currHeight, currValidators := states[0].GetValidatorSet()
currValidatorCount := currValidators.Size()

for _, state := range states {
for validatorID, state := range states {
height, validators := state.GetValidatorSet()
if height != currHeight {
panic("they should all have the same heights")
}
if len(validators.Validators) != currValidatorCount {
panic("they should all have the same initial validator count")
}
if !currValidators.Equals(validators) {
panic("all validators should be the same")
}
assert.Equal(t, currHeight, height, "validator_id=%d", validatorID)
assert.Equal(t, currValidatorCount, len(validators.Validators), "validator_id=%d", validatorID)
assert.True(t, currValidators.Equals(validators), "validator_id=%d", validatorID)
}
}
Loading

0 comments on commit 009ced9

Please sign in to comment.