Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make StakeHistory clone-on-write #21573

Merged
merged 1 commit into from
Dec 3, 2021
Merged

Make StakeHistory clone-on-write #21573

merged 1 commit into from
Dec 3, 2021

Conversation

brooksprumo
Copy link
Contributor

@brooksprumo brooksprumo commented Dec 2, 2021

Problem

Stake history is cloned into every bank, regardless if is is changed or not.

Summary of Changes

Implement clone-on-write semantics for stake history.

Comment on lines +8 to +10
/// The SDK's stake history with clone-on-write semantics
#[derive(Default, Clone, PartialEq, Debug, Deserialize, Serialize, AbiExample)]
pub struct StakeHistory(Arc<StakeHistoryInner>);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Similar to StageDelegations in #21542, we need an Arc here since banks are sent across threads (i.e. the accounts background services).

@@ -312,7 +312,7 @@ mod test_bank_serialize {

// This some what long test harness is required to freeze the ABI of
// Bank's serialization due to versioned nature
#[frozen_abi(digest = "5vYNtKztrNKfb6TtRktXdLCbU73rJSWhLwguCHLvFujZ")]
#[frozen_abi(digest = "BJQdQMuXV3349GUWo9Gq3wqxbxV1hJ1jjq9JmXBY3zRV")]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Assuming #21542 gets merged first, this digest will need to change again.

@@ -14,7 +17,6 @@ use {
self,
state::{Delegation, StakeActivationStatus, StakeState},
},
stake_history::StakeHistory,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pretty nice! The only visible change to stakes.rs is where to get StakeHistory from.

@brooksprumo brooksprumo marked this pull request as ready for review December 2, 2021 21:35
@brooksprumo brooksprumo requested a review from jstarry December 2, 2021 21:35
@codecov
Copy link

codecov bot commented Dec 2, 2021

Codecov Report

Merging #21573 (12e21ff) into master (0ef1b25) will increase coverage by 0.0%.
The diff coverage is 100.0%.

@@           Coverage Diff           @@
##           master   #21573   +/-   ##
=======================================
  Coverage    81.6%    81.6%           
=======================================
  Files         508      509    +1     
  Lines      142340   142380   +40     
=======================================
+ Hits       116155   116243   +88     
+ Misses      26185    26137   -48     

jstarry
jstarry previously approved these changes Dec 3, 2021
@mergify mergify bot dismissed jstarry’s stale review December 3, 2021 15:10

Pull request has been modified.

@brooksprumo brooksprumo merged commit 46fe561 into master Dec 3, 2021
@brooksprumo brooksprumo deleted the stake5 branch December 3, 2021 18:10
jbiseda pushed a commit to jbiseda/solana that referenced this pull request Dec 6, 2021
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.

2 participants