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

Move balance check into debug assertion #12516

Merged
merged 4 commits into from
Nov 26, 2024

Conversation

mooori
Copy link
Contributor

@mooori mooori commented Nov 26, 2024

It was decided offline that check_balance should not be called in release builds anymore. This PR implements this change by gating check_balance(...) behind cfg!(debug_assertions).

Copy link

codecov bot commented Nov 26, 2024

Codecov Report

Attention: Patch coverage is 64.70588% with 6 lines in your changes missing coverage. Please review.

Project coverage is 70.06%. Comparing base (9407fe9) to head (3a5ae5d).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
runtime/runtime/src/lib.rs 64.70% 5 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #12516      +/-   ##
==========================================
- Coverage   70.09%   70.06%   -0.03%     
==========================================
  Files         840      840              
  Lines      170147   170159      +12     
  Branches   170147   170159      +12     
==========================================
- Hits       119257   119218      -39     
- Misses      45727    45772      +45     
- Partials     5163     5169       +6     
Flag Coverage Δ
backward-compatibility 0.16% <0.00%> (-0.01%) ⬇️
db-migration 0.16% <0.00%> (-0.01%) ⬇️
genesis-check 1.27% <0.00%> (-0.01%) ⬇️
linux 69.29% <64.70%> (-0.02%) ⬇️
linux-nightly 69.64% <64.70%> (+<0.01%) ⬆️
macos 51.30% <64.70%> (+0.03%) ⬆️
pytests 1.58% <0.00%> (-0.01%) ⬇️
sanity-checks 1.39% <0.00%> (-0.01%) ⬇️
unittests 69.88% <64.70%> (-0.03%) ⬇️
upgradability 0.20% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@mooori
Copy link
Contributor Author

mooori commented Nov 26, 2024

I've rewritten it to panic with the error message plus some context. That feels like the closest match to debug_assert with logging / tracing.

@mooori mooori marked this pull request as ready for review November 26, 2024 15:47
@mooori mooori requested a review from a team as a code owner November 26, 2024 15:47
&processing_state.stats,
) {
panic!(
"Balance check failed for shard {} at height {} with block hash {}: {}",
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe add more context here, because it is not clear to me what you mean by "balance check".

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's rephrased a bit in 9528967 and I added the protocol version. Hope that helps to track down where the error originates while not being a too long panic message.

@akhi3030
Copy link
Collaborator

I think this is good to be merged. Any further suggestions can be made in additional PRs.

@mooori mooori added this pull request to the merge queue Nov 26, 2024
Merged via the queue into near:master with commit 8756ac5 Nov 26, 2024
21 of 22 checks passed
@mooori mooori deleted the disable-balance-check branch November 26, 2024 17:42
github-merge-queue bot pushed a commit that referenced this pull request Mar 5, 2025
`check_balance` was converted to a debug assert in PR
#12516

Unfortunately, this was a protocol change and meant old and new nodes
were not in coordination any more.

This PR puts `check_ balance` behind a protocol feature flag
shreyan-gupta added a commit that referenced this pull request Mar 5, 2025
`check_balance` was converted to a debug assert in PR
#12516

Unfortunately, this was a protocol change and meant old and new nodes
were not in coordination any more.

This PR puts `check_ balance` behind a protocol feature flag
VanBarbascu pushed a commit that referenced this pull request Mar 5, 2025
…13055)

`check_balance` was converted to a debug assert in PR
#12516

Unfortunately, this was a protocol change and meant old and new nodes
were not in coordination any more.

This PR puts `check_ balance` behind a protocol feature flag
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.

4 participants