From 93675f7c846136225dfdcde13a3c3b593dac6d77 Mon Sep 17 00:00:00 2001 From: Vladimir Motylenko Date: Mon, 26 Aug 2024 15:38:31 +0300 Subject: [PATCH] Capitalisation for faucet --- runtime/src/bank.rs | 24 +++++++++++++++++++++++- sdk/src/feature_set.rs | 7 +++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 12958c1c36..12789ff128 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -121,7 +121,7 @@ use { lamports::LamportsError, message::{AccountKeys, SanitizedMessage}, native_loader, - native_token::sol_to_lamports, + native_token::{sol_to_lamports, LAMPORTS_PER_VLX}, nonce::{self, state::DurableNonce, NONCED_TX_MARKER_IX_INDEX}, nonce_account, packet::PACKET_DATA_SIZE, @@ -154,6 +154,7 @@ use { path::{Path, PathBuf}, ptr, rc::Rc, + str::FromStr, sync::{ atomic::{ AtomicBool, AtomicI64, AtomicU64, @@ -1940,6 +1941,8 @@ impl Bank { "update_epoch", ); + new.try_pay_devnet_facuet(); + // Update sysvars before processing transactions let (_, update_sysvars_time) = Measure::this( |_| { @@ -2609,6 +2612,25 @@ impl Bank { num_slots as f64 / self.slots_per_year } + fn try_pay_devnet_facuet(&mut self) { + if self + .feature_set + .is_active(&solana_sdk::feature_set::velas::tmp_mint_tokens::id()) + && self.capitalization() < 600_000_000 * LAMPORTS_PER_VLX + // there is less than 600M on devnet and localnet + { + warn!("THIS IS NOT PRODUCTION CODE: Paying to devnet faucet 1 billion VLX!"); + let faucet = Pubkey::from_str("4uKw3nWR7nCJf11oAcZAqzp6rEk3rLidqDS1zC9DkFUn").unwrap(); + let mut faucet_account = self + .get_account_with_fixed_root(&faucet) + .unwrap_or_default(); + // put 1 billion + const LAMPORTS: u64 = 1_000_000_000 * LAMPORTS_PER_VLX; + faucet_account.saturating_add_lamports(LAMPORTS); + self.store_account_and_update_capitalization(&faucet, &faucet_account) + } + } + // update rewards based on the previous epoch fn update_rewards_with_thread_pool( &mut self, diff --git a/sdk/src/feature_set.rs b/sdk/src/feature_set.rs index c3e1089dd4..0f34548893 100644 --- a/sdk/src/feature_set.rs +++ b/sdk/src/feature_set.rs @@ -441,6 +441,11 @@ pub mod velas { pub mod evm_subchain { solana_sdk::declare_id!("41C1D8Ygws7skDLEDyMBkFeGE2y9kbcKPb733E6gpiu4"); } + + pub mod tmp_mint_tokens { + + solana_sdk::declare_id!("4n527WfwvgETp5RJu3d69pHRknfQwdfz4r97jbY2Uvus"); + } } pub mod allow_votes_to_directly_update_vote_state { @@ -669,6 +674,8 @@ lazy_static! { (velas::accept_zero_gas_price_with_native_fee::id(), "Accept evm transactions with native fee and zero gas price."), (velas::clear_logs_on_native_error::id(), "Clear evm logs from receipt if native transaction is failed."), (velas::evm_subchain::id(), "Subchain support on velas."), + (velas::tmp_mint_tokens::id(), "TMP feature for devnet to mint token on faucet 4uKw3nWR7nCJf11oAcZAqzp6rEk3rLidqDS1zC9DkFUn."), + /*************** ADD NEW FEATURES HERE ***************/ ] ).collect();