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

feat: adjusting tokenomics #99

Merged
merged 20 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 26 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# Changelog

spec version `132`

adding a storage migration to remove authorities

spec version `131`

Flagging metadata hash

spec version `130`

Adding metadata hash

spec version `129`

Tweaked bridge closing

spec version `128`

Tweaked bridge parameters

spec version `127`

Added bridge

spec version `126`

**Breaking Changes**
Expand All @@ -9,7 +33,7 @@ Moved:
- `delegate_rootnet_control` extrinsic has been moved to `SubnetEmissionModule` from `SubspaceModule`.
- Some storages have been moved to `SubnetEmissionModule` from `SubspaceModule`:
- WeightEncryptionMap
-
-
Deleted:
- `TrustRatio`

Expand Down Expand Up @@ -68,7 +92,7 @@ Subnet Emission Module:

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

Subspace Module:
Expand Down
68 changes: 68 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ frame-system = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polk
frame-system-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-stable2409", default-features = false }
frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-stable2409", default-features = false }
frame-try-runtime = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-stable2409", default-features = false }
frame-metadata-hash-extension = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-stable2409", default-features = false }
pallet-aura = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-stable2409", default-features = false }
pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-stable2409", default-features = false }
pallet-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-stable2409", default-features = false }
Expand Down
11 changes: 5 additions & 6 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@ use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
use sp_runtime::traits::Block as BlockT;
use std::{path::PathBuf, sync::Arc, time::Duration};

#[cfg(feature = "testnet")]
use std::path::Path;

#[cfg(feature = "testnet")]
use sp_core::H256;

use crate::{
cli::Sealing,
client::{Client, FullBackend},
};
#[cfg(feature = "testnet")]
use std::path::Path;

#[cfg(feature = "testnet")]
use sp_core::{H256, U256};

#[cfg(feature = "testnet")]
pub use crate::eth::{
Expand Down
8 changes: 8 additions & 0 deletions pallets/offworker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ use types::{
use util::process_consensus_params;

mod dispatches;
pub mod migrations;
mod process;
mod profitability;
pub mod types;
Expand Down Expand Up @@ -134,7 +135,14 @@ pub mod pallet {
}
}

#[cfg(feature = "testnet")]
const STORAGE_VERSION: StorageVersion = StorageVersion::new(16);

#[cfg(not(feature = "testnet"))]
const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);

#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T>(_);

#[pallet::hooks]
Expand Down
29 changes: 29 additions & 0 deletions pallets/offworker/src/migrations.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use crate::*;
use frame_support::{
pallet_prelude::Weight,
traits::{OnRuntimeUpgrade, StorageVersion},
};

pub mod v1 {
use super::*;

pub struct MigrateToV1<T>(sp_std::marker::PhantomData<T>);

impl<T: Config> OnRuntimeUpgrade for MigrateToV1<T> {
fn on_runtime_upgrade() -> frame_support::weights::Weight {
let on_chain_version = StorageVersion::get::<Pallet<T>>();
if on_chain_version != 0 {
log::info!("Storage v1 already updated");
return Weight::zero();
}

StorageVersion::new(1).put::<Pallet<T>>();

Authorities::<T>::kill();

log::info!("Migrated to v1");

Weight::zero()
}
}
}
2 changes: 1 addition & 1 deletion pallets/subnet_emission/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub mod pallet {
const STORAGE_VERSION: StorageVersion = StorageVersion::new(16);

#[cfg(not(feature = "testnet"))]
const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
const STORAGE_VERSION: StorageVersion = StorageVersion::new(2);

#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
Expand Down
41 changes: 8 additions & 33 deletions pallets/subnet_emission/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,22 @@ use frame_support::{
traits::{OnRuntimeUpgrade, StorageVersion},
};

pub mod v1 {
pub mod v2 {
use super::*;

pub struct MigrateToV1<T>(sp_std::marker::PhantomData<T>);
pub struct MigrateToV2<T>(sp_std::marker::PhantomData<T>);

impl<T: Config> OnRuntimeUpgrade for MigrateToV1<T> {
impl<T: Config> OnRuntimeUpgrade for MigrateToV2<T> {
fn on_runtime_upgrade() -> frame_support::weights::Weight {
let on_chain_version = StorageVersion::get::<Pallet<T>>();
if on_chain_version != 0 {
log::info!("Storage v1 already updated");
if on_chain_version != 1 {
log::info!("Storage v2 already updated");
return Weight::zero();
}

StorageVersion::new(1).put::<Pallet<T>>();

pallet_subspace::migrations::v15::old_storage::Weights::<T>::iter().for_each(
|(netuid, uid, values)| {
log::info!("migrating weights for netuid: {}, uid: {}", netuid, uid);
Weights::<T>::insert(netuid, uid, values);
},
);

// Just for clarity, (although not explicitly needed)
let _ =
pallet_subspace::migrations::v15::old_storage::Weights::<T>::clear(u32::MAX, None);

log::info!("Migrated to v1");

crate::UnitEmission::<T>::put(6427777777);
StorageVersion::new(2).put::<Pallet<T>>();
log::info!("Migrated to v2");
Weight::zero()
}
}
}

// // Kill all weight DEW related data
// let _ = ConsensusParameters::<T>::clear(u32::MAX, None);
// let _ = SubnetDecryptionData::<T>::clear(u32::MAX, None);
// let _ = ConsensusParameters::<T>::clear(u32::MAX, None);
// let _ = WeightEncryptionData::<T>::clear(u32::MAX, None);
// let _ = DecryptedWeights::<T>::clear(u32::MAX, None);
// let _ = BannedDecryptionNodes::<T>::clear(u32::MAX, None);
// let _ = DecryptionNodes::<T>::kill();

// let _ = WeightSettingDelegation::<T>::clear(u32::MAX, None);
// let _ = Weights::<T>::clear_prefix(5, u32::MAX, None);
2 changes: 2 additions & 0 deletions pallets/subspace/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,8 @@ pub mod pallet {
pub type WeightSettingDelegation<T: Config> =
StorageDoubleMap<_, Identity, u16, Identity, T::AccountId, T::AccountId>;

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

/// Default values for fees used throughout the module
Expand Down
6 changes: 6 additions & 0 deletions pallets/subspace/src/selections/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,5 +209,11 @@ pub mod errors {
/// Cannot decrease fees below their current values.
/// Fees can only be increased to prevent economic attacks.
CannotDecreaseFee,
/// General error for not having enough balance
NotEnoughBalance,
/// Not having enough tokens to bridge back
NotEnoughBridgedTokens,
/// User is trying to bridge tokens in closed period
OutsideValidBlockRange,
}
}
2 changes: 2 additions & 0 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ frame-executive.workspace = true
frame-support.workspace = true
frame-system.workspace = true
frame-try-runtime = { workspace = true, optional = true }
frame-metadata-hash-extension.workspace = true
pallet-aura.workspace = true
pallet-balances.workspace = true
pallet-grandpa.workspace = true
Expand Down Expand Up @@ -187,3 +188,4 @@ try-runtime = [
"pallet-evm-chain-id/try-runtime",
"fp-self-contained/try-runtime",
]
metadata-hash = ["substrate-wasm-builder/metadata-hash"]
11 changes: 10 additions & 1 deletion runtime/build.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
fn main() {
#[cfg(feature = "std")]
#[cfg(all(feature = "std", not(feature = "metadata-hash")))]
{
substrate_wasm_builder::WasmBuilder::new()
.with_current_project()
.export_heap_base()
.import_memory()
.build();
}
#[cfg(all(feature = "std", feature = "metadata-hash"))]
{
substrate_wasm_builder::WasmBuilder::new()
.with_current_project()
.export_heap_base()
.import_memory()
.enable_metadata_hash("COMAI", 9)
.build();
}
}
Loading
Loading