-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
worker: enhancement of the current block generation logic. #1186
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setunapo
changed the title
worker: some block produce enhancement of work.go
worker: enhancement of the current block generation logic.
Nov 17, 2022
setunapo
force-pushed
the
worker_develop
branch
from
November 17, 2022 04:26
abdc7c6
to
6c017c4
Compare
brilliant-lx
requested review from
j75689,
kyrie-yl,
unclezoro,
keefel,
qinglin89 and
yutianwu
November 17, 2022 04:36
Currently, validator only try once to get transactions from TxPool to produce the block. However, new transactions could arrive while the validator is committing transaction. Validator should be allowed to add these new arrived transactions as long as Header.Timestamp is not reached This commit will: ** commitTransactions return with error code ** drop current mining block on new block imported ** try fillTransactions several times for the best not use append mode to follow the GasPrice rule. ** check if there is enough time for another fillTransactions.
setunapo
force-pushed
the
worker_develop
branch
from
November 17, 2022 04:45
6c017c4
to
5c88f9f
Compare
qinglin89
reviewed
Nov 17, 2022
miner/worker.go
Outdated
return | ||
} | ||
} | ||
if len(remoteTxs) > 0 { | ||
txs := types.NewTransactionsByPriceAndNonce(env.signer, remoteTxs, env.header.BaseFee) | ||
if w.commitTransactions(env, txs, interruptCh, stopTimer) { | ||
err = w.commitTransactions(env, txs, interruptCh, stopTimer) | ||
if err == errBlockInterruptedByNewHead || err == errBlockInterruptedByOutOfGas || err == errBlockInterruptedByTimeout { |
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.
this if
seems useless here, would return anyway
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.
accepted.
It may not efficient if schedule fillTransactions when new transactions arrive. It could make the CPU keep running. To make is more efficient: 1.schedule fillTransactions when a certain amount of transaction are arrived. 2.or there is not much time left.
setunapo
force-pushed
the
worker_develop
branch
from
November 17, 2022 08:05
05ad34f
to
dad8b3f
Compare
unclezoro
reviewed
Nov 17, 2022
unclezoro
reviewed
Nov 17, 2022
unclezoro
reviewed
Nov 17, 2022
unclezoro
reviewed
Nov 17, 2022
unclezoro
reviewed
Nov 17, 2022
qinglin89
reviewed
Nov 18, 2022
unclezoro
previously approved these changes
Nov 21, 2022
When new block is imported, there is no need to commit the current work, even the new imported block is offturn and itself is inturn. That is because when offturn block is received, the inturn block is already later to broadcast block, deliver the later block will cause many reorg, which is not reasonable. And also make sure all useless work can be discarded, to avoid goroutine leak.
setunapo
force-pushed
the
worker_develop
branch
from
November 21, 2022 04:21
bd991ec
to
24976d0
Compare
it is not necssary to add more transaction when resubmit is fired. the resubmit logic was for PoW and can be removed later.
setunapo
force-pushed
the
worker_develop
branch
from
November 21, 2022 05:54
56684ed
to
1b2cde0
Compare
unclezoro
approved these changes
Nov 21, 2022
bitdaddy89
approved these changes
Nov 21, 2022
qinglin89
approved these changes
Nov 21, 2022
This was referenced Nov 29, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Currently, validator only try once to get transactions from TxPool to produce the block.
However, new transactions could arrive while the validator is committing transaction.
Validator should be allowed to add these new arrived transactions as long as Header.Timestamp is not reached.
Rationale
This PR will:
And the general workflow of new implementation could be described as:
Example
NA.
Changes
It could effect the mining logic, validators will be update to align the mine logic.