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

Parlia: Some updates of the miner worker #1182

Merged
merged 2 commits into from
Nov 16, 2022

Conversation

setunapo
Copy link
Contributor

@setunapo setunapo commented Nov 15, 2022

Description

Some update of the worker.go

1.Delay() with DelayLeftOver
Right now, DelayLeftOver is used to reserve time for block finalize, not block broadcast.
The general block generation could be described as:
|- fillTransactions -|- finalize a block -|- wait until the period(3s) reached -|- broadcast -|
And the code does not work as expected, some code improve on the Delay() logic.

2.no need to add transaction to the current work if mining is stopped.
It seems that it is unnecessary to add transaction when mining is stopped.
It is a old logic of PoW, which is no longer need for BSC.

Rationale

none

Example

none

Changes

none

Right now, DelayLeftOver is used to reserve time for block finalize, not block
broadcast. And the code does not work as expected.

The general block generation could be described as:
|- fillTransactions -|- finalize a block -|- wait until the period(3s) reached -|- broadcast -|
@setunapo setunapo changed the title WIP: Parlia: Delay() with DelayLeftOver Parlia: Delay() with DelayLeftOver Nov 15, 2022
@setunapo setunapo changed the title Parlia: Delay() with DelayLeftOver Parlia: Some updates of the miner worker Nov 15, 2022
It could be a very old PoW logic, which try to add more transaction
into the pending block when mining is stopped.
Mining can be stopped when:
  1.download started.
  2.manually stopped by RPC.
It is unnecessary to add more transaction into the pending block if a validator is stopped.
And updateSnapshot() is not needed as well, it is to get the pending mining snapshot.
Copy link
Contributor

@keefel keefel left a comment

Choose a reason for hiding this comment

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

LGTM

@brilliant-lx brilliant-lx merged commit 086a99b into bnb-chain:develop Nov 16, 2022
@setunapo setunapo deleted the worker_delay branch November 16, 2022 03:20
if len(localTxs) > 0 {
txs := types.NewTransactionsByPriceAndNonce(env.signer, localTxs, env.header.BaseFee)
if w.commitTransactions(env, txs, interruptCh) {
if w.commitTransactions(env, txs, interruptCh, stopTimer) {
Copy link
Collaborator

@unclezoro unclezoro Nov 16, 2022

Choose a reason for hiding this comment

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

	x := time.NewTimer(time.Second)
	<-x.C
	fmt.Println("read delay 1")
	<-x.C
	fmt.Println("read delay 2")

It turns out that fmt.Println("read delay 2") is not reachable.

So if the timer trigger during the first commitTransactions for local tx, then commitTransactions will have no time delay limitation .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, it do have the problem, will fix it later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
r4r ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants