Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testnet deploy 2/5/2025 #1235

Merged
merged 60 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
cf5b423
pass AccountId as generic to info types instead of T
camfairchild Jan 15, 2025
8d9facc
add TypeInfo to info types
camfairchild Jan 15, 2025
c59dac1
use types when calling info functions
camfairchild Jan 15, 2025
0a82d6b
use new types
camfairchild Jan 15, 2025
fcd19d1
Merge branch 'devnet-ready' into feat/no-more-weird-runtime-api-encoding
camfairchild Jan 21, 2025
48f5c82
Merge branch 'devnet-ready' into feat/no-more-weird-runtime-api-encoding
camfairchild Jan 22, 2025
d44d9ec
use plain type for metagraph info
camfairchild Jan 22, 2025
78f04ed
Merge branch 'devnet-ready' into feat/no-more-weird-runtime-api-encoding
camfairchild Jan 27, 2025
c55b226
add new fields to ChainIdentity and SubnetIdentity
JohnReedV Jan 28, 2025
0c5eaec
add migration and test
JohnReedV Jan 28, 2025
54959f3
Merge branch 'devnet-ready' into feat/no-more-weird-runtime-api-encoding
roman-opentensor Jan 31, 2025
380587c
Merge branch 'devnet-ready' into feat/identity-upgrades
JohnReedV Feb 3, 2025
ea96bec
address freeze_struct
JohnReedV Feb 3, 2025
a7232b0
rename commit_reveal_period
JohnReedV Feb 3, 2025
12f483c
remove subnet_info_v3
JohnReedV Feb 3, 2025
ea136bb
address lint
JohnReedV Feb 3, 2025
2d32d96
update register_network with identity precompile
JohnReedV Feb 3, 2025
6d483b2
fix merge commit
camfairchild Feb 3, 2025
625a3e0
Merge branch 'devnet-ready' into feat/identity-upgrades
JohnReedV Feb 3, 2025
b8b5409
bump spec
camfairchild Feb 3, 2025
913fb1a
remove SubnetInfov3 struct
JohnReedV Feb 3, 2025
69d2b77
rename emission_values => emission_value
JohnReedV Feb 3, 2025
6766f1d
bump spec
JohnReedV Feb 3, 2025
86e898f
Merge pull request #1227 from opentensor/feat/no-more-weird-runtime-a…
sam0x17 Feb 4, 2025
9a271fb
Merge pull request #1233 from opentensor/devnet-ready
sam0x17 Feb 4, 2025
40c8214
Merge branch 'devnet-ready' into feat/identity-upgrades
camfairchild Feb 4, 2025
0213918
use saturating math
JohnReedV Feb 4, 2025
d479346
add cleaned coinbase
Feb 4, 2025
547ca27
noclaim
Feb 4, 2025
1a2ec64
remove complexity
Feb 4, 2025
d81238a
clean coinbase
Feb 5, 2025
b144f21
pre merge
Feb 5, 2025
8ec029d
Merge branch 'devnet-ready' of https://github.com/opentensor/subtenso…
Feb 5, 2025
f29c736
no tao in for non registration
Feb 5, 2025
d4e37e8
Merge pull request #1240 from opentensor/testnet
sam0x17 Feb 5, 2025
ee37f6d
move to moving prices rather than tao reserves
Feb 5, 2025
f7058a2
Merge pull request #1242 from opentensor/devnet
sam0x17 Feb 5, 2025
e252e90
price
Feb 5, 2025
b2639e7
moving alpha
Feb 5, 2025
6c946db
bump spec
JohnReedV Feb 5, 2025
ea355f2
Fix tests
gztensor Feb 5, 2025
f91e7ca
add moving price tests
Feb 5, 2025
160b773
Merge branch 'nonclaim' of https://github.com/opentensor/subtensor in…
Feb 5, 2025
e4ccdfa
add alpha in tests
Feb 5, 2025
ba80bbb
Fix all tests
gztensor Feb 5, 2025
30475f1
Merge branch 'nonclaim' of github.com:opentensor/subtensor into nonclaim
gztensor Feb 5, 2025
3eca45f
Format
gztensor Feb 5, 2025
1ffefe1
Fix unsafe math
gztensor Feb 5, 2025
8af65df
alpha tests
Feb 5, 2025
009961d
fix test
Feb 5, 2025
0e367f7
set tao weight
Feb 5, 2025
290498e
reset default staking fee
Feb 5, 2025
ab105c7
fix names
Feb 5, 2025
452dbac
add mainnet names
Feb 5, 2025
5c96afd
cargo clippy
Feb 5, 2025
bce7cc6
cargo fmt
Feb 5, 2025
8729b25
Merge branch 'devnet-ready' into nonclaim
unconst Feb 5, 2025
8c8bc16
Merge pull request #1241 from opentensor/nonclaim
sam0x17 Feb 5, 2025
ffe3cc0
Merge pull request #1205 from opentensor/feat/identity-upgrades
sam0x17 Feb 5, 2025
c6491fc
Merge pull request #1244 from opentensor/devnet-ready
sam0x17 Feb 5, 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
2 changes: 2 additions & 0 deletions Cargo.lock

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

4 changes: 1 addition & 3 deletions pallets/subtensor/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ publish = false
workspace = true

[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [
"derive",
] }
codec = { workspace = true }
jsonrpsee = { workspace = true, features = ["client-core", "server", "macros"] }
serde = { workspace = true, features = ["derive"] }

Expand Down
172 changes: 128 additions & 44 deletions pallets/subtensor/rpc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
//! RPC interface for the custom Subtensor rpc methods

use codec::{Decode, Encode};
use jsonrpsee::{
core::RpcResult,
proc_macros::rpc,
types::{error::ErrorObject, ErrorObjectOwned},
};
use sp_blockchain::HeaderBackend;
use sp_runtime::traits::Block as BlockT;
use sp_runtime::{traits::Block as BlockT, AccountId32};
use std::sync::Arc;

use sp_api::ProvideRuntimeApi;
Expand Down Expand Up @@ -116,9 +117,12 @@ where
let api = self.client.runtime_api();
let at = at.unwrap_or_else(|| self.client.info().best_hash);

api.get_delegates(at).map_err(|e| {
Error::RuntimeError(format!("Unable to get delegates info: {:?}", e)).into()
})
match api.get_delegates(at) {
Ok(result) => Ok(result.encode()),
Err(e) => {
Err(Error::RuntimeError(format!("Unable to get delegates info: {:?}", e)).into())
}
}
}

fn get_delegate(
Expand All @@ -129,9 +133,20 @@ where
let api = self.client.runtime_api();
let at = at.unwrap_or_else(|| self.client.info().best_hash);

api.get_delegate(at, delegate_account_vec).map_err(|e| {
Error::RuntimeError(format!("Unable to get delegates info: {:?}", e)).into()
})
let delegate_account = match AccountId32::decode(&mut &delegate_account_vec[..]) {
Ok(delegate_account) => delegate_account,
Err(e) => {
return Err(
Error::RuntimeError(format!("Unable to get delegates info: {:?}", e)).into(),
)
}
};
match api.get_delegate(at, delegate_account) {
Ok(result) => Ok(result.encode()),
Err(e) => {
Err(Error::RuntimeError(format!("Unable to get delegates info: {:?}", e)).into())
}
}
}

fn get_delegated(
Expand All @@ -142,9 +157,20 @@ where
let api = self.client.runtime_api();
let at = at.unwrap_or_else(|| self.client.info().best_hash);

api.get_delegated(at, delegatee_account_vec).map_err(|e| {
Error::RuntimeError(format!("Unable to get delegates info: {:?}", e)).into()
})
let delegatee_account = match AccountId32::decode(&mut &delegatee_account_vec[..]) {
Ok(delegatee_account) => delegatee_account,
Err(e) => {
return Err(
Error::RuntimeError(format!("Unable to get delegates info: {:?}", e)).into(),
)
}
};
match api.get_delegated(at, delegatee_account) {
Ok(result) => Ok(result.encode()),
Err(e) => {
Err(Error::RuntimeError(format!("Unable to get delegates info: {:?}", e)).into())
}
}
}

fn get_neurons_lite(
Expand All @@ -155,9 +181,12 @@ where
let api = self.client.runtime_api();
let at = at.unwrap_or_else(|| self.client.info().best_hash);

api.get_neurons_lite(at, netuid).map_err(|e| {
Error::RuntimeError(format!("Unable to get neurons lite info: {:?}", e)).into()
})
match api.get_neurons_lite(at, netuid) {
Ok(result) => Ok(result.encode()),
Err(e) => {
Err(Error::RuntimeError(format!("Unable to get neurons lite info: {:?}", e)).into())
}
}
}

fn get_neuron_lite(
Expand All @@ -169,17 +198,24 @@ where
let api = self.client.runtime_api();
let at = at.unwrap_or_else(|| self.client.info().best_hash);

api.get_neuron_lite(at, netuid, uid).map_err(|e| {
Error::RuntimeError(format!("Unable to get neurons lite info: {:?}", e)).into()
})
match api.get_neuron_lite(at, netuid, uid) {
Ok(result) => Ok(result.encode()),
Err(e) => {
Err(Error::RuntimeError(format!("Unable to get neurons lite info: {:?}", e)).into())
}
}
}

fn get_neurons(&self, netuid: u16, at: Option<<Block as BlockT>::Hash>) -> RpcResult<Vec<u8>> {
let api = self.client.runtime_api();
let at = at.unwrap_or_else(|| self.client.info().best_hash);

api.get_neurons(at, netuid)
.map_err(|e| Error::RuntimeError(format!("Unable to get neurons info: {:?}", e)).into())
match api.get_neurons(at, netuid) {
Ok(result) => Ok(result.encode()),
Err(e) => {
Err(Error::RuntimeError(format!("Unable to get neurons info: {:?}", e)).into())
}
}
}

fn get_neuron(
Expand All @@ -191,8 +227,12 @@ where
let api = self.client.runtime_api();
let at = at.unwrap_or_else(|| self.client.info().best_hash);

api.get_neuron(at, netuid, uid)
.map_err(|e| Error::RuntimeError(format!("Unable to get neuron info: {:?}", e)).into())
match api.get_neuron(at, netuid, uid) {
Ok(result) => Ok(result.encode()),
Err(e) => {
Err(Error::RuntimeError(format!("Unable to get neuron info: {:?}", e)).into())
}
}
}

fn get_subnet_info(
Expand All @@ -203,8 +243,12 @@ where
let api = self.client.runtime_api();
let at = at.unwrap_or_else(|| self.client.info().best_hash);

api.get_subnet_info(at, netuid)
.map_err(|e| Error::RuntimeError(format!("Unable to get subnet info: {:?}", e)).into())
match api.get_subnet_info(at, netuid) {
Ok(result) => Ok(result.encode()),
Err(e) => {
Err(Error::RuntimeError(format!("Unable to get subnet info: {:?}", e)).into())
}
}
}

fn get_subnet_hyperparams(
Expand All @@ -215,23 +259,36 @@ where
let api = self.client.runtime_api();
let at = at.unwrap_or_else(|| self.client.info().best_hash);

api.get_subnet_hyperparams(at, netuid)
.map_err(|e| Error::RuntimeError(format!("Unable to get subnet info: {:?}", e)).into())
match api.get_subnet_hyperparams(at, netuid) {
Ok(result) => Ok(result.encode()),
Err(e) => {
Err(Error::RuntimeError(format!("Unable to get subnet info: {:?}", e)).into())
}
}
}

fn get_all_dynamic_info(&self, at: Option<<Block as BlockT>::Hash>) -> RpcResult<Vec<u8>> {
let api = self.client.runtime_api();
let at = at.unwrap_or_else(|| self.client.info().best_hash);
api.get_all_dynamic_info(at).map_err(|e| {
Error::RuntimeError(format!("Unable to get dynamic subnets info: {:?}", e)).into()
})

match api.get_all_dynamic_info(at) {
Ok(result) => Ok(result.encode()),
Err(e) => Err(Error::RuntimeError(format!(
"Unable to get dynamic subnets info: {:?}",
e
))
.into()),
}
}

fn get_all_metagraphs(&self, at: Option<<Block as BlockT>::Hash>) -> RpcResult<Vec<u8>> {
let api = self.client.runtime_api();
let at = at.unwrap_or_else(|| self.client.info().best_hash);
api.get_all_metagraphs(at)
.map_err(|e| Error::RuntimeError(format!("Unable to get metagraps: {:?}", e)).into())

match api.get_all_metagraphs(at) {
Ok(result) => Ok(result.encode()),
Err(e) => Err(Error::RuntimeError(format!("Unable to get metagraps: {:?}", e)).into()),
}
}

fn get_dynamic_info(
Expand All @@ -241,9 +298,15 @@ where
) -> RpcResult<Vec<u8>> {
let api = self.client.runtime_api();
let at = at.unwrap_or_else(|| self.client.info().best_hash);
api.get_dynamic_info(at, netuid).map_err(|e| {
Error::RuntimeError(format!("Unable to get dynamic subnets info: {:?}", e)).into()
})

match api.get_dynamic_info(at, netuid) {
Ok(result) => Ok(result.encode()),
Err(e) => Err(Error::RuntimeError(format!(
"Unable to get dynamic subnets info: {:?}",
e
))
.into()),
}
}

fn get_metagraph(
Expand All @@ -253,9 +316,14 @@ where
) -> RpcResult<Vec<u8>> {
let api = self.client.runtime_api();
let at = at.unwrap_or_else(|| self.client.info().best_hash);
api.get_metagraph(at, netuid).map_err(|e| {
Error::RuntimeError(format!("Unable to get dynamic subnets info: {:?}", e)).into()
})
match api.get_metagraph(at, netuid) {
Ok(result) => Ok(result.encode()),
Err(e) => Err(Error::RuntimeError(format!(
"Unable to get dynamic subnets info: {:?}",
e
))
.into()),
}
}

fn get_subnet_state(
Expand All @@ -265,17 +333,25 @@ where
) -> RpcResult<Vec<u8>> {
let api = self.client.runtime_api();
let at = at.unwrap_or_else(|| self.client.info().best_hash);
api.get_subnet_state(at, netuid).map_err(|e| {
Error::RuntimeError(format!("Unable to get subnet state info: {:?}", e)).into()
})

match api.get_subnet_state(at, netuid) {
Ok(result) => Ok(result.encode()),
Err(e) => {
Err(Error::RuntimeError(format!("Unable to get subnet state info: {:?}", e)).into())
}
}
}

fn get_subnets_info(&self, at: Option<<Block as BlockT>::Hash>) -> RpcResult<Vec<u8>> {
let api = self.client.runtime_api();
let at = at.unwrap_or_else(|| self.client.info().best_hash);

api.get_subnets_info(at)
.map_err(|e| Error::RuntimeError(format!("Unable to get subnets info: {:?}", e)).into())
match api.get_subnets_info(at) {
Ok(result) => Ok(result.encode()),
Err(e) => {
Err(Error::RuntimeError(format!("Unable to get subnets info: {:?}", e)).into())
}
}
}

fn get_subnet_info_v2(
Expand All @@ -286,16 +362,24 @@ where
let api = self.client.runtime_api();
let at = at.unwrap_or_else(|| self.client.info().best_hash);

api.get_subnet_info_v2(at, netuid)
.map_err(|e| Error::RuntimeError(format!("Unable to get subnet info: {:?}", e)).into())
match api.get_subnet_info_v2(at, netuid) {
Ok(result) => Ok(result.encode()),
Err(e) => {
Err(Error::RuntimeError(format!("Unable to get subnet info: {:?}", e)).into())
}
}
}

fn get_subnets_info_v2(&self, at: Option<<Block as BlockT>::Hash>) -> RpcResult<Vec<u8>> {
let api = self.client.runtime_api();
let at = at.unwrap_or_else(|| self.client.info().best_hash);

api.get_subnets_info_v2(at)
.map_err(|e| Error::RuntimeError(format!("Unable to get subnets info: {:?}", e)).into())
match api.get_subnets_info_v2(at) {
Ok(result) => Ok(result.encode()),
Err(e) => {
Err(Error::RuntimeError(format!("Unable to get subnets info: {:?}", e)).into())
}
}
}

fn get_network_lock_cost(&self, at: Option<<Block as BlockT>::Hash>) -> RpcResult<u64> {
Expand Down
7 changes: 5 additions & 2 deletions pallets/subtensor/runtime-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,21 @@ workspace = true

[dependencies]
sp-api = { workspace = true }
sp-runtime = { workspace = true }
frame-support = { workspace = true }
serde = { workspace = true, features = ["derive"] }

codec = { workspace = true }
# local
pallet-subtensor = { version = "4.0.0-dev", path = "../../subtensor", default-features = false }

[features]
default = ["std"]
std = [
"sp-api/std",
"sp-runtime/std",
"frame-support/std",
"pallet-subtensor/std",
"serde/std"
"serde/std",
"codec/std"
]
pow-faucet = []
Loading
Loading