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

On-chain unresponsiveness reporting #1215

Merged
merged 16 commits into from
Dec 17, 2024
Merged

Conversation

HCastano
Copy link
Collaborator

@HCastano HCastano commented Dec 12, 2024

This is another take on #667 but without subgroups.

This PR adds a new extrinsic, report_unstable_peer(), to the Staking pallet allowing
TSS nodes in the signing committee to report other TSS nodes in the committee.

Internally this extrinsic calls out to the Slashing pallet to note these reports.
Eventually something will be done to punish any repeat offenders (probably chill them
from the validator set), but that'll be work for a later PR.

I'm in the middle of another PR which adds the triggering mechanism to the TSS itself.

@HCastano HCastano marked this pull request as draft December 12, 2024 21:48
@@ -90,6 +90,7 @@ pub mod pallet {
+ frame_system::Config
+ pallet_staking::Config
+ pallet_parameters::Config
+ pallet_slashing::Config
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I know this is gonna trigger Jesse, but in a future PR I want to move this to be loosely coupled

Copy link
Member

Choose a reason for hiding this comment

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

idk I just think it makes the code more unreadable and less flexible but wtv

@HCastano HCastano added the Bump `spec_version` A change which affects the current runtime behaviour label Dec 16, 2024
@HCastano HCastano marked this pull request as ready for review December 16, 2024 20:57
Copy link
Contributor

@ameba23 ameba23 left a comment

Choose a reason for hiding this comment

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

⭐ Looks great.

My only concern would be possible circular dependency problems - as even if we can call pallet-staking's chill from the slashing pallet without needing pallet-staking-extension, we are probably anyway going to need stuff from the staking extension pallet there for example to be able to mark a bad signer for removal from the signer set at the next reshare, or remove a TSS node, or something along those lines. So i would probably have put this extrinsic in the slashing pallet.

Thinking about it, i expect your plan is to put a trait in entropy-shared in order to do this, like with the AttestationHandler.

@@ -34,6 +34,7 @@ p256 ={ version="0.13.2", default-features=false, features=["ecdsa"
rand ={ version="0.8.5", default-features=false, features=["alloc"] }

pallet-parameters={ version="0.3.0", path="../parameters", default-features=false }
pallet-slashing={ version="0.3.0", path="../slashing", default-features=false }
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure you are not going to run in to problems with needing the staking extension pallet to be a dependency of the slashing pallet in order to call chill? Or can you call chill on pallet-staking directly without having circular dependencies?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Discussed below

// Note: This operation is O(n), but with a small enough Signer group this should be
// fine to do on-chain.
let signers = Self::signers();
ensure!(signers.contains(&reporter_validator_id), Error::<T>::NotSigner);
Copy link
Contributor

Choose a reason for hiding this comment

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

This means relayers cannot use this to report that they were unable to relay a signature request to a member of the signing committee. Which is fine for now but maybe at some point we will want a separate extrinsic for that purpose.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes that's a good point. I meant to bring it up in the PR description but forgot. The
essence of the question here is whether or not we give relayers the power to report. I'm
not entirely sure yet, but it's something we can decide on later

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Opened #1223

let offender_validator_id = Self::threshold_to_stash(&offender_tss_account)
.ok_or(Error::<T>::NoThresholdKey)?;

// Note: This operation is O(n), but with a small enough Signer group this should be
Copy link
Contributor

Choose a reason for hiding this comment

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

I would like a formal justification for the capitilization of Signer.

Suggested change
// Note: This operation is O(n), but with a small enough Signer group this should be
// Note: This operation is O(n), but with a small enough signer group this should be

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The storage struct is called Signers, QED? lol

Pls don't make me run CI again for this 😅

@HCastano
Copy link
Collaborator Author

HCastano commented Dec 17, 2024

@ameba23

My only concern would be possible circular dependency problems - as even if we can call pallet-staking's chill from the slashing pallet without needing pallet-staking-extension, we are probably anyway going to need stuff from the staking extension pallet there for example to be able to mark a bad signer for removal from the signer set at the next reshare, or remove a TSS node, or something along those lines.

Yeah so I'm not entirely sure how we'll be doing the last bit (calling chill()), but
I'm kinda hoping that the Offences pallet (which is what Slashing uses under the hood)
will just do that bit for us. If we have to interface with Staking directly then yes it
might be a problem.

So i would probably have put this extrinsic in the slashing pallet.

The problem with putting it in the Slashing pallet is that we don't have access to the
types needed to identify validators or signers (e.g ThresholdToStash, Signers).

Thinking about it, i expect your plan is to put a trait in entropy-shared in order to do this, like with the AttestationHandler.

Yeah I do want to do this eventually so the Slashing mechanism can be somewhat flexible
and configurable. This could also help with some of the circular dependencies that may
arise.

@HCastano HCastano merged commit 2892c05 into master Dec 17, 2024
8 checks passed
@HCastano HCastano deleted the hc/annoying-peer-on-chain-take-2 branch December 17, 2024 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bump `spec_version` A change which affects the current runtime behaviour
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants