From 68d2616e35e0e76820d0f0d1d41bfdbec831c96b Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 8 Apr 2020 11:56:01 -0700 Subject: [PATCH] stake-monitor: Add 1 SOL grace, to allow for a complaint system account to fund a reasonable number of transactions. (bp #9359) (#9363) automerge --- stake-monitor/README.md | 3 +++ stake-monitor/src/lib.rs | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/stake-monitor/README.md b/stake-monitor/README.md index 736f274752..6e9e719ddb 100644 --- a/stake-monitor/README.md +++ b/stake-monitor/README.md @@ -12,3 +12,6 @@ In terms of `solana` command-line subcommands: * `delegate-stake` / `deactivate-stake` / `stake-authorize` / `split-stake`: These commands do not affect compliance * `withdraw-stake` / `stake-set-lockup`: These commands will cause non-compliance * `transfer`: Any additional funds transferred after `create-stake-account` are excluded from the "compliant balance" + +System accounts can also be manually enrolled with the `solana-stake-monitor enroll` subcommand. +An enrolled system account must always maintain a balance greater than the balance it had at enrollment minus 1 SOL. diff --git a/stake-monitor/src/lib.rs b/stake-monitor/src/lib.rs index 1c70e005cc..be46a29ecd 100644 --- a/stake-monitor/src/lib.rs +++ b/stake-monitor/src/lib.rs @@ -3,8 +3,8 @@ use serde::{Deserialize, Serialize}; use solana_client::{client_error::Result as ClientResult, rpc_client::RpcClient}; use solana_metrics::{datapoint_error, datapoint_info}; use solana_sdk::{ - clock::Slot, program_utils::limited_deserialize, pubkey::Pubkey, signature::Signature, - transaction::Transaction, + clock::Slot, native_token::LAMPORTS_PER_SOL, program_utils::limited_deserialize, + pubkey::Pubkey, signature::Signature, transaction::Transaction, }; use solana_stake_program::{stake_instruction::StakeInstruction, stake_state::Lockup}; use solana_transaction_status::{ConfirmedBlock, RpcTransactionStatusMeta, TransactionEncoding}; @@ -203,7 +203,9 @@ fn process_transaction( for (index, account_pubkey) in message.account_keys.iter().enumerate() { if let Some(mut account_info) = accounts.get_mut(&account_pubkey.to_string()) { let post_balance = meta.post_balances[index]; - if account_info.compliant_since.is_some() && post_balance < account_info.lamports { + if account_info.compliant_since.is_some() + && post_balance <= account_info.lamports.saturating_sub(LAMPORTS_PER_SOL) + { account_info.compliant_since = None; account_info.transactions.push(AccountTransactionInfo { op: AccountOperation::FailedToMaintainMinimumBalance,