Skip to content

Commit

Permalink
Capitalisation for faucet
Browse files Browse the repository at this point in the history
  • Loading branch information
vldm committed Aug 26, 2024
1 parent 6415c59 commit 93675f7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
24 changes: 23 additions & 1 deletion runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -154,6 +154,7 @@ use {
path::{Path, PathBuf},
ptr,
rc::Rc,
str::FromStr,
sync::{
atomic::{
AtomicBool, AtomicI64, AtomicU64,
Expand Down Expand Up @@ -1940,6 +1941,8 @@ impl Bank {
"update_epoch",
);

new.try_pay_devnet_facuet();

// Update sysvars before processing transactions
let (_, update_sysvars_time) = Measure::this(
|_| {
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions sdk/src/feature_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 93675f7

Please sign in to comment.