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

Feature - Epoch boundary recompilation phase #33477

Merged

Conversation

Lichtso
Copy link
Contributor

@Lichtso Lichtso commented Oct 1, 2023

Problem

This is a different approach to the problem as #32172 was flawed. It ended the recompilation phase at the first block after the epoch boundary, but we need to wait for a rerooting to be sure that we won't replay any blocks from before the epoch boundary anymore.

Summary of Changes

  • Adds LoadedPrograms::upcoming_environments: Which is Some during the recompilation phase, even if there is no change to any environment.
  • Moves LoadedPrograms::prune_feature_set_transition() into LoadedPrograms::prune(): Delays it to happen on the first rerooting after the epoch boundary.
  • Removes the manually managed FEATURES_AFFECTING_RBPF list: Because we can now automatically detect changes by using BuiltinProgram::eq().
  • Adds parameter recompile to Bank::load_program(): Which is Some when called from within the recompilation phase.

@Lichtso Lichtso requested a review from pgarg66 October 1, 2023 21:55
@Lichtso Lichtso force-pushed the feature_transition_recompilation branch 3 times, most recently from c74fd46 to 496b3d8 Compare October 2, 2023 09:09
runtime/src/bank/tests.rs Outdated Show resolved Hide resolved
@Lichtso Lichtso force-pushed the feature_transition_recompilation branch 4 times, most recently from 2cd41cf to b82339f Compare October 2, 2023 23:22
runtime/src/bank/tests.rs Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Oct 3, 2023

Codecov Report

Merging #33477 (a5db6d5) into master (1814b2b) will decrease coverage by 0.1%.
The diff coverage is 77.2%.

@@            Coverage Diff            @@
##           master   #33477     +/-   ##
=========================================
- Coverage    81.9%    81.9%   -0.1%     
=========================================
  Files         809      809             
  Lines      218062   218105     +43     
=========================================
+ Hits       178672   178684     +12     
- Misses      39390    39421     +31     

@Lichtso Lichtso force-pushed the feature_transition_recompilation branch 3 times, most recently from e5d13d3 to 0fac427 Compare October 3, 2023 13:51
pgarg66
pgarg66 previously approved these changes Oct 3, 2023
Copy link
Contributor

@pgarg66 pgarg66 left a comment

Choose a reason for hiding this comment

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

Looks great!

@Lichtso Lichtso force-pushed the feature_transition_recompilation branch 3 times, most recently from 7a850e0 to b9c2b05 Compare October 13, 2023 17:41
@Lichtso Lichtso force-pushed the feature_transition_recompilation branch from b9c2b05 to 3a9ca95 Compare October 13, 2023 20:48
@Lichtso Lichtso force-pushed the feature_transition_recompilation branch 3 times, most recently from a29f8cc to 0d25f22 Compare October 25, 2023 08:23
@Lichtso Lichtso added the v1.17 PRs that should be backported to v1.17 label Oct 25, 2023
@Lichtso Lichtso force-pushed the feature_transition_recompilation branch from 0d25f22 to a5814fe Compare October 26, 2023 19:27
runtime/src/bank.rs Outdated Show resolved Hide resolved
runtime/src/bank.rs Outdated Show resolved Hide resolved
let mut loaded_programs_cache = new.loaded_programs_cache.write().unwrap();
loaded_programs_cache.replenish(key, recompiled);
}
} else if new.epoch() != loaded_programs_cache.latest_root_epoch
Copy link
Contributor

Choose a reason for hiding this comment

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

Could a malicious leader trigger this check by adding a bank in a future epoch? Does it make sense to make this check more specific (e.g. new.epoch == loaded_programs_cache.latest_root_epoch + 1, and slot is within N slots in the new epoch)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aren't leaders bound by the leader schedule in that they can't just submit a block for any slot, but only the one they were assigned to?

Copy link
Contributor

Choose a reason for hiding this comment

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

I remember seeing this in one of the outages where the leader submitted a slot way in future. Maybe its not an issue anymore due to other checks.

Would making this check more strict cause any problems? It can be done in a separate PR if that's preferred.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://github.com/solana-labs/solana/blob/1814b2bc81aca29b322f8e1f280494c1b9ee6b32/turbine/src/sigverify_shreds.rs#L141C6-L141C6

Would making this check more strict cause any problems?

Probably not, but haven't thought it through.

@Lichtso Lichtso force-pushed the feature_transition_recompilation branch from a5814fe to 5347856 Compare October 27, 2023 11:02
@Lichtso Lichtso force-pushed the feature_transition_recompilation branch 2 times, most recently from 8e7c67d to 1bad18d Compare October 27, 2023 17:51
@Lichtso Lichtso force-pushed the feature_transition_recompilation branch from 1bad18d to a5db6d5 Compare October 27, 2023 18:09
@Lichtso Lichtso merged commit a9509f5 into solana-labs:master Nov 9, 2023
32 checks passed
@Lichtso Lichtso deleted the feature_transition_recompilation branch November 9, 2023 12:11
mergify bot pushed a commit that referenced this pull request Nov 9, 2023
* Adds LoadedPrograms::upcoming_environments.

* Moves LoadedPrograms::prune_feature_set_transition() into LoadedPrograms::prune().

* Adds parameter recompile to Bank::load_program().

* Sets latest_root_slot/epoch and environments in Bank::finish_init().

* Removes FEATURES_AFFECTING_RBPF list.

* Adjusts test_feature_activation_loaded_programs_recompilation_phase().

(cherry picked from commit a9509f5)

# Conflicts:
#	runtime/src/bank/tests.rs
Lichtso added a commit that referenced this pull request Nov 9, 2023
* Adds LoadedPrograms::upcoming_environments.

* Moves LoadedPrograms::prune_feature_set_transition() into LoadedPrograms::prune().

* Adds parameter recompile to Bank::load_program().

* Sets latest_root_slot/epoch and environments in Bank::finish_init().

* Removes FEATURES_AFFECTING_RBPF list.

* Adjusts test_feature_activation_loaded_programs_recompilation_phase().

(cherry picked from commit a9509f5)
Lichtso added a commit that referenced this pull request Nov 9, 2023
…) (#34003)

Feature - Epoch boundary recompilation phase (#33477)

* Adds LoadedPrograms::upcoming_environments.

* Moves LoadedPrograms::prune_feature_set_transition() into LoadedPrograms::prune().

* Adds parameter recompile to Bank::load_program().

* Sets latest_root_slot/epoch and environments in Bank::finish_init().

* Removes FEATURES_AFFECTING_RBPF list.

* Adjusts test_feature_activation_loaded_programs_recompilation_phase().

(cherry picked from commit a9509f5)

Co-authored-by: Alexander Meißner <AlexanderMeissner@gmx.net>
anwayde pushed a commit to firedancer-io/solana that referenced this pull request Nov 16, 2023
…na-labs#33477) (solana-labs#34003)

Feature - Epoch boundary recompilation phase (solana-labs#33477)

* Adds LoadedPrograms::upcoming_environments.

* Moves LoadedPrograms::prune_feature_set_transition() into LoadedPrograms::prune().

* Adds parameter recompile to Bank::load_program().

* Sets latest_root_slot/epoch and environments in Bank::finish_init().

* Removes FEATURES_AFFECTING_RBPF list.

* Adjusts test_feature_activation_loaded_programs_recompilation_phase().

(cherry picked from commit a9509f5)

Co-authored-by: Alexander Meißner <AlexanderMeissner@gmx.net>
anwayde pushed a commit to firedancer-io/solana that referenced this pull request Nov 16, 2023
…na-labs#33477) (solana-labs#34003)

Feature - Epoch boundary recompilation phase (solana-labs#33477)

* Adds LoadedPrograms::upcoming_environments.

* Moves LoadedPrograms::prune_feature_set_transition() into LoadedPrograms::prune().

* Adds parameter recompile to Bank::load_program().

* Sets latest_root_slot/epoch and environments in Bank::finish_init().

* Removes FEATURES_AFFECTING_RBPF list.

* Adjusts test_feature_activation_loaded_programs_recompilation_phase().

(cherry picked from commit a9509f5)

Co-authored-by: Alexander Meißner <AlexanderMeissner@gmx.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v1.17 PRs that should be backported to v1.17
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants