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

[stateless_validation] Add testing for handling state witness and chunk endorsements #10504

Merged
merged 2 commits into from
Jan 26, 2024

Conversation

shreyan-gupta
Copy link
Contributor

This PR improves the testing infrastructure for stateless validation to handle cases of network message propagation of ChunkStateWitness and ChunkEndorsement.

With the changes in validation of signature in chunk header, we need to handle ChunkEndorsement messages at the time of block production.

@shreyan-gupta shreyan-gupta added the A-stateless-validation Area: stateless validation label Jan 25, 2024
@shreyan-gupta shreyan-gupta requested a review from a team as a code owner January 25, 2024 22:39
Copy link

codecov bot commented Jan 25, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (7ccc492) 71.97% compared to head (e2494cf) 72.00%.
Report is 1 commits behind head on master.

Files Patch % Lines
chain/client/src/test_utils/test_env.rs 98.11% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10504      +/-   ##
==========================================
+ Coverage   71.97%   72.00%   +0.03%     
==========================================
  Files         720      720              
  Lines      146260   146265       +5     
  Branches   146260   146265       +5     
==========================================
+ Hits       105264   105322      +58     
+ Misses      36163    36117      -46     
+ Partials     4833     4826       -7     
Flag Coverage Δ
backward-compatibility 0.08% <0.00%> (ø)
db-migration 0.08% <0.00%> (ø)
genesis-check 1.26% <0.00%> (-0.01%) ⬇️
integration-tests 36.89% <98.11%> (+<0.01%) ⬆️
linux 71.29% <0.00%> (+<0.01%) ⬆️
linux-nightly 71.55% <98.11%> (+0.03%) ⬆️
macos 55.20% <0.00%> (-0.01%) ⬇️
pytests 1.48% <0.00%> (-0.01%) ⬇️
sanity-checks 1.27% <0.00%> (-0.01%) ⬇️
unittests 67.89% <0.00%> (+<0.01%) ⬆️
upgradability 0.13% <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.

) = msg
{
chunk_hashes.remove(endorsement.chunk_hash());
for network_adapter in network_adapters.iter() {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: you can replace network_adapters.iter() with &network_adapters

&mut self,
mut chunk_hashes: HashMap<ChunkHash, (BlockHeight, ShardId)>,
chunk_hash_to_account_ids: &mut HashMap<ChunkHash, HashSet<AccountId>>,
Copy link
Contributor

Choose a reason for hiding this comment

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

do you need this to be a &mut? Could you take the whole object by ownership?

) {
let _span = tracing::debug_span!(target: "test", "get_all_chunk_endorsements").entered();
let network_adapters = self.network_adapters.clone();
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we actually need to clone this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes as otherwise we would hold a mut reference to self within the loop. rustc wasn't happy

@shreyan-gupta shreyan-gupta added this pull request to the merge queue Jan 26, 2024
Merged via the queue into master with commit e14ee4d Jan 26, 2024
25 of 26 checks passed
@shreyan-gupta shreyan-gupta deleted the shreyan/stateless_validation/improve_test branch January 26, 2024 01:14
github-merge-queue bot pushed a commit that referenced this pull request Jan 26, 2024
…10507)

This PR uncomments two checks
- We now filter chunks based on whether they have enough stake endorsed
or not.
- We validate chunk endorsements in block header.

Enabling this breaks a bunch of tests mainly for two reasons
- Some tests are handled by mocking out parts/doing manual block
production which doesn't take care of chunk endorsement signatures
- A number of tests that work with multiple validators don't have the
appropriate network request handlers for chunk endorsement and state
witness processing.

These tests are impossible to explore and fix in a single PR and I've
created a task list to help with this here:
#10506

Note that we need to merge in the changes from
#10501 ,
#10503 and
#10504 before we can merge this.
Till then probably the tests would keep failing

Tip: Probably a good idea to review PR commit by commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-stateless-validation Area: stateless validation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants