Skip to content

Commit 8dc526c

Browse files
authored
Merge pull request #99 from renlabs-dev/main
feat: adjusting tokenomics
2 parents 6657bdb + e8f04bb commit 8dc526c

File tree

13 files changed

+189
-51
lines changed

13 files changed

+189
-51
lines changed

CHANGELOG.md

+26-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
# Changelog
22

3+
spec version `132`
4+
5+
adding a storage migration to remove authorities
6+
7+
spec version `131`
8+
9+
Flagging metadata hash
10+
11+
spec version `130`
12+
13+
Adding metadata hash
14+
15+
spec version `129`
16+
17+
Tweaked bridge closing
18+
19+
spec version `128`
20+
21+
Tweaked bridge parameters
22+
23+
spec version `127`
24+
25+
Added bridge
26+
327
spec version `126`
428

529
**Breaking Changes**
@@ -9,7 +33,7 @@ Moved:
933
- `delegate_rootnet_control` extrinsic has been moved to `SubnetEmissionModule` from `SubspaceModule`.
1034
- Some storages have been moved to `SubnetEmissionModule` from `SubspaceModule`:
1135
- WeightEncryptionMap
12-
-
36+
-
1337
Deleted:
1438
- `TrustRatio`
1539

@@ -68,7 +92,7 @@ Subnet Emission Module:
6892

6993
- `DecryptionNodeBanQueue`:
7094
- Description: Queue of decryption nodes that will be banned next epoch.
71-
- Type: StorageDoubleMap<u16, T::AccountId, u64>
95+
- Type: StorageDoubleMap<u16, T::AccountId, u64>
7296
- Default: None (empty double map)
7397

7498
Subspace Module:

Cargo.lock

+68
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ frame-system = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polk
115115
frame-system-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-stable2409", default-features = false }
116116
frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-stable2409", default-features = false }
117117
frame-try-runtime = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-stable2409", default-features = false }
118+
frame-metadata-hash-extension = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-stable2409", default-features = false }
118119
pallet-aura = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-stable2409", default-features = false }
119120
pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-stable2409", default-features = false }
120121
pallet-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-stable2409", default-features = false }

node/src/service.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,15 @@ use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
1515
use sp_runtime::traits::Block as BlockT;
1616
use std::{path::PathBuf, sync::Arc, time::Duration};
1717

18-
#[cfg(feature = "testnet")]
19-
use std::path::Path;
20-
21-
#[cfg(feature = "testnet")]
22-
use sp_core::H256;
23-
2418
use crate::{
2519
cli::Sealing,
2620
client::{Client, FullBackend},
2721
};
22+
#[cfg(feature = "testnet")]
23+
use std::path::Path;
24+
25+
#[cfg(feature = "testnet")]
26+
use sp_core::{H256, U256};
2827

2928
#[cfg(feature = "testnet")]
3029
pub use crate::eth::{

pallets/offworker/src/lib.rs

+8
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ use types::{
4848
use util::process_consensus_params;
4949

5050
mod dispatches;
51+
pub mod migrations;
5152
mod process;
5253
mod profitability;
5354
pub mod types;
@@ -134,7 +135,14 @@ pub mod pallet {
134135
}
135136
}
136137

138+
#[cfg(feature = "testnet")]
139+
const STORAGE_VERSION: StorageVersion = StorageVersion::new(16);
140+
141+
#[cfg(not(feature = "testnet"))]
142+
const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
143+
137144
#[pallet::pallet]
145+
#[pallet::storage_version(STORAGE_VERSION)]
138146
pub struct Pallet<T>(_);
139147

140148
#[pallet::hooks]

pallets/offworker/src/migrations.rs

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
use crate::*;
2+
use frame_support::{
3+
pallet_prelude::Weight,
4+
traits::{OnRuntimeUpgrade, StorageVersion},
5+
};
6+
7+
pub mod v1 {
8+
use super::*;
9+
10+
pub struct MigrateToV1<T>(sp_std::marker::PhantomData<T>);
11+
12+
impl<T: Config> OnRuntimeUpgrade for MigrateToV1<T> {
13+
fn on_runtime_upgrade() -> frame_support::weights::Weight {
14+
let on_chain_version = StorageVersion::get::<Pallet<T>>();
15+
if on_chain_version != 0 {
16+
log::info!("Storage v1 already updated");
17+
return Weight::zero();
18+
}
19+
20+
StorageVersion::new(1).put::<Pallet<T>>();
21+
22+
Authorities::<T>::kill();
23+
24+
log::info!("Migrated to v1");
25+
26+
Weight::zero()
27+
}
28+
}
29+
}

pallets/subnet_emission/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub mod pallet {
4848
const STORAGE_VERSION: StorageVersion = StorageVersion::new(16);
4949

5050
#[cfg(not(feature = "testnet"))]
51-
const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
51+
const STORAGE_VERSION: StorageVersion = StorageVersion::new(2);
5252

5353
#[pallet::pallet]
5454
#[pallet::storage_version(STORAGE_VERSION)]

pallets/subnet_emission/src/migrations.rs

+8-33
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,22 @@ use frame_support::{
44
traits::{OnRuntimeUpgrade, StorageVersion},
55
};
66

7-
pub mod v1 {
7+
pub mod v2 {
88
use super::*;
99

10-
pub struct MigrateToV1<T>(sp_std::marker::PhantomData<T>);
10+
pub struct MigrateToV2<T>(sp_std::marker::PhantomData<T>);
1111

12-
impl<T: Config> OnRuntimeUpgrade for MigrateToV1<T> {
12+
impl<T: Config> OnRuntimeUpgrade for MigrateToV2<T> {
1313
fn on_runtime_upgrade() -> frame_support::weights::Weight {
1414
let on_chain_version = StorageVersion::get::<Pallet<T>>();
15-
if on_chain_version != 0 {
16-
log::info!("Storage v1 already updated");
15+
if on_chain_version != 1 {
16+
log::info!("Storage v2 already updated");
1717
return Weight::zero();
1818
}
19-
20-
StorageVersion::new(1).put::<Pallet<T>>();
21-
22-
pallet_subspace::migrations::v15::old_storage::Weights::<T>::iter().for_each(
23-
|(netuid, uid, values)| {
24-
log::info!("migrating weights for netuid: {}, uid: {}", netuid, uid);
25-
Weights::<T>::insert(netuid, uid, values);
26-
},
27-
);
28-
29-
// Just for clarity, (although not explicitly needed)
30-
let _ =
31-
pallet_subspace::migrations::v15::old_storage::Weights::<T>::clear(u32::MAX, None);
32-
33-
log::info!("Migrated to v1");
34-
19+
crate::UnitEmission::<T>::put(6427777777);
20+
StorageVersion::new(2).put::<Pallet<T>>();
21+
log::info!("Migrated to v2");
3522
Weight::zero()
3623
}
3724
}
3825
}
39-
40-
// // Kill all weight DEW related data
41-
// let _ = ConsensusParameters::<T>::clear(u32::MAX, None);
42-
// let _ = SubnetDecryptionData::<T>::clear(u32::MAX, None);
43-
// let _ = ConsensusParameters::<T>::clear(u32::MAX, None);
44-
// let _ = WeightEncryptionData::<T>::clear(u32::MAX, None);
45-
// let _ = DecryptedWeights::<T>::clear(u32::MAX, None);
46-
// let _ = BannedDecryptionNodes::<T>::clear(u32::MAX, None);
47-
// let _ = DecryptionNodes::<T>::kill();
48-
49-
// let _ = WeightSettingDelegation::<T>::clear(u32::MAX, None);
50-
// let _ = Weights::<T>::clear_prefix(5, u32::MAX, None);

pallets/subspace/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,8 @@ pub mod pallet {
469469
pub type WeightSettingDelegation<T: Config> =
470470
StorageDoubleMap<_, Identity, u16, Identity, T::AccountId, T::AccountId>;
471471

472+
#[pallet::storage]
473+
pub type Bridged<T: Config> = StorageMap<_, Identity, T::AccountId, u64, ValueQuery>;
472474
// --- Module Fees ---
473475

474476
/// Default values for fees used throughout the module

pallets/subspace/src/selections/errors.rs

+6
Original file line numberDiff line numberDiff line change
@@ -209,5 +209,11 @@ pub mod errors {
209209
/// Cannot decrease fees below their current values.
210210
/// Fees can only be increased to prevent economic attacks.
211211
CannotDecreaseFee,
212+
/// General error for not having enough balance
213+
NotEnoughBalance,
214+
/// Not having enough tokens to bridge back
215+
NotEnoughBridgedTokens,
216+
/// User is trying to bridge tokens in closed period
217+
OutsideValidBlockRange,
212218
}
213219
}

runtime/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ frame-executive.workspace = true
3232
frame-support.workspace = true
3333
frame-system.workspace = true
3434
frame-try-runtime = { workspace = true, optional = true }
35+
frame-metadata-hash-extension.workspace = true
3536
pallet-aura.workspace = true
3637
pallet-balances.workspace = true
3738
pallet-grandpa.workspace = true
@@ -187,3 +188,4 @@ try-runtime = [
187188
"pallet-evm-chain-id/try-runtime",
188189
"fp-self-contained/try-runtime",
189190
]
191+
metadata-hash = ["substrate-wasm-builder/metadata-hash"]

runtime/build.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
fn main() {
2-
#[cfg(feature = "std")]
2+
#[cfg(all(feature = "std", not(feature = "metadata-hash")))]
33
{
44
substrate_wasm_builder::WasmBuilder::new()
55
.with_current_project()
66
.export_heap_base()
77
.import_memory()
88
.build();
99
}
10+
#[cfg(all(feature = "std", feature = "metadata-hash"))]
11+
{
12+
substrate_wasm_builder::WasmBuilder::new()
13+
.with_current_project()
14+
.export_heap_base()
15+
.import_memory()
16+
.enable_metadata_hash("COMAI", 9)
17+
.build();
18+
}
1019
}

0 commit comments

Comments
 (0)