Skip to content

Tune and make configurable the PeerTransactionTracker #8537

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

Merged
merged 4 commits into from
Apr 11, 2025

Conversation

fab-10
Copy link
Contributor

@fab-10 fab-10 commented Apr 10, 2025

PR description

In PR #7755 the default behavior of the peer transaction tracker changed from always remember the txs exchanged with a peer (at least until they fits in the cache) to forget a txs has been already exchanged in case it is evicted from the pool for reason not related to the validity.

While the new default solves issues with re-broadcasting the same tx in small networks, it does not works well for public networks, where there are many thousands of pending txs and a lot of independent nodes, since it can cause the broadcast and the re-evaluation of already seen txs, with the waste of network and computation resources.

So this PR changes the current default based on the txpool implementation that is chosen:

  • for Layered the default is to not forget on eviction (new behavior), since it is the implementation designed for public networks.
  • for Sequencer the default is to forget on eviction (current behavior) since it is the implementation that is used in private/permissioned networks.

Moreover it is possible to overwrite the default behavior using the new experimental option Xpeer-tracker-forget-evicted-txs.

Another option has been added to customized the max size of the cache that keeps memory of the tx exchanged with each peers, so it can be tuned to adapt to increases in the pending txs number. The new option is Xmax-tracked-seen-txs-per-peer and by default is now 200_000 entries, double from the previous hard coded value.

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:

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

@fab-10 fab-10 marked this pull request as draft April 10, 2025 09:23
@fab-10 fab-10 force-pushed the make-p2p-broadcast-more-configurable branch from ae010be to ffced9f Compare April 10, 2025 10:52
@fab-10 fab-10 marked this pull request as ready for review April 10, 2025 11:59
@fab-10 fab-10 changed the title Make max tracked seen txs and forget evicted txs values configurable in the peer tracker Tune and make configurable the PeerTransactionTracker Apr 10, 2025
@fab-10 fab-10 force-pushed the make-p2p-broadcast-more-configurable branch 2 times, most recently from d38f003 to 0625525 Compare April 10, 2025 12:02
@CommandLine.Option(
names = {PEER_TRACKER_FORGET_EVICTED_TXS_FLAG},
paramLabel = "<BOOLEAN>",
hidden = true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need a fallback value so --Xpeer-tracker-forget-evicted-txs will work without "=true"?

Copy link
Contributor Author

@fab-10 fab-10 Apr 11, 2025

Choose a reason for hiding this comment

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

Good point, the important thing is that fallback value does not act as a default, because in this case the default is chosen at runtime depending on the txpool implementation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fallback value added

config -> assertThat(config.getUnstable().getPeerTrackerForgetEvictedTxs()).isTrue(),
"--tx-pool",
LAYERED.name().toLowerCase(Locale.ROOT),
"--Xpeer-tracker-forget-evicted-txs=true");
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a another test for --Xpeer-tracker-forget-evicted-txs using the fallBack value if we want to support that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

fab-10 and others added 4 commits April 11, 2025 10:19
…in the peer tracker

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
…nPoolOptions.java

Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
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 make-p2p-broadcast-more-configurable branch from 51f9003 to 11bf0e9 Compare April 11, 2025 08:31
@fab-10 fab-10 enabled auto-merge (squash) April 11, 2025 08:32
@fab-10 fab-10 merged commit abc01e2 into hyperledger:main Apr 11, 2025
43 checks passed
@fab-10 fab-10 deleted the make-p2p-broadcast-more-configurable branch April 11, 2025 08:54
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.

3 participants