Skip to content

Commit 4a73af6

Browse files
committed
merge with devnet ready
2 parents a0819b4 + 357a9e1 commit 4a73af6

Some content is hidden

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

52 files changed

+2834
-413
lines changed

.github/workflows/docker.yml

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ on:
44
release:
55
types: [published]
66
workflow_dispatch:
7+
inputs:
8+
branch-or-tag:
9+
description: "Branch or tag to use for the Docker image tag and ref to checkout (optional)"
10+
required: false
11+
default: ""
12+
13+
push:
14+
branches:
15+
- devnet-ready
16+
- devnet
17+
- testnet
718

819
permissions:
920
contents: read
@@ -16,8 +27,18 @@ jobs:
1627
runs-on: SubtensorCI
1728

1829
steps:
30+
- name: Determine Docker tag and ref
31+
id: tag
32+
run: |
33+
branch_or_tag="${{ github.event.inputs.branch-or-tag || github.ref_name }}"
34+
echo "Determined branch or tag: $branch_or_tag"
35+
echo "tag=$branch_or_tag" >> $GITHUB_ENV
36+
echo "ref=$branch_or_tag" >> $GITHUB_ENV
37+
1938
- name: Checkout code
2039
uses: actions/checkout@v4
40+
with:
41+
ref: ${{ env.ref }}
2142

2243
- name: Set up QEMU
2344
uses: docker/setup-qemu-action@v2
@@ -32,18 +53,10 @@ jobs:
3253
username: ${{ github.actor }}
3354
password: ${{ secrets.GITHUB_TOKEN }}
3455

35-
- name: Extract metadata (tags, labels) for Docker
36-
id: meta
37-
uses: docker/metadata-action@v4
38-
with:
39-
images: ghcr.io/${{ github.repository }}
40-
4156
- name: Build and push Docker image
4257
uses: docker/build-push-action@v4
4358
with:
4459
context: .
4560
push: true
4661
tags: |
47-
${{ steps.meta.outputs.tags }}
48-
ghcr.io/${{ github.repository }}:latest
49-
labels: ${{ steps.meta.outputs.labels }}
62+
ghcr.io/${{ github.repository }}:${{ env.tag }}

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,10 @@ fc-consensus = { git = "https://github.com/opentensor/frontier", rev = "635bdac8
180180
fp-consensus = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
181181
fp-dynamic-fee = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
182182
fc-api = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
183-
fc-rpc = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
183+
fc-rpc = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false, features = ["rpc-binary-search-estimate"]}
184184
fc-rpc-core = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
185185
fc-mapping-sync = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
186+
precompile-utils = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
186187

187188
# Frontier FRAME
188189
pallet-base-fee = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }

hyperparameters.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ TxRateLimit: u64 = 1; // [1 @ 64,888]
77
### netuid 1 (text_prompting)
88
```rust
99
Rho: u16 = 10;
10-
Kappa: u16 = 32_767; // 0.5 = 65535/2
10+
Kappa: u16 = 32_767; // 0.5 = 65535/2
1111
MaxAllowedUids: u16 = 1024;
1212
Issuance: u64 = 0;
1313
MinAllowedWeights: u16 = 8;
@@ -32,10 +32,11 @@ ActivityCutoff: u16 = 5000;
3232
MaxRegistrationsPerBlock: u16 = 1;
3333
PruningScore : u16 = u16::MAX;
3434
BondsMovingAverage: u64 = 900_000;
35+
BondsPenalty: u16 = 0;
3536
WeightsVersionKey: u64 = 1020;
3637
MinDifficulty: u64 = 10_000_000;
3738
MaxDifficulty: u64 = u64::MAX / 4;
38-
ServingRateLimit: u64 = 10;
39+
ServingRateLimit: u64 = 10;
3940
Burn: u64 = 1_000_000_000; // 1 tao
4041
MinBurn: u64 = 1_000_000_000; // 1 tao
4142
MaxBurn: u64 = 100_000_000_000; // 100 tao
@@ -45,7 +46,7 @@ WeightsSetRateLimit: u64 = 100;
4546
### netuid 3 (causallmnext)
4647
```rust
4748
Rho: u16 = 10;
48-
Kappa: u16 = 32_767; // 0.5 = 65535/2
49+
Kappa: u16 = 32_767; // 0.5 = 65535/2
4950
MaxAllowedUids: u16 = 4096;
5051
Issuance: u64 = 0;
5152
MinAllowedWeights: u16 = 50;
@@ -70,6 +71,7 @@ ActivityCutoff: u16 = 5000; // [5000 @ 7,163]
7071
MaxRegistrationsPerBlock: u16 = 1;
7172
PruningScore : u16 = u16::MAX;
7273
BondsMovingAverage: u64 = 900_000;
74+
BondsPenalty: u16 = 0;
7375
WeightsVersionKey: u64 = 400;
7476
MinDifficulty: u64 = 10_000_000;
7577
MaxDifficulty: u64 = u64::MAX / 4;

node/src/chain_spec/localnet.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,17 @@ fn localnet_genesis(
7777
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
7878
2000000000000u128,
7979
),
80+
// ETH
81+
(
82+
// Alith - 0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac
83+
AccountId::from_str("5Fghzk1AJt88PeFEzuRfXzbPchiBbsVGTTXcdx599VdZzkTA").unwrap(),
84+
2000000000000u128,
85+
),
86+
(
87+
// Baltathar - 0x3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0
88+
AccountId::from_str("5GeqNhKWj1KG78VHzbmo3ZjZgUTrCuWeamdgiA114XHGdaEr").unwrap(),
89+
2000000000000u128,
90+
),
8091
];
8192

8293
// Check if the environment variable is set

pallets/admin-utils/src/benchmarking.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,14 @@ mod benchmarks {
100100
_(RawOrigin::Root, 1u16/*netuid*/, 100u64/*bonds_moving_average*/)/*sudo_set_bonds_moving_average*/;
101101
}
102102

103+
#[benchmark]
104+
fn sudo_set_bonds_penalty() {
105+
pallet_subtensor::Pallet::<T>::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);
106+
107+
#[extrinsic_call]
108+
_(RawOrigin::Root, 1u16/*netuid*/, 100u16/*bonds_penalty*/)/*sudo_set_bonds_penalty*/;
109+
}
110+
103111
#[benchmark]
104112
fn sudo_set_max_allowed_validators() {
105113
pallet_subtensor::Pallet::<T>::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);

pallets/admin-utils/src/lib.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,31 @@ pub mod pallet {
685685
Ok(())
686686
}
687687

688+
/// The extrinsic sets the bonds penalty for a subnet.
689+
/// It is only callable by the root account or subnet owner.
690+
/// The extrinsic will call the Subtensor pallet to set the bonds penalty.
691+
#[pallet::call_index(60)]
692+
#[pallet::weight(<T as Config>::WeightInfo::sudo_set_bonds_penalty())]
693+
pub fn sudo_set_bonds_penalty(
694+
origin: OriginFor<T>,
695+
netuid: u16,
696+
bonds_penalty: u16,
697+
) -> DispatchResult {
698+
pallet_subtensor::Pallet::<T>::ensure_subnet_owner_or_root(origin, netuid)?;
699+
700+
ensure!(
701+
pallet_subtensor::Pallet::<T>::if_subnet_exist(netuid),
702+
Error::<T>::SubnetDoesNotExist
703+
);
704+
pallet_subtensor::Pallet::<T>::set_bonds_penalty(netuid, bonds_penalty);
705+
log::debug!(
706+
"BondsPenalty( netuid: {:?} bonds_penalty: {:?} ) ",
707+
netuid,
708+
bonds_penalty
709+
);
710+
Ok(())
711+
}
712+
688713
/// The extrinsic sets the maximum registrations per block for a subnet.
689714
/// It is only callable by the root account.
690715
/// The extrinsic will call the Subtensor pallet to set the maximum registrations per block.

pallets/admin-utils/src/tests/mock.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ parameter_types! {
8686
pub const InitialImmunityPeriod: u16 = 2;
8787
pub const InitialMaxAllowedUids: u16 = 2;
8888
pub const InitialBondsMovingAverage: u64 = 900_000;
89+
pub const InitialBondsPenalty: u16 = 0;
8990
pub const InitialStakePruningMin: u16 = 0;
9091
pub const InitialFoundationDistribution: u64 = 0;
9192
pub const InitialDefaultDelegateTake: u16 = 11_796; // 18% honest number.
@@ -163,6 +164,7 @@ impl pallet_subtensor::Config for Test {
163164
type InitialMaxRegistrationsPerBlock = InitialMaxRegistrationsPerBlock;
164165
type InitialPruningScore = InitialPruningScore;
165166
type InitialBondsMovingAverage = InitialBondsMovingAverage;
167+
type InitialBondsPenalty = InitialBondsPenalty;
166168
type InitialMaxAllowedValidators = InitialMaxAllowedValidators;
167169
type InitialDefaultDelegateTake = InitialDefaultDelegateTake;
168170
type InitialMinDelegateTake = InitialMinDelegateTake;

pallets/admin-utils/src/tests/mod.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,39 @@ fn test_sudo_set_bonds_moving_average() {
741741
});
742742
}
743743

744+
#[test]
745+
fn test_sudo_set_bonds_penalty() {
746+
new_test_ext().execute_with(|| {
747+
let netuid: u16 = 1;
748+
let to_be_set: u16 = 10;
749+
add_network(netuid, 10);
750+
let init_value: u16 = SubtensorModule::get_bonds_penalty(netuid);
751+
assert_eq!(
752+
AdminUtils::sudo_set_bonds_penalty(
753+
<<Test as Config>::RuntimeOrigin>::signed(U256::from(1)),
754+
netuid,
755+
to_be_set
756+
),
757+
Err(DispatchError::BadOrigin)
758+
);
759+
assert_eq!(
760+
AdminUtils::sudo_set_bonds_penalty(
761+
<<Test as Config>::RuntimeOrigin>::root(),
762+
netuid + 1,
763+
to_be_set
764+
),
765+
Err(Error::<Test>::SubnetDoesNotExist.into())
766+
);
767+
assert_eq!(SubtensorModule::get_bonds_penalty(netuid), init_value);
768+
assert_ok!(AdminUtils::sudo_set_bonds_penalty(
769+
<<Test as Config>::RuntimeOrigin>::root(),
770+
netuid,
771+
to_be_set
772+
));
773+
assert_eq!(SubtensorModule::get_bonds_penalty(netuid), to_be_set);
774+
});
775+
}
776+
744777
#[test]
745778
fn test_sudo_set_rao_recycled() {
746779
new_test_ext().execute_with(|| {

pallets/admin-utils/src/weights.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ pub trait WeightInfo {
4242
fn sudo_set_weights_set_rate_limit() -> Weight;
4343
fn sudo_set_weights_version_key() -> Weight;
4444
fn sudo_set_bonds_moving_average() -> Weight;
45+
fn sudo_set_bonds_penalty() -> Weight;
4546
fn sudo_set_max_allowed_validators() -> Weight;
4647
fn sudo_set_difficulty() -> Weight;
4748
fn sudo_set_adjustment_interval() -> Weight;
@@ -182,6 +183,19 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
182183
}
183184
/// Storage: SubtensorModule NetworksAdded (r:1 w:0)
184185
/// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured)
186+
/// Storage: SubtensorModule BondsPenalty (r:0 w:1)
187+
/// Proof Skipped: SubtensorModule BondsPenalty (max_values: None, max_size: None, mode: Measured)
188+
fn sudo_set_bonds_penalty() -> Weight {
189+
// Proof Size summary in bytes:
190+
// Measured: `1111`
191+
// Estimated: `4697`
192+
// Minimum execution time: 46_099_000 picoseconds.
193+
Weight::from_parts(47_510_000, 4697)
194+
.saturating_add(T::DbWeight::get().reads(1_u64))
195+
.saturating_add(T::DbWeight::get().writes(1_u64))
196+
}
197+
/// Storage: SubtensorModule NetworksAdded (r:1 w:0)
198+
/// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured)
185199
/// Storage: SubtensorModule MaxAllowedUids (r:1 w:0)
186200
/// Proof Skipped: SubtensorModule MaxAllowedUids (max_values: None, max_size: None, mode: Measured)
187201
/// Storage: SubtensorModule MaxAllowedValidators (r:0 w:1)
@@ -559,6 +573,19 @@ impl WeightInfo for () {
559573
}
560574
/// Storage: SubtensorModule NetworksAdded (r:1 w:0)
561575
/// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured)
576+
/// Storage: SubtensorModule BondsPenalty (r:0 w:1)
577+
/// Proof Skipped: SubtensorModule BondsPenalty (max_values: None, max_size: None, mode: Measured)
578+
fn sudo_set_bonds_penalty() -> Weight {
579+
// Proof Size summary in bytes:
580+
// Measured: `1111`
581+
// Estimated: `4697`
582+
// Minimum execution time: 46_099_000 picoseconds.
583+
Weight::from_parts(47_510_000, 4697)
584+
.saturating_add(RocksDbWeight::get().reads(1_u64))
585+
.saturating_add(RocksDbWeight::get().writes(1_u64))
586+
}
587+
/// Storage: SubtensorModule NetworksAdded (r:1 w:0)
588+
/// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured)
562589
/// Storage: SubtensorModule MaxAllowedUids (r:1 w:0)
563590
/// Proof Skipped: SubtensorModule MaxAllowedUids (max_values: None, max_size: None, mode: Measured)
564591
/// Storage: SubtensorModule MaxAllowedValidators (r:0 w:1)

0 commit comments

Comments
 (0)