Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
67f8d58
Include all sn owner hotkeys in burn keys
gztensor Aug 1, 2025
2a9de22
Migration for root TAO counters
gztensor Aug 14, 2025
3dab531
fmt
gztensor Aug 14, 2025
742e234
auto-update benchmark weights
github-actions[bot] Aug 14, 2025
29c3902
Update transaction extensions
shamil-gadelshin Aug 13, 2025
790c9a8
Refactor subtensor transaction extension
shamil-gadelshin Aug 14, 2025
5d9052d
Update dispatch classes
shamil-gadelshin Aug 15, 2025
947faff
Add transaction prority doc.
shamil-gadelshin Aug 15, 2025
1ffe9d4
Implement burn keys with limit settable by sn owner
gztensor Aug 15, 2025
d34ed2c
Remove weights transaction priority
shamil-gadelshin Aug 18, 2025
1014f6b
Add DrandPriority transaction extenstion.
shamil-gadelshin Aug 18, 2025
ead55ec
Merge branch 'devnet-ready' into change-transaction-extension2
shamil-gadelshin Aug 18, 2025
e559ac1
auto-update benchmark weights
github-actions[bot] Aug 18, 2025
61b7271
Read hotkeys outside the incentive loop
gztensor Aug 19, 2025
0985e40
Merge branch 'devnet-ready' into fix/fix/root-reserves-migration
gztensor Aug 19, 2025
6b87f44
Merge branch 'fix/fix/root-reserves-migration' of github.com:opentens…
gztensor Aug 19, 2025
aac2c10
Comment on amount in migration
gztensor Aug 19, 2025
7c6658b
cd: copy WebAssembly artifacts to subtensor-localnet docker image
zyzniewski-reef Aug 14, 2025
0c4e375
improve evm test stability
open-junius Aug 20, 2025
c7a0706
run uid precompile first
open-junius Aug 20, 2025
a9fafae
bump version
open-junius Aug 20, 2025
6d89ae9
CRV3WeightCommitsV2 => TimelockedWeightCommits
JohnReedV Aug 21, 2025
6914f21
bump spec
JohnReedV Aug 21, 2025
74b668c
init solution
open-junius Aug 21, 2025
e450f7b
cargo clippy
open-junius Aug 21, 2025
098a277
commit Cargo.lock
open-junius Aug 21, 2025
ad2a5a9
cargo fix
open-junius Aug 21, 2025
d53c683
commit Cargo.lock
open-junius Aug 21, 2025
1d13f5f
cargo clippy
open-junius Aug 21, 2025
edb75fb
commit Cargo.lock
open-junius Aug 21, 2025
f45b48f
commit Cargo.lock
open-junius Aug 21, 2025
57bf710
commit Cargo.lock
open-junius Aug 21, 2025
839d1d4
commit Cargo.lock
open-junius Aug 21, 2025
51d2998
commit Cargo.lock
open-junius Aug 21, 2025
da06618
bump version
open-junius Aug 21, 2025
045a9e3
fix unit test
open-junius Aug 21, 2025
6ee5b09
fix clippy
open-junius Aug 21, 2025
c589847
revert code change
open-junius Aug 21, 2025
dfe4033
fix unit tests
open-junius Aug 21, 2025
268f153
fix unit tests
open-junius Aug 21, 2025
53f0f7f
fix unit tests
open-junius Aug 21, 2025
8d870a5
Merge pull request #1961 from opentensor/improve-evm-test
sam0x17 Aug 21, 2025
7118288
Merge branch 'devnet-ready' into commit-reveal-mandatory
open-junius Aug 21, 2025
277488c
rebase PR
open-junius Aug 21, 2025
e8cdefe
fix e2e test
open-junius Aug 21, 2025
e5908ed
Merge pull request #1955 from opentensor/change-transaction-extension2
sam0x17 Aug 21, 2025
5142613
Merge pull request #1963 from opentensor/rename-crv3weightcommitsv2
sam0x17 Aug 21, 2025
51f78d3
Set numbers for migrate_fix_root_tao_and_alpha_in
gztensor Aug 21, 2025
e2746c6
Spec version
gztensor Aug 21, 2025
ffafe39
Merge branch 'devnet-ready' into fix/root-reserves-migration
gztensor Aug 21, 2025
0d65e77
Merge pull request #1905 from opentensor/fix/owner-burn-keys
sam0x17 Aug 21, 2025
eae038f
Add migrate_fix_root_tao_and_alpha_in to migration hook
gztensor Aug 21, 2025
b29bc7f
auto-update benchmark weights
github-actions[bot] Aug 21, 2025
6bd03ae
Merge pull request #1966 from opentensor/fix/root-reserves-migration
sam0x17 Aug 21, 2025
e7eccd3
fix conflict
open-junius Aug 22, 2025
1765c16
fix the unit test
open-junius Aug 22, 2025
42d5af1
fix e2e test stability
open-junius Aug 22, 2025
74a06df
fix e2e test stability
open-junius Aug 22, 2025
480423c
update lease amount
open-junius Aug 22, 2025
963cb3a
increase lock amount for leasing network test
open-junius Aug 22, 2025
2474c87
revert loan value
open-junius Aug 22, 2025
1ead833
Merge pull request #1952 from zyzniewski-reef/cd/webassembly_artifacts
sam0x17 Aug 22, 2025
e4d743e
Update lib.rs
gztensor Aug 22, 2025
f91be75
Merge pull request #1971 from opentensor/reduce_register_cost_fast_block
open-junius Aug 22, 2025
4a60bb9
revert network lock fee
open-junius Aug 23, 2025
a48e04d
Merge pull request #1972 from opentensor/revert-network-lock-value
open-junius Aug 25, 2025
c13d202
rebase PR
open-junius Aug 25, 2025
c5ddb8e
Update benchmarks.rs
JohnReedV Aug 25, 2025
81ac427
Merge pull request #1964 from opentensor/commit-reveal-mandatory
sam0x17 Aug 25, 2025
323cbaf
Fix liquidity limit.
shamil-gadelshin Aug 27, 2025
ca2fa1e
Merge pull request #1982 from opentensor/fix-max-allowed-positions
sam0x17 Aug 27, 2025
663a29c
fix rpc panic due to wrong flag name
l0r1s Aug 27, 2025
a39a7a2
Merge pull request #1985 from opentensor/fix-rpc-panic-2
sam0x17 Aug 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Dockerfile-localnet
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ COPY --from=builder /build/snapshot.json /snapshot.json
COPY --from=builder /build/scripts/localnet.sh scripts/localnet.sh
RUN chmod +x /scripts/localnet.sh

# Copy WebAssembly artifacts
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
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

## Ubdate certificates
RUN apt-get update && apt-get install -y ca-certificates

Expand Down
36 changes: 36 additions & 0 deletions docs/transaction-priority.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## Transaction Priority

### Overview
In Subtensor, transaction priority is determined by custom transaction extensions, which alter or override the default Substrate SDK behavior. Extensions affecting transaction priority are:

- **`ChargeTransactionPaymentWrapper`** (wraps `ChargeTransactionPayment`)
- **`DrandPriority`**

Substrate SDK combines priorities from all transaction extensions using addition.

---

### 1. `ChargeTransactionPaymentWrapper`
In the Substrate SDK, `ChargeTransactionPayment` normally calculates transaction priority based on:
- **Tip** — an extra fee paid by the sender.
- **Weight** — computational complexity of the transaction.
- **Dispatch class** — category of the transaction (`Normal`, `Operational`, `Mandatory`).

However, in Subtensor, `ChargeTransactionPaymentWrapper` **overrides** this logic.
It replaces the dynamic calculation with a **flat priority scale** based only on the dispatch class.

#### Current priority values:
| Dispatch Class | Priority Value | Notes |
|---------------------|-------------------|--------------------------------------------------------------|
| `Normal` | `1` | Standard transactions |
| `Mandatory` | `1` | Rarely used, same as `Normal` |
| `Operational` | `10_000_000_000` | Reserved for critical system extrinsics (e.g.: `sudo` calls) |


---

### 2. `DrandPriority`

Special pallet_drand priority: 10_000 for `write_pulse` extrinsic.

---
7 changes: 4 additions & 3 deletions evm-tests/src/substrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,30 +168,31 @@ export async function waitForTransactionCompletion(api: TypedApi<typeof devnet>,
// })
}


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

// TODO investigate why finalized not for each extrinsic
if (value.type === "finalized") {
console.log("Transaction is finalized in block:", value.txHash);
subscription.unsubscribe();
clearTimeout(timeoutId);
if (!value.ok) {
console.log("Transaction threw an error:", value.dispatchError)
}
// Resolve the promise when the transaction is finalized
resolve();

}
},
error(err) {
console.error("Transaction failed:", err);
subscription.unsubscribe();
clearTimeout(timeoutId);
// Reject the promise in case of an error
reject(err);

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

setTimeout(() => {
const timeoutId = setTimeout(() => {
subscription.unsubscribe();
console.log('unsubscribed because of timeout for tx {}', txHash);
reject()
Expand Down
2 changes: 1 addition & 1 deletion evm-tests/src/subtensor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export async function addNewSubnetwork(api: TypedApi<typeof devnet>, hotkey: Key
// force set balance for a ss58 address
export async function forceSetBalanceToSs58Address(api: TypedApi<typeof devnet>, ss58Address: string) {
const alice = getAliceSigner()
const balance = tao(1e8)
const balance = tao(1e10)
const internalCall = api.tx.Balances.force_set_balance({ who: MultiAddress.Id(ss58Address), new_free: balance })
const tx = api.tx.Sudo.sudo({ call: internalCall.decodedCall })

Expand Down
37 changes: 27 additions & 10 deletions evm-tests/test/neuron.precompile.reveal-weights.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import { generateRandomEthersWallet } from "../src/utils"
import { convertH160ToPublicKey } from "../src/address-utils"
import { blake2AsU8a } from "@polkadot/util-crypto"
import {
forceSetBalanceToEthAddress, forceSetBalanceToSs58Address, addNewSubnetwork, setCommitRevealWeightsEnabled, setWeightsSetRateLimit, burnedRegister,
forceSetBalanceToEthAddress, forceSetBalanceToSs58Address, addNewSubnetwork, setWeightsSetRateLimit, burnedRegister,
setTempo, setCommitRevealWeightsInterval,
startCall
startCall,
} from "../src/subtensor"

// hardcode some values for reveal hash
Expand Down Expand Up @@ -52,6 +52,7 @@ describe("Test neuron precompile reveal weights", () => {
const coldkey = getRandomSubstrateKeypair();

let api: TypedApi<typeof devnet>
let commitEpoch: number;

// sudo account alice as signer
let alice: PolkadotSigner;
Expand All @@ -65,13 +66,11 @@ describe("Test neuron precompile reveal weights", () => {
await forceSetBalanceToSs58Address(api, convertPublicKeyToSs58(coldkey.publicKey))
await forceSetBalanceToEthAddress(api, wallet.address)
let netuid = await addNewSubnetwork(api, hotkey, coldkey)
// await disableCommitRevealWeights(api, netuid)
await startCall(api, netuid, coldkey)

console.log("test the case on subnet ", netuid)

// enable commit reveal feature
await setCommitRevealWeightsEnabled(api, netuid, true)
// set it as 0, we can set the weight anytime
await setWeightsSetRateLimit(api, netuid, BigInt(0))

const ss58Address = convertH160ToSS58(wallet.address)
Expand All @@ -90,8 +89,15 @@ describe("Test neuron precompile reveal weights", () => {
const subnetId = totalNetworks - 1
const commitHash = getCommitHash(subnetId, wallet.address)
const contract = new ethers.Contract(INEURON_ADDRESS, INeuronABI, wallet);
const tx = await contract.commitWeights(subnetId, commitHash)
await tx.wait()
try {
const tx = await contract.commitWeights(subnetId, commitHash)
await tx.wait()
} catch (e) {
console.log("commitWeights failed", e)
}

const commitBlock = await api.query.System.Number.getValue()
commitEpoch = Math.trunc(commitBlock / (100 + 1))

const ss58Address = convertH160ToSS58(wallet.address)

Expand All @@ -108,9 +114,19 @@ describe("Test neuron precompile reveal weights", () => {
const netuid = totalNetworks - 1
const contract = new ethers.Contract(INEURON_ADDRESS, INeuronABI, wallet);
// set tempo or epoch large, then enough time to reveal weight
await setTempo(api, netuid, 60000)
// set interval epoch as 0, we can reveal at the same epoch
await setCommitRevealWeightsInterval(api, netuid, BigInt(0))
await setTempo(api, netuid, 100)
// set interval epoch as 1, it is the minimum value now
await setCommitRevealWeightsInterval(api, netuid, BigInt(1))

while (true) {
const currentBlock = await api.query.System.Number.getValue()
const currentEpoch = Math.trunc(currentBlock / (100 + 1))
// wait for one second for fast blocks
if (currentEpoch > commitEpoch) {
break
}
await new Promise(resolve => setTimeout(resolve, 1000))
}

const tx = await contract.revealWeights(
netuid,
Expand All @@ -120,6 +136,7 @@ describe("Test neuron precompile reveal weights", () => {
version_key
);
await tx.wait()

const ss58Address = convertH160ToSS58(wallet.address)

// check the weight commit is removed after reveal successfully
Expand Down
39 changes: 23 additions & 16 deletions node/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use crate::client::FullClient;

use node_subtensor_runtime as runtime;
use node_subtensor_runtime::check_nonce;
use node_subtensor_runtime::pallet_subtensor;
use node_subtensor_runtime::{check_nonce, transaction_payment_wrapper};
use runtime::{BalancesCall, SystemCall};
use sc_cli::Result;
use sc_client_api::BlockBackend;
Expand Down Expand Up @@ -123,21 +123,27 @@ pub fn create_benchmark_extrinsic(
.checked_next_power_of_two()
.map(|c| c / 2)
.unwrap_or(2) as u64;
let extra: runtime::TransactionExtensions = (
frame_system::CheckNonZeroSender::<runtime::Runtime>::new(),
frame_system::CheckSpecVersion::<runtime::Runtime>::new(),
frame_system::CheckTxVersion::<runtime::Runtime>::new(),
frame_system::CheckGenesis::<runtime::Runtime>::new(),
frame_system::CheckEra::<runtime::Runtime>::from(sp_runtime::generic::Era::mortal(
period,
best_block.saturated_into(),
)),
check_nonce::CheckNonce::<runtime::Runtime>::from(nonce),
frame_system::CheckWeight::<runtime::Runtime>::new(),
pallet_transaction_payment::ChargeTransactionPayment::<runtime::Runtime>::from(0),
pallet_subtensor::SubtensorTransactionExtension::<runtime::Runtime>::new(),
frame_metadata_hash_extension::CheckMetadataHash::<runtime::Runtime>::new(true),
);
let extra: runtime::TransactionExtensions =
(
frame_system::CheckNonZeroSender::<runtime::Runtime>::new(),
frame_system::CheckSpecVersion::<runtime::Runtime>::new(),
frame_system::CheckTxVersion::<runtime::Runtime>::new(),
frame_system::CheckGenesis::<runtime::Runtime>::new(),
frame_system::CheckEra::<runtime::Runtime>::from(sp_runtime::generic::Era::mortal(
period,
best_block.saturated_into(),
)),
check_nonce::CheckNonce::<runtime::Runtime>::from(nonce),
frame_system::CheckWeight::<runtime::Runtime>::new(),
transaction_payment_wrapper::ChargeTransactionPaymentWrapper::new(
pallet_transaction_payment::ChargeTransactionPayment::<runtime::Runtime>::from(0),
),
pallet_subtensor::transaction_extension::SubtensorTransactionExtension::<
runtime::Runtime,
>::new(),
pallet_drand::drand_priority::DrandPriority::<runtime::Runtime>::new(),
frame_metadata_hash_extension::CheckMetadataHash::<runtime::Runtime>::new(true),
);

let raw_payload = runtime::SignedPayload::from_raw(
call.clone(),
Expand All @@ -152,6 +158,7 @@ pub fn create_benchmark_extrinsic(
(),
(),
(),
(),
None,
),
);
Expand Down
4 changes: 2 additions & 2 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,14 +318,14 @@ fn customise_config(arg_matches: &ArgMatches, config: Configuration) -> Configur

// If the operator did **not** supply `--rpc-max-subscriptions-per-connection` set to high value.
config.rpc.max_subs_per_conn = match arg_matches
.value_source("rpc-max-subscriptions-per-connection")
.value_source("rpc_max_subscriptions_per_connection")
{
Some(ValueSource::CommandLine) => cli.run.rpc_params.rpc_max_subscriptions_per_connection,
_ => 10000,
};

// If the operator did **not** supply `--rpc-max-connections` set to high value.
config.rpc.max_connections = match arg_matches.value_source("rpc-max-connections") {
config.rpc.max_connections = match arg_matches.value_source("rpc_max_connections") {
Some(ValueSource::CommandLine) => cli.run.rpc_params.rpc_max_connections,
_ => 10000,
};
Expand Down
27 changes: 18 additions & 9 deletions pallets/admin-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ pub mod pallet {
BondsMovingAverageMaxReached,
/// Only root can set negative sigmoid steepness values
NegativeSigmoidSteepness,
/// Reveal Peroid is not within the valid range.
RevealPeriodOutOfBounds,
}
/// Enum for specifying the type of precompile operation.
#[derive(
Expand Down Expand Up @@ -1311,14 +1309,10 @@ pub mod pallet {
Error::<T>::SubnetDoesNotExist
);

const MAX_COMMIT_REVEAL_PEROIDS: u64 = 100;
ensure!(
interval <= MAX_COMMIT_REVEAL_PEROIDS,
Error::<T>::RevealPeriodOutOfBounds
);

pallet_subtensor::Pallet::<T>::set_reveal_period(netuid, interval);
log::debug!("SetWeightCommitInterval( netuid: {netuid:?}, interval: {interval:?} ) ");

pallet_subtensor::Pallet::<T>::set_reveal_period(netuid, interval)?;

Ok(())
}

Expand Down Expand Up @@ -1673,6 +1667,21 @@ pub mod pallet {
pallet_subtensor::Pallet::<T>::set_commit_reveal_weights_version(version);
Ok(())
}

/// Sets the number of immune owner neurons
#[pallet::call_index(72)]
#[pallet::weight(Weight::from_parts(15_000_000, 0)
.saturating_add(<T as frame_system::Config>::DbWeight::get().reads(1_u64))
.saturating_add(<T as frame_system::Config>::DbWeight::get().writes(1_u64)))]
pub fn sudo_set_owner_immune_neuron_limit(
origin: OriginFor<T>,
netuid: NetUid,
immune_neurons: u16,
) -> DispatchResult {
pallet_subtensor::Pallet::<T>::ensure_subnet_owner_or_root(origin, netuid)?;
pallet_subtensor::Pallet::<T>::set_owner_immune_neuron_limit(netuid, immune_neurons)?;
Ok(())
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions pallets/admin-utils/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ fn test_sudo_set_commit_reveal_weights_enabled() {
let netuid = NetUid::from(1);
add_network(netuid, 10);

let to_be_set: bool = true;
let to_be_set: bool = false;
let init_value: bool = SubtensorModule::get_commit_reveal_weights_enabled(netuid);

assert_ok!(AdminUtils::sudo_set_commit_reveal_weights_enabled(
Expand Down Expand Up @@ -1459,7 +1459,7 @@ fn sudo_set_commit_reveal_weights_interval() {
netuid,
too_high
),
Error::<Test>::RevealPeriodOutOfBounds
pallet_subtensor::Error::<Test>::RevealPeriodTooLarge
);

let to_be_set = 55;
Expand Down
2 changes: 1 addition & 1 deletion pallets/commitments/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ pub mod pallet {
Weight::from_parts(33_480_000, 0)
.saturating_add(T::DbWeight::get().reads(5_u64))
.saturating_add(T::DbWeight::get().writes(4_u64)),
DispatchClass::Operational,
DispatchClass::Normal,
Pays::No
))]
pub fn set_commitment(
Expand Down
2 changes: 2 additions & 0 deletions pallets/drand/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ frame-system.workspace = true
sp-core.workspace = true
sp-io.workspace = true
sp-runtime.workspace = true
sp-std.workspace = true
# arkworks dependencies
sp-ark-bls12-381.workspace = true
ark-bls12-381 = { workspace = true, features = ["curve"] }
Expand Down Expand Up @@ -55,6 +56,7 @@ std = [
"frame-system/std",
"scale-info/std",
"sp-core/std",
"sp-std/std",
"sp-io/std",
"sp-keystore/std",
"sp-keyring/std",
Expand Down
Loading
Loading