Skip to content

Commit

Permalink
Merge branch 'v0.6-dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
shumkov committed Oct 14, 2021
2 parents 99ef5d9 + f199781 commit b766e89
Show file tree
Hide file tree
Showing 85 changed files with 2,185 additions and 687 deletions.
20 changes: 15 additions & 5 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,25 @@ jobs:
with:
go-version: "^1.15.4"
- uses: actions/checkout@v2
- uses: technote-space/get-diff-action@v4
- uses: technote-space/get-diff-action@v5.0.1
with:
PATTERNS: |
**/**.go
go.mod
go.sum
- name: install
run: sudo make install
if: env.GIT_DIFF != ''
- name: build
run: GOOS=linux GOARCH=${{ matrix.goarch }} make build
if: "env.GIT_DIFF != ''"
if: matrix.goarch == 'amd64' && env.GIT_DIFF != ''
- name: build
run: |
sudo apt-get install gcc-arm-linux-gnueabihf g++-8-arm-linux-gnueabihf
export CC=arm-linux-gnueabihf-gcc
export CXX=arm-linux-gnueabihf-g++-8
GOOS=linux GOARCH=${{ matrix.goarch }} sudo make build
if: matrix.goarch == 'arm' && env.GIT_DIFF != ''

tests:
runs-on: ubuntu-latest
Expand All @@ -106,7 +116,7 @@ jobs:
with:
go-version: "^1.15.4"
- uses: actions/checkout@v2
- uses: technote-space/get-diff-action@v4
- uses: technote-space/get-diff-action@v5.0.1
with:
PATTERNS: |
**/**.go
Expand Down Expand Up @@ -144,7 +154,7 @@ jobs:
run: |
echo "::set-output name=hash::$(git --git-dir=third_party/bls-signatures/src/.git rev-parse HEAD)"
shell: bash
- uses: technote-space/get-diff-action@v4
- uses: technote-space/get-diff-action@v5.0.1
with:
PATTERNS: |
**/**.go
Expand All @@ -169,7 +179,7 @@ jobs:
- run: |
cat ./*profile.out | grep -v "mode: atomic" >> coverage.txt
if: env.GIT_DIFF
- uses: codecov/codecov-action@v2.0.2
- uses: codecov/codecov-action@v2.1.0
with:
file: ./coverage.txt
if: env.GIT_DIFF
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set suffix to Docker tags
uses: actions/github-script@v3
uses: actions/github-script@v4.1
id: suffix
with:
result-encoding: string
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
run: |
echo "::set-output name=hash::$(git --git-dir=third_party/bls-signatures/src/.git rev-parse HEAD)"
shell: bash
- uses: technote-space/get-diff-action@v4
- uses: technote-space/get-diff-action@v5.0.1
with:
PATTERNS: |
**/**.go
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
run: |
echo "::set-output name=hash::$(git --git-dir=third_party/bls-signatures/src/.git rev-parse HEAD)"
shell: bash
- uses: technote-space/get-diff-action@v4
- uses: technote-space/get-diff-action@v5.0.1
with:
PATTERNS: |
**/**.go
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
with:
go-version: "^1.15.5"
- uses: actions/checkout@v2
- uses: technote-space/get-diff-action@v4
- uses: technote-space/get-diff-action@v5.0.1
with:
PATTERNS: |
**/**.go
Expand Down Expand Up @@ -95,7 +95,7 @@ jobs:
with:
go-version: "^1.15.5"
- uses: actions/checkout@v2
- uses: technote-space/get-diff-action@v4
- uses: technote-space/get-diff-action@v5.0.1
with:
PATTERNS: |
**/**.go
Expand Down Expand Up @@ -135,7 +135,7 @@ jobs:
with:
go-version: "^1.15.5"
- uses: actions/checkout@v2
- uses: technote-space/get-diff-action@v4
- uses: technote-space/get-diff-action@v5.0.1
with:
PATTERNS: |
**/**.go
Expand Down Expand Up @@ -166,7 +166,7 @@ jobs:
with:
go-version: "^1.15.5"
- uses: actions/checkout@v2
- uses: technote-space/get-diff-action@v4
- uses: technote-space/get-diff-action@v5.0.1
with:
PATTERNS: |
**/**.go
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,4 @@ test/fuzz/**/corpus
test/fuzz/**/crashers
test/fuzz/**/suppressions
test/fuzz/**/*.zip
test/app/grpc_client
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ clean_certs:

format:
find . -name '*.go' -type f -not -path "*.git*" -not -name '*.pb.go' -not -name '*pb_test.go' | xargs gofmt -w -s
find . -name '*.go' -type f -not -path "*.git*" -not -name '*.pb.go' -not -name '*pb_test.go' | xargs golines -w
find . -name '*.go' -type f -not -path "*.git*" -not -name '*.pb.go' -not -name '*pb_test.go' | xargs goimports -w -local ${REPO_NAME}
.PHONY: format

Expand Down
1 change: 1 addition & 0 deletions abci/example/kvstore/kvstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func testKVStore(t *testing.T, app types.Application, tx []byte, key, value stri
Path: "/store",
Data: []byte(key),
})

require.Equal(t, code.CodeTypeOK, resQuery.Code)
require.Equal(t, key, string(resQuery.Key))
require.Equal(t, value, string(resQuery.Value))
Expand Down
9 changes: 5 additions & 4 deletions abci/example/kvstore/persistent_kvstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (
"strconv"
"strings"

"github.com/tendermint/tendermint/crypto"

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"
cryptoenc "github.com/tendermint/tendermint/crypto/encoding"
"github.com/tendermint/tendermint/libs/log"
pc "github.com/tendermint/tendermint/proto/tendermint/crypto"
Expand Down Expand Up @@ -168,8 +168,9 @@ func (app *PersistentKVStoreApplication) BeginBlock(req types.RequestBeginBlock)
}

// Update the validator set
func (app *PersistentKVStoreApplication) EndBlock(req types.RequestEndBlock) types.ResponseEndBlock {
return types.ResponseEndBlock{ValidatorSetUpdate: &app.ValidatorSetUpdates}
func (app *PersistentKVStoreApplication) EndBlock(_ types.RequestEndBlock) types.ResponseEndBlock {
c := proto.Clone(&app.ValidatorSetUpdates).(*types.ValidatorSetUpdate)
return types.ResponseEndBlock{ValidatorSetUpdate: c}
}

func (app *PersistentKVStoreApplication) ListSnapshots(
Expand Down
6 changes: 3 additions & 3 deletions abci/tests/test_cli/ex1.abci.out
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

> commit
-> code: OK
-> data.hex: 0x0000000000000000
-> data.hex: 0x0000000000000000000000000000000000000000000000000000000000000000

> deliver_tx "abc"
-> code: OK
Expand All @@ -22,7 +22,7 @@

> commit
-> code: OK
-> data.hex: 0x0200000000000000
-> data.hex: 0x0200000000000000000000000000000000000000000000000000000000000000

> query "abc"
-> code: OK
Expand All @@ -38,7 +38,7 @@

> commit
-> code: OK
-> data.hex: 0x0400000000000000
-> data.hex: 0x0400000000000000000000000000000000000000000000000000000000000000

> query "def"
-> code: OK
Expand Down
2 changes: 1 addition & 1 deletion blockchain/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestBcStatusResponseMessageValidateBasic(t *testing.T) {
func TestBlockchainMessageVectors(t *testing.T) {
coreChainLock := types.NewMockChainLock(1)

block := types.MakeBlock(int64(3), coreChainLock.CoreBlockHeight, &coreChainLock, []types.Tx{types.Tx("Hello World")}, nil, nil)
block := types.MakeBlock(int64(3), coreChainLock.CoreBlockHeight, &coreChainLock, []types.Tx{types.Tx("Hello World")}, nil, nil, 0)
block.Version.Block = 11 // overwrite updated protocol version

bpb, err := block.ToProto()
Expand Down
82 changes: 63 additions & 19 deletions blockchain/v0/reactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ import (
var config *cfg.Config

func randGenesisDoc(numValidators int) (*types.GenesisDoc, []types.PrivValidator) {
validators, privValidators, quorumHash, thresholdPublicKey := types.GenerateGenesisValidators(numValidators)
validators, privValidators, quorumHash, thresholdPublicKey := types.GenerateGenesisValidators(
numValidators,
)
return &types.GenesisDoc{
GenesisTime: tmtime.Now(),
ChainID: config.ChainID(),
Expand All @@ -43,8 +45,12 @@ type BlockchainReactorPair struct {
app proxy.AppConns
}

func newBlockchainReactor(logger log.Logger, genDoc *types.GenesisDoc, privVals []types.PrivValidator,
maxBlockHeight int64) BlockchainReactorPair {
func newBlockchainReactor(
logger log.Logger,
genDoc *types.GenesisDoc,
privVals []types.PrivValidator,
maxBlockHeight int64,
) BlockchainReactorPair {
if len(privVals) != 1 {
panic("only support one validator")
}
Expand Down Expand Up @@ -79,16 +85,31 @@ func newBlockchainReactor(logger log.Logger, genDoc *types.GenesisDoc, privVals
fastSync := true
db := dbm.NewMemDB()
stateStore = sm.NewStore(db)
blockExec := sm.NewBlockExecutor(stateStore, log.TestingLogger(), proxyApp.Consensus(), proxyApp.Query(),
mock.Mempool{}, sm.EmptyEvidencePool{}, nil)
blockExec := sm.NewBlockExecutor(
stateStore,
log.TestingLogger(),
proxyApp.Consensus(),
proxyApp.Query(),
mock.Mempool{},
sm.EmptyEvidencePool{},
nil,
)

if err = stateStore.Save(state); err != nil {
panic(err)
}

// let's add some blocks in
for blockHeight := int64(1); blockHeight <= maxBlockHeight; blockHeight++ {
lastCommit := types.NewCommit(blockHeight-1, 0, types.BlockID{}, types.StateID{LastAppHash: nil},
nil, nil, nil)
lastCommit := types.NewCommit(
blockHeight-1,
0,
types.BlockID{},
types.StateID{LastAppHash: nil},
nil,
nil,
nil,
)
if blockHeight > 1 {
lastBlockMeta := blockStore.LoadBlockMeta(blockHeight - 1)
lastBlock := blockStore.LoadBlock(blockHeight - 1)
Expand Down Expand Up @@ -206,7 +227,12 @@ func TestBadBlockStopsPeer(t *testing.T) {

// Other chain needs a different validator set
otherGenDoc, otherPrivVals := randGenesisDoc(1)
otherChain := newBlockchainReactor(log.TestingLogger(), otherGenDoc, otherPrivVals, maxBlockHeight)
otherChain := newBlockchainReactor(
log.TestingLogger(),
otherGenDoc,
otherPrivVals,
maxBlockHeight,
)

defer func() {
err := otherChain.reactor.Stop()
Expand All @@ -230,11 +256,16 @@ func TestBadBlockStopsPeer(t *testing.T) {
nodeProTxHashes[2] = &proTxHash
nodeProTxHashes[3] = &proTxHash

switches := p2p.MakeConnectedSwitches(config.P2P, nodeProTxHashes, func(i int, s *p2p.Switch) *p2p.Switch {
s.AddReactor("BLOCKCHAIN", reactorPairs[i].reactor)
return s
switches := p2p.MakeConnectedSwitches(
config.P2P,
nodeProTxHashes,
func(i int, s *p2p.Switch) *p2p.Switch {
s.AddReactor("BLOCKCHAIN", reactorPairs[i].reactor)
return s

}, p2p.Connect2Switches)
},
p2p.Connect2Switches,
)

defer func() {
for _, r := range reactorPairs {
Expand Down Expand Up @@ -274,17 +305,23 @@ func TestBadBlockStopsPeer(t *testing.T) {

switches = append(
switches,
p2p.MakeConnectedSwitches(config.P2P, nodeProTxHashes, func(i int, s *p2p.Switch) *p2p.Switch {
s.AddReactor("BLOCKCHAIN", reactorPairs[len(reactorPairs)-1].reactor)
return s
}, p2p.Connect2Switches)...)
p2p.MakeConnectedSwitches(
config.P2P,
nodeProTxHashes,
func(i int, s *p2p.Switch) *p2p.Switch {
s.AddReactor("BLOCKCHAIN", reactorPairs[len(reactorPairs)-1].reactor)
return s
},
p2p.Connect2Switches,
)...)

for i := 0; i < len(reactorPairs)-1; i++ {
p2p.Connect2Switches(switches, i, len(reactorPairs)-1)
}

for {
if lastReactorPair.reactor.pool.IsCaughtUp() || lastReactorPair.reactor.Switch.Peers().Size() == 0 {
if lastReactorPair.reactor.pool.IsCaughtUp() ||
lastReactorPair.reactor.Switch.Peers().Size() == 0 {
break
}

Expand All @@ -306,8 +343,15 @@ func makeTxs(height int64) (txs []types.Tx) {

func makeBlock(height int64, coreChainLock *types.CoreChainLock, state sm.State,
lastCommit *types.Commit) *types.Block {
block, _ := state.MakeBlock(height, coreChainLock, makeTxs(height), lastCommit,
nil, state.Validators.GetProposer().ProTxHash)
block, _ := state.MakeBlock(
height,
coreChainLock,
makeTxs(height),
lastCommit,
nil,
state.Validators.GetProposer().ProTxHash,
0,
)
return block
}

Expand Down
11 changes: 9 additions & 2 deletions blockchain/v1/peer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,13 @@ func checkByStoppingPeerTimer(t *testing.T, peer *BpPeer, running bool) {
func makeSmallBlock(height int) *types.Block {
coreChainLock := types.NewMockChainLock(1)

return types.MakeBlock(int64(height), coreChainLock.CoreBlockHeight, &coreChainLock,
[]types.Tx{types.Tx("foo")}, nil, nil)
return types.MakeBlock(
int64(height),
coreChainLock.CoreBlockHeight,
&coreChainLock,
[]types.Tx{types.Tx("foo")},
nil,
nil,
0,
)
}
Loading

0 comments on commit b766e89

Please sign in to comment.