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

Laura/fetch certificates for stream follower #1121

Merged
merged 4 commits into from
Mar 30, 2022

Conversation

lanvidr
Copy link
Contributor

@lanvidr lanvidr commented Mar 28, 2022

Handles the 2nd & 3rd bullet points of #729

@lanvidr lanvidr requested review from gdanezis and oxade March 28, 2022 23:10
Copy link
Collaborator

@gdanezis gdanezis left a comment

Choose a reason for hiding this comment

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

Nice one, lets todo the missing checks at least & we could avoid possibly the use of a channel by returning batch_info_items.map( ... ) ?

match batch_info_response_item.clone() {
BatchInfoResponseItem(UpdateItem::Batch(signed_batch)) => {
// check signature of batch
let result = signed_batch.signature.check(&signed_batch.signature, signed_batch.authority);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Lets add a bunch of todos here for all the other checks:

  • The signature should be valid over the set of transactions that the batch contains.
  • And also over the hash of the previous batch.
  • And the sequence numbers of trasnactions enclosed need to be correct and the size matching?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was going to do these now but these now but realized that this may need more discussion. I've added in todos here.

BatchInfoResponseItem(UpdateItem::Transaction((_seq, digest))) => {
// make transaction info request which checks transaction certificate
let transaction_info_request = TransactionInfoRequest{ transaction_digest: digest };
let transaction_info_response = self.handle_transaction_info_request(transaction_info_request).await;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This actually does not pipeline the requests, so it will be slow. We should fix the underlying implementation (best, todo) or make a pipelined variant for this use case.

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 the code around the question I asked earlier slack. Is this where we would leverage a local store and only request ones that are not already there?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made an issue for this, and will work on this shortly #1127

Copy link
Collaborator

@gdanezis gdanezis Mar 29, 2022

Choose a reason for hiding this comment

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

Right now, lets assume you need to download them and finalise this PR, we can later specify a flag on whether the requester wants to request them by default or not. Or you can implement the flag now i you prefer. Up to you.

}
}
Err(_) => {
continue;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are we sure we want to continue on err? If so lets comment why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The handle_batch_streaming on the AuthorityClient keeps processing until there are up to 10 errors found. This is because if we return on the first error, we might forgo processing of valid items later in the stream. But we also need to balance with byzantine tolerance, so we still limit the number of errors before we stop. Do you think we would do better to return on the first error?

Copy link
Collaborator

Choose a reason for hiding this comment

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

we might forgo processing of valid items later in the stream

If we have an error are we guaranteed that subsequent items in the stream make sense? Ie is there a condition under which the authority side of the streaming will send an error, and then continue streaming items?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One message may have been corrupted in the encoding / decoding process? I imagine all sorts of unpredicted one-off things will eventually happen.

@@ -301,6 +301,8 @@ impl Signature {

pub struct AuthoritySignature(pub dalek::Signature);

impl BcsSignable for AuthoritySignature {}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where do we need 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.

The check function called on the signed_batch requires that the value implements BcsSignable.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hm, but are we not calling .check() on the batch, rather than on the signature?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@lanvidr lanvidr force-pushed the laura/fetch_certificates_for_stream_follower branch 3 times, most recently from 4e02fa3 to f34df16 Compare March 29, 2022 23:53
@lanvidr lanvidr force-pushed the laura/fetch_certificates_for_stream_follower branch from f34df16 to 27e5f3e Compare March 30, 2022 00:20
@lanvidr lanvidr merged commit feab273 into main Mar 30, 2022
@lanvidr lanvidr deleted the laura/fetch_certificates_for_stream_follower branch March 30, 2022 02:20
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.

2 participants