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

feat: skip processing old state witnesses #11081

Merged
merged 3 commits into from
Apr 17, 2024
Merged

Conversation

pugachAG
Copy link
Contributor

@pugachAG pugachAG commented Apr 16, 2024

This PR introduces protection against wasting stateless validator resources on processing state witness when chunk endorsement is guaranteed not to have an effect on the chain state. In particular any chunk with height_created that doesn't exceed the height of the last final block can be safely skipped.

Part of #10565.

Copy link

codecov bot commented Apr 16, 2024

Codecov Report

Attention: Patch coverage is 23.07692% with 10 lines in your changes are missing coverage. Please review.

Project coverage is 71.06%. Comparing base (a595da4) to head (93d0441).
Report is 14 commits behind head on master.

Files Patch % Lines
...nt/src/stateless_validation/chunk_validator/mod.rs 23.07% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11081      +/-   ##
==========================================
- Coverage   71.09%   71.06%   -0.03%     
==========================================
  Files         761      764       +3     
  Lines      153042   153237     +195     
  Branches   153042   153237     +195     
==========================================
+ Hits       108802   108898      +96     
- Misses      39800    39906     +106     
+ Partials     4440     4433       -7     
Flag Coverage Δ
backward-compatibility 0.24% <0.00%> (-0.01%) ⬇️
db-migration 0.24% <0.00%> (-0.01%) ⬇️
genesis-check 1.43% <0.00%> (+<0.01%) ⬆️
integration-tests 36.74% <23.07%> (+0.04%) ⬆️
linux 69.48% <0.00%> (-0.04%) ⬇️
linux-nightly 70.52% <23.07%> (-0.05%) ⬇️
macos 54.17% <0.00%> (-0.11%) ⬇️
pytests 1.66% <0.00%> (+<0.01%) ⬆️
sanity-checks 1.45% <0.00%> (+<0.01%) ⬆️
unittests 66.74% <0.00%> (-0.05%) ⬇️
upgradability 0.29% <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.

Copy link
Contributor

@jancionear jancionear left a comment

Choose a reason for hiding this comment

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

LGTM 👍

I wonder if it would be possible to unify this logic and the one for orphaned witnesses, but it might not be that simple 🤔

chunk_hash=?witness.chunk_header.chunk_hash(),
witness_height=witness.chunk_header.height_created(),
final_height=final_head.height,
"Skipping old state witness",
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe expand this string to say skipping old state witness generated for already final blocks? (as what "old" witness means may not be clear)

@pugachAG
Copy link
Contributor Author

@jancionear

I wonder if it would be possible to unify this logic and the one for orphaned witnesses

Indeed that would be nice. I've looked into that, but there is very little overlap except for the height check, so not much to extract 😞

@pugachAG pugachAG enabled auto-merge April 17, 2024 15:14
@pugachAG pugachAG added this pull request to the merge queue Apr 17, 2024
@pugachAG pugachAG removed this pull request from the merge queue due to a manual request Apr 17, 2024
@pugachAG pugachAG enabled auto-merge April 17, 2024 15:21
@pugachAG pugachAG added this pull request to the merge queue Apr 17, 2024
Merged via the queue into master with commit 6d17fa9 Apr 17, 2024
27 of 29 checks passed
@pugachAG pugachAG deleted the skip-old-state-witness branch April 17, 2024 16:05
github-merge-queue bot pushed a commit that referenced this pull request Apr 18, 2024
…ght check (#11097)

It is safe to also drop state witness with `height_created` equal to the
height of the last final block.
This is mostly to stay consistent with the check introduced in #11081.
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.

None yet

4 participants