Skip to content

Commit d4d8182

Browse files
sam0x17JohnReedVgztensorcamfairchildales-otf
authored
mainnet deploy 1/7/2025 (#1133)
* if its the epoch block push to next epoch * fmt * Remove check for minimum stake for revoking childkeys * Apply childkeys even if sn registration is disabled * Fmt * Delete runtime/src/precompiles/subnet.rs * Update pallets/subtensor/src/tests/children.rs Co-authored-by: Cameron Fairchild <[email protected]> * bump spec * Remove nakamoto_gen.json * bump spec * rename EVM_TO_SUBSTRATE_DECIMALS * add logging to checked mul and div * use opentensor repo for fp --------- Co-authored-by: JohnReedV <[email protected]> Co-authored-by: Greg Zaitsev <[email protected]> Co-authored-by: gztensor <[email protected]> Co-authored-by: Cameron Fairchild <[email protected]> Co-authored-by: Aliaksandr Tsurko <[email protected]> Co-authored-by: Unconst <[email protected]>
1 parent c1c25e2 commit d4d8182

File tree

8 files changed

+219
-88
lines changed

8 files changed

+219
-88
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -166,32 +166,32 @@ sc-network-sync = { git = "https://github.com/paritytech/polkadot-sdk.git", tag
166166
substrate-prometheus-endpoint = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false }
167167

168168
# Frontier
169-
fp-evm = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
170-
fp-rpc = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
171-
fp-self-contained = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false, features = [
169+
fp-evm = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
170+
fp-rpc = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
171+
fp-self-contained = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false, features = [
172172
"serde",
173173
] }
174-
fp-account = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
175-
fc-storage = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
176-
fc-db = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
177-
fc-consensus = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
178-
fp-consensus = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
179-
fp-dynamic-fee = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
180-
fc-api = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
181-
fc-rpc = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
182-
fc-rpc-core = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
183-
fc-mapping-sync = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
174+
fp-account = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
175+
fc-storage = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
176+
fc-db = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
177+
fc-consensus = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
178+
fp-consensus = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
179+
fp-dynamic-fee = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
180+
fc-api = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
181+
fc-rpc = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
182+
fc-rpc-core = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
183+
fc-mapping-sync = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
184184

185185
# Frontier FRAME
186-
pallet-base-fee = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
187-
pallet-dynamic-fee = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
188-
pallet-ethereum = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
189-
pallet-evm = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
190-
pallet-evm-chain-id = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
191-
pallet-evm-precompile-modexp = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
192-
pallet-evm-precompile-sha3fips = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
193-
pallet-evm-precompile-simple = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
194-
pallet-hotfix-sufficients = { git = "https://github.com/gztensor/frontier", rev = "b9c606f9", default-features = false }
186+
pallet-base-fee = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
187+
pallet-dynamic-fee = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
188+
pallet-ethereum = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
189+
pallet-evm = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
190+
pallet-evm-chain-id = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
191+
pallet-evm-precompile-modexp = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
192+
pallet-evm-precompile-sha3fips = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
193+
pallet-evm-precompile-simple = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
194+
pallet-hotfix-sufficients = { git = "https://github.com/opentensor/frontier", rev = "635bdac882", default-features = false }
195195

196196
#DRAND
197197
pallet-drand = { path = "pallets/drand", default-features = false }

nakamoto_gen.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

pallets/subtensor/src/coinbase/run_coinbase.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl<T: Config> Pallet<T> {
6565
// --- 3. Drain the subnet block emission and accumulate it as subnet emission, which increases until the tempo is reached in #4.
6666
// subnet_blockwise_emission -> subnet_pending_emission
6767
for netuid in subnets.clone().iter() {
68-
if *netuid == 0 || !Self::is_registration_allowed(*netuid) {
68+
if *netuid == 0 || !Self::get_network_registration_allowed(*netuid) {
6969
continue;
7070
}
7171
// --- 3.1 Get the network's block-wise emission amount.
@@ -105,7 +105,10 @@ impl<T: Config> Pallet<T> {
105105
};
106106
}
107107

108-
// --- 4.3 Drain the subnet emission.
108+
// 4.3 Apply pending childkeys of this subnet for the next epoch
109+
Self::do_set_pending_children(*netuid);
110+
111+
// --- 4.4 Drain the subnet emission.
109112
let mut subnet_emission: u64 = PendingEmission::<T>::get(*netuid);
110113
PendingEmission::<T>::insert(*netuid, 0);
111114
log::debug!(
@@ -114,39 +117,39 @@ impl<T: Config> Pallet<T> {
114117
subnet_emission
115118
);
116119

117-
// --- 4.4 Set last step counter.
120+
// --- 4.5 Set last step counter.
118121
Self::set_blocks_since_last_step(*netuid, 0);
119122
Self::set_last_mechanism_step_block(*netuid, current_block);
120123

121-
if *netuid == 0 || !Self::is_registration_allowed(*netuid) {
124+
if *netuid == 0 || !Self::get_network_registration_allowed(*netuid) {
122125
// Skip netuid 0 payouts
123126
continue;
124127
}
125128

126-
// --- 4.5 Distribute owner take.
129+
// --- 4.6 Distribute owner take.
127130
if SubnetOwner::<T>::contains_key(netuid) {
128131
// Does the subnet have an owner?
129132

130-
// --- 4.5.1 Compute the subnet owner cut.
133+
// --- 4.6.1 Compute the subnet owner cut.
131134
let owner_cut: I96F32 = I96F32::from_num(subnet_emission).saturating_mul(
132135
I96F32::from_num(Self::get_subnet_owner_cut())
133136
.saturating_div(I96F32::from_num(u16::MAX)),
134137
);
135138

136-
// --- 4.5.2 Remove the cut from the subnet emission
139+
// --- 4.6.2 Remove the cut from the subnet emission
137140
subnet_emission = subnet_emission.saturating_sub(owner_cut.to_num::<u64>());
138141

139-
// --- 4.5.3 Add the cut to the balance of the owner
142+
// --- 4.6.3 Add the cut to the balance of the owner
140143
Self::add_balance_to_coldkey_account(
141144
&Self::get_subnet_owner(*netuid),
142145
owner_cut.to_num::<u64>(),
143146
);
144147

145-
// --- 4.5.4 Increase total issuance on the chain.
148+
// --- 4.6.4 Increase total issuance on the chain.
146149
Self::coinbase(owner_cut.to_num::<u64>());
147150
}
148151

149-
// 4.6 Pass emission through epoch() --> hotkey emission.
152+
// 4.7 Pass emission through epoch() --> hotkey emission.
150153
let hotkey_emission: Vec<(T::AccountId, u64, u64)> =
151154
Self::epoch(*netuid, subnet_emission);
152155
log::debug!(
@@ -155,7 +158,7 @@ impl<T: Config> Pallet<T> {
155158
hotkey_emission
156159
);
157160

158-
// 4.7 Accumulate the tuples on hotkeys:
161+
// 4.8 Accumulate the tuples on hotkeys:
159162
for (hotkey, mining_emission, validator_emission) in hotkey_emission {
160163
// 4.8 Accumulate the emission on the hotkey and parent hotkeys.
161164
Self::accumulate_hotkey_emission(
@@ -166,9 +169,6 @@ impl<T: Config> Pallet<T> {
166169
);
167170
log::debug!("Accumulated emissions on hotkey {:?} for netuid {:?}: mining {:?}, validator {:?}", hotkey, *netuid, mining_emission, validator_emission);
168171
}
169-
170-
// 4.5 Apply pending childkeys of this subnet for the next epoch
171-
Self::do_set_pending_children(*netuid);
172172
} else {
173173
// No epoch, increase blocks since last step and continue
174174
Self::set_blocks_since_last_step(

pallets/subtensor/src/staking/set_children.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,12 @@ impl<T: Config> Pallet<T> {
110110
}
111111

112112
// Check that the parent key has at least the minimum own stake
113+
// if children vector is not empty
113114
// (checking with check_weights_min_stake wouldn't work because it considers
114115
// grandparent stake in this case)
115116
ensure!(
116-
Self::get_total_stake_for_hotkey(&hotkey) >= StakeThreshold::<T>::get(),
117+
children.is_empty()
118+
|| Self::get_total_stake_for_hotkey(&hotkey) >= StakeThreshold::<T>::get(),
117119
Error::<T>::NotEnoughStakeToSetChildkeys
118120
);
119121

pallets/subtensor/src/subnets/weights.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,11 @@ impl<T: Config> Pallet<T> {
262262

263263
// 5. Retrieve or initialize the VecDeque of commits for the hotkey.
264264
let cur_block = Self::get_current_block_as_u64();
265-
let cur_epoch = Self::get_epoch_index(netuid, cur_block);
265+
let cur_epoch = match Self::should_run_epoch(netuid, commit_block) {
266+
true => Self::get_epoch_index(netuid, cur_block).saturating_add(1),
267+
false => Self::get_epoch_index(netuid, cur_block),
268+
};
269+
266270
CRV3WeightCommits::<T>::try_mutate(netuid, cur_epoch, |commits| -> DispatchResult {
267271
// 6. Verify that the number of unrevealed commits is within the allowed limit.
268272

0 commit comments

Comments
 (0)