write_version -> write_version_obsolete (#29176)

This commit is contained in:
Jeff Washington (jwash) 2022-12-14 09:43:40 -06:00 committed by GitHub
parent 7a97121747
commit b77bef4ee3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 42 additions and 32 deletions

View File

@ -134,7 +134,7 @@ impl AccountsUpdateNotifierImpl {
executable: stored_account_meta.account_meta.executable,
rent_epoch: stored_account_meta.account_meta.rent_epoch,
data: stored_account_meta.data,
write_version: stored_account_meta.meta.write_version,
write_version: stored_account_meta.meta.write_version_obsolete,
txn_signature: None,
})
}

View File

@ -40,7 +40,7 @@ fn append_account(
StorableAccountsWithHashesAndWriteVersions::new_with_hashes_and_write_versions(
&accounts,
vec![&hash],
vec![storage_meta.write_version],
vec![storage_meta.write_version_obsolete],
);
let res = vec.append_accounts(&storable_accounts, 0);
res.and_then(|res| res.first().cloned())

View File

@ -744,7 +744,9 @@ impl<'a> LoadedAccount<'a> {
pub fn write_version(&self) -> StoredMetaWriteVersion {
match self {
LoadedAccount::Stored(stored_account_meta) => stored_account_meta.meta.write_version,
LoadedAccount::Stored(stored_account_meta) => {
stored_account_meta.meta.write_version_obsolete
}
LoadedAccount::Cached(_) => CACHE_VIRTUAL_WRITE_VERSION,
}
}
@ -3721,8 +3723,8 @@ impl AccountsDb {
match stored_accounts.entry(*new_entry.account.pubkey()) {
Entry::Occupied(mut occupied_entry) => {
assert!(
new_entry.account.meta.write_version
> occupied_entry.get().account.meta.write_version
new_entry.account.meta.write_version_obsolete
> occupied_entry.get().account.meta.write_version_obsolete
);
occupied_entry.insert(new_entry);
}
@ -3925,7 +3927,7 @@ impl AccountsDb {
for alive_account in &shrink_collect.alive_accounts {
accounts.push(&alive_account.account);
hashes.push(alive_account.account.hash);
write_versions.push(alive_account.account.meta.write_version);
write_versions.push(alive_account.account.meta.write_version_obsolete);
}
find_alive_elapsed.stop();
@ -7029,10 +7031,12 @@ impl AccountsDb {
Vec::<(StoredMetaWriteVersion, Option<StoredAccountMeta<'_>>)>::with_capacity(len);
for storage in storages {
let mut iterator = storage.accounts.account_iter();
if let Some(item) = iterator
.next()
.map(|stored_account| (stored_account.meta.write_version, Some(stored_account)))
{
if let Some(item) = iterator.next().map(|stored_account| {
(
stored_account.meta.write_version_obsolete,
Some(stored_account),
)
}) {
current.push(item);
progress.push(iterator);
}
@ -7058,7 +7062,10 @@ impl AccountsDb {
scanner.found_account(&LoadedAccount::Stored(account.1.unwrap()));
}
let next = progress[min_index].next().map(|stored_account| {
(stored_account.meta.write_version, Some(stored_account))
(
stored_account.meta.write_version_obsolete,
Some(stored_account),
)
});
match next {
Some(item) => {
@ -8668,7 +8675,7 @@ impl AccountsDb {
let mut accounts_map = GenerateIndexAccountsMap::with_capacity(num_accounts);
storage_maps.iter().for_each(|storage| {
storage.accounts.account_iter().for_each(|stored_account| {
let this_version = stored_account.meta.write_version;
let this_version = stored_account.meta.write_version_obsolete;
let pubkey = stored_account.pubkey();
assert!(!self.is_filler_account(pubkey));
match accounts_map.entry(*pubkey) {
@ -9693,7 +9700,7 @@ pub mod tests {
let hash = Hash::new(&[2; 32]);
let stored_meta = StoredMeta {
/// global write version
write_version: 0,
write_version_obsolete: 0,
/// key for the account
pubkey,
data_len: 43,
@ -9761,22 +9768,22 @@ pub mod tests {
let pubkey4 = solana_sdk::pubkey::new_rand();
let meta = StoredMeta {
write_version: 5,
write_version_obsolete: 5,
pubkey,
data_len: 7,
};
let meta2 = StoredMeta {
write_version: 5,
write_version_obsolete: 5,
pubkey: pubkey2,
data_len: 7,
};
let meta3 = StoredMeta {
write_version: 5,
write_version_obsolete: 5,
pubkey: pubkey3,
data_len: 7,
};
let meta4 = StoredMeta {
write_version: 5,
write_version_obsolete: 5,
pubkey: pubkey4,
data_len: 7,
};
@ -12402,7 +12409,7 @@ pub mod tests {
let executable = true;
let rent_epoch = 2;
let meta = StoredMeta {
write_version: 5,
write_version_obsolete: 5,
pubkey: Pubkey::new_unique(),
data_len: 7,
};

View File

@ -96,9 +96,9 @@ impl AccountsDb {
accounts.for_each(|account| {
account_len += 1;
if let Some(previous_write_version) = previous_write_version {
assert!(previous_write_version < account.meta.write_version);
assert!(previous_write_version < account.meta.write_version_obsolete);
}
previous_write_version = Some(account.meta.write_version);
previous_write_version = Some(account.meta.write_version_obsolete);
if notified_accounts.contains(&account.meta.pubkey) {
notify_stats.skipped_accounts += 1;
return;

View File

@ -135,7 +135,7 @@ pub mod tests {
let hash = Hash::new(&[2; 32]);
let stored_meta = StoredMeta {
/// global write version
write_version: 0,
write_version_obsolete: 0,
/// key for the account
pubkey,
data_len: 43,

View File

@ -150,7 +150,10 @@ impl<'a: 'b, 'b, T: ReadableAccount + Sync + 'b, U: StorableAccounts<'a, T>, V:
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct StoredMeta {
/// global write version
pub write_version: StoredMetaWriteVersion,
/// This will be made completely obsolete such that we stop storing it.
/// We will not support multiple append vecs per slot anymore, so this concept is no longer necessary.
/// Order of stores of an account to an append vec will determine 'latest' account data per pubkey.
pub write_version_obsolete: StoredMetaWriteVersion,
/// key for the account
pub pubkey: Pubkey,
pub data_len: u64,
@ -656,7 +659,7 @@ impl AppendVec {
data_len: account
.map(|account| account.data().len())
.unwrap_or_default() as u64,
write_version: accounts.write_version(i),
write_version_obsolete: accounts.write_version(i),
};
let meta_ptr = &stored_meta as *const StoredMeta;
let account_meta_ptr = &account_meta as *const AccountMeta;
@ -716,7 +719,7 @@ pub mod tests {
StorableAccountsWithHashesAndWriteVersions::new_with_hashes_and_write_versions(
&account_data,
vec![&hash],
vec![data.0.write_version],
vec![data.0.write_version_obsolete],
);
self.append_accounts(&storable_accounts, 0)

View File

@ -39,7 +39,7 @@ pub fn create_test_account(sample: usize) -> (StoredMeta, AccountSharedData) {
let mut account = AccountSharedData::new(sample as u64, 0, &Pubkey::default());
account.set_data((0..data_len).map(|_| data_len as u8).collect());
let stored_meta = StoredMeta {
write_version: 0,
write_version_obsolete: 0,
pubkey: Pubkey::default(),
data_len: data_len as u64,
};

View File

@ -363,7 +363,7 @@ impl<'a> SnapshotMinimizer<'a> {
for alive_account in keep_accounts {
accounts.push(&alive_account.account);
hashes.push(alive_account.account.hash);
write_versions.push(alive_account.account.meta.write_version);
write_versions.push(alive_account.account.meta.write_version_obsolete);
}
let new_storage = self.accounts_db().get_store_for_shrink(slot, aligned_total);

View File

@ -195,7 +195,7 @@ impl<'a> StorableAccounts<'a, StoredAccountMeta<'a>>
self.1[index].hash
}
fn write_version(&self, index: usize) -> u64 {
self.1[index].meta.write_version
self.1[index].meta.write_version_obsolete
}
}
@ -238,7 +238,7 @@ impl<'a> StorableAccounts<'a, StoredAccountMeta<'a>>
self.1[index].account.hash
}
fn write_version(&self, index: usize) -> u64 {
self.1[index].account.meta.write_version
self.1[index].account.meta.write_version_obsolete
}
}
#[cfg(test)]
@ -281,7 +281,7 @@ pub mod tests {
let executable = false;
let rent_epoch = 0;
let meta = StoredMeta {
write_version: 5,
write_version_obsolete: 5,
pubkey: pk,
data_len: 7,
};
@ -338,7 +338,7 @@ pub mod tests {
account.clone(),
starting_slot % max_slots,
StoredMeta {
write_version: 0, // just something
write_version_obsolete: 0, // just something
pubkey: pk,
data_len: u64::MAX, // just something
},

View File

@ -42,7 +42,7 @@ fn main() {
info!(
" account: {:?} version: {} lamports: {} data: {} hash: {:?}",
account.pubkey(),
account.meta.write_version,
account.meta.write_version_obsolete,
account.account_meta.lamports,
account.meta.data_len,
account.hash
@ -59,7 +59,7 @@ fn main() {
fn is_account_zeroed(account: &StoredAccountMeta) -> bool {
account.hash == &Hash::default()
&& account.meta.data_len == 0
&& account.meta.write_version == 0
&& account.meta.write_version_obsolete == 0
&& account.pubkey() == &Pubkey::default()
&& account.clone_account() == AccountSharedData::default()
}