Skip to content

Conversation

@timorl
Copy link
Contributor

@timorl timorl commented Dec 30, 2022

Description

Implements the validator and justifications. Makes the code a bit of a mess, mostly because some of this stuff was already there and still needs to be used externally while we still have the legacy justification sync.

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist:

  • I have created new documentation

@timorl timorl changed the title Add justifications and validator implementations A0-1820: Add justifications and validator implementations Dec 30, 2022
@timorl timorl requested review from DamianStraszak, lesniak43 and maciejnems and removed request for lesniak43 December 30, 2022 15:04
Copy link
Contributor

@maciejnems maciejnems left a comment

Choose a reason for hiding this comment

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

From what I understand outside of session map, the only write lock we have is for subscribing for authority list, so there is no possibility of new deadlocks to occur after changing it to sync code.

impl<H: SubstrateHeader<Number = BlockNumber>> Verifier<Justification<H>> for FullVerifier {
type Error = VerificationError;

fn verify(&self, justification: Justification<H>) -> Result<Justification<H>, Self::Error> {
Copy link
Contributor

@maciejnems maciejnems Jan 2, 2023

Choose a reason for hiding this comment

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

This verify seems to be pretty heavy. On each call it locks on SessionMap, clones authorities and creates a new verifier. Still I'm not sure if there is a better way, to create a full verifier.

I guess we would have to somehow cache already existing verifiers and remove them from cache once they are not needed, which is already done in SessionMap :// maybe @DamianStraszak has an idea for that.

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 agree this is annoying... I'll look into how hard it would be to rewrite ROSM some more to avoid 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.

Ok, it seems I'll rewrite much more here after all, I'll open a separate PR for some smaller part of this and then write one for the verifier (although it will take longer). This one will likely get closed.

fn from(authority_data: SessionAuthorityData) -> Self {
SessionVerifier {
authority_verifier: AuthorityVerifier::new(authority_data.authorities().to_vec()),
emergency_signer: authority_data.emergency_finalizer().clone(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Also this clone should probably not happen, as we move SessionAuthorityData. That said I'm not sure how to get authorities and signer out of SessionAuthorityData ://

@timorl timorl changed the title A0-1820: Add justifications and validator implementations WIP: A0-1820: Add justifications and validator implementations Jan 3, 2023
@timorl timorl closed this Feb 7, 2023
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