-
Notifications
You must be signed in to change notification settings - Fork 346
Prepare next proposal #4594
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
Prepare next proposal #4594
Conversation
consensus/consensusfsm/fsm.go
Outdated
@@ -466,7 +466,9 @@ func (m *ConsensusFSM) onReceiveBlock(evt fsm.Event) (fsm.State, error) { | |||
m.ctx.Logger().Debug("Failed to generate proposal endorsement", zap.Error(err)) | |||
return sAcceptBlockProposal, nil | |||
} | |||
|
|||
if err := m.ctx.PrepareNextProposal(cEvt.Data()); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shall we prepare next proposal in aba9583#diff-1a3210b28d700ae99106a6432536ca469599340962b961e9bedf543b5a15e13dR505
var privateKey crypto.PrivateKey = nil | ||
if idx := slices.Index(ctx.encodedAddrs, nextProposer); idx < 0 { | ||
return nil | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete else
ctx.loggerWithStats().Debug("accept block proposal", log.Hex("block", blockHash)) | ||
} else if ctx.round.IsLocked() { | ||
blockHash = ctx.round.HashOfBlockInLock() | ||
} else { | ||
if err := ctx.prepareNextProposal(ctx.round.Height()-1, ctx.round.PrevHash()); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why now need to prepareNextProposal()
in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
msg == nil means that the proposal for this round was not received in time; in this case, it's possible to mint the proposal for round +1 in advance.
privateKey = ctx.priKeys[idx] | ||
} | ||
ctx.logger().Debug("prepare next proposal", log.Hex("prevHash", prevHash[:]), zap.Uint64("height", ctx.round.height+1), zap.Time("timestamp", startTime), zap.String("nextproposer", nextProposer)) | ||
go func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why use go func()
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor:
if fork.MintNewBlock() errs out, the error won't be captured and handled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MintNewBlock
keep mint result in memory, and will return it if mint same block. Here is to just to start the next proposal mint in advance, which can be run in background.
|
Description
base #4593
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Test Configuration:
Checklist: