Skip to content

Commit

Permalink
Use Alice as sudo account, update signing key to Alice & Bob, remove …
Browse files Browse the repository at this point in the history
…signing_key_proof_of_ownership, and decrease challenge period/unlocking period/domain runtime upgrade delay

Signed-off-by: linning <linningde25@gmail.com>
  • Loading branch information
NingLin-P committed Sep 17, 2024
1 parent 3727d07 commit 5f65d94
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 38 deletions.
12 changes: 3 additions & 9 deletions crates/pallet-domains/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1348,18 +1348,12 @@ mod pallet {
domain_id: DomainId,
amount: BalanceOf<T>,
config: OperatorConfig<BalanceOf<T>>,
signing_key_proof_of_ownership: OperatorSignature,
) -> DispatchResult {
let owner = ensure_signed(origin)?;

let (operator_id, current_epoch_index) = do_register_operator::<T>(
owner,
domain_id,
amount,
config,
Some(signing_key_proof_of_ownership),
)
.map_err(Error::<T>::from)?;
let (operator_id, current_epoch_index) =
do_register_operator::<T>(owner, domain_id, amount, config, None)
.map_err(Error::<T>::from)?;

Self::deposit_event(Event::OperatorRegistered {
operator_id,
Expand Down
10 changes: 5 additions & 5 deletions crates/pallet-domains/src/staking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1493,7 +1493,7 @@ pub(crate) mod tests {
domain_id,
operator_stake,
operator_config.clone(),
signature,
// signature,
);
assert_ok!(res);

Expand Down Expand Up @@ -1537,7 +1537,7 @@ pub(crate) mod tests {
domain_id,
Default::default(),
operator_config,
OperatorSignature::unchecked_from([1u8; 64]),
// OperatorSignature::unchecked_from([1u8; 64]),
);
assert_err!(
res,
Expand Down Expand Up @@ -1570,7 +1570,7 @@ pub(crate) mod tests {
domain_id,
Default::default(),
operator_config,
signature,
// signature,
);
assert_err!(
res,
Expand Down Expand Up @@ -1645,7 +1645,7 @@ pub(crate) mod tests {
domain_id,
operator_stake,
operator_config.clone(),
signature.clone(),
// signature.clone(),
);
assert_err!(
res,
Expand All @@ -1664,7 +1664,7 @@ pub(crate) mod tests {
domain_id,
operator_stake,
operator_config,
signature,
// signature,
);
assert_err!(
res,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ where
minimum_nominator_stake: Balance::MAX,
nomination_tax: Default::default(),
},
signing_key_proof_of_ownership: signature,
// signing_key_proof_of_ownership: signature,
};
self.submit_consensus_extrinsic(Some(nonce), call.into())
}
Expand Down
12 changes: 5 additions & 7 deletions crates/subspace-node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,7 @@ pub fn devnet_config_compiled() -> Result<GenericChainSpec, String> {
properties
})
.with_genesis_config({
let sudo_account =
AccountId::from_ss58check("5CXTmJEusve5ixyJufqHThmy4qUrrm6FyLCR7QfE4bbyMTNC")
.expect("Wrong root account address");
let sudo_account = get_account_id_from_seed("Alice");

let balances = vec![(sudo_account.clone(), Balance::MAX / 2)];
patch_domain_runtime_version(
Expand Down Expand Up @@ -198,10 +196,10 @@ pub fn devnet_config_compiled() -> Result<GenericChainSpec, String> {
permissioned_action_allowed_by: PermissionedActionAllowedBy::Accounts(vec![
sudo_account.clone(),
]),
genesis_domains: vec![auto_id_chain_spec::get_genesis_domain(
SpecId::DevNet,
sudo_account.clone(),
)?],
genesis_domains: vec![
evm_chain_spec::get_genesis_domain(SpecId::DevNet, sudo_account.clone())?,
auto_id_chain_spec::get_genesis_domain(SpecId::DevNet, sudo_account.clone())?,
],
},
CouncilDemocracyConfigParams::<BlockNumber>::fast_params(),
sudo_account.clone(),
Expand Down
4 changes: 1 addition & 3 deletions crates/subspace-node/src/domain/auto_id_chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,7 @@ fn get_operator_params(
},
SpecId::DevNet => GenesisOperatorParams {
operator_allow_list: OperatorAllowList::Anyone,
operator_signing_key: OperatorPublicKey::unchecked_from(hex!(
"18df97b9335e11f239f8f3f8041819d42f27b60845cf209416fdba8de15f4b7c"
)),
operator_signing_key: get_public_key_from_seed::<OperatorPublicKey>("Bob"),
},
}
}
Expand Down
13 changes: 9 additions & 4 deletions crates/subspace-node/src/domain/evm_chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,14 @@ pub fn get_testnet_endowed_accounts_by_spec_id(spec_id: SpecId) -> Vec<(MultiAcc
.into_iter()
.map(|acc| (AccountId20Converter::convert(acc), 1_000_000 * SSC))
.collect(),
SpecId::DevNet | SpecId::Gemini => vec![],
SpecId::DevNet => {
let alith_account = get_dev_accounts()[0].clone();
vec![(
AccountId20Converter::convert(alith_account),
1_000_000 * SSC,
)]
}
SpecId::Gemini => vec![],
}
}

Expand Down Expand Up @@ -188,9 +195,7 @@ fn get_operator_params(
},
SpecId::DevNet => GenesisOperatorParams {
operator_allow_list: OperatorAllowList::Anyone,
operator_signing_key: OperatorPublicKey::unchecked_from(hex!(
"aa3b05b4d649666723e099cf3bafc2f2c04160ebe0e16ddc82f72d6ed97c4b6b"
)),
operator_signing_key: get_public_key_from_seed::<OperatorPublicKey>("Alice"),
},
}
}
Expand Down
6 changes: 3 additions & 3 deletions crates/subspace-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ parameter_types! {
pub const InitialDomainTxRange: u64 = INITIAL_DOMAIN_TX_RANGE;
pub const DomainTxRangeAdjustmentInterval: u64 = TX_RANGE_ADJUSTMENT_INTERVAL_BLOCKS;
/// Runtime upgrade is delayed for 1 day at 6 sec block time.
pub const DomainRuntimeUpgradeDelay: BlockNumber = 14_400;
pub const DomainRuntimeUpgradeDelay: BlockNumber = 100;
/// Minimum operator stake to become an operator.
// TODO: this value should be properly updated before mainnet
pub const MinOperatorStake: Balance = 100 * SSC;
Expand All @@ -759,8 +759,8 @@ parameter_types! {
pub const MaxBundlesPerBlock: u32 = 10;
pub const DomainInstantiationDeposit: Balance = 100 * SSC;
pub const MaxDomainNameLength: u32 = 32;
pub const BlockTreePruningDepth: u32 = 14_400;
pub const StakeWithdrawalLockingPeriod: DomainNumber = 14_400;
pub const BlockTreePruningDepth: u32 = 100;
pub const StakeWithdrawalLockingPeriod: DomainNumber = 100;
// TODO: revisit these. For now epoch every 10 mins for a 6 second block and only 100 number of staking
// operations allowed within each epoch.
pub const StakeEpochDuration: DomainNumber = 100;
Expand Down
12 changes: 6 additions & 6 deletions domains/client/domain-operator/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4536,12 +4536,12 @@ async fn test_bad_receipt_chain() {
minimum_nominator_stake: Balance::MAX,
nomination_tax: Default::default(),
},
signing_key_proof_of_ownership: OperatorSignature::from(
OperatorSigningKeyProofOfOwnershipData {
operator_owner: Sr25519Alice.to_account_id(),
}
.using_encoded(|e| Sr25519Keyring::Charlie.sign(e)),
),
// signing_key_proof_of_ownership: OperatorSignature::from(
// OperatorSigningKeyProofOfOwnershipData {
// operator_owner: Sr25519Alice.to_account_id(),
// }
// .using_encoded(|e| Sr25519Keyring::Charlie.sign(e)),
// ),
})
.await
.unwrap();
Expand Down

0 comments on commit 5f65d94

Please sign in to comment.