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: general improvements in tm2/bft/consensus #1495

Closed
wants to merge 13 commits into from
Closed

Conversation

petar-dambovaliev
Copy link
Contributor

@petar-dambovaliev petar-dambovaliev commented Jan 3, 2024

These are general improvements to concurrency in tm2

  • Don't acquire write lock when it is not necessary
  • Handle ignored errors
  • Implement a uniform comparison method (readability + type safety)

@github-actions github-actions bot added the 📦 🌐 tendermint v2 Issues or PRs tm2 related label Jan 3, 2024
Copy link

codecov bot commented Jan 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 47.48%. Comparing base (84ba9c9) to head (92abef4).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1495      +/-   ##
==========================================
- Coverage   47.49%   47.48%   -0.01%     
==========================================
  Files         388      389       +1     
  Lines       61305    61623     +318     
==========================================
+ Hits        29117    29264     +147     
- Misses      29750    29910     +160     
- Partials     2438     2449      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@petar-dambovaliev petar-dambovaliev changed the title [bug] remove deadlock in tm2 bug: remove deadlock in tm2 Jan 3, 2024
@petar-dambovaliev petar-dambovaliev changed the title bug: remove deadlock in tm2 fix: remove deadlock in tm2 Jan 3, 2024
@petar-dambovaliev petar-dambovaliev changed the title fix: remove deadlock in tm2 fix: general improvements in tm2/bft/consensus Jan 12, 2024
@github-actions github-actions bot added the 📦 🤖 gnovm Issues or PRs gnovm related label Jan 15, 2024
@petar-dambovaliev petar-dambovaliev marked this pull request as ready for review January 15, 2024 16:49
@petar-dambovaliev petar-dambovaliev requested review from moul and a team as code owners January 15, 2024 16:49
Copy link
Member

@zivkovicmilos zivkovicmilos left a comment

Choose a reason for hiding this comment

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

Thank you for the improvements 🙏

Copy link
Contributor

@kristovatlas kristovatlas left a comment

Choose a reason for hiding this comment

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

I did not review business logic much since I'm not up to speed on consensus yet. This PR passes all of the following checks:

  • This PR introduces new 3rd-party source code or binaries:
    • External code is from a reputable source
    • External code has underwent a documented security audit and high/severe findings have been mitigated
    • External code has associated vulnerability disclosure policy and contact information
    • External code has published previous vulnerabilities/fixes
    • Version of external code is latest
  • Findings introduced by the first-order source code of this PR generated by GoSec have been reviewed
    • gnovm/pkg/gnomod/fetch.go - no findings
    • tm2/ordering/ordering.go - no findings
    • tm2/pkg/bft/consensus/common_test.go - no findings
    • tm2/pkg/bft/consensus/reactor.go - findings not in scope of PR
    • tm2/pkg/bft/consensus/state.go - findings not in scope of PR
    • tm2/pkg/bft/consensus/types/round_state.go - no findings
    • tm2/pkg/bft/consensus/types/round_state_test.go - no findings
    • tm2/pkg/bft/consensus/wal_generator.go - no findings
    • tm2/pkg/bft/types/priv_validator.go - no findings
    • tm2/pkg/bft/types/validator.go - no findings
    • tm2/pkg/bft/types/validator_set.go - no findings
    • tm2/pkg/bft/types/validator_set_test.go - no findings
    • tm2/pkg/bft/wal/wal.go - findings not in scope of PR
    • tm2/pkg/crypto/crypto.go - no findings
    • tm2/pkg/crypto/keys/client/add.go - no findings
    • tm2/pkg/store/cache/mergeiterator.go - no findings
  • This PR has impacts the most security sensitive areas of the code such as entropy generation, secret storage, transaction/message signing, etc.
  • Comment: Consensus code may be security sensitive
  • This PR includes sufficient test coverage to demonstrate defensive programming, lack of surreptitious code, etc.
  • PR does not contain undocumented “magic values”

Copy link
Member

@thehowl thehowl left a comment

Choose a reason for hiding this comment

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

Disagree on the ordering package, rest looks pretty much OK.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not convinced by this package.

Go has recently introduced a utility function for comparison. Its return values are simple integers -1 0 1, same as bytes.Compare and all other similar functions. Do you have a compelling case as to why we should have this, as compared to using < 0 == 0 > 0 for comparison functions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only reason i have is it is more civilized...

tm2/pkg/bft/consensus/types/round_state.go Outdated Show resolved Hide resolved
tm2/pkg/bft/consensus/wal_generator.go Outdated Show resolved Hide resolved
tm2/pkg/bft/wal/wal.go Outdated Show resolved Hide resolved
@thehowl
Copy link
Member

thehowl commented Mar 28, 2024

I still don't think that adding ordering is a good idea if no-one in Go does it. I'll add this to the review meeting so we can decide.

Copy link
Member

@thehowl thehowl left a comment

Choose a reason for hiding this comment

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

From the review meeting: we agreed that returning structs instead of integers in this place, and going against the established go convention of returning -1 / 0 / 1 is not something we want to do. So PR good to go after we resolve that :)

@petar-dambovaliev
Copy link
Contributor Author

From the review meeting: we agreed that returning structs instead of integers in this place, and going against the established go convention of returning -1 / 0 / 1 is not something we want to do. So PR good to go after we resolve that :)

If that is removed, there is pretty much nothing in the PR that is left. I am closing this PR.

@thehowl thehowl deleted the 1320 branch December 8, 2024 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 🌐 tendermint v2 Issues or PRs tm2 related 📦 🤖 gnovm Issues or PRs gnovm related
Projects
Status: Done
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants