From 141048ee74c9939e02be547c32cc0e87b5ad63b8 Mon Sep 17 00:00:00 2001 From: HaoranYi Date: Tue, 20 Feb 2024 16:45:38 -0600 Subject: [PATCH] update comments for is_builtin (#35258) Co-authored-by: HaoranYi --- sdk/src/account.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sdk/src/account.rs b/sdk/src/account.rs index 227a56668..96cdd5b90 100644 --- a/sdk/src/account.rs +++ b/sdk/src/account.rs @@ -845,9 +845,12 @@ pub fn is_executable(account: &impl ReadableAccount, feature_set: &FeatureSet) - } } -/// Return true if the account program is a builtin program. Note that for -/// builtin program, even when its account data is empty, it is still be -/// executable, such as vote program etc. +/// Return true if the account program is a builtin program. +/// +/// This function also ensures that all valid builtin programs have non-empty +/// program data. Typically, the program data contains only the "name" for the +/// program. If, for some reason, the program account's data is empty, we should +/// exclude such a program from `builtins`. pub fn is_builtin(account: &impl ReadableAccount) -> bool { native_loader::check_id(account.owner()) && !account.data().is_empty() }