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

Add vesting migration and extend to 4 years #838

Merged
merged 13 commits into from
Jan 31, 2025
15 changes: 14 additions & 1 deletion 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 @@ -10,6 +10,7 @@ exclude = ["examples"]

[workspace]
members = [
"account-util",
"primitives",
"primitives/crypto",
"primitives/rpc/*",
Expand Down
18 changes: 18 additions & 0 deletions account-util/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[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"] }
96 changes: 96 additions & 0 deletions account-util/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
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);
}
}
}
2 changes: 1 addition & 1 deletion pallets/multi-asset-delegation/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl<T: crate::Config> MultiAssetDelegationInfo<T::AccountId, BalanceOf<T>, Bloc

fn is_operator_active(operator: &T::AccountId) -> bool {
Operators::<T>::get(operator)
.map_or(false, |metadata| matches!(metadata.status, OperatorStatus::Active))
.is_some_and(|metadata| matches!(metadata.status, OperatorStatus::Active))
}

fn get_operator_stake(operator: &T::AccountId) -> BalanceOf<T> {
Expand Down
2 changes: 1 addition & 1 deletion primitives/src/services/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ impl<'de, S: Get<u32>> serde::Deserialize<'de> for BoundedString<S> {
{
struct StringVisitor<S: Get<u32>>(PhantomData<S>);

impl<'de, S: Get<u32>> serde::de::Visitor<'de> for StringVisitor<S> {
impl<S: Get<u32>> serde::de::Visitor<'_> for StringVisitor<S> {
type Value = String;

fn expecting(&self, formatter: &mut core::fmt::Formatter) -> core::fmt::Result {
Expand Down
3 changes: 1 addition & 2 deletions primitives/src/services/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ use crate::Weight;
use educe::Educe;
use fp_evm::CallInfo;
use frame_support::pallet_prelude::*;
use serde::Deserializer;
#[cfg(feature = "std")]
use serde::{Deserialize, Serialize};
use serde::{Deserialize, Deserializer, Serialize};
use sp_core::{ByteArray, RuntimeDebug, H160, U256};
use sp_runtime::Percent;

Expand Down
22 changes: 22 additions & 0 deletions runtime/mainnet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,28 @@ 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 = []
Expand Down
5 changes: 3 additions & 2 deletions runtime/mainnet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1449,13 +1449,14 @@ pub type Executive = frame_executive::Executive<
Runtime,
AllPalletsWithSystem,
(
migrations::MigrateSessionKeys<Runtime>,
migrations::session_key_migrations_08062024::MigrateSessionKeys<Runtime>,
// 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::SetNextAssetId<ConstU128<50_000>, Runtime>,
migrations::assets_indices_migration_01162025::SetNextAssetId<ConstU128<50_000>, Runtime>,
migrations::investor_team_vesting_migration_11302024::UpdateTeamInvestorVesting<Runtime>,
),
>;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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<ID, T: pallet_assets::Config>(core::marker::PhantomData<(ID, T)>);
impl<ID, T: pallet_assets::Config> OnRuntimeUpgrade for SetNextAssetId<ID, T>
where
T::AssetId: Incrementable,
ID: Get<T::AssetId>,
{
fn on_runtime_upgrade() -> frame_support::weights::Weight {
if !NextAssetId::<T>::exists() {
NextAssetId::<T>::put(ID::get());
T::DbWeight::get().reads_writes(1, 1)
} else {
T::DbWeight::get().reads(1)
}
}
}
Loading
Loading