Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check nil pointer #1506

Merged
merged 1 commit into from
Sep 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion consensus/istanbul/qbft/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func (c *core) startNewRound(round *big.Int) {
c.valSet.CalcProposer(lastProposer, newView.Round.Uint64())
c.setState(StateAcceptRequest)

if round.Cmp(c.current.Round()) > 0 {
if c.current != nil && round.Cmp(c.current.Round()) > 0 {
roundMeter.Mark(new(big.Int).Sub(round, c.current.Round()).Int64())
}

Expand Down
9 changes: 6 additions & 3 deletions consensus/istanbul/qbft/core/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,12 @@ func (c *core) verifySignatures(m qbfttypes.QBFTMessage) error {
}

func (c *core) currentLogger(state bool, msg qbfttypes.QBFTMessage) log.Logger {
logCtx := []interface{}{
"current.round", c.current.Round().Uint64(),
"current.sequence", c.current.Sequence().Uint64(),
logCtx := []interface{}{}
if c.current != nil {
logCtx = append(logCtx,
"current.round", c.current.Round().Uint64(),
"current.sequence", c.current.Sequence().Uint64(),
)
}

if state {
Expand Down
9 changes: 8 additions & 1 deletion consensus/istanbul/qbft/core/roundchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package core

import (
"errors"
"math/big"
"sort"
"sync"
Expand All @@ -26,6 +27,7 @@ import (
"github.com/ethereum/go-ethereum/consensus/istanbul"
qbfttypes "github.com/ethereum/go-ethereum/consensus/istanbul/qbft/types"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rlp"
)

Expand Down Expand Up @@ -150,7 +152,12 @@ func (c *core) handleRoundChange(roundChange *qbfttypes.RoundChange) error {
// propose the block proposal that we generated
_, proposal := c.highestPrepared(currentRound)
if proposal == nil {
proposal = c.current.pendingRequest.Proposal
if c.current != nil && c.current.pendingRequest != nil {
proposal = c.current.pendingRequest.Proposal
} else {
log.Warn("round change returns an error: no proposal as pending request is nil")
return errors.New("no proposal as pending request is nil")
}
}

// Prepare justification for ROUND-CHANGE messages
Expand Down