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

test: enable simple resharding v3 test #12191

Merged
merged 3 commits into from
Oct 8, 2024
Merged

Conversation

Longarithm
Copy link
Member

Do minimal changes to the code allowing to check that number of shards in the new epoch increased.

This code can be reused to test each separate component for resharding v3:

  • non-contiguous shard ids
  • state sync
  • memtries resharding
  • ...

To make the test pass, nodes must track all shards for now, because state sync is not implemented yet. So every node must think that it has enough state to skip state sync.

Note that it doesn't mean at all that resharding works already. State is also not properly constructed yet, so tx processing will either be incorrect or crash the node.

Copy link

codecov bot commented Oct 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.68%. Comparing base (e129b31) to head (b03af30).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #12191      +/-   ##
==========================================
+ Coverage   71.61%   71.68%   +0.07%     
==========================================
  Files         824      824              
  Lines      165513   165526      +13     
  Branches   165513   165526      +13     
==========================================
+ Hits       118524   118650     +126     
+ Misses      41858    41740     -118     
- Partials     5131     5136       +5     
Flag Coverage Δ
backward-compatibility 0.17% <0.00%> (-0.01%) ⬇️
db-migration 0.17% <0.00%> (-0.01%) ⬇️
genesis-check 1.25% <0.00%> (-0.01%) ⬇️
integration-tests 38.85% <100.00%> (+0.12%) ⬆️
linux 71.38% <80.95%> (-0.02%) ⬇️
linux-nightly 71.25% <100.00%> (+0.07%) ⬆️
macos 54.13% <54.54%> (-0.03%) ⬇️
pytests 1.57% <0.00%> (-0.01%) ⬇️
sanity-checks 1.38% <0.00%> (-0.01%) ⬇️
unittests 65.33% <54.54%> (-0.02%) ⬇️
upgradability 0.21% <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.

@@ -2347,7 +2347,12 @@ impl Chain {
) -> bool {
let result = epoch_manager.will_shard_layout_change(parent_hash);
let will_shard_layout_change = match result {
Ok(will_shard_layout_change) => will_shard_layout_change,
Ok(_will_shard_layout_change) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: could we add a todo here to enable this later?

Copy link
Contributor

@wacban wacban left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines 2351 to 2353
// Before state sync is fixed, we don't catch up split shards.
// Assume that all needed shards are tracked already.
// will_shard_layout_change,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a TODO(resharding) here?

cc @marcelo-gonzalez you will likely need fix that as part of state sync & resharding integration

if idx < validator_num {
client_config.tracked_shards = Vec::new();
} else {
let not_a_validator = {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: It's better to use positive statements ( is_validator ) - it makes it more readable
mini-nit: maybe worth moving to a helper method

let clients = accounts.iter().cloned().collect_vec();
let block_and_chunk_producers = (0..8).map(|idx| accounts[idx].as_str()).collect_vec();
// TODO: set up chunk validator-only nodes.
let clients = vec![accounts[0].clone(), accounts[3].clone(), accounts[6].clone()];
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you only pick a few accounts here? Can you add a comment?

Comment on lines +50 to +52
base_epoch_config.block_producer_kickout_threshold = 0;
base_epoch_config.chunk_producer_kickout_threshold = 0;
base_epoch_config.chunk_validator_only_kickout_threshold = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why no kickouts? Is it temporary until all is implemented? If so can you add a todo?

Copy link
Contributor

@Trisfald Trisfald left a comment

Choose a reason for hiding this comment

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

🚀

/// which is incorrect!!!
/// - Nodes must not track all shards. State sync must succeed.
/// - Set up chunk validator-only nodes. State witness must pass validation.
/// - Tx load must be consistent. Txs and receipts must cross resharding
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be better if test cross shard receipts in a separate test, but yes tx should be consistent

base_epoch_config.block_producer_kickout_threshold = 0;
base_epoch_config.chunk_producer_kickout_threshold = 0;
base_epoch_config.chunk_validator_only_kickout_threshold = 0;
base_epoch_config.shard_layout = ShardLayout::v1(vec!["account3".parse().unwrap()], None, 3);
Copy link
Contributor

Choose a reason for hiding this comment

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

We should test also the case where we go from ShardLayout::v2 to ShardLayout::v2. Maybe in following PRs we can have a common setup method

shards_split_map.insert(last_shard_id, vec![max_shard_id + 1, max_shard_id + 2]);
boundary_accounts.push(AccountId::try_from("x.near".to_string()).unwrap());
// Keep this way until non-contiguous shard ids are supported.
// let new_shards = vec![max_shard_id + 1, max_shard_id + 2];
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: add todo?

@Longarithm Longarithm added this pull request to the merge queue Oct 8, 2024
Merged via the queue into near:master with commit d0a33c3 Oct 8, 2024
28 of 30 checks passed
@Longarithm Longarithm deleted the rv3-fix-test branch October 8, 2024 20:33
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