Skip to content

Commit 894bacf

Browse files
committed
Resolve git conflicts
2 parents a9470a5 + 37506bd commit 894bacf

File tree

26 files changed

+378
-159
lines changed

26 files changed

+378
-159
lines changed
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# .github/workflows/apply-benchmark-patch.yml
2+
name: Apply-Benchmark-Patch
3+
4+
on:
5+
pull_request:
6+
types: [labeled]
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
actions: read # required to list & download artifacts across workflows
12+
13+
jobs:
14+
apply:
15+
if: ${{ github.event.label.name == 'apply-benchmark-patch' }}
16+
runs-on: Benchmarking
17+
18+
steps:
19+
- name: Check out PR branch
20+
uses: actions/checkout@v4
21+
with:
22+
repository: ${{ github.event.pull_request.head.repo.full_name }}
23+
ref: ${{ github.event.pull_request.head.ref }}
24+
fetch-depth: 0
25+
26+
- name: Install GitHub CLI
27+
run: |
28+
sudo DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt-get update
29+
sudo DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt-get install -y --no-install-recommends -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" gh
30+
echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
31+
32+
- name: Download latest bench patch artifact from heavy workflow
33+
uses: dawidd6/action-download-artifact@v3
34+
with:
35+
workflow: run-benchmarks.yml
36+
pr: ${{ github.event.pull_request.number }}
37+
name: bench-patch
38+
path: .
39+
allow_forks: true
40+
check_artifacts: true
41+
search_artifacts: true
42+
workflow_conclusion: ""
43+
if_no_artifact_found: warn
44+
45+
- name: Extract bench patch archive
46+
run: |
47+
set -euo pipefail
48+
if [ -f "bench-patch.tgz" ]; then
49+
tar -xzf bench-patch.tgz
50+
elif [ -f "bench-patch/bench-patch.tgz" ]; then
51+
tar -xzf bench-patch/bench-patch.tgz
52+
else
53+
echo "No bench-patch.tgz found after download."
54+
exit 0
55+
fi
56+
ls -la .bench_patch || true
57+
58+
- name: Apply and commit patch
59+
run: |
60+
set -euo pipefail
61+
62+
if [ ! -d ".bench_patch" ]; then
63+
echo "No .bench_patch directory found after extraction."
64+
exit 0
65+
fi
66+
67+
if [ -f ".bench_patch/summary.txt" ]; then
68+
echo "==== summary.txt ===="
69+
sed -n '1,200p' .bench_patch/summary.txt || true
70+
echo "====================="
71+
fi
72+
73+
if [ ! -f ".bench_patch/benchmark_patch.diff" ]; then
74+
echo "No benchmark_patch.diff found (no auto-patch created)."
75+
exit 0
76+
fi
77+
78+
git config user.name "github-actions[bot]"
79+
git config user.email "github-actions[bot]@users.noreply.github.com"
80+
81+
if ! git apply --index --3way .bench_patch/benchmark_patch.diff; then
82+
echo "Patch failed to apply cleanly. Please re-run Validate-Benchmarks to regenerate."
83+
exit 1
84+
fi
85+
86+
if git diff --cached --quiet; then
87+
echo "Patch applied but produced no changes (already up to date)."
88+
exit 0
89+
fi
90+
91+
echo "==== diff preview ===="
92+
git diff --cached --stat
93+
git diff --cached | head -n 120 || true
94+
echo "======================"
95+
96+
branch=$(git symbolic-ref --quiet --short HEAD || true)
97+
if [ -z "$branch" ]; then
98+
echo "Not on a branch - cannot push" >&2
99+
exit 1
100+
fi
101+
102+
git commit -m "auto-update benchmark weights"
103+
git push origin "HEAD:${branch}"
104+
105+
- name: Remove apply-benchmark-patch label
106+
if: ${{ success() }}
107+
run: |
108+
gh pr edit ${{ github.event.pull_request.number }} \
109+
--repo "${{ github.repository }}" \
110+
--remove-label "apply-benchmark-patch" || true

.github/workflows/run-benchmarks.yml

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# .github/workflows/benchmarks.yml
1+
# .github/workflows/run-benchmarks.yml
22
name: Validate-Benchmarks
33

44
on:
@@ -20,10 +20,8 @@ jobs:
2020

2121
env:
2222
SKIP_BENCHMARKS: "0"
23-
AUTO_COMMIT_WEIGHTS: "1"
2423

2524
steps:
26-
# ──────────────────────────────────────────────────────────────────
2725
- name: Check out PR branch
2826
if: ${{ env.SKIP_BENCHMARKS != '1' }}
2927
uses: actions/checkout@v4
@@ -124,16 +122,45 @@ jobs:
124122
echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV"
125123
fi
126124
125+
- name: Ensure artifact folder exists
126+
if: ${{ env.SKIP_BENCHMARKS != '1' }}
127+
run: mkdir -p .bench_patch
128+
127129
- name: Run & validate benchmarks
128130
if: ${{ env.SKIP_BENCHMARKS != '1' }}
129-
uses: nick-fields/retry@v3
131+
timeout-minutes: 180
132+
run: |
133+
chmod +x scripts/benchmark_action.sh
134+
scripts/benchmark_action.sh
135+
136+
- name: List artifact contents (for debugging)
137+
if: ${{ always() }}
138+
run: |
139+
echo "Workspace: $GITHUB_WORKSPACE"
140+
if [ -d ".bench_patch" ]; then
141+
echo "== .bench_patch =="
142+
ls -la .bench_patch || true
143+
else
144+
echo ".bench_patch directory is missing"
145+
fi
146+
147+
- name: Archive bench patch
148+
if: ${{ always() }}
149+
run: |
150+
if [ -d ".bench_patch" ]; then
151+
tar -czf bench-patch.tgz .bench_patch
152+
ls -lh bench-patch.tgz
153+
else
154+
echo "No .bench_patch directory to archive."
155+
fi
156+
157+
- name: Upload patch artifact (if prepared)
158+
if: ${{ always() }}
159+
uses: actions/upload-artifact@v4
130160
with:
131-
timeout_minutes: 180
132-
max_attempts: 3
133-
retry_wait_seconds: 60
134-
command: |
135-
chmod +x scripts/benchmark_action.sh
136-
scripts/benchmark_action.sh
161+
name: bench-patch
162+
path: bench-patch.tgz
163+
if-no-files-found: warn
137164

138165
# (6) — final check after run
139166
- name: Check skip label after run

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ pub trait SubnetInfo<AccountId> {
174174
fn exists(netuid: NetUid) -> bool;
175175
fn mechanism(netuid: NetUid) -> u16;
176176
fn is_owner(account_id: &AccountId, netuid: NetUid) -> bool;
177+
fn is_subtoken_enabled(netuid: NetUid) -> bool;
177178
}
178179

179180
pub trait BalanceOps<AccountId> {

pallets/admin-utils/src/benchmarking.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,17 @@ mod benchmarks {
356356
fn sudo_set_owner_hparam_rate_limit() {
357357
#[extrinsic_call]
358358
_(RawOrigin::Root, 10u64/*limit*/)/*sudo_set_owner_hparam_rate_limit*/;
359+
}
360+
361+
#[benchmark]
362+
fn sudo_set_owner_immune_neuron_limit() {
363+
pallet_subtensor::Pallet::<T>::init_new_network(
364+
1u16.into(), /*netuid*/
365+
1u16, /*sudo_tempo*/
366+
);
367+
368+
#[extrinsic_call]
369+
_(RawOrigin::Root, 1u16.into()/*netuid*/, 5u16/*immune_neurons*/)/*sudo_set_owner_immune_neuron_limit()*/;
359370
}
360371

361372
//impl_benchmark_test_suite!(AdminUtils, crate::mock::new_test_ext(), crate::mock::Test);

pallets/admin-utils/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ pub mod pallet {
775775
/// It is only callable by root and subnet owner.
776776
/// The extrinsic will call the Subtensor pallet to set the maximum burn.
777777
#[pallet::call_index(23)]
778-
#[pallet::weight(Weight::from_parts(15_940_000, 0)
778+
#[pallet::weight(Weight::from_parts(19_420_000, 0)
779779
.saturating_add(<T as frame_system::Config>::DbWeight::get().reads(2_u64))
780780
.saturating_add(<T as frame_system::Config>::DbWeight::get().writes(1_u64)))]
781781
pub fn sudo_set_max_burn(
@@ -1786,8 +1786,8 @@ pub mod pallet {
17861786

17871787
/// Sets the number of immune owner neurons
17881788
#[pallet::call_index(72)]
1789-
#[pallet::weight(Weight::from_parts(15_000_000, 0)
1790-
.saturating_add(<T as frame_system::Config>::DbWeight::get().reads(1_u64))
1789+
#[pallet::weight(Weight::from_parts(4_639_000, 0)
1790+
.saturating_add(<T as frame_system::Config>::DbWeight::get().reads(0_u64))
17911791
.saturating_add(<T as frame_system::Config>::DbWeight::get().writes(1_u64)))]
17921792
pub fn sudo_set_owner_immune_neuron_limit(
17931793
origin: OriginFor<T>,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ impl pallet_subtensor::Config for Test {
227227
type HotkeySwapOnSubnetInterval = HotkeySwapOnSubnetInterval;
228228
type ProxyInterface = ();
229229
type LeaseDividendsDistributionInterval = LeaseDividendsDistributionInterval;
230+
type GetCommitments = ();
230231
}
231232

232233
parameter_types! {

pallets/commitments/Cargo.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ hex.workspace = true
3535
sha2.workspace = true
3636

3737
log.workspace = true
38-
39-
pallet-subtensor.workspace = true
4038
subtensor-runtime-common.workspace = true
4139

4240
[dev-dependencies]
@@ -57,7 +55,6 @@ std = [
5755
"log/std",
5856
"pallet-balances/std",
5957
"pallet-drand/std",
60-
"pallet-subtensor/std",
6158
"rand_chacha/std",
6259
"scale-info/std",
6360
"sha2/std",
@@ -76,13 +73,11 @@ runtime-benchmarks = [
7673
"sp-runtime/runtime-benchmarks",
7774
"pallet-balances/runtime-benchmarks",
7875
"pallet-drand/runtime-benchmarks",
79-
"pallet-subtensor/runtime-benchmarks",
8076
]
8177
try-runtime = [
8278
"frame-support/try-runtime",
8379
"frame-system/try-runtime",
8480
"pallet-balances/try-runtime",
8581
"sp-runtime/try-runtime",
8682
"pallet-drand/try-runtime",
87-
"pallet-subtensor/try-runtime",
8883
]

pallets/commitments/src/lib.rs

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ mod mock;
1010
pub mod types;
1111
pub mod weights;
1212

13-
pub use pallet::*;
14-
pub use types::*;
15-
pub use weights::WeightInfo;
16-
1713
use ark_serialize::CanonicalDeserialize;
14+
use codec::Encode;
15+
use frame_support::IterableStorageDoubleMap;
1816
use frame_support::{
1917
BoundedVec,
2018
traits::{Currency, Get},
2119
};
20+
use frame_system::pallet_prelude::BlockNumberFor;
21+
pub use pallet::*;
2222
use scale_info::prelude::collections::BTreeSet;
2323
use sp_runtime::SaturatedConversion;
2424
use sp_runtime::{Saturating, Weight, traits::Zero};
@@ -29,7 +29,9 @@ use tle::{
2929
stream_ciphers::AESGCMStreamCipherProvider,
3030
tlock::{TLECiphertext, tld},
3131
};
32+
pub use types::*;
3233
use w3f_bls::EngineBLS;
34+
pub use weights::WeightInfo;
3335

3436
type BalanceOf<T> =
3537
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
@@ -550,4 +552,28 @@ impl<T: Config> Pallet<T> {
550552

551553
Ok(total_weight)
552554
}
555+
pub fn get_commitments(netuid: NetUid) -> Vec<(T::AccountId, Vec<u8>)> {
556+
let commitments: Vec<(T::AccountId, Vec<u8>)> =
557+
<CommitmentOf<T> as IterableStorageDoubleMap<
558+
NetUid,
559+
T::AccountId,
560+
Registration<BalanceOf<T>, T::MaxFields, BlockNumberFor<T>>,
561+
>>::iter_prefix(netuid)
562+
.map(|(account, registration)| {
563+
let bytes = registration.encode();
564+
(account, bytes)
565+
})
566+
.collect();
567+
commitments
568+
}
569+
}
570+
571+
pub trait GetCommitments<AccountId> {
572+
fn get_commitments(netuid: NetUid) -> Vec<(AccountId, Vec<u8>)>;
573+
}
574+
575+
impl<AccountId> GetCommitments<AccountId> for () {
576+
fn get_commitments(_netuid: NetUid) -> Vec<(AccountId, Vec<u8>)> {
577+
Vec::new()
578+
}
553579
}

pallets/subtensor/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ runtime-common.workspace = true
4242
subtensor-runtime-common = { workspace = true, features = ["approx"] }
4343

4444
pallet-drand.workspace = true
45+
pallet-commitments.workspace = true
4546
pallet-collective.workspace = true
4647
pallet-membership.workspace = true
4748
hex-literal.workspace = true
@@ -78,6 +79,7 @@ std = [
7879
"log/std",
7980
"num-traits/std",
8081
"pallet-balances/std",
82+
"pallet-commitments/std",
8183
"pallet-collective/std",
8284
"pallet-drand/std",
8385
"pallet-membership/std",
@@ -119,6 +121,7 @@ runtime-benchmarks = [
119121
"frame-system/runtime-benchmarks",
120122
"pallet-balances/runtime-benchmarks",
121123
"pallet-collective/runtime-benchmarks",
124+
"pallet-commitments/runtime-benchmarks",
122125
"pallet-drand/runtime-benchmarks",
123126
"pallet-membership/runtime-benchmarks",
124127
"pallet-preimage/runtime-benchmarks",
@@ -140,6 +143,7 @@ try-runtime = [
140143
"sp-runtime/try-runtime",
141144
"pallet-collective/try-runtime",
142145
"pallet-drand/try-runtime",
146+
"pallet-commitments/try-runtime",
143147
"pallet-crowdloan/try-runtime",
144148
"runtime-common/try-runtime"
145149
]

0 commit comments

Comments
 (0)