Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

deserialize StakeHistory incrementally #35252

Closed
wants to merge 12 commits into from

Conversation

2501babe
Copy link
Contributor

Problem

with 512 maximum entries, each of which is four u64, stake history can be as large as 16kb. the current stake program makes the data structure available as part of the transaction context, but in moving to bpf, we don't want to have to deserialize the entire thing and use half our heap, since stake history is used in the stake program typically (perhaps exclusively) to locate only one 32 byte entry for a given epoch

Summary of Changes

this adds a new struct StakeHistoryData, which is a newtype wrapper over the raw account data. it also adds a trait StakeHistoryGetEntry, which provides a function equivalent to StakeHistory::get(), and changes some key consumers of StakeHistory to accept T: StakeHistoryGetEntry instead. this allows existing functionality to (NOTE: mostly, see comments) remain unchanged, while also permitting new functionality for the bpf stake program

the impl for StakeHistoryData does the same thing as StakeHistory::get(): search for an entry matching a given epoch and return it, parsing only as much of the data is needed to locate the relevant entry

Copy link

codecov bot commented Feb 20, 2024

Codecov Report

Attention: Patch coverage is 84.21053% with 12 lines in your changes are missing coverage. Please review.

Project coverage is 81.6%. Comparing base (d472725) to head (5cadc74).
Report is 108 commits behind head on master.

❗ Current head 5cadc74 differs from pull request most recent head cd6d8a8. Consider uploading reports for the commit cd6d8a8 to get more accurate results

Additional details and impacted files
@@            Coverage Diff            @@
##           master   #35252     +/-   ##
=========================================
- Coverage    81.6%    81.6%   -0.1%     
=========================================
  Files         833      833             
  Lines      224761   224820     +59     
=========================================
+ Hits       183481   183501     +20     
- Misses      41280    41319     +39     

@willhickey
Copy link
Contributor

This repository is no longer in use. Please re-open this pull request in the agave repo: https://github.com/anza-xyz/agave

@willhickey willhickey closed this Mar 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants