Skip to content

Moves status cache serde-for-snapshots code into own module#7604

Merged
brooksprumo merged 1 commit intoanza-xyz:masterfrom
brooksprumo:snap/serde-transaction-error
Aug 20, 2025
Merged

Moves status cache serde-for-snapshots code into own module#7604
brooksprumo merged 1 commit intoanza-xyz:masterfrom
brooksprumo:snap/serde-transaction-error

Conversation

@brooksprumo
Copy link
Copy Markdown

@brooksprumo brooksprumo commented Aug 19, 2025

Problem

The SDK's TransactionError and InstructionError changed, which caused snapshots to break due to the serialization of the status cache. This was mitigated in #7559 by airgap-ing the TransactionError type, and performing conversions when serializing and deserializing the status cache.

This new code was living in snapshot_bank_utils.rs, which was not ideal. For one, it required snapshot_utils.rs to import from snapshot_bank_utils, and the whole point of these two files being separate was so that snapshot_utils.rs did not import from snapshot_bank_utils.rs nor anything from Bank.

For two, there is already precedent for putting these "serde" types within the serde_snapshot module.

Summary of Changes

Move the serde code of the status cache into its own module under serde_snapshot.

Note, no functionality was changed in this PR, minus the bench (see comments inline below).

@brooksprumo brooksprumo self-assigned this Aug 19, 2025
@brooksprumo brooksprumo force-pushed the snap/serde-transaction-error branch from 8130933 to cbc6e3c Compare August 20, 2025 03:21
@brooksprumo brooksprumo force-pushed the snap/serde-transaction-error branch from cbc6e3c to 5171076 Compare August 20, 2025 03:21
let path = tempfile::NamedTempFile::new().unwrap().into_temp_path();
bencher.iter(|| {
let _ = serialize_status_cache(&status_cache.root_slot_deltas(), &path).unwrap();
let _ = serialize(&status_cache.root_slot_deltas()).unwrap();
Copy link
Copy Markdown
Author

@brooksprumo brooksprumo Aug 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was added in #7593 to cleanup some tasks from #7559. One was adding this bench. This bench is calling serialize_status_cache() (the fn I'm moving in this PR to a new module), and I realized it is writing to a file.

Microbenchmarks are notoriously finicky, and ones that hit disk are even more so. I've moved this one back to using the stock serialize method here (just like the other status cache bench above, bench_status_cache_serialize()). This also saves us from having to conditionally make serialize_status_cache() public beyond just the crate.

We have metrics for the actual runtime of serialize_status_cache(), and I feel that is sufficient for our needs here.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok no worries, that's fine. Just be aware that bincode::serialize on the status cache isn't really what's being run in snapshots with the current code -- we're converting to the serde types and then calling bincode::serialize on those.

@brooksprumo brooksprumo marked this pull request as ready for review August 20, 2025 03:45
@brooksprumo brooksprumo requested a review from joncinque August 20, 2025 03:53
@brooksprumo
Copy link
Copy Markdown
Author

@joncinque I realize that I led you astray in #7593, sorry about that! Please accept my work here as penance.

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 28.91986% with 204 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.4%. Comparing base (c68c510) to head (5171076).

Additional details and impacted files
@@            Coverage Diff            @@
##           master    #7604     +/-   ##
=========================================
- Coverage    83.4%    83.4%   -0.1%     
=========================================
  Files         812      813      +1     
  Lines      364968   364971      +3     
=========================================
- Hits       304439   304387     -52     
- Misses      60529    60584     +55     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

@joncinque joncinque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Thanks for cleaning this up

let path = tempfile::NamedTempFile::new().unwrap().into_temp_path();
bencher.iter(|| {
let _ = serialize_status_cache(&status_cache.root_slot_deltas(), &path).unwrap();
let _ = serialize(&status_cache.root_slot_deltas()).unwrap();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok no worries, that's fine. Just be aware that bincode::serialize on the status cache isn't really what's being run in snapshots with the current code -- we're converting to the serde types and then calling bincode::serialize on those.

@brooksprumo brooksprumo merged commit 34fd542 into anza-xyz:master Aug 20, 2025
40 checks passed
@brooksprumo brooksprumo deleted the snap/serde-transaction-error branch August 20, 2025 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants