diff --git a/Cargo.lock b/Cargo.lock index bf3fa2ca5..b34bbb5ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 4 +version = 3 [[package]] name = "Inflector" @@ -12,19 +12,6 @@ dependencies = [ "regex", ] -[[package]] -name = "account-util" -version = "1.2.5" -dependencies = [ - "frame-support", - "pallet-airdrop-claims", - "pallet-vesting", - "sp-core", - "sp-runtime", - "sp-std", - "tangle-primitives", -] - [[package]] name = "addchain" version = "0.2.0" diff --git a/Cargo.toml b/Cargo.toml index 7cbe4fef1..ada29a2bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,6 @@ exclude = ["examples"] [workspace] members = [ - "account-util", "primitives", "primitives/crypto", "primitives/rpc/*", diff --git a/account-util/Cargo.toml b/account-util/Cargo.toml deleted file mode 100644 index acefeeb63..000000000 --- a/account-util/Cargo.toml +++ /dev/null @@ -1,18 +0,0 @@ -[package] -name = "account-util" -version.workspace = true -authors.workspace = true -edition.workspace = true -license.workspace = true -homepage.workspace = true -repository.workspace = true -exclude.workspace = true - -[dependencies] -frame-support = { workspace = true, features = ["std"] } -sp-core = { workspace = true, features = ["std"] } -sp-runtime = { workspace = true, features = ["std"] } -sp-std = { workspace = true, features = ["std"] } -pallet-airdrop-claims = { workspace = true, features = ["std"] } -pallet-vesting = { workspace = true, features = ["std"] } -tangle-primitives = { workspace = true, features = ["std"] } \ No newline at end of file diff --git a/account-util/src/lib.rs b/account-util/src/lib.rs deleted file mode 100644 index 536980440..000000000 --- a/account-util/src/lib.rs +++ /dev/null @@ -1,96 +0,0 @@ -use tangle_primitives::Balance; - -pub const BLOCK_TIME: u128 = 6; -pub const ONE_YEAR_BLOCKS: u64 = (365 * 24 * 60 * 60 / BLOCK_TIME) as u64; - -pub const INVESTOR_ACCOUNTS: [(&str, Balance); 29] = [ - ("5FCviiKcJzVfdwqv451JRQc93ZTSbbC9YfgKMkN3LpNMBjS3", 100000000000000000000000), - ("0xC02ad7b9a9121fc849196E844DC869D2250DF3A6", 150000000000000000000000), - ("5HBKM8XL7sr7S7qx6ukugDJUBhm16Ubnz1KuJCdHmHQvtc7Z", 400000000000000000000000), - ("0x86f99feff4cd3268ccefc760a6bbce2e07aa4d8e", 100000000000000000000000), - ("5HCJQLeQqCf64C6uy7CSoTND35QNdi1zU66TTM6QPCG9u9BB", 500000000000000000000000), - ("5DhQMPP69vRBNvZ6w4E9qii1yj56M66YXuPkkvz12yvn5ufN", 2750000000000000000000000), - ("0x17B74Dcf1E422AF5964056eB836321aE7A820035", 200000000000000000000000), - ("5Df1Sec4ZmeidskuuPtpt4SSCL6U5St19fsv4sBAwvkwmvin", 100000000000000000000000), - ("5FerzxKQZoP9wxjRhS1PHA4v27aPQMoZpXmufcQk1JYE5xU8", 100000000000000000000000), - ("0x75afaece8cf2a7974b1e541648923afd9339b3f8", 150000000000000000000000), - ("0x5a82d0bad9995b1bfa71de79b5e524decb5bee1c", 1000000000000000000000000), - ("5Cf5SfzngS9T9fdQSsKt1GJ42BQPP7FqU4trLwgkDD1ZVBN7", 20000000000000000000000), - ("0x5da7351A4Cb03c33e11F51841bc614d985812821", 20000000000000000000000), - ("5DDTvr7P2MaUirj3rSvpcF5DLxECiAqpQegdVCzAuwxingVC", 50000000000000000000000), - ("5CXkTTyNzVuE2fwNBzSwmmtcCntnun5vMDx6Wnn5VjopGUVx", 160000000000000000000000), - ("5G9Ji4EEiTehMKa9Nfe2rGozZB3XEyRtyvJWt2wYLMRYyAyn", 180000000000000000000000), - ("5EZcQuvjvuv1K4Ugg2ofLEhAC3NXPbaCAytPR3hmUqBv1Bhe", 200000000000000000000000), - ("5Fe8pwn27TNBuM1Agz1ivCMykX795woPQkjwiWD4UoSndmQj", 220000000000000000000000), - ("5HWLv9RvMSZ6FwuQswHCo1nmYxmAqRutqh37Vapx3pmXbVU3", 240000000000000000000000), - ("5ENgRjBQue32ppyLw1u55Rbe36gDWTJgZmcbSfZwrJAyt2tZ", 781850000000000000000000), - ("5DhzryWQpJTQfdauBf7yGKpr6LW42ye4oYvEYiVbMcGN7GZt", 879590000000000000000000), - ("5C52zXiWq7BM5x55soCudf8daW12NTLtMfisBiYd5Pov1Hw1", 977320000000000000000000), - ("5HbRuwKiUw4g7yh9iNBQ6zFG63sgZyGoZ4ep61CqMYTzk4gU", 1075050000000000000000000), - ("5HnQ2onP12Vhv3dVUvmKocbWr5sMjunCmjt2MmtxMr5z5dp1", 1172780000000000000000000), - ("5CAbD6BFcATxi9jVpixNtsLKovQy6RWQMQynHtapqAtKL8vT", 338150000000000000000000), - ("5DP7RmWdPD6TWbTNgBu6iKzYsm95fHETXyy5tQvEmS6zDhPn", 380410000000000000000000), - ("5EyDntnRYxgWLuHFRmSnirioDNpMDCUTQ4bwRYV3LGHQoMxo", 422680000000000000000000), - ("5DkNqZs22mLYXKy7c2vrtstqbcQBU1ArPKw51xvC37eGsuNP", 464950000000000000000000), - ("5CQJt5A7GmEUhh7S3MtaiBGvNRTY6PFw6KHJFcTVD4ZxBty7", 507220000000000000000000), -]; - -pub const TEAM_ACCOUNTS: [(&str, Balance); 11] = [ - ("5H4H4pVXrqs6r1kwdzevPXQnLAU8518hXSi6N25jYGiPrSoD", 10000000000000000000000), - ("5DoX7xYr8kzLEdZRXzSHJvRahtntVWdAowe3P9KjjWKrRXNV", 150000000000000000000000), - ("5HBXHgGuu5kuFtiLFxa7r3ygKCDBmddnyAA7AQ5HpLuJqXQb", 200000000000000000000000), - ("5FjoBt9hjDSb81GuVK9Bqf1NHJcmeKFUnMmyXik1579dP9dW", 30000000000000000000000), - ("5EbkKKTdRJzP1j3aM3S7q178du6tW7ZVWK9Dtjx9CbTFEpGf", 100000000000000000000000), - ("5HYMCFxV9C8VGWXd5PAgD59accAsKmopEFfuKFhU2YAE6Xhu", 200000000000000000000000), - ("5DhQuvKtVi41vPL8nSTFCTY7UJvNUQwEg9wAXRTU37iHBVRj", 15000000000000000000000), - ("5FEb3bjP4KsFpet1sf81MerFqmTjTx8db2H3WctwvmB75At8", 250000000000000000000000), - ("5F7UEB6Lo141pHYS1ySPf4UDTkuBEimSZmV9uehYJvXbc4CW", 150000000000000000000000), - ("5H4RzH7KC1UZYwwNGgxmUEuahzYK21UJibS5jNkupHbLToqw", 30000000000000000000000), - ("5FH32Ro5cTpLE1FhP3skdi16UuVariyzoQfyK7vvjE2CHEtX", 28721849310000000043843584), -]; - -#[cfg(test)] -mod tests { - use super::*; - use core::str::FromStr; - use pallet_airdrop_claims::MultiAddress; - use sp_core::H160; - use sp_runtime::AccountId32; - - #[test] - fn test_decoding_accounts_into_account_id_32_bytes() { - for (address, _) in INVESTOR_ACCOUNTS { - let account_id = if address.starts_with("0x") { - MultiAddress::EVM( - H160::from_str(address).expect("should be a valid address").into(), - ) - .to_account_id_32() - } else { - let account = MultiAddress::Native( - AccountId32::from_str(address).expect("should be a valid address"), - ) - .to_account_id_32(); - - assert_eq!( - account, - AccountId32::from_str(address).expect("should be a valid address") - ); - - account - }; - - let account_id_bytes: [u8; 32] = account_id.into(); - println!("INVESTOR | {:?}", account_id_bytes); - } - - for (address, _) in TEAM_ACCOUNTS { - let account_id = MultiAddress::Native( - AccountId32::from_str(address).expect("should be a valid address"), - ) - .to_account_id_32(); - - let account_id_bytes: [u8; 32] = account_id.into(); - println!("TEAM | {:?}", account_id_bytes); - } - } -} diff --git a/pallets/multi-asset-delegation/src/traits.rs b/pallets/multi-asset-delegation/src/traits.rs index f5576ef4f..5ed182340 100644 --- a/pallets/multi-asset-delegation/src/traits.rs +++ b/pallets/multi-asset-delegation/src/traits.rs @@ -38,7 +38,7 @@ impl MultiAssetDelegationInfo, Bloc fn is_operator_active(operator: &T::AccountId) -> bool { Operators::::get(operator) - .is_some_and(|metadata| matches!(metadata.status, OperatorStatus::Active)) + .map_or(false, |metadata| matches!(metadata.status, OperatorStatus::Active)) } fn get_operator_stake(operator: &T::AccountId) -> BalanceOf { diff --git a/primitives/src/services/field.rs b/primitives/src/services/field.rs index ba62dc06a..c03869aaf 100644 --- a/primitives/src/services/field.rs +++ b/primitives/src/services/field.rs @@ -528,7 +528,7 @@ impl<'de, S: Get> serde::Deserialize<'de> for BoundedString { { struct StringVisitor>(PhantomData); - impl> serde::de::Visitor<'_> for StringVisitor { + impl<'de, S: Get> serde::de::Visitor<'de> for StringVisitor { type Value = String; fn expecting(&self, formatter: &mut core::fmt::Formatter) -> core::fmt::Result { diff --git a/primitives/src/services/mod.rs b/primitives/src/services/mod.rs index 31ba7b53b..115f4c262 100644 --- a/primitives/src/services/mod.rs +++ b/primitives/src/services/mod.rs @@ -19,8 +19,9 @@ use crate::Weight; use educe::Educe; use fp_evm::CallInfo; use frame_support::pallet_prelude::*; +use serde::Deserializer; #[cfg(feature = "std")] -use serde::{Deserialize, Deserializer, Serialize}; +use serde::{Deserialize, Serialize}; use sp_core::{ByteArray, RuntimeDebug, H160, U256}; use sp_runtime::Percent; diff --git a/runtime/mainnet/Cargo.toml b/runtime/mainnet/Cargo.toml index 36da9ae0a..d3d9535a7 100644 --- a/runtime/mainnet/Cargo.toml +++ b/runtime/mainnet/Cargo.toml @@ -281,28 +281,6 @@ std = [ "pallet-evm-precompile-multi-asset-delegation/std", ] -try-runtime = [ - "frame-support/try-runtime", - "frame-executive/try-runtime", - "frame-system/try-runtime", - "pallet-balances/try-runtime", - "pallet-grandpa/try-runtime", - "pallet-timestamp/try-runtime", - "pallet-vesting/try-runtime", - "pallet-assets/try-runtime", - "pallet-collective/try-runtime", - "pallet-tx-pause/try-runtime", - "pallet-staking/try-runtime", - "sp-runtime/try-runtime", - - # Frontier - "pallet-ethereum/try-runtime", - "pallet-evm/try-runtime", - "pallet-hotfix-sufficients/try-runtime", - # Tangle - "pallet-services/try-runtime", -] - integration-tests = ["tangle-primitives/integration-tests"] with-rocksdb-weights = [] with-paritydb-weights = [] diff --git a/runtime/mainnet/src/lib.rs b/runtime/mainnet/src/lib.rs index 26df64225..e01df5bf6 100644 --- a/runtime/mainnet/src/lib.rs +++ b/runtime/mainnet/src/lib.rs @@ -1449,14 +1449,13 @@ pub type Executive = frame_executive::Executive< Runtime, AllPalletsWithSystem, ( - migrations::session_key_migrations_08062024::MigrateSessionKeys, + migrations::MigrateSessionKeys, // AssetId limits // 0 - 1000 (reserved for future use) // 1000 - 50000 (reserved for LST pools) // 50000 - 1000000 (reserved for native assets) // set user start at 50_000, everything below is reserved for system use - migrations::assets_indices_migration_01162025::SetNextAssetId, Runtime>, - migrations::investor_team_vesting_migration_11302024::UpdateTeamInvestorVesting, + migrations::SetNextAssetId, Runtime>, ), >; diff --git a/runtime/mainnet/src/migrations/session_key_migrations_08062024.rs b/runtime/mainnet/src/migrations.rs similarity index 79% rename from runtime/mainnet/src/migrations/session_key_migrations_08062024.rs rename to runtime/mainnet/src/migrations.rs index 9ee6e0e6c..d68d25362 100644 --- a/runtime/mainnet/src/migrations/session_key_migrations_08062024.rs +++ b/runtime/mainnet/src/migrations.rs @@ -1,5 +1,7 @@ -use crate::{AccountId, Babe, Grandpa, KeyTypeId, OpaqueKeys, Session, SessionKeys}; -use frame_support::{pallet_prelude::*, traits::OnRuntimeUpgrade}; +use super::*; +use frame_support::traits::Incrementable; +use frame_support::traits::OnRuntimeUpgrade; +use pallet_assets::NextAssetId; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use sp_runtime::{BoundToRuntimeAppPublic, RuntimeAppPublic, RuntimeDebug}; @@ -69,3 +71,20 @@ impl OnRuntimeUpgrade for MigrateSessionKeys { T::DbWeight::get().reads_writes(10, 10) } } + +/// Set [`NextAssetId`] to the value of `ID` if [`NextAssetId`] does not exist yet. +pub struct SetNextAssetId(core::marker::PhantomData<(ID, T)>); +impl OnRuntimeUpgrade for SetNextAssetId +where + T::AssetId: Incrementable, + ID: Get, +{ + fn on_runtime_upgrade() -> frame_support::weights::Weight { + if !NextAssetId::::exists() { + NextAssetId::::put(ID::get()); + T::DbWeight::get().reads_writes(1, 1) + } else { + T::DbWeight::get().reads(1) + } + } +} diff --git a/runtime/mainnet/src/migrations/assets_indices_migration_01162025.rs b/runtime/mainnet/src/migrations/assets_indices_migration_01162025.rs deleted file mode 100644 index c6512f982..000000000 --- a/runtime/mainnet/src/migrations/assets_indices_migration_01162025.rs +++ /dev/null @@ -1,20 +0,0 @@ -use frame_support::traits::Incrementable; -use frame_support::{pallet_prelude::*, traits::OnRuntimeUpgrade}; -use pallet_assets::NextAssetId; - -/// Set [`NextAssetId`] to the value of `ID` if [`NextAssetId`] does not exist yet. -pub struct SetNextAssetId(core::marker::PhantomData<(ID, T)>); -impl OnRuntimeUpgrade for SetNextAssetId -where - T::AssetId: Incrementable, - ID: Get, -{ - fn on_runtime_upgrade() -> frame_support::weights::Weight { - if !NextAssetId::::exists() { - NextAssetId::::put(ID::get()); - T::DbWeight::get().reads_writes(1, 1) - } else { - T::DbWeight::get().reads(1) - } - } -} diff --git a/runtime/mainnet/src/migrations/investor_team_vesting_migration_11302024.rs b/runtime/mainnet/src/migrations/investor_team_vesting_migration_11302024.rs deleted file mode 100644 index 6727c2306..000000000 --- a/runtime/mainnet/src/migrations/investor_team_vesting_migration_11302024.rs +++ /dev/null @@ -1,321 +0,0 @@ -use frame_support::{pallet_prelude::*, traits::OnRuntimeUpgrade}; -use pallet_vesting::{MaxVestingSchedulesGet, Vesting, VestingInfo}; -use sp_runtime::{ - traits::{Convert, EnsureDiv, Header, Zero}, - Percent, Saturating, -}; -use sp_std::vec::Vec; - -pub const BLOCK_TIME: u128 = 6; -pub const ONE_YEAR_BLOCKS: u64 = (365 * 24 * 60 * 60 / BLOCK_TIME) as u64; - -pub const INVESTOR_ACCOUNTS: [[u8; 32]; 29] = [ - [ - 138, 249, 246, 184, 248, 138, 249, 225, 200, 68, 130, 170, 83, 137, 64, 251, 106, 197, 74, - 79, 232, 191, 177, 86, 84, 71, 188, 169, 202, 64, 231, 36, - ], - [ - 225, 94, 83, 233, 185, 41, 177, 181, 248, 143, 147, 205, 180, 83, 14, 125, 47, 25, 125, - 248, 22, 125, 226, 220, 156, 78, 175, 3, 230, 244, 140, 52, - ], - [ - 226, 56, 28, 178, 235, 59, 229, 44, 201, 146, 200, 29, 38, 152, 123, 201, 70, 248, 93, 143, - 16, 158, 67, 242, 146, 71, 119, 144, 164, 118, 131, 239, - ], - [ - 83, 94, 177, 114, 5, 76, 126, 89, 124, 208, 48, 113, 197, 113, 201, 20, 143, 244, 231, 128, - 68, 163, 167, 63, 84, 227, 193, 177, 216, 112, 208, 84, - ], - [ - 226, 248, 45, 109, 239, 71, 153, 69, 230, 189, 169, 9, 81, 83, 24, 60, 250, 169, 164, 251, - 82, 166, 31, 117, 66, 164, 222, 120, 208, 80, 196, 88, - ], - [ - 72, 57, 99, 4, 212, 215, 132, 34, 128, 223, 72, 106, 143, 56, 37, 98, 103, 77, 253, 149, - 40, 92, 6, 129, 204, 248, 163, 22, 61, 149, 207, 120, - ], - [ - 165, 243, 249, 88, 179, 113, 230, 225, 100, 88, 23, 11, 87, 179, 246, 32, 54, 85, 215, 64, - 68, 146, 82, 238, 21, 108, 206, 162, 78, 144, 200, 158, - ], - [ - 70, 101, 198, 201, 165, 102, 235, 103, 142, 23, 51, 45, 209, 4, 177, 120, 143, 223, 81, - 222, 187, 212, 130, 212, 103, 129, 129, 86, 35, 141, 167, 97, - ], - [ - 158, 193, 210, 91, 210, 217, 80, 151, 219, 193, 65, 163, 149, 70, 177, 108, 77, 81, 5, 84, - 187, 146, 59, 162, 138, 78, 236, 7, 21, 109, 42, 66, - ], - [ - 73, 92, 137, 97, 116, 188, 150, 231, 162, 97, 156, 213, 207, 65, 244, 189, 115, 96, 149, - 86, 219, 50, 223, 200, 220, 213, 143, 160, 153, 53, 153, 173, - ], - [ - 196, 215, 35, 118, 232, 152, 244, 80, 42, 241, 100, 107, 224, 191, 61, 29, 64, 54, 3, 112, - 174, 240, 158, 212, 197, 115, 20, 10, 10, 92, 116, 28, - ], - [ - 26, 55, 2, 120, 183, 66, 224, 91, 238, 81, 231, 203, 154, 226, 246, 253, 26, 45, 218, 123, - 51, 5, 122, 148, 251, 110, 109, 204, 217, 81, 117, 18, - ], - [ - 20, 148, 147, 133, 5, 238, 234, 73, 51, 154, 251, 105, 92, 63, 31, 44, 131, 42, 183, 201, - 182, 242, 211, 21, 14, 99, 22, 212, 193, 29, 186, 217, - ], - [ - 50, 234, 142, 113, 250, 70, 204, 94, 20, 44, 9, 35, 5, 25, 87, 208, 53, 96, 94, 47, 51, - 135, 10, 94, 133, 29, 179, 167, 247, 226, 137, 19, - ], - [ - 20, 160, 96, 205, 27, 33, 238, 218, 236, 77, 34, 88, 25, 163, 112, 231, 10, 110, 163, 111, - 36, 5, 110, 50, 142, 76, 49, 183, 209, 147, 179, 100, - ], - [ - 180, 115, 60, 111, 163, 25, 14, 178, 121, 79, 191, 213, 179, 191, 156, 236, 25, 37, 83, 89, - 216, 107, 123, 146, 254, 218, 30, 154, 115, 101, 39, 47, - ], - [ - 110, 132, 65, 222, 55, 201, 168, 118, 191, 249, 229, 145, 52, 219, 24, 86, 203, 255, 63, - 209, 91, 34, 206, 199, 8, 240, 78, 43, 66, 93, 224, 31, - ], - [ - 158, 51, 219, 46, 28, 186, 50, 107, 225, 183, 177, 124, 244, 215, 38, 15, 44, 229, 59, 64, - 40, 246, 80, 239, 182, 237, 129, 191, 49, 173, 231, 19, - ], - [ - 240, 187, 14, 171, 122, 87, 33, 20, 39, 68, 54, 68, 44, 137, 73, 107, 151, 54, 58, 149, - 132, 130, 222, 184, 244, 65, 148, 162, 98, 23, 127, 76, - ], - [ - 102, 46, 18, 1, 115, 40, 196, 41, 159, 117, 230, 38, 72, 10, 253, 186, 224, 229, 249, 227, - 186, 62, 32, 12, 210, 131, 42, 190, 135, 233, 142, 27, - ], - [ - 72, 173, 142, 236, 101, 180, 147, 239, 64, 70, 44, 143, 198, 254, 51, 143, 104, 149, 94, - 146, 75, 159, 40, 52, 53, 225, 28, 197, 73, 84, 189, 11, - ], - [ - 0, 64, 106, 126, 60, 179, 52, 134, 195, 43, 228, 249, 202, 36, 34, 62, 137, 47, 60, 194, - 123, 253, 171, 30, 205, 154, 28, 23, 3, 169, 223, 100, - ], - [ - 244, 156, 26, 140, 205, 108, 13, 44, 139, 130, 165, 246, 58, 203, 83, 171, 189, 21, 71, 62, - 89, 81, 150, 115, 29, 175, 114, 213, 194, 91, 164, 64, - ], - [ - 252, 249, 120, 35, 115, 244, 16, 85, 11, 113, 242, 83, 208, 86, 198, 225, 23, 163, 23, 142, - 49, 124, 81, 48, 158, 202, 185, 100, 59, 31, 218, 67, - ], - [ - 4, 125, 23, 244, 85, 187, 199, 151, 55, 109, 248, 90, 16, 134, 116, 192, 43, 28, 74, 246, - 21, 111, 172, 109, 27, 122, 88, 247, 219, 172, 88, 63, - ], - [ - 58, 69, 255, 40, 206, 137, 18, 192, 97, 105, 41, 95, 157, 205, 120, 252, 232, 50, 221, 68, - 83, 187, 60, 133, 96, 189, 35, 160, 89, 121, 188, 7, - ], - [ - 128, 133, 255, 113, 171, 251, 146, 3, 232, 220, 247, 119, 166, 113, 67, 37, 228, 170, 48, - 5, 52, 240, 26, 77, 236, 13, 180, 213, 9, 26, 219, 117, - ], - [ - 74, 126, 6, 168, 58, 228, 131, 195, 50, 142, 139, 187, 204, 130, 114, 32, 107, 105, 238, - 136, 202, 91, 109, 251, 247, 98, 9, 37, 122, 202, 33, 103, - ], - [ - 14, 243, 144, 141, 108, 213, 243, 175, 130, 92, 68, 191, 148, 27, 215, 242, 160, 27, 197, - 13, 240, 118, 166, 253, 214, 93, 174, 242, 127, 123, 238, 97, - ], -]; - -pub const TEAM_ACCOUNTS: [[u8; 32]; 11] = [ - [ - 220, 217, 183, 10, 4, 9, 183, 98, 108, 186, 26, 64, 22, 216, 218, 25, 244, 223, 92, 233, - 252, 94, 141, 22, 183, 137, 231, 27, 177, 22, 29, 115, - ], - [ - 76, 227, 164, 218, 58, 124, 28, 230, 95, 126, 222, 255, 134, 77, 195, 221, 66, 232, 244, - 126, 236, 194, 114, 109, 153, 160, 168, 1, 36, 105, 130, 23, - ], - [ - 226, 96, 78, 172, 142, 71, 162, 218, 115, 191, 193, 196, 247, 215, 108, 71, 131, 198, 47, - 143, 92, 45, 64, 78, 106, 176, 223, 167, 103, 39, 29, 33, - ], - [ - 162, 133, 55, 193, 209, 134, 98, 231, 154, 181, 108, 72, 150, 15, 166, 174, 160, 28, 203, - 238, 113, 51, 80, 242, 197, 70, 70, 237, 33, 244, 251, 67, - ], - [ - 112, 37, 90, 147, 193, 18, 157, 49, 188, 57, 43, 67, 30, 93, 62, 212, 223, 135, 97, 116, - 54, 19, 11, 84, 98, 79, 154, 98, 77, 97, 206, 66, - ], - [ - 242, 66, 123, 184, 39, 134, 15, 110, 181, 6, 187, 139, 110, 58, 126, 105, 95, 171, 231, - 171, 87, 30, 111, 88, 107, 141, 246, 112, 113, 230, 9, 127, - ], - [ - 72, 59, 70, 104, 50, 224, 148, 240, 27, 23, 121, 167, 237, 7, 2, 93, 243, 25, 196, 146, - 218, 197, 22, 10, 202, 137, 163, 190, 17, 122, 123, 109, - ], - [ - 140, 62, 57, 135, 164, 41, 178, 70, 246, 25, 233, 31, 140, 164, 85, 53, 161, 191, 95, 135, - 14, 199, 197, 207, 246, 169, 16, 169, 148, 151, 139, 65, - ], - [ - 134, 208, 142, 123, 190, 119, 188, 116, 227, 216, 142, 226, 46, 220, 83, 54, 139, 193, 61, - 97, 158, 5, 182, 111, 230, 196, 184, 226, 213, 199, 1, 90, - ], - [ - 220, 247, 191, 133, 183, 80, 119, 15, 91, 184, 117, 45, 0, 7, 150, 96, 236, 168, 190, 205, - 63, 90, 138, 73, 172, 186, 174, 240, 173, 126, 237, 8, - ], - [ - 142, 28, 43, 221, 218, 185, 87, 61, 140, 176, 148, 219, 255, 186, 36, 162, 178, 194, 27, - 126, 113, 227, 245, 182, 4, 232, 96, 116, 131, 135, 36, 67, - ], -]; - -/// Migration to update team and investor vesting schedules to 4 years with 1 year cliff -pub struct UpdateTeamInvestorVesting(sp_std::marker::PhantomData); - -pub type BalanceOf = - <::Currency as frame_support::traits::Currency< - ::AccountId, - >>::Balance; - -pub type BlockNumberOf = - <<::Block as sp_runtime::traits::Block>::Header as Header>::Number; - -impl OnRuntimeUpgrade - for UpdateTeamInvestorVesting -{ - fn on_runtime_upgrade() -> Weight { - let mut reads = 0u64; - let mut writes = 0u64; - - // Update investor vesting schedules - for account in INVESTOR_ACCOUNTS.iter() { - let account_id: T::AccountId = - T::AccountId::decode(&mut account.as_ref()).expect("Invalid account ID"); - update_account_vesting::(&account_id, &mut reads, &mut writes); - } - - // Update team vesting schedule - for account in TEAM_ACCOUNTS.iter() { - let account_id: T::AccountId = - T::AccountId::decode(&mut account.as_ref()).expect("Invalid account ID"); - update_account_vesting::(&account_id, &mut reads, &mut writes); - } - - T::DbWeight::get().reads_writes(reads, writes) - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, &'static str> { - Ok(Vec::new()) - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade(_state: Vec) -> Result<(), &'static str> { - // Verify schedules for all accounts - for (address, _) in INVESTOR_ACCOUNTS { - let account_id = if address.starts_with("0x") { - MultiAddress::Evm(H160::from_str(address).expect("should be a valid address")) - .to_account_id_32() - } else { - address.parse().expect("Invalid account ID") - }; - verify_updated_schedule::(&account_id)?; - } - for (address, _) in TEAM_ACCOUNT_TO_UPDATE { - let account_id = address.parse().expect("Invalid account ID"); - verify_updated_schedule::(&account_id)?; - } - - Ok(()) - } -} - -// Update investor vesting schedules -fn update_account_vesting( - account_id: &T::AccountId, - reads: &mut u64, - writes: &mut u64, -) { - let schedules = Vesting::::get(account_id); - *reads += 1; - if let Some(schedules) = schedules { - update_vesting_schedule::(account_id, schedules.to_vec()); - *writes += 1; - } -} - -fn update_vesting_schedule( - account_id: &T::AccountId, - schedules: Vec, BlockNumberOf>>, -) { - // Calculate total vested amount - let total_vested = schedules - .iter() - .map(|schedule| schedule.locked()) - .fold(Zero::zero(), |acc: BalanceOf, val: BalanceOf| acc.saturating_add(val)); - - if total_vested.is_zero() { - return; - } - - // New vesting parameters - let one_year_blocks = BlockNumberOf::::from(ONE_YEAR_BLOCKS as u32); - let three_year_blocks = one_year_blocks.saturating_mul(BlockNumberOf::::from(3u32)); - - // At 1 year cliff, 25% unlocks - let quarter_percentage = Percent::from_percent(25); - let cliff_amount = quarter_percentage.mul_floor(total_vested); - // Remaining 75% vests linearly over 3 years - let remaining_amount = total_vested.saturating_sub(cliff_amount); - let per_block = remaining_amount - .ensure_div(T::BlockNumberToBalance::convert(three_year_blocks)) - .unwrap(); - - let mut bounded_new_schedules: BoundedVec< - VestingInfo, BlockNumberOf>, - MaxVestingSchedulesGet, - > = BoundedVec::new(); - - bounded_new_schedules - .try_push(VestingInfo::new(cliff_amount, Zero::zero(), one_year_blocks)) - .expect("Failed to push new schedules"); - bounded_new_schedules - .try_push(VestingInfo::new(remaining_amount, per_block, one_year_blocks)) - .expect("Failed to push new schedules"); - - // Update storage - Vesting::::insert(account_id, bounded_new_schedules); -} - -#[cfg(feature = "try-runtime")] -fn verify_updated_schedule( - account_id: &T::AccountId, -) -> Result<(), &'static str> { - use sp_runtime::traits::Block; - - if let Some(schedules) = Vesting::::get(account_id) { - ensure!(schedules.len() >= 2, "Schedule should have at least 2 entries"); - ensure!( - schedules[0].starting_block() - == <<::Block as Block>::Header as Header>::Number::from( - ONE_YEAR_BLOCKS as u32 - ), - "First schedule should start at 1 year" - ); - ensure!( - schedules[1].starting_block() - == <<::Block as Block>::Header as Header>::Number::from( - ONE_YEAR_BLOCKS as u32 - ), - "Second schedule should start at 1 year" - ); - ensure!(schedules[0].per_block().is_zero(), "First schedule should have zero per_block"); - } - Ok(()) -} diff --git a/runtime/mainnet/src/migrations/mod.rs b/runtime/mainnet/src/migrations/mod.rs deleted file mode 100644 index 6b6fcfcf4..000000000 --- a/runtime/mainnet/src/migrations/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod assets_indices_migration_01162025; -pub mod investor_team_vesting_migration_11302024; -pub mod session_key_migrations_08062024;