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

Improve the selection of the most profitable built block #7174

Merged
merged 7 commits into from
Jun 7, 2024

Conversation

fab-10
Copy link
Contributor

@fab-10 fab-10 commented Jun 4, 2024

PR description

when in PoS networks, Besu repeatedly builds proposal until the getPayload method is called, in order to try to include new txs that could arrive in the meantime, so when more that one block is created in the interval, we need to have a strategy to select the best one, currently the decision is simply made on the gas used of the block, since we include txs from the most profitable to the least.
So in theory the more the block is filled the more value it should have, but it turns out that there are edge cases where this assumption fails, in particular when the are enough txs to fill the block since the beginning, and following blocks are just a little smaller that the previous in term of gas, they are discarded even if better in term of value.

Real world example:

  • 1st block iteration has cumulativeGasUsed=29988510 and 50 txs
  • last has cumulativeGasUsed=29984151 and 185 txs with higher value, but since smaller by ~4000 gas is not selected as best.

Calculating the block value, does not add computation time to getPayload, since it was already done to include it in the response, and was refactored to compute it only one and use everywhere it is needed.

Fixed Issue(s)

Thanks for sending a pull request! Have you done the following?

  • Checked out our contribution guidelines?
  • Considered documentation and added the doc-change-required label to this PR if updates are required.
  • Considered the changelog and included an update if required.
  • For database changes (e.g. KeyValueSegmentIdentifier) considered compatibility and performed forwards and backwards compatibility tests

Locally, you can run these tests to catch failures early:

  • unit tests: ./gradlew build
  • acceptance tests: ./gradlew acceptanceTest
  • integration tests: ./gradlew integrationTest
  • reference tests: ./gradlew ethereum:referenceTests:referenceTests

@fab-10 fab-10 force-pushed the select-most-profitable-proposal branch 3 times, most recently from 7efd4c8 to d24a505 Compare June 5, 2024 10:29
@fab-10 fab-10 force-pushed the select-most-profitable-proposal branch from d24a505 to c19f3c2 Compare June 5, 2024 10:29
Signed-off-by: Fabio Di Fabio <[email protected]>
@fab-10 fab-10 marked this pull request as ready for review June 5, 2024 12:31
Copy link
Contributor

@jflo jflo left a comment

Choose a reason for hiding this comment

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

Approved, but will need to adopt suggested change to fix javadocs.

@fab-10 fab-10 enabled auto-merge (squash) June 7, 2024 13:54
@fab-10 fab-10 merged commit 40d6b26 into hyperledger:main Jun 7, 2024
40 checks passed
@fab-10 fab-10 deleted the select-most-profitable-proposal branch June 7, 2024 14:30
gtebrean pushed a commit to gtebrean/besu that referenced this pull request Jun 26, 2024
…#7174)

* Improve the selection of the most profitable built block

Signed-off-by: Fabio Di Fabio <[email protected]>

* Update CHANGELOG

Signed-off-by: Fabio Di Fabio <[email protected]>

* Update consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/PayloadWrapper.java

Co-authored-by: Justin Florentine <[email protected]>
Signed-off-by: Fabio Di Fabio <[email protected]>

---------

Signed-off-by: Fabio Di Fabio <[email protected]>
Co-authored-by: Justin Florentine <[email protected]>
Signed-off-by: George Tebrean <[email protected]>
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