Skip to content

Commit 0f37b9a

Browse files
committed
merge devnet-ready
2 parents 4c1ca4a + f91be75 commit 0f37b9a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1518
-738
lines changed

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Dockerfile-localnet

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ COPY --from=builder /build/snapshot.json /snapshot.json
5252
COPY --from=builder /build/scripts/localnet.sh scripts/localnet.sh
5353
RUN chmod +x /scripts/localnet.sh
5454

55+
# Copy WebAssembly artifacts
56+
COPY --from=builder /build/target/fast-runtime/release/wbuild/node-subtensor-runtime/node_subtensor_runtime.compact.compressed.wasm target/fast-runtime/release/node_subtensor_runtime.compact.compressed.wasm
57+
COPY --from=builder /build/target/non-fast-runtime/release/wbuild/node-subtensor-runtime/node_subtensor_runtime.compact.compressed.wasm target/non-fast-runtime/release/node_subtensor_runtime.compact.compressed.wasm
58+
5559
## Ubdate certificates
5660
RUN apt-get update && apt-get install -y ca-certificates
5761

docs/transaction-priority.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
## Transaction Priority
2+
3+
### Overview
4+
In Subtensor, transaction priority is determined by custom transaction extensions, which alter or override the default Substrate SDK behavior. Extensions affecting transaction priority are:
5+
6+
- **`ChargeTransactionPaymentWrapper`** (wraps `ChargeTransactionPayment`)
7+
- **`DrandPriority`**
8+
9+
Substrate SDK combines priorities from all transaction extensions using addition.
10+
11+
---
12+
13+
### 1. `ChargeTransactionPaymentWrapper`
14+
In the Substrate SDK, `ChargeTransactionPayment` normally calculates transaction priority based on:
15+
- **Tip** — an extra fee paid by the sender.
16+
- **Weight** — computational complexity of the transaction.
17+
- **Dispatch class** — category of the transaction (`Normal`, `Operational`, `Mandatory`).
18+
19+
However, in Subtensor, `ChargeTransactionPaymentWrapper` **overrides** this logic.
20+
It replaces the dynamic calculation with a **flat priority scale** based only on the dispatch class.
21+
22+
#### Current priority values:
23+
| Dispatch Class | Priority Value | Notes |
24+
|---------------------|-------------------|--------------------------------------------------------------|
25+
| `Normal` | `1` | Standard transactions |
26+
| `Mandatory` | `1` | Rarely used, same as `Normal` |
27+
| `Operational` | `10_000_000_000` | Reserved for critical system extrinsics (e.g.: `sudo` calls) |
28+
29+
30+
---
31+
32+
### 2. `DrandPriority`
33+
34+
Special pallet_drand priority: 10_000 for `write_pulse` extrinsic.
35+
36+
---

evm-tests/src/substrate.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,30 +168,31 @@ export async function waitForTransactionCompletion(api: TypedApi<typeof devnet>,
168168
// })
169169
}
170170

171+
171172
export async function getTransactionWatchPromise(tx: Transaction<{}, string, string, void>, signer: PolkadotSigner,) {
172173
return new Promise<void>((resolve, reject) => {
173174
// store the txHash, then use it in timeout. easier to know which tx is not finalized in time
174175
let txHash = ""
175176
const subscription = tx.signSubmitAndWatch(signer).subscribe({
176177
next(value) {
177-
console.log("Event:", value);
178178
txHash = value.txHash
179179

180180
// TODO investigate why finalized not for each extrinsic
181181
if (value.type === "finalized") {
182182
console.log("Transaction is finalized in block:", value.txHash);
183183
subscription.unsubscribe();
184+
clearTimeout(timeoutId);
184185
if (!value.ok) {
185186
console.log("Transaction threw an error:", value.dispatchError)
186187
}
187188
// Resolve the promise when the transaction is finalized
188189
resolve();
189-
190190
}
191191
},
192192
error(err) {
193193
console.error("Transaction failed:", err);
194194
subscription.unsubscribe();
195+
clearTimeout(timeoutId);
195196
// Reject the promise in case of an error
196197
reject(err);
197198

@@ -201,7 +202,7 @@ export async function getTransactionWatchPromise(tx: Transaction<{}, string, str
201202
}
202203
});
203204

204-
setTimeout(() => {
205+
const timeoutId = setTimeout(() => {
205206
subscription.unsubscribe();
206207
console.log('unsubscribed because of timeout for tx {}', txHash);
207208
reject()

evm-tests/src/subtensor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export async function addNewSubnetwork(api: TypedApi<typeof devnet>, hotkey: Key
3232
// force set balance for a ss58 address
3333
export async function forceSetBalanceToSs58Address(api: TypedApi<typeof devnet>, ss58Address: string) {
3434
const alice = getAliceSigner()
35-
const balance = tao(1e8)
35+
const balance = tao(1e10)
3636
const internalCall = api.tx.Balances.force_set_balance({ who: MultiAddress.Id(ss58Address), new_free: balance })
3737
const tx = api.tx.Sudo.sudo({ call: internalCall.decodedCall })
3838

node/src/benchmarking.rs

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
use crate::client::FullClient;
66

77
use node_subtensor_runtime as runtime;
8-
use node_subtensor_runtime::check_nonce;
98
use node_subtensor_runtime::pallet_subtensor;
9+
use node_subtensor_runtime::{check_nonce, transaction_payment_wrapper};
1010
use runtime::{BalancesCall, SystemCall};
1111
use sc_cli::Result;
1212
use sc_client_api::BlockBackend;
@@ -123,21 +123,27 @@ pub fn create_benchmark_extrinsic(
123123
.checked_next_power_of_two()
124124
.map(|c| c / 2)
125125
.unwrap_or(2) as u64;
126-
let extra: runtime::TransactionExtensions = (
127-
frame_system::CheckNonZeroSender::<runtime::Runtime>::new(),
128-
frame_system::CheckSpecVersion::<runtime::Runtime>::new(),
129-
frame_system::CheckTxVersion::<runtime::Runtime>::new(),
130-
frame_system::CheckGenesis::<runtime::Runtime>::new(),
131-
frame_system::CheckEra::<runtime::Runtime>::from(sp_runtime::generic::Era::mortal(
132-
period,
133-
best_block.saturated_into(),
134-
)),
135-
check_nonce::CheckNonce::<runtime::Runtime>::from(nonce),
136-
frame_system::CheckWeight::<runtime::Runtime>::new(),
137-
pallet_transaction_payment::ChargeTransactionPayment::<runtime::Runtime>::from(0),
138-
pallet_subtensor::SubtensorTransactionExtension::<runtime::Runtime>::new(),
139-
frame_metadata_hash_extension::CheckMetadataHash::<runtime::Runtime>::new(true),
140-
);
126+
let extra: runtime::TransactionExtensions =
127+
(
128+
frame_system::CheckNonZeroSender::<runtime::Runtime>::new(),
129+
frame_system::CheckSpecVersion::<runtime::Runtime>::new(),
130+
frame_system::CheckTxVersion::<runtime::Runtime>::new(),
131+
frame_system::CheckGenesis::<runtime::Runtime>::new(),
132+
frame_system::CheckEra::<runtime::Runtime>::from(sp_runtime::generic::Era::mortal(
133+
period,
134+
best_block.saturated_into(),
135+
)),
136+
check_nonce::CheckNonce::<runtime::Runtime>::from(nonce),
137+
frame_system::CheckWeight::<runtime::Runtime>::new(),
138+
transaction_payment_wrapper::ChargeTransactionPaymentWrapper::new(
139+
pallet_transaction_payment::ChargeTransactionPayment::<runtime::Runtime>::from(0),
140+
),
141+
pallet_subtensor::transaction_extension::SubtensorTransactionExtension::<
142+
runtime::Runtime,
143+
>::new(),
144+
pallet_drand::drand_priority::DrandPriority::<runtime::Runtime>::new(),
145+
frame_metadata_hash_extension::CheckMetadataHash::<runtime::Runtime>::new(true),
146+
);
141147

142148
let raw_payload = runtime::SignedPayload::from_raw(
143149
call.clone(),
@@ -152,6 +158,7 @@ pub fn create_benchmark_extrinsic(
152158
(),
153159
(),
154160
(),
161+
(),
155162
None,
156163
),
157164
);

pallets/admin-utils/src/lib.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,6 +1673,21 @@ pub mod pallet {
16731673
pallet_subtensor::Pallet::<T>::set_commit_reveal_weights_version(version);
16741674
Ok(())
16751675
}
1676+
1677+
/// Sets the number of immune owner neurons
1678+
#[pallet::call_index(72)]
1679+
#[pallet::weight(Weight::from_parts(15_000_000, 0)
1680+
.saturating_add(<T as frame_system::Config>::DbWeight::get().reads(1_u64))
1681+
.saturating_add(<T as frame_system::Config>::DbWeight::get().writes(1_u64)))]
1682+
pub fn sudo_set_owner_immune_neuron_limit(
1683+
origin: OriginFor<T>,
1684+
netuid: NetUid,
1685+
immune_neurons: u16,
1686+
) -> DispatchResult {
1687+
pallet_subtensor::Pallet::<T>::ensure_subnet_owner_or_root(origin, netuid)?;
1688+
pallet_subtensor::Pallet::<T>::set_owner_immune_neuron_limit(netuid, immune_neurons)?;
1689+
Ok(())
1690+
}
16761691
}
16771692
}
16781693

pallets/commitments/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ pub mod pallet {
208208
Weight::from_parts(33_480_000, 0)
209209
.saturating_add(T::DbWeight::get().reads(5_u64))
210210
.saturating_add(T::DbWeight::get().writes(4_u64)),
211-
DispatchClass::Operational,
211+
DispatchClass::Normal,
212212
Pays::No
213213
))]
214214
pub fn set_commitment(

pallets/drand/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ frame-system.workspace = true
2727
sp-core.workspace = true
2828
sp-io.workspace = true
2929
sp-runtime.workspace = true
30+
sp-std.workspace = true
3031
# arkworks dependencies
3132
sp-ark-bls12-381.workspace = true
3233
ark-bls12-381 = { workspace = true, features = ["curve"] }
@@ -55,6 +56,7 @@ std = [
5556
"frame-system/std",
5657
"scale-info/std",
5758
"sp-core/std",
59+
"sp-std/std",
5860
"sp-io/std",
5961
"sp-keystore/std",
6062
"sp-keyring/std",

0 commit comments

Comments
 (0)