Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Conversation

@octol
Copy link
Contributor

@octol octol commented Apr 9, 2021

In #8392 we started storing the latest justification for every finalized block. With this we can now respond with this latest justification in prove_finality when asked for a block in the latest authority set.

This also removes ProvableJustification

Also fix a bug where the FinalityProof::unknown_headers did not contain the last header in the sequence, that is, the header corresponding to the justification also included.

@octol octol added A3-in_progress Pull request is in progress. No review needed at this stage. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. labels Apr 9, 2021
@octol octol requested a review from andresilva as a code owner April 9, 2021 10:16
@github-actions github-actions bot added A0-please_review Pull request needs code review. and removed A3-in_progress Pull request is in progress. No review needed at this stage. labels Apr 9, 2021
@octol octol requested review from bkchr and expenses April 12, 2021 09:35
@expenses expenses requested a review from tomaka April 14, 2021 11:47
#[derive(Debug, Encode, Decode, Clone, PartialEq)]
pub struct AuthoritySetChanges<N>(Vec<(u64, N)>);

/// The response when queuering for a the set id for a specific block. Either we get a set id
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// The response when queuering for a the set id for a specific block. Either we get a set id
/// The response when querying for a the set id for a specific block. Either we get a set id

@expenses
Copy link
Contributor

I'm not quite sure what this changes with respect to grandpa warp sync. Does it make anything faster for smoldot?

Copy link
Contributor

@andresilva andresilva left a comment

Choose a reason for hiding this comment

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

If you don't want to deal with removing ProvableJustification in this PR that's OK, but please don't change the signature of best_justification and update_best_justification.

) -> R
where
Header: HeaderT,
J: ProvableJustification<Header>,
Copy link
Contributor

Choose a reason for hiding this comment

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

I wanted to remove ProvableJustification as it is a bit useless right now. Tests can just create a proper GrandpaJustification.

Comment on lines 692 to 699
#[derive(Debug, PartialEq)]
pub enum AuthoritySetChangeId<N> {
/// The requested block is in the latest set.
Latest,
/// Tuple containing the set id and the last block number of that set.
Set(SetId, N),
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't really like this type, seems overly complicated for what we're doing here. Perhaps we should just drop the assumption that some data might not be available.

}
}

pub(crate) fn block_is_current_set(&self, block_number: N) -> Option<bool> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can just be moved above as it's not used elsewhere.

@andresilva
Copy link
Contributor

I'm not quite sure what this changes with respect to grandpa warp sync. Does it make anything faster for smoldot?

It should make no difference for grandpa warp sync, this only affects the grandpa_proveFinality RPC API.

@tomaka tomaka removed their request for review April 14, 2021 13:12
@octol
Copy link
Contributor Author

octol commented Apr 15, 2021

Thanks for the feedback :)
I'll remove ProvableJustification

@octol octol requested a review from andresilva April 19, 2021 06:45
@octol
Copy link
Contributor Author

octol commented Apr 19, 2021

Pushed a new set of commits that primarily removes ProvableJustification

@andresilva andresilva changed the title grandpa: prove_finality learn how to respond with the latest justification grandpa-rpc: allow proving finality of blocks from latest authority set Apr 19, 2021
Copy link
Contributor

@andresilva andresilva left a comment

Choose a reason for hiding this comment

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

I pushed some changes myself. Tests still need some cleaning up.

};
let proof = check_finality_proof::<_, TestJustification>(
1,
let proof = check_finality_proof::<Block>(
Copy link
Contributor

Choose a reason for hiding this comment

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

With the latest changes I think we're not actually testing anything 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.

We're mostly just testing GrandpaJustification::verify, but that's mostly what check_finality_proof does anyway I think?


for block in to_finalize {
let just = block.encode();
client.finalize_block(BlockId::Number(*block), Some((ID, just))).unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

The justification we're creating here is actually just a block number. This probably made sense before the latest changes when the test code was generic on the justification type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's just some Vec<u8>, but wanted something unique per block in case the tests checked for those justifications. I'll change this to something simpler

precommits,
};

let best_grandpa_just = GrandpaJustification::from_commit(&client, 8, commit).unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe adding some comments around the setup in this test will make it easier to understand.

};

let best_grandpa_just = GrandpaJustification::from_commit(&client, 8, commit).unwrap();
store_best_justification(&client, &best_grandpa_just);
Copy link
Contributor

Choose a reason for hiding this comment

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

If this test is supposed to be using the justification from the block then why store the best justification? That's what we test in the test below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Storing the best justification too, just to check that it is not the one that gets used

let block8 = &blocks[7];

let grandpa_just8 = vec![42];
client.finalize_block(BlockId::Number(8), Some((ID, grandpa_just8.clone()))).unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we store a valid justification here?

@expenses expenses requested review from expenses and removed request for expenses April 20, 2021 10:34
@octol octol requested a review from andresilva April 22, 2021 10:50
Copy link
Contributor

@andresilva andresilva left a comment

Choose a reason for hiding this comment

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

lgtm

@andresilva
Copy link
Contributor

bot merge

@ghost
Copy link

ghost commented Apr 28, 2021

Trying merge.

@ghost
Copy link

ghost commented Apr 28, 2021

Bot will approve on the behalf of @andresilva, since they are a team lead, in an attempt to reach the minimum approval count

@ghost ghost merged commit 37e97cf into master Apr 28, 2021
@ghost ghost deleted the jon/respond-with-latest-justification branch April 28, 2021 11:13
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants