Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
Merge pull request #147 from binance-chain/no_panic
Browse files Browse the repository at this point in the history
[R4R]fix not panic when do not have block under state sync
  • Loading branch information
unclezoro authored Jul 27, 2020
2 parents e8c83b9 + 23aa6c5 commit 40a8c51
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# Changelog

## v0.32.3-binance.3
- [sync] [\#147](https://github.com/binance-chain/bnc-tendermint/pull/147) fix not panic when do not have block under state sync

## v0.32.3-binance.2
### BUG FIXES:
- [status] [\#140](https://github.com/binance-chain/bnc-tendermint/pull/140) fix hot sync not a catched up status
- [consensus] [\#140](https://github.com/binance-chain/bnc-tendermint/pull/141) fix bug in load last validator set
- [index] [\#140](https://github.com/binance-chain/bnc-tendermint/pull/142) fix index height can not set after state sync
- [consensus] [\#141](https://github.com/binance-chain/bnc-tendermint/pull/141) fix bug in load last validator set
- [index] [\#142](https://github.com/binance-chain/bnc-tendermint/pull/142) fix index height can not set after state sync

## v0.32.3-binance.1

Expand Down
4 changes: 2 additions & 2 deletions consensus/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,8 @@ OUTER_LOOP:
if prs.ProposalBlockParts == nil {
blockMeta := conR.conS.blockStore.LoadBlockMeta(prs.Height)
if blockMeta == nil {
panic(fmt.Sprintf("Failed to load block %d when blockStore is at %d",
prs.Height, conR.conS.blockStore.Height()))
time.Sleep(conR.conS.config.PeerGossipSleepDuration)
continue OUTER_LOOP
}
ps.InitProposalBlockParts(blockMeta.BlockID.PartsHeader)
// continue the loop since prs is a copy and not effected by this initialization
Expand Down
1 change: 1 addition & 0 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,7 @@ func (n *Node) ConfigureRPC() {
rpccore.SetEventBus(n.eventBus)
rpccore.SetLogger(n.Logger.With("module", "rpc"))
rpccore.SetConfig(*n.config.RPC)
rpccore.SetHotSync(n.config.HotSync)
}

func (n *Node) startRPC() ([]net.Listener, error) {
Expand Down
7 changes: 6 additions & 1 deletion rpc/core/pipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ var (

logger log.Logger

config cfg.RPCConfig
config cfg.RPCConfig
hotSync bool
)

func SetStateDB(db dbm.DB) {
Expand Down Expand Up @@ -159,6 +160,10 @@ func SetConfig(c cfg.RPCConfig) {
config = c
}

func SetHotSync(h bool) {
hotSync = h
}

func validatePage(page, perPage, totalCount int) (int, error) {
if perPage < 1 {
panic(fmt.Sprintf("zero or negative perPage: %d", perPage))
Expand Down
2 changes: 1 addition & 1 deletion rpc/core/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ import (
// ```
func Status(ctx *rpctypes.Context) (*ctypes.ResultStatus, error) {
var latestHeight int64
if consensusReactor.FastSync() {
if consensusReactor.FastSync() || hotSync {
latestHeight = blockStore.Height()
} else {
latestHeight = consensusState.GetLastHeight()
Expand Down

0 comments on commit 40a8c51

Please sign in to comment.