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

Comments

Use batching verification in the runtime#6643

Closed
NikVolf wants to merge 13 commits intomasterfrom
nv-batch-verification-agai
Closed

Use batching verification in the runtime#6643
NikVolf wants to merge 13 commits intomasterfrom
nv-batch-verification-agai

Conversation

@NikVolf
Copy link
Contributor

@NikVolf NikVolf commented Jul 13, 2020

No description provided.

@NikVolf NikVolf added A0-please_review Pull request needs code review. B3-apinoteworthy C3-medium PR touches the given topic and has a medium impact on builders. labels Jul 13, 2020
@NikVolf NikVolf added the A1-needs_burnin Pull request needs to be tested on a live validator node before merge. DevOps is notified via matrix label Jul 13, 2020
@bkchr bkchr added the A1-onice label Jul 13, 2020
@bkchr
Copy link
Member

bkchr commented Jul 13, 2020

Put this on-ice as we need to wait until all validators are updated properly.

Copy link
Member

@bkchr bkchr left a comment

Choose a reason for hiding this comment

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

Can you please also change the signature batching function in primitives/io to panic, if there is no batching registered.

}
}

impl Verify for sp_core::ecdsa::Signature {
Copy link
Member

Choose a reason for hiding this comment

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

Why not for ecdsa?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ecdsa is a bit tricky, since it dominates the verification (takes much more time compared to transaction execution)

Node can be forced to do much more work before first ecdsa is resolved as invalid

Copy link
Member

@bkchr bkchr Jul 20, 2020

Choose a reason for hiding this comment

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

The other signatures probably also take more time to verify than a simple transfer. This feature is ridiculous if you draw the line here. Than we don't need async verification at all. If this would be a problem in the future, we could disable async signature verification when importing blocks on the tip of the chain. However, for syncing we want the best performance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To me, you can trick node to verify 1000 or so heavy signatures for free until first one is resolved and possibly completely stop some validators, not going to add it here until some proof that this is safe provided.

Copy link
Member

Choose a reason for hiding this comment

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

I can also force you to verify 3000 sr25519 signatures. Where it the difference?

Copy link
Member

Choose a reason for hiding this comment

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

Okay, you basically just want early exit of the scheduled verifications? So that we abort all, if one fails? Should not be that hard to implement, just make the future select on an exit signal.

And ECDSA is also not orders of magnitudes slower, on my machine it was factor 3 slower.

Copy link

Choose a reason for hiding this comment

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

We can support Ed25519 batch verification eventually I think, but not worth the time right now.

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 ECDSA performance is better than I had impression of, indeed just 3x thanks @bkchr, #6697

So should be no problem adding it also

Copy link
Member

Choose a reason for hiding this comment

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

Nevertheless, I like the idea of adding an early bail out for these verification tasks if one failed. This should prevent the problems you have described 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.

I added implementation for standalone ECDSA, but I think the way it works it can't be used in MultiSignature, since it uses AccountId32, which can store only blake2(public), but not public itself

@NikVolf
Copy link
Contributor Author

NikVolf commented Jul 20, 2020

Can you please also change the signature batching function in primitives/io to panic, if there is no batching registered.

How this supposed to work in block production?

@bkchr
Copy link
Member

bkchr commented Jul 20, 2020

Can you please also change the signature batching function in primitives/io to panic, if there is no batching registered.

How this supposed to work in block production?

Good point :(

@gnunicorn
Copy link
Contributor

closing because of inactivity.

@gnunicorn gnunicorn closed this Sep 9, 2020
@burdges
Copy link

burdges commented Sep 9, 2020

We want "batch verifiers" for basically all crypto, including both fancy future stuff like Groth16 and Plonk and ideally even our basic merkle tree proof checks, so that parachains do their heavy work off their main thread using algorithms with predictable runtimes. This helps enormously with preventing incorrect slashing in paritytech/polkadot#1656

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. A1-needs_burnin Pull request needs to be tested on a live validator node before merge. DevOps is notified via matrix C3-medium PR touches the given topic and has a medium impact on builders.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants