Skip to content

chore: simplify poolRoutine - #2152

Closed
faddat wants to merge 48 commits into
cometbft:mainfrom
faddat:faddat/simplifypoolRoutine
Closed

faddat wants to merge 48 commits into
cometbft:mainfrom
faddat:faddat/simplifypoolRoutine

Conversation

@faddat

@faddat faddat commented Jan 27, 2024 •

Copy link
Copy Markdown
Contributor

By various metrics, poolRoutine is the most complex function in CometBFT.

  • cyclomatic complexity
  • cognitive complexity

This PR is from #2130, which I'll break down into smaller PRs similar to the flaky test PR. I was able to identify this function as excessively complex by configuring linters in the way described in #2130.

review notes

I ended up removing some comments from the code, but it's possible that they should have been moved to one of the new helper functions. Please let me know if the comments should be restored.


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

@faddat
faddat requested a review from a team as a code owner January 27, 2024 15:20
@faddat
faddat requested a review from a team January 27, 2024 15:20
@faddat

faddat commented Jan 27, 2024

Copy link
Copy Markdown
Contributor Author

Please note that this PR illustrates the flaky test problem.

@faddat
faddat marked this pull request as draft January 29, 2024 16:08
@faddat
faddat force-pushed the faddat/simplifypoolRoutine branch from 86499ed to 06e8c90 Compare January 29, 2024 16:23
@faddat
faddat marked this pull request as ready for review January 31, 2024 16:23
@faddat faddat mentioned this pull request Feb 10, 2024
3 of 35 tasks
@faddat

faddat commented Feb 16, 2024

Copy link
Copy Markdown
Contributor Author

Let's run the p2p tests and profile them, to learn how much RAM we can save

@faddat

faddat commented Mar 14, 2024 •

Copy link
Copy Markdown
Contributor Author

@faddat

faddat commented Mar 14, 2024

Copy link
Copy Markdown
Contributor Author
  • e2e is not flaky.

Comment thread internal/blocksync/reactor.go Resolved
@adizere adizere self-assigned this Apr 3, 2024
@adizere

adizere commented Apr 3, 2024

Copy link
Copy Markdown
Contributor

@faddat what is left here? thinking of closing this since it seems very delicate and low confidence in changes

@adizere adizere added this to the 2024-Q2 milestone Apr 3, 2024
@faddat

faddat commented Apr 6, 2024

Copy link
Copy Markdown
Contributor Author

Low confidence in the changes or in the code that tests them?

@faddat

faddat commented Apr 8, 2024 •

Copy link
Copy Markdown
Contributor Author

@adizere my thoughts on closing this or not -

  1. if low confidence in the changes here then by all means this PR should be closed

  2. If the situation is as I suspect and you have low confidence in the code that tests these changes, then I think effort should be directed at tests. I noticed that the main branch is once again not passing tests. If you would like the tests in this repository to actually pass, actually all the time, and actually have meaning, then we should make a rule: PRs must pass tests and follow it. I have high confidence that such a rule would improve the tests. Flaky tests harm everyone's confidence in everything because they pevent us from knowing what works and what doesn't and they simultaneously make PRs like this rather.... dicey to write and dicey to review.

Could there be a problem in my changes?

Yep, code can have bugs

Is there an issue with test flakiness in this repo?

Yep

Do flaky tests make it impossible (at times) or difficult (at other times) to tell the difference between the two?

yep

From my POV, this is a worthy concept of a PR, and it could be that it is not ideally organized, and could need to be rewritten or passed over again. But it is significantly harder to know because I also know that the tests overall aren't reliable.

If you'd like a rewrite though, please just let me know that, along with some feedback. Happy to do so.

@melekes

melekes commented Apr 15, 2024

Copy link
Copy Markdown
Collaborator

I'm going to review this tomorrow.

"vote_extensions_disabled", voteExtensionsDisabled,
"blocks_synced", blocksSynced,
"initial_commit_has_extensions", initialCommitHasExtensions,
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

return is missing here!

in the original code:

402: continue FOR_LOOP

@melekes melekes mentioned this pull request Apr 16, 2024
1 of 4 tasks
@melekes

melekes commented Apr 16, 2024

Copy link
Copy Markdown
Collaborator

Closing in favor of #2820

@melekes melekes closed this Apr 16, 2024
github-merge-queue Bot pushed a commit that referenced this pull request Apr 24, 2024
Replaces #2152

Co-authored by: @faddat 

---

#### PR checklist

- [ ] ~~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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants