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(resharding) - congestion info computation #12581

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

wacban
Copy link
Contributor

@wacban wacban commented Dec 9, 2024

Implementing the congestion info computation based on the parent congestion info and the receipt groups info from the parent trie. The seed used for the allowed shard is a bit hacky - please let me know if this makes sense.

I added assertion checking that the buffered gas in congestion info is zero iff the buffers are empty. With this in place the test_resharding_v3_buffered_receipts_towards_splitted_shard tests fail without the updated congestion info and pass with it in place.

@wacban wacban requested a review from a team as a code owner December 9, 2024 16:45
@@ -213,11 +222,24 @@ impl ReshardingManager {
};
let mem_changes = trie_changes.mem_trie_changes.as_ref().unwrap();
let new_state_root = mem_tries.apply_memtrie_changes(block_height, mem_changes);
drop(mem_tries);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is annoying but needed to prevent a deadlock.

let epoch_id = block.header().epoch_id();
let protocol_version = self.epoch_manager.get_epoch_protocol_version(epoch_id)?;

let trie = tries.get_trie_for_shard(new_shard_uid, new_state_root);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

bootstrap_congestion_info requires TrieAccess - can I get it somehow from the memtries above directly?

// TODO(resharding): set all fields of `ChunkExtra`. Consider stronger
// typing. Clarify where it should happen when `State` and
// `FlatState` update is implemented.
let mut child_chunk_extra = ChunkExtra::clone(&chunk_extra);
*child_chunk_extra.state_root_mut() = new_state_root;
// TODO(resharding) - Implement proper congestion info for
// resharding. The current implementation is very expensive.
Copy link
Contributor

@jancionear jancionear Dec 10, 2024

Choose a reason for hiding this comment

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

While we're waiting for the bandwidth scheduler to give us an efficient way to do the same

OutgoingMetadatas are already fully functional and merged into master, I didn't plan to add anything else. What sort of functionality are you looking for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah nice! I think all I need is the total size of the buffered receipts. I'll check and come back.

@wacban wacban marked this pull request as draft December 10, 2024 09:30
Copy link
Contributor

@marcelo-gonzalez marcelo-gonzalez left a comment

Choose a reason for hiding this comment

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

looks pretty sane to me but I am not super familiar w congestion control, so ill let others approve

@wacban
Copy link
Contributor Author

wacban commented Dec 11, 2024

I will do the proper version anyway so don't mind it for now please.

@wacban wacban force-pushed the waclaw-resharding branch 2 times, most recently from 9529c2f to e55dae2 Compare December 12, 2024 11:52
@wacban
Copy link
Contributor Author

wacban commented Dec 13, 2024

nayduck with extra assertions:
https://nayduck.nearone.org/#/run/917

Copy link

codecov bot commented Dec 18, 2024

Codecov Report

Attention: Patch coverage is 88.40580% with 16 lines in your changes missing coverage. Please review.

Project coverage is 70.48%. Comparing base (e692d20) to head (bb0f0be).
Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
chain/chain/src/resharding/manager.rs 91.48% 0 Missing and 8 partials ⚠️
...chain/src/stateless_validation/chunk_validation.rs 77.27% 0 Missing and 5 partials ⚠️
core/primitives/src/types.rs 57.14% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #12581      +/-   ##
==========================================
- Coverage   70.49%   70.48%   -0.01%     
==========================================
  Files         845      845              
  Lines      172247   172384     +137     
  Branches   172247   172384     +137     
==========================================
+ Hits       121426   121506      +80     
- Misses      45725    45761      +36     
- Partials     5096     5117      +21     
Flag Coverage Δ
backward-compatibility 0.16% <0.00%> (-0.01%) ⬇️
db-migration 0.16% <0.00%> (-0.01%) ⬇️
genesis-check 1.36% <0.00%> (-0.01%) ⬇️
linux 69.30% <9.42%> (-0.05%) ⬇️
linux-nightly 70.08% <88.40%> (-0.01%) ⬇️
pytests 1.66% <0.75%> (-0.01%) ⬇️
sanity-checks 1.47% <0.75%> (-0.01%) ⬇️
unittests 70.31% <88.40%> (-0.01%) ⬇️
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.

@wacban wacban changed the title feat(resharding) - brute force congestion info computation feat(resharding) - congestion info computation Dec 18, 2024
@wacban wacban marked this pull request as ready for review December 18, 2024 15:00
Copy link
Contributor

@marcelo-gonzalez marcelo-gonzalez left a comment

Choose a reason for hiding this comment

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

I think it looks okay to me, but I will let @jancionear approve, since I'm not as familiar with the bandwidth scheduler/congestion code. But ping me if you need me to stamp to unblock it

let gas = receipt_groups.total_gas();
let gas = gas.try_into().expect("ReceiptGroup gas must fit in u64");

congestion_info
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 not have to set total_receipts_num as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good sanity check! The total_receipts_num field is part of ReceiptGroupsQueueData which is resharded by copying to left child only. It is handled by the memtrie and flat storage split operations. MemTrie is already implemented here and this PR adds the flat storage equivalent.

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.

3 participants