Skip to content

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

Merged
merged 4 commits into from
Apr 21, 2025
Merged

Prepare next proposal #4594

merged 4 commits into from
Apr 21, 2025

Conversation

envestcc
Copy link
Member

Description

base #4593

Type of change

Please delete options that are not relevant.

  • [] Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • [] Code refactor or improvement
  • [] Breaking change (fix or feature that would cause a new or changed behavior of existing functionality)
  • [] This change requires a documentation update

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

  • [] make test
  • [] fullsync
  • [] Other test (please specify)

Test Configuration:

  • Firmware version:
  • Hardware:
  • Toolchain:
  • SDK:

Checklist:

  • [] My code follows the style guidelines of this project
  • [] I have performed a self-review of my code
  • [] I have commented my code, particularly in hard-to-understand areas
  • [] I have made corresponding changes to the documentation
  • [] My changes generate no new warnings
  • [] I have added tests that prove my fix is effective or that my feature works
  • [] New and existing unit tests pass locally with my changes
  • [] Any dependent changes have been merged and published in downstream modules

@envestcc envestcc mentioned this pull request Mar 26, 2025
@envestcc envestcc mentioned this pull request Mar 28, 2025
@envestcc envestcc marked this pull request as ready for review April 2, 2025 02:40
@envestcc envestcc requested review from CoderZhi, dustinxie, Liuhaai and a team as code owners April 2, 2025 02:40
@@ -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 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

var privateKey crypto.PrivateKey = nil
if idx := slices.Index(ctx.encodedAddrs, nextProposer); idx < 0 {
return nil
} else {
Copy link
Collaborator

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 {
Copy link
Member

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?

Copy link
Member Author

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() {
Copy link
Member

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

Copy link
Member

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

Copy link
Member Author

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.

Copy link

@CoderZhi CoderZhi merged commit f7a636c into iotexproject:master Apr 21, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants