Skip to content

Commit

Permalink
[TieredStorage] Include executable field into AccountMetaFlags (solan…
Browse files Browse the repository at this point in the history
…a-labs#34724)

#### Problem
Before we have fully switched to the new way to determine whether
an account is executable, we still need a bit for th executable flag at
this moment in the TieredStorage as well as for backward compatibility
in case we want to revert it back.

#### Summary of Changes
This PR adds the executable flag into AccountMetaFlags.

#### Test Plan
Updated existing tests for AccountMetaFlags to cover executable flag.
  • Loading branch information
yhchiang-sol authored Jan 16, 2024
1 parent 0e90e98 commit 3fa44e6
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion accounts-db/src/tiered_storage/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ pub struct AccountMetaFlags {
pub has_rent_epoch: bool,
/// whether the account meta has account hash
pub has_account_hash: bool,
/// whether the account is executable
pub executable: bool,
/// the reserved bits.
reserved: B30,
reserved: B29,
}

// Ensure there are no implicit padding bytes
Expand Down Expand Up @@ -90,6 +92,7 @@ impl AccountMetaFlags {
let mut flags = AccountMetaFlags::default();
flags.set_has_rent_epoch(optional_fields.rent_epoch.is_some());
flags.set_has_account_hash(optional_fields.account_hash.is_some());
flags.set_executable(false);
flags
}
}
Expand Down Expand Up @@ -177,12 +180,20 @@ pub mod tests {

assert!(flags.has_rent_epoch());
assert!(!flags.has_account_hash());
assert!(!flags.executable());
verify_flags_serialization(&flags);

flags.set_has_account_hash(true);

assert!(flags.has_rent_epoch());
assert!(flags.has_account_hash());
assert!(!flags.executable());
verify_flags_serialization(&flags);

flags.set_executable(true);
assert!(flags.has_rent_epoch());
assert!(flags.has_account_hash());
assert!(flags.executable());
verify_flags_serialization(&flags);

// make sure the reserved bits are untouched.
Expand Down

0 comments on commit 3fa44e6

Please sign in to comment.