Skip to content

Commit e750ca4

Browse files
committed
Merge remote-tracking branch 'origin/devnet-ready' into forbid-saturating-math-lint
2 parents 33a5052 + b7f2640 commit e750ca4

39 files changed

+1116
-466
lines changed

.github/workflows/docker.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ on:
99
description: "Branch or tag to use for the Docker image tag and ref to checkout (optional)"
1010
required: false
1111
default: ""
12-
1312
push:
1413
branches:
1514
- devnet-ready
@@ -35,6 +34,13 @@ jobs:
3534
echo "tag=$branch_or_tag" >> $GITHUB_ENV
3635
echo "ref=$branch_or_tag" >> $GITHUB_ENV
3736
37+
# Check if this is a tagged release (not devnet-ready/devnet/testnet)
38+
if [[ "${{ github.event_name }}" == "release" && "$branch_or_tag" != "devnet-ready" && "$branch_or_tag" != "devnet" && "$branch_or_tag" != "testnet" ]]; then
39+
echo "latest_tag=true" >> $GITHUB_ENV
40+
else
41+
echo "latest_tag=false" >> $GITHUB_ENV
42+
fi
43+
3844
- name: Checkout code
3945
uses: actions/checkout@v4
4046
with:
@@ -60,3 +66,4 @@ jobs:
6066
push: true
6167
tags: |
6268
ghcr.io/${{ github.repository }}:${{ env.tag }}
69+
${{ env.latest_tag == 'true' && format('ghcr.io/{0}:latest', github.repository) || '' }}

Cargo.lock

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

Cargo.toml

Lines changed: 61 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,14 @@ rayon = "1.10"
2323

2424
[workspace]
2525
members = [
26-
"node",
27-
"pallets/commitments",
28-
"pallets/subtensor",
29-
"pallets/admin-utils",
30-
"pallets/collective",
31-
"pallets/registry",
32-
"primitives/*",
33-
"runtime",
34-
"support/tools",
35-
"support/macros",
36-
"support/linting",
37-
"support/procedural-fork",
38-
"pallets/drand",
26+
"common",
27+
"node",
28+
"pallets/*",
29+
"precompiles",
30+
"primitives/*",
31+
"runtime",
32+
"support/*",
3933
]
40-
exclude = ["support/procedural-fork"]
4134
resolver = "2"
4235

4336
[workspace.lints.clippy]
@@ -46,14 +39,29 @@ arithmetic-side-effects = "deny"
4639
type_complexity = "allow"
4740
unwrap-used = "deny"
4841
manual_inspect = "allow"
49-
useless_conversion = "allow" # until polkadot is patched
42+
useless_conversion = "allow" # until polkadot is patched
5043

5144
[workspace.dependencies]
45+
pallet-admin-utils = { default-features = false, path = "pallets/admin-utils" }
46+
pallet-collective = { default-features = false, path = "pallets/collective" }
47+
pallet-commitments = { default-features = false, path = "pallets/commitments" }
48+
pallet-registry = { default-features = false, path = "pallets/registry" }
49+
pallet-subtensor = { default-features = false, path = "pallets/subtensor" }
50+
subtensor-custom-rpc = { default-features = false, path = "pallets/subtensor/rpc" }
51+
subtensor-custom-rpc-runtime-api = { default-features = false, path = "pallets/subtensor/runtime-api" }
52+
subtensor-precompiles = { default-features = false, path = "precompiles" }
53+
subtensor-runtime-common = { default-features = false, path = "common" }
54+
node-subtensor-runtime = { default-features = false, path = "runtime" }
55+
5256
async-trait = "0.1"
5357
cargo-husky = { version = "1", default-features = false }
5458
clap = "4.5.4"
55-
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive"] }
56-
ed25519-dalek = { version = "2.1.0", default-features = false, features = ["alloc"] }
59+
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = [
60+
"derive",
61+
] }
62+
ed25519-dalek = { version = "2.1.0", default-features = false, features = [
63+
"alloc",
64+
] }
5765
enumflags2 = "0.7.9"
5866
futures = "0.3.30"
5967
hex = { version = "0.4", default-features = false }
@@ -64,7 +72,9 @@ memmap2 = "0.9.4"
6472
ndarray = { version = "0.15.6", default-features = false }
6573
parity-util-mem = "0.12.0"
6674
rand = "0.8.5"
67-
scale-codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["derive"] }
75+
scale-codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = [
76+
"derive",
77+
] }
6878
scale-info = { version = "2.11.2", default-features = false }
6979
serde = { version = "1.0.214", default-features = false }
7080
serde-tuple-vec-map = { version = "1.0.1", default-features = false }
@@ -74,11 +84,11 @@ serde_with = { version = "=2.0.0", default-features = false }
7484
smallvec = "1.13.2"
7585
litep2p = { git = "https://github.com/paritytech/litep2p", tag = "v0.7.0" }
7686
syn = { version = "2.0.87", features = [
77-
"full",
78-
"visit-mut",
79-
"visit",
80-
"extra-traits",
81-
"parsing",
87+
"full",
88+
"visit-mut",
89+
"visit",
90+
"extra-traits",
91+
"parsing",
8292
] }
8393
quote = "1"
8494
proc-macro2 = { version = "1", features = ["span-locations"] }
@@ -181,7 +191,9 @@ fc-consensus = { git = "https://github.com/opentensor/frontier", rev = "635bdac8
181191
fp-consensus = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
182192
fp-dynamic-fee = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
183193
fc-api = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
184-
fc-rpc = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false, features = ["rpc-binary-search-estimate"]}
194+
fc-rpc = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false, features = [
195+
"rpc-binary-search-estimate",
196+
] }
185197
fc-rpc-core = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
186198
fc-mapping-sync = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
187199
precompile-utils = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
@@ -199,21 +211,34 @@ pallet-hotfix-sufficients = { git = "https://github.com/opentensor/frontier", re
199211

200212
#DRAND
201213
pallet-drand = { path = "pallets/drand", default-features = false }
202-
sp-crypto-ec-utils = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", features = ["bls12-381"] }
203-
getrandom = { version = "0.2.15", features = ["custom"], default-features = false }
204-
sp-keystore = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false }
214+
sp-crypto-ec-utils = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", features = [
215+
"bls12-381",
216+
] }
217+
getrandom = { version = "0.2.15", features = [
218+
"custom",
219+
], default-features = false }
220+
sp-keystore = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false }
205221
w3f-bls = { version = "=0.1.3", default-features = false }
206-
ark-crypto-primitives = { version = "0.4.0", default-features = false, features = [ "r1cs", "snark" ] }
207-
ark-scale = { version = "0.0.11", default-features = false, features = ["hazmat"] }
222+
ark-crypto-primitives = { version = "0.4.0", default-features = false, features = [
223+
"r1cs",
224+
"snark",
225+
] }
226+
ark-scale = { version = "0.0.11", default-features = false, features = [
227+
"hazmat",
228+
] }
208229
sp-ark-bls12-381 = { git = "https://github.com/paritytech/substrate-curves", default-features = false }
209-
ark-bls12-381 = { version = "0.4.0", features = ["curve"], default-features = false }
210-
ark-serialize = { version = "0.4.0", features = [ "derive" ], default-features = false }
230+
ark-bls12-381 = { version = "0.4.0", features = [
231+
"curve",
232+
], default-features = false }
233+
ark-serialize = { version = "0.4.0", features = [
234+
"derive",
235+
], default-features = false }
211236
ark-ff = { version = "0.4.0", default-features = false }
212237
ark-ec = { version = "0.4.0", default-features = false }
213238
ark-std = { version = "0.4.0", default-features = false }
214239
anyhow = "1.0.81"
215240
sha2 = { version = "0.10.8", default-features = false }
216-
rand_chacha = { version = "0.3.1", default-features = false }
241+
rand_chacha = { version = "0.3.1", default-features = false }
217242
tle = { git = "https://github.com/ideal-lab5/timelock", rev = "5416406cfd32799e31e1795393d4916894de4468", default-features = false }
218243

219244
frame-metadata = "16"
@@ -232,11 +257,11 @@ codegen-units = 1
232257
[features]
233258
default = []
234259
try-runtime = [
235-
"node-subtensor/try-runtime",
236-
"node-subtensor-runtime/try-runtime",
260+
"node-subtensor/try-runtime",
261+
"node-subtensor-runtime/try-runtime",
237262
]
238263
runtime-benchmarks = [
239-
"node-subtensor/runtime-benchmarks",
240-
"node-subtensor-runtime/runtime-benchmarks",
264+
"node-subtensor/runtime-benchmarks",
265+
"node-subtensor-runtime/runtime-benchmarks",
241266
]
242267
metadata-hash = ["node-subtensor-runtime/metadata-hash"]

common/Cargo.toml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[package]
2+
name = "subtensor-runtime-common"
3+
version = "0.1.0"
4+
edition = "2024"
5+
authors = ["Opentensor Foundation <https://github.com/opentensor/>"]
6+
homepage = "https://opentensor.ai/"
7+
publish = false
8+
repository = "https://github.com/opentensor/subtensor/"
9+
10+
[package.metadata.docs.rs]
11+
targets = ["x86_64-unknown-linux-gnu"]
12+
13+
[dependencies]
14+
codec = { workspace = true }
15+
frame-support = { workspace = true }
16+
scale-info = { workspace = true }
17+
sp-runtime = { workspace = true }
18+
sp-core = { workspace = true }
19+
20+
[lints]
21+
workspace = true
22+
23+
[features]
24+
default = ["std"]
25+
fast-blocks = []
26+
std = [
27+
"codec/std",
28+
"frame-support/std",
29+
"scale-info/std",
30+
"sp-core/std",
31+
"sp-runtime/std",
32+
]

common/src/lib.rs

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#![cfg_attr(not(feature = "std"), no_std)]
2+
3+
use codec::{Decode, Encode, MaxEncodedLen};
4+
use scale_info::TypeInfo;
5+
use sp_runtime::{
6+
MultiSignature,
7+
traits::{IdentifyAccount, Verify},
8+
};
9+
10+
/// Balance of an account.
11+
pub type Balance = u64;
12+
13+
/// An index to a block.
14+
pub type BlockNumber = u32;
15+
16+
/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.
17+
pub type Signature = MultiSignature;
18+
19+
/// Some way of identifying an account on the chain. We intentionally make it equivalent to the
20+
/// public key of our transaction signing scheme.
21+
pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;
22+
23+
/// Index of a transaction in the chain.
24+
pub type Index = u32;
25+
26+
/// A hash of some data used by the chain.
27+
pub type Hash = sp_core::H256;
28+
29+
pub type Nonce = u32;
30+
31+
/// Transfers below SMALL_TRANSFER_LIMIT are considered small transfers
32+
pub const SMALL_TRANSFER_LIMIT: Balance = 500_000_000; // 0.5 TAO
33+
34+
#[derive(
35+
Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, MaxEncodedLen, TypeInfo,
36+
)]
37+
pub enum ProxyType {
38+
Any,
39+
Owner, // Subnet owner Calls
40+
NonCritical,
41+
NonTransfer,
42+
Senate,
43+
NonFungibile, // Nothing involving moving TAO
44+
Triumvirate,
45+
Governance, // Both above governance
46+
Staking,
47+
Registration,
48+
Transfer,
49+
SmallTransfer,
50+
RootWeights,
51+
ChildKeys,
52+
SudoUncheckedSetCode,
53+
}
54+
55+
impl Default for ProxyType {
56+
// allow all Calls; required to be most permissive
57+
fn default() -> Self {
58+
Self::Any
59+
}
60+
}
61+
62+
pub mod time {
63+
use super::*;
64+
65+
/// This determines the average expected block time that we are targeting. Blocks will be
66+
/// produced at a minimum duration defined by `SLOT_DURATION`. `SLOT_DURATION` is picked up by
67+
/// `pallet_timestamp` which is in turn picked up by `pallet_aura` to implement `fn
68+
/// slot_duration()`.
69+
///
70+
/// Change this to adjust the block time.
71+
#[cfg(not(feature = "fast-blocks"))]
72+
pub const MILLISECS_PER_BLOCK: u64 = 12000;
73+
74+
/// Fast blocks for development
75+
#[cfg(feature = "fast-blocks")]
76+
pub const MILLISECS_PER_BLOCK: u64 = 250;
77+
78+
// NOTE: Currently it is not possible to change the slot duration after the chain has started.
79+
// Attempting to do so will brick block production.
80+
pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;
81+
82+
// Time is measured by number of blocks.
83+
pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);
84+
pub const HOURS: BlockNumber = MINUTES * 60;
85+
pub const DAYS: BlockNumber = HOURS * 24;
86+
}

0 commit comments

Comments
 (0)