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

Update schnorrkel to 0.9, remove deprecated api usage #5138

Closed
wants to merge 1 commit into from

Conversation

NikVolf
Copy link
Contributor

@NikVolf NikVolf commented Mar 5, 2020

No description provided.

@@ -776,6 +780,7 @@ mod test {
}

#[test]
#[ignore = "sr25519 signatures from 1.1 version are no longer supported"]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

what can be used instead?

Copy link
Member

Choose a reason for hiding this comment

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

Remove? The test is useless now^^

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.

changes lgtm, not sure about backwards compatibility issues.

).is_ok(),
Err(_) => false,
}
let signature = match schnorrkel::Signature::from_bytes(sig) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should try to sync kusama with this, not sure if there's txs signed with schnorrkel 0.1.1 that we won't be able to verify anymore. cc @burdges

Copy link
Contributor

Choose a reason for hiding this comment

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

Or BABE blocks for that matter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe we should try to sync kusama with this, not sure if there's txs signed with schnorrkel 0.1.1 that we won't be able to verify anymore. cc @burdges

Yep, trying to do it right now

@burdges said something that 1.1 were only used on Alexander

Copy link

Choose a reason for hiding this comment

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

We never supported VRFs from 0.1.1 because BABE did not work until after the audit. ;)

Just send schnorrkel a PR reverting w3f/schnorrkel@8f37065 if you really need it, but if these exist then we maybe we could keep that pain isolated to kusama, and disable the preaudit_deprecated feature for polkadot.

Copy link
Contributor

Choose a reason for hiding this comment

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

There will be old txs (old blocks) signed with 0.1.1 - the JS side only moved to 0.8.5 in Jan once Alex was dropped.

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.

Did you synced Kusama with it?

@@ -776,6 +780,7 @@ mod test {
}

#[test]
#[ignore = "sr25519 signatures from 1.1 version are no longer supported"]
Copy link
Member

Choose a reason for hiding this comment

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

Remove? The test is useless now^^

@@ -609,6 +612,7 @@ mod compatibility_test {
}

#[test]
#[ignore = "sr25519 signatures from version 1.1 are no longer supported"]
Copy link
Member

Choose a reason for hiding this comment

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

Same

@NikVolf NikVolf added the A3-in_progress Pull request is in progress. No review needed at this stage. label Mar 5, 2020
@NikVolf
Copy link
Contributor Author

NikVolf commented Mar 5, 2020

Did you synced Kusama with it?

got error in block 3876

Also can confirm that concerns in #5112 are valid.
Node just keeps spamming about runtime panic when invalid block is encountered.

@burdges
Copy link

burdges commented Mar 5, 2020

Any thoughts?

I've temporarily pushed f4447cd7eb0c793905aa85af4d32c71a78ea020a that reverts 8f3706591dcf0648086b5dfb4bd832970483ac03 and restores the preaudit_deprecated feature, but..

We should avoid support for preaudit_deprecated in polkadot because allowing it screws up batch verification for ed25519 without adding a key type field.

We actually have some key type field I suppose, so maybe we could leverage that for kusama somehow.

@burdges
Copy link

burdges commented Mar 5, 2020

I've an idea: Could kusama verify these old signature entirely from the runtime? We'd drop support for them from in the host in this case. Is that too annoying?

@bkchr
Copy link
Member

bkchr commented Mar 5, 2020

I've an idea: Could kusama verify these old signature entirely from the runtime? We'd drop support for them from in the host in this case. Is that too annoying?

No, the problem is that we can not modify the old runtimes anymore. However, we could probably workaround and only accept from now on the new signatures when building a block but still support verifying the old ones.

@burdges
Copy link

burdges commented Mar 16, 2020

I'll need to publish schnorrkel 0.9.1 with w3f/schnorrkel@f4447cd included I suppose?

Would it help if we assigned some new identifier byte for signature types?

@NikVolf
Copy link
Contributor Author

NikVolf commented Mar 16, 2020

I'll need to publish schnorrkel 0.9.1 with w3f/schnorrkel@f4447cd included I suppose?

Yeah, if it is an improvement on 0.8.*, we can update to it

@burdges
Copy link

burdges commented Mar 17, 2020

I've published 0.9.1 that brings back the preaudit_deprecated feature.

We cannot do a logical or in a batch verification, so #5023 requires the old and new signatures be distinguished. We need not distinguish them on-chain however. Instead, we expose both old and new verification mechanisms to the runtime, so the runtime could switch at some block height or whatever.

@Demi-Marie
Copy link
Contributor

I've published 0.9.1 that brings back the preaudit_deprecated feature.

We cannot do a logical or in a batch verification, so #5023 requires the old and new signatures be distinguished. We need not distinguish them on-chain however. Instead, we expose both old and new verification mechanisms to the runtime, so the runtime could switch at some block height or whatever.

Will we be able to get rid of the cruft at some point, once a certain block hash becomes hard-coded in the client?

@burdges
Copy link

burdges commented Mar 17, 2020

Will we be able to get rid of the cruft at some point, once a certain block hash becomes hard-coded in the client?

Yes and no. We'll ignore this entirely on Polkadot, so we can drop it from substrate builds that only support Polkadot. We cannot drop it from substrate builds that support Kusama, at least not until some consensus upgrade forces some "harder" fork. We should've gone through this pain for alexandre vs kusama, but we took the more relaxed approach there so we pay for it now.

@NikVolf
Copy link
Contributor Author

NikVolf commented Mar 17, 2020

I've published 0.9.1 that brings back the preaudit_deprecated feature.

We cannot do a logical or in a batch verification, so #5023 requires the old and new signatures be distinguished. We need not distinguish them on-chain however. Instead, we expose both old and new verification mechanisms to the runtime, so the runtime could switch at some block height or whatever.

Can this signatures be distinguished at runtime, at runtime?
We can just skip batch for them then, and forbid when block building.

@burdges
Copy link

burdges commented Mar 17, 2020

Can this signatures be distinguished at runtime, at runtime?
We can just skip batch for them then, and forbid when block building.

Yes I think this works, so no fancy checks.

Signatures by 0.1.1 should fail Signature::from_bytes. I published 0.1.1 on 2 April 2019, but only added the distinguishing marker checked by Signature::from_bytes on 19 April 2019: https://github.com/w3f/schnorrkel/commits/master?after=2d004cffa5dc3bf6dafeebee8d4d40b9f696462f+34&path%5B%5D=src&path%5B%5D=sign.rs

I published 0.2-0.7 in June-July, but yanked them all before Kusama's launch. We kept support for 0.1.1 for the alexandre testnet and only screwed up by not supporting 0.1.1 in Kusama.

I'd still prefer if polkadot avoided any support 0.1.1. ;)

@bkchr
Copy link
Member

bkchr commented Mar 19, 2020

Was done by: #5316

@bkchr bkchr closed this Mar 19, 2020
@bkchr bkchr deleted the nv-update-schnorrkel branch March 19, 2020 16:25
@NikVolf
Copy link
Contributor Author

NikVolf commented Mar 19, 2020

It was not done by #5316, doing it properly (with disabling generation of deprecated signatures) requires runtime api versioning I'm working on now

@bkchr
Copy link
Member

bkchr commented Mar 19, 2020

I know, but I see this as a new pr with a different scope.

@burdges
Copy link

burdges commented Mar 19, 2020

I'll amend my comment above: We'll separate proper schnorrkel signatures from these deprecated signatures for batch verification using schnorrkel::Signature::from_bytes, but we've no similar mechanism for separating the 0.1.1 signatures from ed25519 signatures for ed25519 batch verification. We could however just leave ed25519 batch verification off for kusma, while leaving schnorrkel 0.1.1 verification off for polkadot. If this switch gets controlled in the runtime, then kusama could flip ed25519 batch verification on at some point too.

@bkchr
Copy link
Member

bkchr commented Mar 19, 2020

Batch verification will require runtime changes and when this comes we will have support for disabling the old signature verification.

@bkchr
Copy link
Member

bkchr commented Mar 19, 2020

Tldr, we should get this working.

@NikVolf NikVolf restored the nv-update-schnorrkel branch March 20, 2020 15:12
@kirushik
Copy link

@bkchr is there a tracking issue for this task somewhere? Or any other way of monitoring the progress (and, more importantly, of ensuring that we don't leave preaudit_deprecated feature of schnorrkel on for any Polkadot release builds)?

@bkchr
Copy link
Member

bkchr commented Apr 14, 2020

The proper solution was implemented here: #5358

The problem is that we will never be able to disable preaudit_deprecated, because Kusama requires it when syncing from genesis. And the way we currently build Kusama, prevents us from disabling the feature for Polkadot, because it would automatically be enabled by Kusama (everything is build in the same env). However, newer runtimes don't expose the old function, this means we don't accept anymore signatures that are build with the 1.0 schnorrkel.

@Demi-Marie
Copy link
Contributor

@bkchr we can (and probably should) switch to separate environments instead. We can also hardcode the hash of every block made on Kusama with the old signature. We then don’t need to validate the signatures any more.

@bkchr
Copy link
Member

bkchr commented Apr 14, 2020

Why should we do this? We can not call this implementation anymore from newer runtimes. (it would work, but you would need to have control over the build process and get this runtime as the canonical one)

@Demi-Marie
Copy link
Contributor

@bkchr to remove cruft, reduce code size, and to ensure that this does not wind up in Polkadot.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A3-in_progress Pull request is in progress. No review needed at this stage.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants