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

Fix to avoid broadcasting full blob txs #6835

Merged
merged 8 commits into from
Mar 28, 2024

Conversation

fab-10
Copy link
Contributor

@fab-10 fab-10 commented Mar 28, 2024

PR description

As @macfarla discovered, Besu is wrongly sending the full blob tx payload to a subset of peers, specifically the subset of peers that are selected for full tx broadcast ( sqrt(num of peers) ), and the problem was that there is a single queue for full tx and hash only broadcast, so for this subset of peers, actually it could happen that both kind of broadcasts are performed, and sending full blob tx is a breach of the protocol.
This PR finalize the work started by @gfukushima , that introduces 2 queues, one for full txs, and one for hashes only, so the specific broadcast methods do not incur in fetching a tx that is not meant for them.

Fixed Issue(s)

fixes #6777

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

gfukushima and others added 3 commits March 28, 2024 16:28
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
@fab-10 fab-10 force-pushed the fix-blob-tx-full-broadcast branch from c08ecc0 to c3d96e8 Compare March 28, 2024 10:09
@ahamlat
Copy link
Contributor

ahamlat commented Mar 28, 2024

Testing this PR, I see now consistant Geth peers

      "name": "Geth/v1.14.0-unstable-ac6060a4-20240319/linux-amd64/go1.21.6",
      "name": "Geth/v1.13.14-stable-2bd6bd01/linux-amd64/go1.21.6",
      "name": "Geth/v1.13.14-stable-d65126b5/linux-amd64/go1.21.8",
      "name": "Geth/v1.13.14-stable-aaff12e3/linux-amd64/go1.22.0",
      "name": "Nethermind/v1.25.4+20b10b35/linux-x64/dotnet8.0.2",
      "name": "Nethermind/v1.25.4+20b10b35/linux-x64/dotnet8.0.2",
      "name": "Nethermind/v1.25.4+20b10b35/linux-x64/dotnet8.0.2",
      "name": "Nethermind/v1.25.4+20b10b35/linux-x64/dotnet8.0.2",
      "name": "erigon/v2.58.0/linux-amd64/go1.21.6",
      "name": "Nethermind/v1.25.4+20b10b35/linux-x64/dotnet8.0.2",
      "name": "Geth/v1.13.14-stable-d65126b5/linux-amd64/go1.21.8",
      "name": "erigon/v2.58.2-125509e4/linux-arm64/go1.20.14",
      "name": "Geth/v1.13.14-stable-2bd6bd01/linux-amd64/go1.21.6",
      "name": "Geth/v1.13.14-stable-d65126b5/linux-amd64/go1.21.8",
      "name": "Nethermind/v1.25.4+20b10b35/linux-x64/dotnet8.0.2",
      "name": "reth/v0.1.0-alpha.21",
      "name": "erigon/v2.59.0-0f0a4452/linux-amd64/go1.20.2",
      "name": "erigon/v2.58.0-9731f716/linux-amd64/go1.20.14",
      "name": "erigon/v2.58.2-125509e4/linux-amd64/go1.21.5",
      "name": "Nethermind/v1.25.4+20b10b35/linux-x64/dotnet8.0.2",
      "name": "Nethermind/v1.25.4+20b10b35/linux-x64/dotnet8.0.2",
      "name": "Nethermind/v1.25.4+20b10b35/linux-x64/dotnet8.0.2",
      "name": "Geth/v1.13.14-stable-2bd6bd01/linux-amd64/go1.21.6",
      "name": "Nethermind/v1.25.4+20b10b35/linux-x64/dotnet8.0.2",
      "name": "reth/v0.1.0-alpha.21",
      ```

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
@fab-10 fab-10 force-pushed the fix-blob-tx-full-broadcast branch from b584079 to a51ce2e Compare March 28, 2024 13:01
@fab-10 fab-10 marked this pull request as ready for review March 28, 2024 13:13
@fab-10 fab-10 changed the title Fix blob tx full broadcast Fix to avoid broadcasting full blob txs Mar 28, 2024
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
@fab-10 fab-10 enabled auto-merge (squash) March 28, 2024 16:09
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.

Comments are optional.

public synchronized Set<Transaction> claimTransactionHashesToSendToPeer(final EthPeer peer) {
final Set<Transaction> transactionHashesToSend = this.transactionHashesToSend.remove(peer);
if (transactionHashesToSend != null) {
markTransactionHashesAsSeen(peer, toHashList(transactionHashesToSend));
Copy link
Contributor

Choose a reason for hiding this comment

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

should work, but i wonder if it would be more correct to mark them as seen after we know they've been sent to the peer. we could restore them to the cache in the exception handling of NewPooledTransactionHashesMessageSender:63

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point, will review next

@@ -77,7 +102,7 @@ public void onTransactionsAdded(final Collection<Transaction> transactions) {
return;
}

final int numPeersToSendFullTransactions = (int) Math.ceil(Math.sqrt(currPeerCount));
final int numPeersToSendFullTransactions = (int) Math.round(Math.sqrt(currPeerCount));
Copy link
Contributor

Choose a reason for hiding this comment

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

This allows for rounding down as well as up, instead of ceil which is up only. It still works, but I'm unclear why it is necessary or preferred?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is not necessary, just seems more appropriate to round instead of ceil, to avoid strange results when few peers are connected, for example with 2 peers, with round we have 1, otherwise is 2.

txBroadcaster =
new TransactionBroadcaster(
ethContext,
transactionTracker,
transactionsMessageSender,
newPooledTransactionHashesMessageSender);
newPooledTransactionHashesMessageSender,
FIXED_RANDOM_SEED);
Copy link
Contributor

Choose a reason for hiding this comment

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

Excellent move. My list of "flaky tests to fix" thanks you!

@fab-10 fab-10 disabled auto-merge March 28, 2024 16:58
@fab-10 fab-10 enabled auto-merge (squash) March 28, 2024 17:06
@fab-10 fab-10 merged commit 3a2eb4e into hyperledger:main Mar 28, 2024
42 checks passed
@fab-10 fab-10 deleted the fix-blob-tx-full-broadcast branch March 29, 2024 15:00
macfarla pushed a commit that referenced this pull request Apr 8, 2024
* separate queue for tx hashes

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

---------

Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Co-authored-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
amsmota pushed a commit to Citi/besu that referenced this pull request Apr 16, 2024
* separate queue for tx hashes

Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>

* Refinements

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

* Update tests

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

* Update CHANGELOG

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

* Refinements

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

---------

Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Co-authored-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: amsmota <antonio.mota@citi.com>
amsmota pushed a commit to Citi/besu that referenced this pull request Apr 16, 2024
* separate queue for tx hashes

Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>

* Refinements

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

* Update tests

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

* Update CHANGELOG

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

* Refinements

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

---------

Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Co-authored-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: amsmota <antonio.mota@citi.com>
matthew1001 pushed a commit to kaleido-io/besu that referenced this pull request Jun 7, 2024
* separate queue for tx hashes

Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>

* Refinements

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

* Update tests

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

* Update CHANGELOG

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

* Refinements

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>

---------

Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Co-authored-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
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.

bug(devp2p): unsolicited type 3 transactions broadcast
4 participants