Skip to content

Commit e2675b4

Browse files
authored
Merge pull request #1746 from opentensor/fix/netuid-compatibility
Fix NetUid metadata issue
2 parents 897b1e9 + c352c2d commit e2675b4

File tree

2 files changed

+50
-18
lines changed

2 files changed

+50
-18
lines changed

.github/workflows/check-bittensor-e2e-tests.yml.yml

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,20 @@ on:
1818
- main
1919
types: [opened, synchronize, reopened, labeled, unlabeled]
2020

21+
workflow_dispatch:
22+
inputs:
23+
verbose:
24+
description: "Output more information when triggered manually"
25+
required: false
26+
default: ""
27+
2128
env:
2229
CARGO_TERM_COLOR: always
2330
VERBOSE: ${{ github.event.inputs.verbose }}
2431

2532
jobs:
2633
apply-label-to-new-pr:
2734
runs-on: ubuntu-latest
28-
if: ${{ github.event.pull_request.draft == false }}
2935
outputs:
3036
should_continue: ${{ steps.check.outputs.should_continue }}
3137
steps:
@@ -63,11 +69,9 @@ jobs:
6369
LABELS=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name')
6470
echo "Current labels: $LABELS"
6571
if echo "$LABELS" | grep -q "run-bittensor-e2e-tests"; then
66-
echo "run-bittensor-e2e-tests=true" >> $GITHUB_ENV
67-
echo "::set-output name=run-bittensor-e2e-tests::true"
72+
echo "run-bittensor-e2e-tests=true" >> $GITHUB_OUTPUT
6873
else
69-
echo "run-bittensor-e2e-tests=false" >> $GITHUB_ENV
70-
echo "::set-output name=run-bittensor-e2e-tests::false"
74+
echo "run-bittensor-e2e-tests=false" >> $GITHUB_OUTPUT
7175
fi
7276
env:
7377
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -94,7 +98,7 @@ jobs:
9498
id: get-btcli-tests
9599
run: |
96100
test_files=$(find ${{ github.workspace }}/btcli/tests/e2e_tests -name "test*.py" | jq -R -s -c 'split("\n") | map(select(. != ""))')
97-
echo "::set-output name=test-files::$test_files"
101+
echo "test-files=$test_files" >> $GITHUB_OUTPUT
98102
shell: bash
99103

100104
find-sdk-e2e-tests:
@@ -119,7 +123,7 @@ jobs:
119123
id: get-sdk-tests
120124
run: |
121125
test_files=$(find ${{ github.workspace }}/bittensor/tests/e2e_tests -name "test*.py" | jq -R -s -c 'split("\n") | map(select(. != ""))')
122-
echo "::set-output name=test-files::$test_files"
126+
echo "test-files=$test_files" >> $GITHUB_OUTPUT
123127
shell: bash
124128

125129
build-image-with-current-branch:
@@ -128,6 +132,13 @@ jobs:
128132
steps:
129133
- name: Checkout code
130134
uses: actions/checkout@v4
135+
with:
136+
ref: ${{ github.head_ref }}
137+
138+
- name: Patch non-fast-block node
139+
run: |
140+
chmod +x ./scripts/localnet_patch.sh
141+
./scripts/localnet_patch.sh
131142
132143
- name: Set up QEMU
133144
uses: docker/setup-qemu-action@v3
@@ -182,6 +193,8 @@ jobs:
182193

183194
- name: Install uv
184195
uses: astral-sh/setup-uv@v5
196+
with:
197+
enable-cache: 'false'
185198

186199
- name: Create Python virtual environment
187200
working-directory: ${{ github.workspace }}
@@ -201,10 +214,6 @@ jobs:
201214
uv run --active pip install '.[dev]'
202215
uv run --active pip install pytest
203216
204-
- name: Install uv dependencies
205-
working-directory: ${{ github.workspace }}/btcli
206-
run: uv sync --all-extras --dev
207-
208217
- name: Download Cached Docker Image
209218
uses: actions/download-artifact@v4
210219
with:
@@ -213,6 +222,9 @@ jobs:
213222
- name: Load Docker Image
214223
run: docker load -i subtensor-localnet.tar
215224

225+
- name: Retag Docker Image
226+
run: docker tag localnet ghcr.io/opentensor/subtensor-localnet:devnet-ready
227+
216228
# - name: Run tests
217229
# working-directory: ${{ github.workspace }}/btcli
218230
# run: |
@@ -223,6 +235,7 @@ jobs:
223235
working-directory: ${{ github.workspace }}/btcli
224236
run: |
225237
source ${{ github.workspace }}/venv/bin/activate
238+
export SKIP_PULL=1
226239
set +e
227240
for i in 1 2; do
228241
echo "🔁 Attempt $i: Running tests"
@@ -277,6 +290,8 @@ jobs:
277290

278291
- name: Install uv
279292
uses: astral-sh/setup-uv@v5
293+
with:
294+
enable-cache: 'false'
280295

281296
- name: Create Python virtual environment
282297
working-directory: ${{ github.workspace }}
@@ -296,10 +311,6 @@ jobs:
296311
uv run --active pip install '.[dev]'
297312
uv run --active pip install pytest
298313
299-
- name: Install uv dependencies
300-
working-directory: ${{ github.workspace }}/bittensor
301-
run: uv sync --all-extras --dev
302-
303314
- name: Download Cached Docker Image
304315
uses: actions/download-artifact@v4
305316
with:
@@ -308,6 +319,9 @@ jobs:
308319
- name: Load Docker Image
309320
run: docker load -i subtensor-localnet.tar
310321

322+
- name: Retag Docker Image
323+
run: docker tag localnet ghcr.io/opentensor/subtensor-localnet:devnet-ready
324+
311325
# - name: Run tests
312326
# working-directory: ${{ github.workspace }}/bittensor
313327
# run: |
@@ -318,6 +332,7 @@ jobs:
318332
working-directory: ${{ github.workspace }}/bittensor
319333
run: |
320334
source ${{ github.workspace }}/venv/bin/activate
335+
export SKIP_PULL=1
321336
set +e
322337
for i in 1 2; do
323338
echo "🔁 Attempt $i: Running tests"
@@ -335,4 +350,4 @@ jobs:
335350
echo "🕒 Retrying..."
336351
sleep 5
337352
fi
338-
done
353+
done

common/src/lib.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub type Nonce = u32;
3535
/// Transfers below SMALL_TRANSFER_LIMIT are considered small transfers
3636
pub const SMALL_TRANSFER_LIMIT: Balance = 500_000_000; // 0.5 TAO
3737

38-
#[freeze_struct("f1746d0b1911967")]
38+
#[freeze_struct("9b6be98fb98e9b17")]
3939
#[repr(transparent)]
4040
#[derive(
4141
Deserialize,
@@ -52,8 +52,8 @@ pub const SMALL_TRANSFER_LIMIT: Balance = 500_000_000; // 0.5 TAO
5252
PartialEq,
5353
PartialOrd,
5454
RuntimeDebug,
55-
TypeInfo,
5655
)]
56+
#[serde(transparent)]
5757
pub struct NetUid(u16);
5858

5959
impl NetUid {
@@ -104,6 +104,13 @@ impl From<u16> for NetUid {
104104
}
105105
}
106106

107+
impl TypeInfo for NetUid {
108+
type Identity = <u16 as TypeInfo>::Identity;
109+
fn type_info() -> scale_info::Type {
110+
<u16 as TypeInfo>::type_info()
111+
}
112+
}
113+
107114
#[derive(
108115
Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, MaxEncodedLen, TypeInfo,
109116
)]
@@ -157,3 +164,13 @@ pub mod time {
157164
pub const HOURS: BlockNumber = MINUTES * 60;
158165
pub const DAYS: BlockNumber = HOURS * 24;
159166
}
167+
168+
#[cfg(test)]
169+
mod tests {
170+
use super::*;
171+
172+
#[test]
173+
fn netuid_has_u16_bin_repr() {
174+
assert_eq!(NetUid(5).encode(), 5u16.encode());
175+
}
176+
}

0 commit comments

Comments
 (0)