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 unused register_operator(signing_key_proof_of_ownership) argument #3264

Merged
merged 3 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 3 additions & 19 deletions crates/pallet-domains/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use frame_support::traits::fungible::{Inspect, Mutate};
use frame_support::traits::Hooks;
use frame_system::{Pallet as System, RawOrigin};
use sp_core::crypto::{Ss58Codec, UncheckedFrom};
use sp_core::ByteArray;
use sp_domains::{
dummy_opaque_bundle, DomainId, ExecutionReceipt, OperatorAllowList, OperatorId,
OperatorPublicKey, OperatorRewardSource, OperatorSignature, PermissionedActionAllowedBy,
Expand Down Expand Up @@ -580,23 +579,9 @@ mod benchmarks {

// TODO: the `(key, signature)` is failed to verify in `cargo test --features runtime-benchmarks` but it
teor2345 marked this conversation as resolved.
Show resolved Hide resolved
// will pass when doing the actual benchmark with `subspace-node benchmark pallet ...`, need more investigations.
let (key, signature) = {
let key = OperatorPublicKey::from_ss58check(
"5Gv1Uopoqo1k7125oDtFSCmxH4DzuCiBU7HBKu2bF1GZFsEb",
)
.unwrap();

// signature data included operator_account since result from `account` with same
// input is always deterministic
let sig = OperatorSignature::from_slice(&[
88, 91, 154, 118, 137, 117, 109, 164, 232, 186, 101, 199, 94, 12, 91, 47, 228, 198,
61, 146, 200, 227, 152, 191, 205, 114, 81, 127, 192, 158, 48, 96, 211, 199, 237,
121, 170, 38, 118, 109, 3, 44, 198, 54, 155, 133, 240, 77, 200, 117, 107, 34, 248,
238, 144, 101, 200, 146, 20, 94, 180, 98, 40, 134,
])
.unwrap();
(key, sig)
};
let key =
OperatorPublicKey::from_ss58check("5Gv1Uopoqo1k7125oDtFSCmxH4DzuCiBU7HBKu2bF1GZFsEb")
.unwrap();
let operator_config = OperatorConfig {
signing_key: key,
minimum_nominator_stake: T::MinNominatorStake::get(),
Expand All @@ -609,7 +594,6 @@ mod benchmarks {
domain_id,
T::MinOperatorStake::get(),
operator_config.clone(),
signature,
);

assert_eq!(NextOperatorId::<T>::get(), operator_id + 1);
Expand Down
4 changes: 1 addition & 3 deletions crates/pallet-domains/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,7 @@ mod pallet {
use sp_domains::{
BundleDigest, DomainBundleSubmitted, DomainId, DomainSudoCall, DomainsTransfersTracker,
EpochIndex, GenesisDomain, OnChainRewards, OnDomainInstantiated, OperatorAllowList,
OperatorId, OperatorPublicKey, OperatorRewardSource, OperatorSignature, RuntimeId,
RuntimeObject, RuntimeType,
OperatorId, OperatorPublicKey, OperatorRewardSource, RuntimeId, RuntimeObject, RuntimeType,
};
use sp_domains_fraud_proof::fraud_proof_runtime_interface::domain_runtime_call;
use sp_domains_fraud_proof::storage_proof::{self, FraudProofStorageKeyProvider};
Expand Down Expand Up @@ -1357,7 +1356,6 @@ mod pallet {
domain_id: DomainId,
amount: BalanceOf<T>,
config: OperatorConfig<BalanceOf<T>>,
_signing_key_proof_of_ownership: OperatorSignature,
) -> DispatchResult {
let owner = ensure_signed(origin)?;

Expand Down
77 changes: 1 addition & 76 deletions crates/pallet-domains/src/staking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1438,16 +1438,14 @@ pub(crate) mod tests {
use crate::{
bundle_storage_fund, BalanceOf, Error, NominatorId, SlashedReason, MAX_NOMINATORS_TO_SLASH,
};
use codec::Encode;
use frame_support::traits::fungible::Mutate;
use frame_support::traits::Currency;
use frame_support::weights::Weight;
use frame_support::{assert_err, assert_ok};
use sp_core::crypto::UncheckedFrom;
use sp_core::{sr25519, Pair, U256};
use sp_domains::{
DomainId, OperatorAllowList, OperatorId, OperatorPair, OperatorPublicKey,
OperatorRewardSource, OperatorSignature, OperatorSigningKeyProofOfOwnershipData,
OperatorRewardSource,
};
use sp_runtime::traits::Zero;
use sp_runtime::{PerThing, Perbill};
Expand All @@ -1468,7 +1466,6 @@ pub(crate) mod tests {
operator_stake: BalanceOf<Test>,
minimum_nominator_stake: BalanceOf<Test>,
signing_key: OperatorPublicKey,
signature: OperatorSignature,
mut nominators: BTreeMap<NominatorId<Test>, (BalanceOf<Test>, BalanceOf<Test>)>,
) -> (OperatorId, OperatorConfig<BalanceOf<Test>>) {
nominators.insert(operator_account, (operator_free_balance, operator_stake));
Expand Down Expand Up @@ -1525,7 +1522,6 @@ pub(crate) mod tests {
domain_id,
operator_stake,
operator_config.clone(),
signature,
);
assert_ok!(res);

Expand Down Expand Up @@ -1569,7 +1565,6 @@ pub(crate) mod tests {
domain_id,
Default::default(),
operator_config,
OperatorSignature::unchecked_from([1u8; 64]),
);
assert_err!(
res,
Expand All @@ -1592,17 +1587,11 @@ pub(crate) mod tests {
nomination_tax: Default::default(),
};

let data = OperatorSigningKeyProofOfOwnershipData {
operator_owner: operator_account,
};
let signature = pair.sign(&data.encode());

let res = Domains::register_operator(
RuntimeOrigin::signed(operator_account),
domain_id,
Default::default(),
operator_config,
signature,
);
assert_err!(
res,
Expand All @@ -1623,18 +1612,13 @@ pub(crate) mod tests {

let mut ext = new_test_ext();
ext.execute_with(|| {
let data = OperatorSigningKeyProofOfOwnershipData {
operator_owner: operator_account,
};
let signature = pair.sign(&data.encode());
let (operator_id, mut operator_config) = register_operator(
domain_id,
operator_account,
operator_free_balance,
operator_total_stake,
SSC,
pair.public(),
signature.clone(),
BTreeMap::new(),
);

Expand Down Expand Up @@ -1677,7 +1661,6 @@ pub(crate) mod tests {
domain_id,
operator_stake,
operator_config.clone(),
signature.clone(),
);
assert_err!(
res,
Expand All @@ -1687,16 +1670,11 @@ pub(crate) mod tests {
// cannot use the locked funds to register a new operator
let new_pair = OperatorPair::from_seed(&U256::from(1u32).into());
operator_config.signing_key = new_pair.public();
let data = OperatorSigningKeyProofOfOwnershipData {
operator_owner: operator_account,
};
let signature = new_pair.sign(&data.encode());
let res = Domains::register_operator(
RuntimeOrigin::signed(operator_account),
domain_id,
operator_stake,
operator_config,
signature,
);
assert_err!(
res,
Expand All @@ -1717,10 +1695,6 @@ pub(crate) mod tests {
let operator_stake = 800 * SSC;
let operator_storage_fee_deposit = 200 * SSC;
let pair = OperatorPair::from_seed(&U256::from(0u32).into());
let data = OperatorSigningKeyProofOfOwnershipData {
operator_owner: operator_account,
};
let signature = pair.sign(&data.encode());

let nominator_account = 2;
let nominator_free_balance = 150 * SSC;
Expand All @@ -1737,7 +1711,6 @@ pub(crate) mod tests {
operator_total_stake,
10 * SSC,
pair.public(),
signature,
BTreeMap::from_iter(vec![(
nominator_account,
(nominator_free_balance, nominator_total_stake),
Expand Down Expand Up @@ -1835,10 +1808,6 @@ pub(crate) mod tests {
let operator_stake = 200 * SSC;
let operator_free_balance = 250 * SSC;
let pair = OperatorPair::from_seed(&U256::from(0u32).into());
let data = OperatorSigningKeyProofOfOwnershipData {
operator_owner: operator_account,
};
let signature = pair.sign(&data.encode());
let mut ext = new_test_ext();
ext.execute_with(|| {
let (operator_id, _) = register_operator(
Expand All @@ -1848,7 +1817,6 @@ pub(crate) mod tests {
operator_stake,
SSC,
pair.public(),
signature,
BTreeMap::new(),
);

Expand Down Expand Up @@ -1960,10 +1928,6 @@ pub(crate) mod tests {
let domain_id = DomainId::new(0);
let operator_account = 0;
let pair = OperatorPair::from_seed(&U256::from(0u32).into());
let data = OperatorSigningKeyProofOfOwnershipData {
operator_owner: operator_account,
};
let signature = pair.sign(&data.encode());
let mut total_balance = nominators.iter().map(|n| n.1).sum::<BalanceOf<Test>>()
+ operator_reward
+ maybe_deposit.unwrap_or(0);
Expand All @@ -1986,7 +1950,6 @@ pub(crate) mod tests {
operator_stake,
minimum_nominator_stake,
pair.public(),
signature,
nominators,
);

Expand Down Expand Up @@ -2601,10 +2564,6 @@ pub(crate) mod tests {
let operator_free_balance = 250 * SSC;
let operator_stake = 200 * SSC;
let pair = OperatorPair::from_seed(&U256::from(0u32).into());
let data = OperatorSigningKeyProofOfOwnershipData {
operator_owner: operator_account,
};
let signature = pair.sign(&data.encode());
let nominator_account = 2;
let nominator_free_balance = 150 * SSC;
let nominator_stake = 100 * SSC;
Expand All @@ -2627,7 +2586,6 @@ pub(crate) mod tests {
operator_stake,
10 * SSC,
pair.public(),
signature,
BTreeMap::from_iter(nominators),
);

Expand Down Expand Up @@ -2732,10 +2690,6 @@ pub(crate) mod tests {
let operator_stake = 200 * SSC;
let operator_extra_deposit = 40 * SSC;
let pair = OperatorPair::from_seed(&U256::from(0u32).into());
let data = OperatorSigningKeyProofOfOwnershipData {
operator_owner: operator_account,
};
let signature = pair.sign(&data.encode());
let nominator_account = 2;
let nominator_free_balance = 150 * SSC;
let nominator_stake = 100 * SSC;
Expand Down Expand Up @@ -2765,7 +2719,6 @@ pub(crate) mod tests {
operator_stake,
10 * SSC,
pair.public(),
signature,
BTreeMap::from_iter(nominators),
);

Expand Down Expand Up @@ -2888,10 +2841,6 @@ pub(crate) mod tests {
let operator_stake = 200 * SSC;
let operator_extra_deposit = 40 * SSC;
let pair = OperatorPair::from_seed(&U256::from(0u32).into());
let data = OperatorSigningKeyProofOfOwnershipData {
operator_owner: operator_account,
};
let signature = pair.sign(&data.encode());

let nominator_accounts: Vec<crate::tests::AccountId> = (2..22).collect();
let nominator_free_balance = 150 * SSC;
Expand Down Expand Up @@ -2929,7 +2878,6 @@ pub(crate) mod tests {
operator_stake,
10 * SSC,
pair.public(),
signature,
BTreeMap::from_iter(nominators),
);

Expand Down Expand Up @@ -3066,21 +3014,6 @@ pub(crate) mod tests {
let pair_2 = OperatorPair::from_seed(&U256::from(1u32).into());
let pair_3 = OperatorPair::from_seed(&U256::from(2u32).into());

let data = OperatorSigningKeyProofOfOwnershipData {
operator_owner: operator_account_1,
};
let signature_1 = pair_1.sign(&data.encode());

let data = OperatorSigningKeyProofOfOwnershipData {
operator_owner: operator_account_2,
};
let signature_2 = pair_2.sign(&data.encode());

let data = OperatorSigningKeyProofOfOwnershipData {
operator_owner: operator_account_3,
};
let signature_3 = pair_3.sign(&data.encode());

let mut ext = new_test_ext();
ext.execute_with(|| {
let (operator_id_1, _) = register_operator(
Expand All @@ -3090,7 +3023,6 @@ pub(crate) mod tests {
operator_stake,
10 * SSC,
pair_1.public(),
signature_1,
Default::default(),
);

Expand All @@ -3101,7 +3033,6 @@ pub(crate) mod tests {
operator_stake,
10 * SSC,
pair_2.public(),
signature_2,
Default::default(),
);

Expand All @@ -3112,7 +3043,6 @@ pub(crate) mod tests {
operator_stake,
10 * SSC,
pair_3.public(),
signature_3,
Default::default(),
);

Expand Down Expand Up @@ -3213,10 +3143,6 @@ pub(crate) mod tests {
let operator_stake = 80 * SSC;
let operator_storage_fee_deposit = 20 * SSC;
let pair = OperatorPair::from_seed(&U256::from(0u32).into());
let data = OperatorSigningKeyProofOfOwnershipData {
operator_owner: operator_account,
};
let signature = pair.sign(&data.encode());
let nominator_account = 2;

let mut ext = new_test_ext();
Expand All @@ -3228,7 +3154,6 @@ pub(crate) mod tests {
operator_total_stake,
SSC,
pair.public(),
signature,
BTreeMap::default(),
);

Expand Down
Loading
Loading