Skip to content

refactor(mempool): Add Iterator to replace TxsFront and TxsWaitChan methods (backport #3459)#4089

Merged
mergify[bot] merged 4 commits intov1.xfrom
mergify/bp/v1.x/pr-3459
Sep 16, 2024
Merged

refactor(mempool): Add Iterator to replace TxsFront and TxsWaitChan methods (backport #3459)#4089
mergify[bot] merged 4 commits intov1.xfrom
mergify/bp/v1.x/pr-3459

Conversation

@mergify
Copy link
Contributor

@mergify mergify bot commented Sep 12, 2024

Closes #3303

This PR adds:

  • the Entry interface, implemented by the existing mempoolTx data type,
  • the Iterator interface, with one method WaitNextCh() <-chan Entry.

On the routine that sends transactions to a peer, we can now use an Iterator to select the next mempool entry to send, instead of the methods TxsFront and TxsWaitChan in CListMempool. These two methods leak implementation details about the CList and are now marked as deprecated. Now all the logic needed to wait for and pick the next available entry is implemented in CListMempool.WaitNextCh.


PR checklist

  • Tests written/updated
  • Changelog entry added in .changelog (we use unclog to manage our changelog)
  • Updated relevant documentation (docs/ or spec/) and code comments
  • Title follows the Conventional Commits spec

This is an automatic backport of pull request #3459 done by [Mergify](https://mergify.com).

…han` methods (#3459)

Closes #3303

This PR adds:
- the `Entry` interface, implemented by the existing `mempoolTx` data
type,
- the `Iterator` interface, with one method `WaitNextCh() <-chan Entry`.

On the routine that sends transactions to a peer, we can now use an
`Iterator` to select the next mempool entry to send, instead of the
methods `TxsFront` and `TxsWaitChan` in `CListMempool`. These two
methods leak implementation details about the CList and are now marked
as deprecated. Now all the logic needed to wait for and pick the next
available entry is implemented in `CListMempool.WaitNextCh`.

---

#### PR checklist

- [X] Tests written/updated
- [x] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [x] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec

---------

Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
(cherry picked from commit d4a82b7)

# Conflicts:
#	mempool/clist_mempool_test.go
#	mempool/reactor.go
@mergify mergify bot requested a review from a team as a code owner September 12, 2024 10:29
@mergify mergify bot added the conflicts label Sep 12, 2024
@mergify mergify bot requested a review from a team September 12, 2024 10:29
@mergify
Copy link
Contributor Author

mergify bot commented Sep 12, 2024

Cherry-pick of d4a82b7 has failed:

On branch mergify/bp/v1.x/pr-3459
Your branch is up to date with 'origin/v1.x'.

You are currently cherry-picking commit d4a82b7ef.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	new file:   .changelog/unreleased/deprecations/3303-mempool-deprecate-txsfront-txswaitchan.md
	new file:   .changelog/unreleased/improvements/3303-mempool-iterator.md
	modified:   mempool/clist_mempool.go
	modified:   mempool/mempool.go
	modified:   mempool/mempoolTx.go

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   mempool/clist_mempool_test.go
	both modified:   mempool/reactor.go

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@hvanz hvanz self-assigned this Sep 16, 2024
mergify bot and others added 2 commits September 16, 2024 21:39
… fails (backport #3647) (#4109)

Fixes a bug introduced in #3459 where instead of retrying the same tx
when the peer is lagging, it was skipping it and moving on to the next
entry. The same used to happen when sending the transaction failed:
instead of retrying to send, it skipped it and proceeded to the next tx.
This PR also reverts #3430, which was not working as expected.

Note that the first commit introduces a new test
`TestMempoolReactorSendLaggingPeer` that initially fails and then it's
fixed:
https://github.com/cometbft/cometbft/actions/runs/10300181146/job/28509056466?pr=3647

---

#### PR checklist

- [X] Tests written/updated
- ~~[ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)~~
- ~~[ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments~~
- [X] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec
<hr>This is an automatic backport of pull request #3647 done by
[Mergify](https://mergify.com).

---------

Co-authored-by: Hernán Vanzetto <15466498+hvanz@users.noreply.github.com>
Co-authored-by: hvanz <hernan.vanzetto@gmail.com>
@hvanz hvanz removed the conflicts label Sep 16, 2024
@mergify mergify bot merged commit 030b8b4 into v1.x Sep 16, 2024
@mergify mergify bot deleted the mergify/bp/v1.x/pr-3459 branch September 16, 2024 19:48
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.

1 participant