Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 15ee704d9ffafa586be3ac1c889ee74dea7f3192
Author: Cong Zhao <zhaocong89@gmail.com>
Date:   Wed Jan 30 20:54:34 2019 +0800

    tendermint#121 second iteration

commit cd8a777a9659627feffabd61552535aaf2af8bb1
Author: Cong Zhao <zhaocong89@gmail.com>
Date:   Thu Dec 13 15:24:08 2018 +0800

    tendermint#121 state sync mode

commit 53e8710
Merge: 3f17d89 551d864
Author: cong <ackratos@users.noreply.github.com>
Date:   Mon Dec 24 10:19:23 2018 +0800

    Merge pull request tendermint#19 from BiJie/sentry

    [R4R]fix sentry node replay faild

commit 551d864
Author: fudongbai <296179868@qq.com>
Date:   Mon Dec 24 10:06:49 2018 +0800

    fix sentry node replay faild

commit 3f17d89
Merge: 93d3b62 ddeee6c
Author: zjubfd <baifudong@lancai.cn>
Date:   Mon Dec 17 15:16:46 2018 +0800

    Merge pull request tendermint#18 from BiJie/nostate

    [R4R]validator do not verify hash when with no state

commit 93d3b62
Merge: a1ad253 dbeddbc
Author: zjubfd <baifudong@lancai.cn>
Date:   Mon Dec 17 15:16:32 2018 +0800

    Merge pull request tendermint#17 from BiJie/idmissing

    [R4R]fix reconnect id missing  ,resolve tendermint#16

commit ddeee6c
Author: fudongbai <296179868@qq.com>
Date:   Mon Dec 17 15:00:46 2018 +0800

    validator do not verify hash when with no state

commit dbeddbc
Author: fudongbai <296179868@qq.com>
Date:   Fri Dec 14 16:19:12 2018 +0800

    fix reconnect id missing

commit a1ad253
Merge: 451a393 a561225
Author: cong <ackratos@users.noreply.github.com>
Date:   Fri Nov 30 15:07:50 2018 +0800

    Merge pull request tendermint#13 from BiJie/issue_262_pagination_testfix

    [R4R] tendermint#262 Fix tx search pagination test case

commit a561225
Author: Cong Zhao <zhaocong89@gmail.com>
Date:   Fri Nov 30 15:05:03 2018 +0800

    tendermint#262 Fix tx search pagination test case

commit 451a393
Merge: d345772 44fcecc
Author: zjubfd <baifudong@lancai.cn>
Date:   Fri Nov 30 14:04:58 2018 +0800

    Merge pull request tendermint#8 from BiJie/sentrynode

    [R4R]support Sentry Node, add simple blockexecutor and  restrictPeers config param#7

commit 44fcecc
Author: fudongbai <296179868@qq.com>
Date:   Wed Nov 28 16:58:20 2018 +0800

    add withAppStat param

commit d345772
Merge: 4f6dfec 0f8d95e
Author: cong <ackratos@users.noreply.github.com>
Date:   Tue Nov 27 13:41:23 2018 +0800

    Merge pull request tendermint#12 from BiJie/issue262_pagination

    [R4R] tendermint#262 Fix tx search pagination

commit 0f8d95e
Author: Cong Zhao <zhaocong89@gmail.com>
Date:   Mon Nov 26 10:48:39 2018 +0800

    tendermint#262 Fix tx search pagination

commit 4f6dfec
Merge: 6fad36f 2367603
Author: cong <ackratos@users.noreply.github.com>
Date:   Fri Nov 23 10:15:15 2018 +0800

    Merge pull request tendermint#11 from BiJie/BlockTimeIota_config_fix

    disable BlockTimeIota

commit 2367603
Author: Cong Zhao <zhaocong89@gmail.com>
Date:   Wed Nov 21 21:27:35 2018 +0800

    disable BlockTimeIota

commit 6fad36f
Merge: 759be18 74ced3b
Author: danliu <savyen@hotmail.com>
Date:   Wed Nov 21 15:19:51 2018 +0800

    Merge pull request tendermint#10 from BiJie/feature/fix_test

    fix mempool test

commit 74ced3b
Author: yutianwu <wzxingbupt@gmail.com>
Date:   Wed Nov 21 15:15:38 2018 +0800

    fix mempool test

commit 759be18
Merge: cf1745a ed87b99
Author: danliu <savyen@hotmail.com>
Date:   Wed Nov 21 15:01:36 2018 +0800

    Merge pull request tendermint#9 from BiJie/feature/change_default_params

    R4R: Change default params

commit ed87b99
Author: yutianwu <wzxingbupt@gmail.com>
Date:   Wed Nov 21 11:11:47 2018 +0800

    update comments

commit 15475b4
Author: yutianwu <wzxingbupt@gmail.com>
Date:   Wed Nov 21 11:08:37 2018 +0800

    change default params

commit cf1745a
Merge: 038d87b d5b5ea8
Author: danliu <savyen@hotmail.com>
Date:   Thu Nov 15 19:05:38 2018 +0800

    Merge pull request tendermint#6 from BiJie/issue_bc280

    Make mempool reactor handles received msg asynchronously

commit d5b5ea8
Author: danliu <danliu@localhost.localdomain>
Date:   Thu Nov 15 16:27:24 2018 +0800

    Make mempool reactor handles received msg asynchronously

commit 038d87b
Merge: 3821815 2363a81
Author: danliu <savyen@hotmail.com>
Date:   Wed Nov 14 16:05:35 2018 +0800

    Merge pull request tendermint#5 from BiJie/dependency-fix

    fix client_golang and go-metrics dependency

commit 2363a81
Author: Cong Zhao <zhaocong89@gmail.com>
Date:   Sat Nov 10 17:24:02 2018 +0800

    fix client_golang and go-metrics dependency

commit 3821815
Merge: 90eda9b 1701b9c
Author: danliu <savyen@hotmail.com>
Date:   Thu Nov 8 19:17:01 2018 +0800

    Merge pull request tendermint#3 from BiJie/issue_bc218

    Add priority lock for CheckTx in mempool and ReCheck ABCI interface

commit 1701b9c
Author: danliu <danliu@localhost.localdomain>
Date:   Thu Nov 8 16:11:17 2018 +0800

    Add priority lock for CheckTx in mempool and ReCheck ABCI interface

commit 90eda9b
Author: Ethan Buchman <ethan@coinculture.info>
Date:   Wed Oct 17 22:09:48 2018 -0400

    changelog and version

commit 1ad379a
Author: Alessio Treglia <quadrispro@ubuntu.com>
Date:   Wed Oct 17 18:55:23 2018 -0700

    Update CHANGELOG_PENDING.md

commit 7220167
Author: Anton Kaliaev <anton.kalyaev@gmail.com>
Date:   Mon Oct 15 06:28:41 2018 +0400

    set next validators along with validators while replay (tendermint#2637)

    Closes tendermint#2634

commit adf8cea
Author: Alessio Treglia <quadrispro@ubuntu.com>
Date:   Thu Oct 11 20:37:21 2018 -0700

    Pass nil to NewValidatorSet() when genesis file's Validators field is nil (tendermint#2617)

    Closes: tendermint#2616
  • Loading branch information
ackratos committed Feb 27, 2019
1 parent 0c3e7bc commit 0f8a6c4
Show file tree
Hide file tree
Showing 25 changed files with 1,014 additions and 15 deletions.
6 changes: 6 additions & 0 deletions abci/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ type Client interface {
InitChainSync(types.RequestInitChain) (*types.ResponseInitChain, error)
BeginBlockSync(types.RequestBeginBlock) (*types.ResponseBeginBlock, error)
EndBlockSync(types.RequestEndBlock) (*types.ResponseEndBlock, error)

LatestSnapshot() (height int64, numKeys int64, err error)
ReadSnapshotChunk(height int64, startIndex, endIndex int64) (chunk [][]byte, err error)
StartRecovery(height int64, numKeys int64) error
WriteRecoveryChunk(chunk [][]byte) error
EndRecovery(height int64) error
}

//----------------------------------------
Expand Down
16 changes: 16 additions & 0 deletions abci/client/grpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,3 +308,19 @@ func (cli *grpcClient) EndBlockSync(params types.RequestEndBlock) (*types.Respon
reqres := cli.EndBlockAsync(params)
return reqres.Response.GetEndBlock(), cli.Error()
}

func (cli *grpcClient) LatestSnapshot() (height int64, numKeys int64, err error) {
return 0, 0, nil
}
func (cli *grpcClient) ReadSnapshotChunk(height int64, startIndex, endIndex int64) (chunk [][]byte, err error) {
return make([][]byte, 0), nil
}
func (cli *grpcClient) StartRecovery(height int64, numKeys int64) error {
return nil
}
func (cli *grpcClient) WriteRecoveryChunk(chunk [][]byte) error {
return nil
}
func (cli *grpcClient) EndRecovery(height int64) error {
return nil
}
32 changes: 32 additions & 0 deletions abci/client/local_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ func (app *localClient) ReCheckTxAsync(tx []byte) *ReqRes {
)
}

func (app *localClient) ReCheckTxAsync(tx []byte) *ReqRes {
app.mtx.Lock()
res := app.Application.ReCheckTx(tx)
app.mtx.Unlock()
return app.callback(
types.ToRequestCheckTx(tx),
types.ToResponseCheckTx(res),
)
}

func (app *localClient) QueryAsync(req types.RequestQuery) *ReqRes {
app.mtx.Lock()
defer app.mtx.Unlock()
Expand Down Expand Up @@ -168,6 +178,28 @@ func (app *localClient) EndBlockAsync(req types.RequestEndBlock) *ReqRes {
)
}

func (app *localClient) LatestSnapshot() (height int64, numKeys int64, err error) {
app.mtx.Lock()
defer app.mtx.Unlock()
return app.Application.LatestSnapshot()
}

func (app *localClient) ReadSnapshotChunk(height int64, startIndex, endIndex int64) (chunk [][]byte, err error) {
return app.Application.ReadSnapshotChunk(height, startIndex, endIndex)
}

func (app *localClient) StartRecovery(height int64, numKeys int64) error {
return app.Application.StartRecovery(height, numKeys)
}

func (app *localClient) WriteRecoveryChunk(chunk [][]byte) error {
return app.Application.WriteRecoveryChunk(chunk)
}

func (app *localClient) EndRecovery(height int64) error {
return app.Application.EndRecovery(height)
}

//-------------------------------------------------------

func (app *localClient) FlushSync() error {
Expand Down
18 changes: 18 additions & 0 deletions abci/client/socket_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,24 @@ func (cli *socketClient) EndBlockSync(req types.RequestEndBlock) (*types.Respons

//----------------------------------------

func (cli *socketClient) LatestSnapshot() (height int64, numKeys int64, err error) {
return 0, 0, nil
}
func (cli *socketClient) ReadSnapshotChunk(height int64, startIndex, endIndex int64) (chunk [][]byte, err error) {
return make([][]byte, 0), nil
}
func (cli *socketClient) StartRecovery(height int64, numKeys int64) error {
return nil
}
func (cli *socketClient) WriteRecoveryChunk(chunk [][]byte) error {
return nil
}
func (cli *socketClient) EndRecovery(height int64) error {
return nil
}

//----------------------------------------

func (cli *socketClient) queueRequest(req *types.Request) *ReqRes {
reqres := NewReqRes(req)

Expand Down
20 changes: 20 additions & 0 deletions abci/example/kvstore/persistent_kvstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,26 @@ func (app *PersistentKVStoreApplication) EndBlock(req types.RequestEndBlock) typ
return types.ResponseEndBlock{ValidatorUpdates: app.ValUpdates}
}

func (app *PersistentKVStoreApplication) LatestSnapshot() (height int64, numKeys int64, err error) {
return 0, 0, nil
}

func (app *PersistentKVStoreApplication) ReadSnapshotChunk(height int64, startIndex, endIndex int64) (chunk [][]byte, err error) {
return make([][]byte, 0), nil
}

func (app *PersistentKVStoreApplication) StartRecovery(height int64, numKeys int64) error {
return nil
}

func (app *PersistentKVStoreApplication) WriteRecoveryChunk(chunk [][]byte) error {
return nil
}

func (app *PersistentKVStoreApplication) EndRecovery(height int64) error {
return nil
}

//---------------------------------------------
// update validators

Expand Down
47 changes: 47 additions & 0 deletions abci/types/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ type Application interface {
DeliverTx(tx []byte) ResponseDeliverTx // Deliver a tx for full processing
EndBlock(RequestEndBlock) ResponseEndBlock // Signals the end of a block, returns changes to the validator set
Commit() ResponseCommit // Commit the state and return the application Merkle root hash

// State Connection
LatestSnapshot() (height int64, numKeys int64, err error) // query application state height and numOfKeys
ReadSnapshotChunk(height int64, startIndex, endIndex int64) (chunk [][]byte, err error)
StartRecovery(height int64, numKeys int64) error
WriteRecoveryChunk(chunk [][]byte) error
EndRecovery(height int64) error
}

//-------------------------------------------------------
Expand Down Expand Up @@ -78,6 +85,26 @@ func (BaseApplication) EndBlock(req RequestEndBlock) ResponseEndBlock {
return ResponseEndBlock{}
}

func (BaseApplication) LatestSnapshot() (height int64, numKeys int64, err error) {
return 0, 0, nil
}

func (BaseApplication) ReadSnapshotChunk(height int64, startIndex, endIndex int64) (chunk [][]byte, err error) {
return make([][]byte, 0), nil
}

func (BaseApplication) StartRecovery(height int64, numKeys int64) error {
return nil
}

func (BaseApplication) WriteRecoveryChunk(chunk [][]byte) error {
return nil
}

func (BaseApplication) EndRecovery(height int64) error {
return nil
}

//-------------------------------------------------------

// GRPCApplication is a GRPC wrapper for Application
Expand Down Expand Up @@ -141,3 +168,23 @@ func (app *GRPCApplication) EndBlock(ctx context.Context, req *RequestEndBlock)
res := app.app.EndBlock(*req)
return &res, nil
}

func (app *GRPCApplication) LatestSnapshot() (height int64, numKeys map[string]int64, err error) {
return 0, make(map[string]int64), nil
}

func (app *GRPCApplication) ReadSnapshotChunk(height int64, startIndex, endIndex int64) (chunk map[string][][]byte, err error) {
return make(map[string][][]byte, 0), nil
}

func (app *GRPCApplication) StartRecovery(height int64, numKeys map[string]int64) error {
return nil
}

func (app *GRPCApplication) WriteRecoveryChunk(storeName string, chunk [][]byte) error {
return nil
}

func (app *GRPCApplication) EndRecovery(height int64) error {
return nil
}
20 changes: 19 additions & 1 deletion blockchain/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,23 @@ func (bcR *BlockchainReactor) OnStop() {
bcR.pool.Stop()
}

// SwitchToBlockchain switches from fastest_sync mode to blockchain mode.
// It resets the state, turns off fastest_sync, and starts the blockchain state-machine
func (bcR *BlockchainReactor) SwitchToBlockchain(state sm.State) {
bcR.Logger.Info("SwitchToBlockchain")
bcR.initialState = state

bcR.fastSync = true
bcR.pool.height = state.LastBlockHeight + 1
err := bcR.pool.Start()
fmt.Printf("state lastheight: %d, apphash: %X\n", state.LastBlockHeight, state.AppHash)
if err != nil {
bcR.Logger.Error("Error starting blockchainReactor", "err", err)
return
}
go bcR.poolRoutine()
}

// GetChannels implements Reactor
func (bcR *BlockchainReactor) GetChannels() []*p2p.ChannelDescriptor {
return []*p2p.ChannelDescriptor{
Expand Down Expand Up @@ -260,7 +277,7 @@ FOR_LOOP:
outbound, inbound, _ := bcR.Switch.NumPeers()
bcR.Logger.Debug("Consensus ticker", "numPending", numPending, "total", lenRequesters,
"outbound", outbound, "inbound", inbound)
if bcR.pool.IsCaughtUp() {
if bcR.pool.IsCaughtUp() && blocksSynced > 0 {
bcR.Logger.Info("Time to switch to consensus reactor!", "height", height)
bcR.pool.Stop()

Expand Down Expand Up @@ -335,6 +352,7 @@ FOR_LOOP:
// TODO: same thing for app - but we would need a way to
// get the hash without persisting the state
var err error
fmt.Printf("state lastheight: %d, apphash: %X\n", state.LastBlockHeight, state.AppHash)
state, err = bcR.blockExec.ApplyBlock(state, firstID, first)
if err != nil {
// TODO This is bad, are we zombie?
Expand Down

0 comments on commit 0f8a6c4

Please sign in to comment.