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

Remove OperatorSigningKey pallet storage #3265

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

teor2345
Copy link
Contributor

This PR removes the storage for the OperatorSigningKey map.

It replaces the usage in the malicious operator with a search though all operator IDs.

Code contributor checklist:

@teor2345 teor2345 added improvement it is already working, but can be better execution Subspace execution labels Nov 28, 2024
@teor2345 teor2345 self-assigned this Nov 28, 2024
.runtime_api()
.operator_id_by_signing_key(consensus_best_hash, signing_key.clone())?;
let mut maybe_operator_id = None;
for operator_id in current_operators.keys().chain(next_operators.iter()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The checks below handle IDs in current and next, so I think we need to search both.

@@ -1655,17 +1644,14 @@ pub(crate) mod tests {
operator_free_balance - operator_total_stake - ExistentialDeposit::get()
);

// cannot register with same operator key
// registering with same operator key is allowed
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this what we want, or is there another way we should check for duplicate operator registrations?

Copy link
Member

Choose a reason for hiding this comment

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

This should be okay. Operators are free to choose their signing key and is no incentive to reuse the signing key albeit operators are at risk using same signing key. But that would not hurt the protocol since all operators need to stake individually and all compromised operators will be slashed accordingly if they used same signing key and key is compromised.

Will also spend sometime thinking on this further but first pass looks good to me

Copy link
Member

@vedhavyas vedhavyas left a comment

Choose a reason for hiding this comment

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

Overall make sense.
Will need to a bit more time thinking on the issue we might not have seen having multiple operators with same signing key.

@@ -325,11 +324,6 @@ pub fn do_register_operator<T: Config>(
Error::InvalidOperatorSigningKey
);

ensure!(
!OperatorSigningKey::<T>::contains_key(config.signing_key.clone()),
Error::DuplicateOperatorSigningKey
Copy link
Member

Choose a reason for hiding this comment

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

we can remove this error as well

@@ -1655,17 +1644,14 @@ pub(crate) mod tests {
operator_free_balance - operator_total_stake - ExistentialDeposit::get()
);

// cannot register with same operator key
// registering with same operator key is allowed
Copy link
Member

Choose a reason for hiding this comment

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

This should be okay. Operators are free to choose their signing key and is no incentive to reuse the signing key albeit operators are at risk using same signing key. But that would not hurt the protocol since all operators need to stake individually and all compromised operators will be slashed accordingly if they used same signing key and key is compromised.

Will also spend sometime thinking on this further but first pass looks good to me

@@ -1604,7 +1593,7 @@ pub(crate) mod tests {
fn test_register_operator() {
let domain_id = DomainId::new(0);
let operator_account = 1;
let operator_free_balance = 1500 * SSC;
let operator_free_balance = 2500 * SSC;
Copy link
Member

Choose a reason for hiding this comment

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

why the change here though ?

@@ -1532,9 +1532,6 @@ sp_api::decl_runtime_apis! {
/// Returns the current epoch and the next epoch operators of the given domain
fn domain_operators(domain_id: DomainId) -> Option<(BTreeMap<OperatorId, Balance>, Vec<OperatorId>)>;

/// Get operator id by signing key
fn operator_id_by_signing_key(signing_key: OperatorPublicKey) -> Option<OperatorId>;
Copy link
Member

Choose a reason for hiding this comment

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

I'm actually surprised this is only used in malicious operator and not the actual one.
maybe a remnent from the bundle equivocation feature we forgot to remove I guess.

.consensus_client
.runtime_api()
.operator_id_by_signing_key(consensus_best_hash, signing_key.clone())?;
let mut maybe_operator_id = None;
Copy link
Member

Choose a reason for hiding this comment

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

if its helpful, I would recommend adding this test runtime api.
We have test specific runtime apis defined that are not implemented in actual runtime.
Just a thought

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
execution Subspace execution improvement it is already working, but can be better
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants