-
Notifications
You must be signed in to change notification settings - Fork 867
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
Add test to check that TX selection doesn't prioritize TXs from the same sender #6022
Conversation
|
…or the same sender Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
8746c69
to
c474dea
Compare
… is WIP for discussion with others. Not sure this is the implementation we want. Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
a8c727a
to
ee7a66f
Compare
@fab-10 I've been looking at a suitable approach to avoid transactions from a single sender monopolizing the transaction selection process and preventing other senders' transactions from being included in a block. The current draft is a working implementation, but I'm not very happy with it. It feels like the logic in
My first go at making this configurable (via
The implementation in the PR needs tidying up (I've got a bunch of old-school for-loops to replace with streams etc) but I wanted to get feedback before continuing. The extra unit tests I've added demonstrate that it works. But I can't help thinking that if the order of
(going by memory - the above may not be correct, but just to give you the idea). However, I think that's a fairly fundamental change to the prioritized transactions ordering so I'm guessing it would have a bunch of side affects. |
@matthew1001 sorry but I could not review this in details until next week. |
Hi @fab-10 no problem about not reviewing until next week. I'm on vacation next week so that might give you some time to take a look and for us to catch up the week after. Very interested in your thought about an alternative TX pool. Are you thinking of something like I think It feels like the following combination is already pretty much available:
If all of those behaviours could be baked into a new type of TX pool then I can see that being appealing to users. Just choose that new pool type, and no need for specific settings. It does make me wonder whether the above options would still be available (i.e. to choose I think I might look at revising the PR (or perhaps creating a 2nd draft to keep the two separate) to use similar behaviour to this one, but changing the |
Yes I am suggesting a new implementation, that is specific for use cases that are different from mainnet, with the requirements that you listed. FYI: @7suyash7 |
Would you be opposed to an interim fix along the lines of the change in this PR? I think I agree that a custom pool implementation for these use-cases would be preferable, but a tactical non-breaking change to provide an option for the current pool implementation would be very useful in the mean time. Out of interest I raised a draft PR (#6106) to see if it regressed any existing behaviour and get feedback on whether it's a valid change to make as a pre-req to this PR. It causes transactions to be sorted by ascending sequence number and added-time, not descending order. I can't think of a downside to that, and it would allow this PR to be much simplified. |
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.
I am fine, finding an interim way to make this txpool fairer, will continue the review after #6106 is sorted out
besu/src/main/java/org/hyperledger/besu/cli/options/stable/TransactionPoolOptions.java
Outdated
Show resolved
Hide resolved
besu/src/main/java/org/hyperledger/besu/cli/options/stable/TransactionPoolOptions.java
Outdated
Show resolved
Hide resolved
...org/hyperledger/besu/ethereum/eth/transactions/sorter/AbstractPendingTransactionsSorter.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
…ded since hyperledger#6106 merged Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
e6a19ab
to
08ca0af
Compare
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
08ca0af
to
6600b49
Compare
assertThat(parsedTransactions.get(1)).isEqualTo(transaction2Sdr2); | ||
assertThat(parsedTransactions.get(2)).isEqualTo(transaction3Sdr2); | ||
assertThat(parsedTransactions.get(3)) | ||
.isEqualTo(transaction2); // Transaction 2 is actually the lowest nonce for this sender |
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.
since the name of the tx is misleading with its nonce, you could consider to rename
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.
Fixed
...g/hyperledger/besu/ethereum/eth/transactions/sorter/AbstractPendingTransactionsTestBase.java
Outdated
Show resolved
Hide resolved
...g/hyperledger/besu/ethereum/eth/transactions/sorter/AbstractPendingTransactionsTestBase.java
Outdated
Show resolved
Hide resolved
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.
suggested renaming to uniform the style
besu/src/main/java/org/hyperledger/besu/cli/options/TransactionPoolOptions.java
Outdated
Show resolved
Hide resolved
...c/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolConfiguration.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
…dering removes the need for it Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
@fab-10 after updating the TX selection ordering, transactions are no longer grouped by sender (at least not in a way that is unfair to specific senders). I've repurposed this PR to add unit tests which demonstrate that to be the case. |
@fab-10 I've marked this as auto-merge if/when you're happy with the new test. |
## Experimental | ||
Xtx-pool-disable-sender-grouping=false |
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.
## Experimental | |
Xtx-pool-disable-sender-grouping=false |
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.
removed since, only stable options are listed here
…ame sender (hyperledger#6022) * Add bool TX pool flag to allow TX selection to skip finding all TXs for the same sender Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Implement one approach to eliminating sender TX grouping. Note - this is WIP for discussion with others. Not sure this is the implementation we want. Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Make the no-sdr-grouping flag experimental, remove code no longer needed since hyperledger#6106 merged Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Update tests, tidy up empty lines Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Fix tests to be inline with recent sender-priority changes Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Address PR comments Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * More unit test updates Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Remove --Xtx-pool-disable-sender-grouping - the new legacy TX pool ordering removes the need for it Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Fix test merge error Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> --------- Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> Signed-off-by: Justin Florentine <justin+github@florentine.us>
…ame sender (hyperledger#6022) * Add bool TX pool flag to allow TX selection to skip finding all TXs for the same sender Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Implement one approach to eliminating sender TX grouping. Note - this is WIP for discussion with others. Not sure this is the implementation we want. Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Make the no-sdr-grouping flag experimental, remove code no longer needed since hyperledger#6106 merged Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Update tests, tidy up empty lines Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Fix tests to be inline with recent sender-priority changes Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Address PR comments Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * More unit test updates Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Remove --Xtx-pool-disable-sender-grouping - the new legacy TX pool ordering removes the need for it Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Fix test merge error Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> --------- Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> Signed-off-by: Justin Florentine <justin+github@florentine.us>
…ame sender (hyperledger#6022) * Add bool TX pool flag to allow TX selection to skip finding all TXs for the same sender Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Implement one approach to eliminating sender TX grouping. Note - this is WIP for discussion with others. Not sure this is the implementation we want. Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Make the no-sdr-grouping flag experimental, remove code no longer needed since hyperledger#6106 merged Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Update tests, tidy up empty lines Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Fix tests to be inline with recent sender-priority changes Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Address PR comments Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * More unit test updates Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Remove --Xtx-pool-disable-sender-grouping - the new legacy TX pool ordering removes the need for it Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Fix test merge error Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> --------- Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> Signed-off-by: Justin Florentine <justin+github@florentine.us>
PR description
Note that this PR is dependent on these PRs:
(My testing showed that #6146 was required and had been missed off #6106)
This PR now simply adds unit tests which demonstrate that the PRs ^^ mean we no longer require a specific CLI option
--Xtx-pool-disable-sender-grouping
Re-ordering the TX selection under those PRs meant that grouping of transactions per sender was no longer an issue in the legacy TX pool.
The intent of this PR is to give the user the option to control whether the transaction pool selection logic prefers to fill the block with all available transactions from each sender it has transactions for, or to treat the transactions equally, regardless of which sender they came from. Discussions with enterprise users have shown that the existing/default behaviour is not what they expect, and further it can cause an active sender to inadvertently monopolize the TX selection and effectively block other senders from having their transactions mined.The PR adds an experimental flag--Xtx-pool-disable-sender-grouping
. When this flag is set, the transaction selection pays no regard to the account the transaction was from.Since this is an experimental feature, I have not added thedoc-change-required
label as I don't believe we document experimental features?