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

CandidateDescriptor: disable collator signature and collator id usage #4665

Merged
merged 15 commits into from
Jul 25, 2024

Conversation

sandreim
Copy link
Contributor

@sandreim sandreim commented May 31, 2024

Collator id and collator signature do not serve any useful purpose. Removing the signature check from runtime but keeping the checks in the node until the runtime is upgraded.

TODO:

  • PRDoc
  • Add node feature for core index commitment enablement

@sandreim sandreim changed the title CandidateDescriptor: disable signature and collator id usage CandidateDescriptor: disable collator signature and collator id usage May 31, 2024
@burdges
Copy link

burdges commented May 31, 2024

Aren't they in the block header anyways?

Signed-off-by: Andrei Sandu <[email protected]>
Signed-off-by: Andrei Sandu <[email protected]>
@sandreim
Copy link
Contributor Author

Aren't they in the block header anyways?

Yeah AFAIK, but the relay chain doesn't make any assumptions about what the header contains. In any case we just don't need them

Signed-off-by: Andrei Sandu <[email protected]>
Signed-off-by: Andrei Sandu <[email protected]>
Signed-off-by: Andrei Sandu <[email protected]>
@sandreim sandreim marked this pull request as ready for review July 23, 2024 12:40
Signed-off-by: Andrei Sandu <[email protected]>
Copy link
Contributor

@alexggh alexggh left a comment

Choose a reason for hiding this comment

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

Looks alright, I have a small concern, but other than that it should be fine.

@@ -1259,11 +1256,6 @@ impl<T: Config> CandidateCheckContext<T> {
);
}

ensure!(
Copy link
Contributor

@alexggh alexggh Jul 23, 2024

Choose a reason for hiding this comment

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

Correlated with this this:

if let Err(()) = candidate.check_collator_signature() {
, isn't it possible we actually stall finality if backers collude to include a candidate with the wrong 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.

With this change, the runtime will no longer care about what is being put in collator signature.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, but wouldn't that mean that the block author will accept blocks with invalid signature, that will then fail the candidate-validation because we are still checking the signature there ?

Anyways, I thought a bit more about this and it is a non-issue because, that will just trigger a dispute which will punish the malicious backers, so this change does not introduce any attack-vector.

Copy link
Contributor Author

@sandreim sandreim Jul 24, 2024

Choose a reason for hiding this comment

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

This is actually a good point. It is a bit subtle but yes, validators strictly need to still check the signatures even if the runtime doesn't. The problem I see with this is that malicious collators can put garbage in the signature, candidates get backed by validators upgraded to not check the signature in the future. During approval checking, these candidates will be disputed by older validators that check the signature.

Then who gets punished depends on which kind of super majority we have. This sounds like a new attack vector to me.

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'll likely need another node feature 🤦🏼 just to give people more time to upgrade, but at least 2/3, then we need to communicate the deadline when it becomes dangerous (due to prev comment) to not have upgraded yet.

Copy link
Contributor Author

@sandreim sandreim Jul 24, 2024

Choose a reason for hiding this comment

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

One way to solve this is to still keep the signature checks only for node but only check them if we don't have a core index (signaled by Ump commitment and zero padding in descriptor).

Copy link
Member

Choose a reason for hiding this comment

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

One way to solve this is to still keep the signature checks only for node but only check them if we don't have a core index (signaled by Ump commitment and zero padding in descriptor).

I had a similar idea, but I don't see how this fixes anything. You still have the problem of different validators arriving at different validity.

The node feature is actually the way to go. We still need to wait for enough validators to upgrade, but then we have perfect consensus on what strategy to use in an instant. Any too old validators might get slashed, but we actually have requirements on validators to keep their node current, so that is fine.

So basic plan is to implement everything at once:

  1. Ignore signature
  2. If signature zero, re-interpret data.
  3. Enable all of that with a node feature.

Collators will not be affected. Collators can still provide a signature, it will simply be ignored. If they set it to 0, we re-interpret fields.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. I'll add the node feature in this PR. It will signal the nodes to not check the signature if there is a core_index.

Copy link
Member

Choose a reason for hiding this comment

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

Once the feature is enabled no signature needs to be checked at all anymore. But we should also directly start re-interpreting fields in case the signature is 0. Otherwise we would need two node features: One to disable checking and then another one to check the core index.

@alindima alindima added the T8-polkadot This PR/Issue is related to/affects the Polkadot network. label Jul 24, 2024
Signed-off-by: Andrei Sandu <[email protected]>
Signed-off-by: Andrei Sandu <[email protected]>
@paritytech-cicd-pr
Copy link

The CI pipeline was cancelled due to failure one of the required jobs.
Job name: cargo-clippy
Logs: https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/6803290

Signed-off-by: Andrei Sandu <[email protected]>
@sandreim sandreim added this pull request to the merge queue Jul 25, 2024
Merged via the queue into master with commit 48afbe3 Jul 25, 2024
158 of 162 checks passed
@sandreim sandreim deleted the sandreim/remove_collator_sig branch July 25, 2024 10:19
TarekkMA pushed a commit to moonbeam-foundation/polkadot-sdk that referenced this pull request Aug 2, 2024
…paritytech#4665)

Collator id and collator signature do not serve any useful purpose.
Removing the signature check from runtime but keeping the checks in the
node until the runtime is upgraded.

TODO: 
- [x] PRDoc
- [x] Add node feature for core index commitment enablement

---------

Signed-off-by: Andrei Sandu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T8-polkadot This PR/Issue is related to/affects the Polkadot network.
Projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

6 participants