Skip to content

Commit ba1008b

Browse files
authored
Merge pull request #1836 from opentensor/devnet
testnet deploy 7/8/2025
2 parents 528867c + f79e216 commit ba1008b

File tree

11 files changed

+167
-73
lines changed

11 files changed

+167
-73
lines changed

.github/workflows/run-benchmarks.yml

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ jobs:
2828
if: ${{ env.SKIP_BENCHMARKS != '1' }}
2929
uses: actions/checkout@v4
3030
with:
31-
ref: ${{ github.head_ref }}
31+
repository: ${{ github.event.pull_request.head.repo.full_name }}
32+
ref: ${{ github.event.pull_request.head.ref }}
3233
fetch-depth: 0
3334

3435
- name: Install GitHub CLI
@@ -38,11 +39,13 @@ jobs:
3839
sudo apt-get install -y gh
3940
echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
4041
41-
# (1) — original skip-label check
42+
# (1) — first skiplabel check
4243
- name: Check skip label
4344
if: ${{ env.SKIP_BENCHMARKS != '1' }}
4445
run: |
45-
labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name')
46+
labels=$(gh pr view ${{ github.event.pull_request.number }} \
47+
--repo "${{ github.repository }}" \
48+
--json labels --jq '.labels[].name')
4649
if echo "$labels" | grep -q "skip-validate-benchmarks"; then
4750
echo "skip-validate-benchmarks label found — skipping benchmarks."
4851
echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV"
@@ -58,7 +61,9 @@ jobs:
5861
- name: Check skip label
5962
if: ${{ env.SKIP_BENCHMARKS != '1' }}
6063
run: |
61-
labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name')
64+
labels=$(gh pr view ${{ github.event.pull_request.number }} \
65+
--repo "${{ github.repository }}" \
66+
--json labels --jq '.labels[].name')
6267
if echo "$labels" | grep -q "skip-validate-benchmarks"; then
6368
echo "skip-validate-benchmarks label found — skipping benchmarks."
6469
echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV"
@@ -75,7 +80,9 @@ jobs:
7580
- name: Check skip label
7681
if: ${{ env.SKIP_BENCHMARKS != '1' }}
7782
run: |
78-
labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name')
83+
labels=$(gh pr view ${{ github.event.pull_request.number }} \
84+
--repo "${{ github.repository }}" \
85+
--json labels --jq '.labels[].name')
7986
if echo "$labels" | grep -q "skip-validate-benchmarks"; then
8087
echo "skip-validate-benchmarks label found — skipping benchmarks."
8188
echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV"
@@ -91,7 +98,9 @@ jobs:
9198
- name: Check skip label
9299
if: ${{ env.SKIP_BENCHMARKS != '1' }}
93100
run: |
94-
labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name')
101+
labels=$(gh pr view ${{ github.event.pull_request.number }} \
102+
--repo "${{ github.repository }}" \
103+
--json labels --jq '.labels[].name')
95104
if echo "$labels" | grep -q "skip-validate-benchmarks"; then
96105
echo "skip-validate-benchmarks label found — skipping benchmarks."
97106
echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV"
@@ -106,7 +115,9 @@ jobs:
106115
- name: Check skip label
107116
if: ${{ env.SKIP_BENCHMARKS != '1' }}
108117
run: |
109-
labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name')
118+
labels=$(gh pr view ${{ github.event.pull_request.number }} \
119+
--repo "${{ github.repository }}" \
120+
--json labels --jq '.labels[].name')
110121
if echo "$labels" | grep -q "skip-validate-benchmarks"; then
111122
echo "skip-validate-benchmarks label found — skipping benchmarks."
112123
echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV"
@@ -118,11 +129,13 @@ jobs:
118129
chmod +x scripts/benchmark_action.sh
119130
scripts/benchmark_action.sh
120131
121-
# (6) — final, unchanged
132+
# (6) — final check after run
122133
- name: Check skip label after run
123134
if: ${{ env.SKIP_BENCHMARKS != '1' }}
124135
run: |
125-
labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name')
136+
labels=$(gh pr view ${{ github.event.pull_request.number }} \
137+
--repo "${{ github.repository }}" \
138+
--json labels --jq '.labels[].name')
126139
if echo "$labels" | grep -q "skip-validate-benchmarks"; then
127140
echo "skip-validate-benchmarks label was found — but benchmarks already ran."
128141
fi

pallets/admin-utils/src/tests/mod.rs

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,6 @@ fn test_sudo_set_network_pow_registration_allowed() {
996996
SubtensorModule::get_network_pow_registration_allowed(netuid),
997997
init_value
998998
);
999-
1000999
assert_ok!(AdminUtils::sudo_set_network_pow_registration_allowed(
10011000
<<Test as Config>::RuntimeOrigin>::root(),
10021001
netuid,
@@ -1009,54 +1008,6 @@ fn test_sudo_set_network_pow_registration_allowed() {
10091008
});
10101009
}
10111010

1012-
#[test]
1013-
fn test_sudo_set_network_registration_allowed() {
1014-
new_test_ext().execute_with(|| {
1015-
let netuid = NetUid::from(1);
1016-
let to_be_set: bool = true;
1017-
add_network(netuid, 10);
1018-
1019-
let owner = SubtensorModule::get_subnet_owner(netuid);
1020-
1021-
let init_value: bool = SubtensorModule::get_network_registration_allowed(netuid);
1022-
assert_eq!(
1023-
AdminUtils::sudo_set_network_registration_allowed(
1024-
<<Test as Config>::RuntimeOrigin>::signed(U256::from(1)),
1025-
netuid,
1026-
to_be_set
1027-
),
1028-
Err(DispatchError::BadOrigin)
1029-
);
1030-
assert_eq!(
1031-
SubtensorModule::get_network_registration_allowed(netuid),
1032-
init_value
1033-
);
1034-
1035-
assert_eq!(
1036-
AdminUtils::sudo_set_network_registration_allowed(
1037-
<<Test as Config>::RuntimeOrigin>::signed(owner),
1038-
netuid,
1039-
to_be_set
1040-
),
1041-
Err(DispatchError::BadOrigin)
1042-
);
1043-
assert_eq!(
1044-
SubtensorModule::get_network_registration_allowed(netuid),
1045-
init_value
1046-
);
1047-
1048-
assert_ok!(AdminUtils::sudo_set_network_registration_allowed(
1049-
<<Test as Config>::RuntimeOrigin>::root(),
1050-
netuid,
1051-
to_be_set
1052-
));
1053-
assert_eq!(
1054-
SubtensorModule::get_network_registration_allowed(netuid),
1055-
to_be_set
1056-
);
1057-
});
1058-
}
1059-
10601011
mod sudo_set_nominator_min_required_stake {
10611012
use super::*;
10621013

pallets/subtensor/src/macros/hooks.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ mod hooks {
123123
// Fix the root subnet TAO storage value
124124
.saturating_add(migrations::migrate_fix_root_subnet_tao::migrate_fix_root_subnet_tao::<T>())
125125
// Fix the owner disable the registration
126-
.saturating_add(migrations::migrate_set_registration_enable::migrate_set_registration_enable::<T>());
126+
.saturating_add(migrations::migrate_set_registration_enable::migrate_set_registration_enable::<T>())
127+
// Migrate Subnet Identities to V3
128+
.saturating_add(migrations::migrate_subnet_identities_to_v3::migrate_subnet_identities_to_v3::<T>());
127129
weight
128130
}
129131

pallets/subtensor/src/migrations/migrate_subnet_identities_to_v3.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ pub fn migrate_subnet_identities_to_v3<T: Config>() -> Weight {
3030
// -----------------------------
3131
let old_subnet_identities = SubnetIdentitiesV2::<T>::iter().collect::<Vec<_>>();
3232
for (netuid, old_subnet_identity) in old_subnet_identities.clone() {
33+
// check for existing SubnetIdentitiesV3 entry, skip if found
34+
if SubnetIdentitiesV3::<T>::contains_key(netuid) {
35+
continue;
36+
}
3337
let new_subnet_identity = SubnetIdentityV3 {
3438
subnet_name: old_subnet_identity.subnet_name,
3539
github_repo: old_subnet_identity.github_repo,

pallets/subtensor/src/subnets/uids.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ impl<T: Config> Pallet<T> {
6161

6262
// 2. Remove previous set memberships.
6363
Uids::<T>::remove(netuid, old_hotkey.clone());
64+
AssociatedEvmAddress::<T>::remove(netuid, uid_to_replace);
6465
IsNetworkMember::<T>::remove(old_hotkey.clone(), netuid);
6566
#[allow(unknown_lints)]
6667
Keys::<T>::remove(netuid, uid_to_replace);

pallets/subtensor/src/swap/swap_hotkey.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ impl<T: Config> Pallet<T> {
379379
// 3.2.1 Swap the UIDS
380380
if let Ok(old_uid) = Uids::<T>::try_get(netuid, old_hotkey) {
381381
Uids::<T>::remove(netuid, old_hotkey);
382+
AssociatedEvmAddress::<T>::remove(netuid, old_uid);
382383
Uids::<T>::insert(netuid, new_hotkey, old_uid);
383384
weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 2));
384385

pallets/subtensor/src/tests/swap_hotkey.rs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use codec::Encode;
55
use frame_support::weights::Weight;
66
use frame_support::{assert_err, assert_noop, assert_ok};
77
use frame_system::{Config, RawOrigin};
8-
use sp_core::{Get, H256, U256};
8+
use sp_core::{Get, H160, H256, U256};
99
use sp_runtime::SaturatedConversion;
1010
use substrate_fixed::types::U64F64;
1111
use subtensor_swap_interface::SwapHandler;
@@ -1432,3 +1432,30 @@ fn test_swap_hotkey_swap_rate_limits() {
14321432
);
14331433
});
14341434
}
1435+
1436+
// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test swap_hotkey -- test_swap_hotkey_with_associated_evm_address --exact --nocapture
1437+
#[test]
1438+
fn test_swap_hotkey_with_associated_evm_address() {
1439+
new_test_ext(1).execute_with(|| {
1440+
let old_hotkey = U256::from(1);
1441+
let new_hotkey = U256::from(2);
1442+
let coldkey = U256::from(3);
1443+
let mut weight = Weight::zero();
1444+
let netuid = add_dynamic_network(&old_hotkey, &coldkey);
1445+
let uid = Uids::<Test>::get(netuid, old_hotkey).unwrap();
1446+
let evm_address = H160::from_slice(&[1_u8; 20]);
1447+
AssociatedEvmAddress::<Test>::insert(netuid, uid, (evm_address, 1));
1448+
1449+
Owner::<Test>::insert(old_hotkey, coldkey);
1450+
assert_ok!(SubtensorModule::perform_hotkey_swap_on_all_subnets(
1451+
&old_hotkey,
1452+
&new_hotkey,
1453+
&coldkey,
1454+
&mut weight
1455+
));
1456+
1457+
assert_eq!(AssociatedEvmAddress::<Test>::get(netuid, uid), None);
1458+
assert!(!Owner::<Test>::contains_key(old_hotkey));
1459+
assert_eq!(Owner::<Test>::get(new_hotkey), coldkey);
1460+
});
1461+
}

pallets/subtensor/src/tests/swap_hotkey_with_subnet.rs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use frame_system::{Config, RawOrigin};
88

99
use super::mock::*;
1010
use crate::*;
11-
use sp_core::{Get, H256, U256};
11+
use sp_core::{Get, H160, H256, U256};
1212
use sp_runtime::SaturatedConversion;
1313
use substrate_fixed::types::U64F64;
1414
// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test swap_hotkey_with_subnet -- test_swap_owner --exact --nocapture
@@ -1556,3 +1556,31 @@ fn test_swap_hotkey_registered_on_other_subnet() {
15561556
);
15571557
});
15581558
}
1559+
1560+
// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test swap_hotkey_with_subnet -- test_swap_hotkey_with_associated_evm_address --exact --nocapture
1561+
#[test]
1562+
fn test_swap_hotkey_with_associated_evm_address() {
1563+
new_test_ext(1).execute_with(|| {
1564+
let old_hotkey = U256::from(1);
1565+
let new_hotkey = U256::from(2);
1566+
let coldkey = U256::from(3);
1567+
1568+
let netuid = add_dynamic_network(&old_hotkey, &coldkey);
1569+
let uid = Uids::<Test>::get(netuid, old_hotkey).unwrap();
1570+
let evm_address = H160::from_slice(&[1_u8; 20]);
1571+
AssociatedEvmAddress::<Test>::insert(netuid, uid, (evm_address, 1));
1572+
SubtensorModule::add_balance_to_coldkey_account(&coldkey, u64::MAX);
1573+
Owner::<Test>::insert(old_hotkey, coldkey);
1574+
System::set_block_number(System::block_number() + HotkeySwapOnSubnetInterval::get());
1575+
assert_ok!(SubtensorModule::do_swap_hotkey(
1576+
RuntimeOrigin::signed(coldkey),
1577+
&old_hotkey,
1578+
&new_hotkey,
1579+
Some(netuid)
1580+
));
1581+
1582+
assert_eq!(AssociatedEvmAddress::<Test>::get(netuid, uid), None);
1583+
assert_eq!(Owner::<Test>::get(old_hotkey), coldkey);
1584+
assert_eq!(Owner::<Test>::get(new_hotkey), coldkey);
1585+
});
1586+
}

0 commit comments

Comments
 (0)