Skip to content

consensus/istanbul: add block lock #127

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

Merged
merged 2 commits into from
Jul 24, 2017
Merged

Conversation

yutelin
Copy link

@yutelin yutelin commented Jul 18, 2017

No description provided.


// HasBlock implements istanbul.Backend.HashBlock
func (sb *backend) HasBlock(hash common.Hash, number *big.Int) bool {
if h := sb.chain.GetHeaderByHash(hash); h != nil {
Copy link

@markya0616 markya0616 Jul 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use GetHeader and check block nil.

// New snapshot for new round
c.current = newRoundState(newView, c.valSet)
// New snapshot for new round. roundChange value implies if locking block is necessary
c.updateRoundState(newView, c.valSet, roundChange)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may update round state based on whether it's locked. no need roundChange

if err := c.checkMessage(msgPreprepare, preprepare.View); err != nil {
if err == errOldMessage {
valSet := c.backend.Validators(preprepare.Proposal).Copy()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get parent proposal's validator

// If it is locked, propose the old proposal
if c.current.IsHashLocked() {
r := &istanbul.Request{
Proposal: currentProposal,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get current proposal from c.current.Prepare.Proposal

// and we are in earlier state before StatePrepared
if c.current.Prepares.Size() > 2*c.valSet.F() && c.state.Cmp(StatePrepared) < 0 {
if c.current.IsHashLocked() || c.current.Prepares.Size() > 2*c.valSet.F() && c.state.Cmp(StatePrepared) < 0 {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(c.current.IsHashLocked() || c.current.Prepares.Size() > 2*c.valSet.F()) && c.state.Cmp(StatePrepared) < 0?

Copy link

@markya0616 markya0616 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yutelin yutelin force-pushed the feature/add-block-lock branch from 55d5ba9 to 7daa006 Compare July 18, 2017 09:03
@yutelin yutelin changed the title [WIP] consensus/istanbul: add block lock consensus/istanbul: add block lock Jul 19, 2017
Copy link

@markya0616 markya0616 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

@bailantaotao bailantaotao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yutelin yutelin merged commit d4ae30d into istanbul/develop Jul 24, 2017
@yutelin yutelin deleted the feature/add-block-lock branch July 24, 2017 02:08
markya0616 pushed a commit that referenced this pull request Jan 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants