stake-monitor: Add 1 SOL grace, to allow for a complaint system account to fund a reasonable number of transactions. (bp #9359) (#9363)

automerge
This commit is contained in:
mergify[bot]
2020-04-08 11:56:01 -07:00
committed by GitHub
parent f506d39339
commit 68d2616e35
2 changed files with 8 additions and 3 deletions

View File

@ -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.

View File

@ -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,