Skip to content

Prepare next proposal #4586

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

Closed
wants to merge 10 commits into from
Closed

Conversation

envestcc
Copy link
Member

@envestcc envestcc commented Mar 19, 2025

Description

two major changes introduced:

  • forked blockchain in consensus, and read delegates at fork
  • prepare next proposal when last proposal received

base #4582

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 marked this pull request as ready for review March 19, 2025 15:16
@envestcc envestcc requested review from CoderZhi, dustinxie, Liuhaai and a team as code owners March 19, 2025 15:16
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
3.7% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@@ -378,6 +378,10 @@ func (sdb *stateDB) ReadView(name string) (interface{}, error) {
return sdb.protocolView.Read(name)
}

func (sdb *stateDB) StateReaderAt(header *block.Header) (protocol.StateReader, error) {
panic("implement me")
Copy link
Member Author

Choose a reason for hiding this comment

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

will implement after #4581

Copy link
Collaborator

@CoderZhi CoderZhi left a comment

Choose a reason for hiding this comment

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

the main idea looks ok. Let's split it into multiple PRs:

  1. refactor getblockhash and getblocktime
  2. refactor the mint part, move logic into consensus
  3. early proposal

Comment on lines +413 to +417
func WithConsensusRoundCtx(ctx context.Context, round ConsensusRoundCtx) context.Context {
return context.WithValue(ctx, consensusRoundContextKey{}, round)
}

func MustGetConsensusRoundCtx(ctx context.Context) ConsensusRoundCtx {
Copy link
Collaborator

Choose a reason for hiding this comment

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

if necessary, move to package rolldpos

}

// MintNewBlock creates a new block with given actions
func (fc *forkChain) MintNewBlock(ctx context.Context) (*block.Block, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

add parameters:

StartTime       time.Time
EncodedProposer string
PrevHash        hash.Hash256

Round is not in use, Height is always equal to tipHeight + 1

Comment on lines +111 to +115
Mint(ctx context.Context) (*block.Block, error)
ReceiveBlock(*block.Block) error
Init(hash.Hash256)
AddProposal(*block.Block) error
Block(hash.Hash256) *block.Block
Copy link
Collaborator

Choose a reason for hiding this comment

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

the BlockBuilderFactory defined here doesn't need to contain all the functions.

@@ -513,12 +513,16 @@ func (builder *Builder) createBlockchain(forSubChain, forTest bool) blockchain.B
} else {
chainOpts = append(chainOpts, blockchain.BlockValidatorOption(builder.cs.factory))
}
consensusCfg := consensusfsm.NewConsensusConfig(builder.cfg.Consensus.RollDPoS.FSM, builder.cfg.DardanellesUpgrade, builder.cfg.Genesis, builder.cfg.Consensus.RollDPoS.Delay)
Copy link
Collaborator

Choose a reason for hiding this comment

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

single node mode may have problem. so, we need to rethink about the usage of BlockTimeCalculatorBuilder.


var mintOpts []factory.MintOption
mintOpts := []factory.MintOption{factory.WithPrivateKeyOption(builder.cfg.Chain.ProducerPrivateKey())}
Copy link
Collaborator

Choose a reason for hiding this comment

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

moving private key to consensus may be a better way.

@envestcc
Copy link
Member Author

splited into #4590, #4593, #4594

@envestcc envestcc closed this Mar 26, 2025
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.

2 participants