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: implemented incoming receipts handling in resharding #9474

Merged
merged 9 commits into from
Sep 6, 2023

Conversation

wacban
Copy link
Contributor

@wacban wacban commented Sep 1, 2023

This PR implements proper handling of incoming receipts in resharding.
Conceptually there are two parts, that take place when iterating back through the chain and collecting incoming receipts.

  • detect when the shard layout changes and adjust the shard id to its parent shard it
  • when picking up the receipts only pick ones that have receiver in the target shard id

For example in the following scenario:

  • resharding 3->3', 4'
  • block 10 is the last with the old shard layout
  • block 10 has some missing chunks and some incoming receipts with receivers in shard 3
    The implementation when getting incoming receipts for 4' will do the following:
  • adjust the shard id from 4' to its parent 3
  • get the incoming receipts for 3
  • filter out only the receipts that have receiver_id falling into 4' in the new shard layout

This scenario is covered by the integration test implemented in #9467.

@wacban wacban changed the title Waclaw resharding incoming fix feat: implemented incoming receipts handling in resharding Sep 1, 2023
@wacban wacban marked this pull request as ready for review September 1, 2023 13:16
@wacban wacban requested a review from a team as a code owner September 1, 2023 13:16
@wacban wacban requested review from jakmeier and removed request for a team September 1, 2023 13:16
@pugachAG pugachAG self-requested a review September 4, 2023 09:26
@jakmeier
Copy link
Contributor

jakmeier commented Sep 4, 2023

I see @pugachAG you have assigned yourself as a reviewer. Thank you for reviewing! I will remove myself, ping me if you think my input specifically is needed somewhere.

@jakmeier jakmeier removed their request for review September 4, 2023 12:16
Copy link
Contributor

@pugachAG pugachAG left a comment

Choose a reason for hiding this comment

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

overall looks good to me, but please take a look at my comments before merging

mut block_hash: CryptoHash,
last_chunk_height_included: BlockHeight,
) -> Result<Vec<ReceiptProofResponse>, Error> {
let _span =
tracing::debug_span!(target: "store", "get_incoming_receipts_for_shard").entered();
Copy link
Contributor

Choose a reason for hiding this comment

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

target: "store" is used in store crate, I think here target: "chain" would be more appropriate (applies to the all instances in this function)

chain/chain/src/store.rs Show resolved Hide resolved
@@ -192,9 +192,11 @@ fn apply_block_from_range(
}
};

// TODO(wacban) OK, has epoch manager handy
Copy link
Contributor

Choose a reason for hiding this comment

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

would be nice to have a bit more descriptive comment here 😃

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Opsie daisy :)

);
ret.push(ReceiptProofResponse(block_hash, receipt_proofs));

// If the shard layout changed we need to filter to make
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: consider moving that part to a separate function, something like

fn filter_incoming_receipts_for_shard(parent_shard_receipts: &[ReceiptProof], ...) -> Vec<ReceiptProof> {
...
}

Comment on lines 287 to 290
// TODO(resharding) adjust the shard proof accordingly
// currently this only matters for state sync
let receipt_proof = ReceiptProof(filtered_receipts, shard_proof);
filtered_receipt_proofs.push(receipt_proof);
Copy link
Contributor Author

@wacban wacban Sep 1, 2023

Choose a reason for hiding this comment

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

Note for the rightfully concerned reviewer.

This method has two important usages:

  • From the get_apply_chunk_job_new_chunk where the proofs are immediately discarded and only the receipts are used
    let receipt_proof_response = &self.store().get_incoming_receipts_for_shard(
  • From the compute_state_response_header where it will likely break things. This method is used for state sync which currently is not supported together with resharding but it will need to be fixed, hence the TODO.
    let incoming_receipts_proofs = self.store.get_incoming_receipts_for_shard(

@@ -192,9 +192,11 @@ fn apply_block_from_range(
}
};

// TODO(wacban) OK, has epoch manager handy
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Opsie daisy :)

Base automatically changed from waclaw-resharding-incoming to master September 6, 2023 12:05
@wacban wacban force-pushed the waclaw-resharding-incoming-fix branch from 73e2d28 to f5d461b Compare September 6, 2023 12:25
@wacban wacban added this pull request to the merge queue Sep 6, 2023
Merged via the queue into master with commit 95b8f30 Sep 6, 2023
@wacban wacban deleted the waclaw-resharding-incoming-fix branch September 6, 2023 14:09
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