-
Notifications
You must be signed in to change notification settings - Fork 268
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
Fix: deploy program on last slot of epoch during environment change #101
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few minor nits but otherwise looks good to me.
The logic in this PR hinges on the fact that LoadedPrograms::upcoming_environments is always set correctly. That field is set here https://github.com/pgarg66/solana/blob/9044bb8f08a0ade2d1e42ca1ebd9fabf2757506c/runtime/src/bank.rs#L1379. Whenever a bank for any slot within slots_in_recompilation_phase
from the epoch end is created, if upcoming_environments isn't already set, it will be set. So even in the case of skipped slots, by the time we get to tx execution for a given bank, upcoming_environments is guaranteed to be set correctly.
hit_max_limit: false, | ||
} | ||
} | ||
|
||
/// Returns the current environments depending on the given epoch | ||
pub fn get_environments_for_epoch(&self, epoch: Epoch) -> &ProgramRuntimeEnvironments { | ||
if epoch != self.latest_root_epoch { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works, but I think >
instead of !=
would make the logic clearer (although I know that in other places we use !=, so feel free to leave != if you prefer to be consistent)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to leave it as is for now. I am not 100% sure why we have !=
check in the other function. Just want to make sure we don't oversee some actual condition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I chose ==
and !=
over <=
and >
to avoid off-by-one-errors such as writing <
instead of <=
. That is all, don't see a semantic reason why we need to stick with ==
.
&self, | ||
epoch: Epoch, | ||
) -> Option<ProgramRuntimeEnvironments> { | ||
if epoch == self.latest_root_epoch { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, I'd prefer <=
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to leave it as is for now. I am not 100% sure why we have !=
check in the other function. Just want to make sure we don't oversee some actual condition.
6150a73
to
10549ea
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #101 +/- ##
=========================================
- Coverage 81.9% 81.9% -0.1%
=========================================
Files 838 838
Lines 226929 227066 +137
=========================================
+ Hits 185924 186024 +100
- Misses 41005 41042 +37 |
@Lichtso FYI. |
239f348
to
ff5995a
Compare
155cb95
to
1e53616
Compare
1e53616
to
3f994fe
Compare
@Lichtso, @alessandrod could you help review this? |
@@ -239,6 +239,24 @@ macro_rules! register_feature_gated_function { | |||
}; | |||
} | |||
|
|||
pub fn morph_into_deployment_environment_v1( | |||
from: Arc<BuiltinProgram<InvokeContext>>, | |||
) -> Result<BuiltinProgram<InvokeContext>, Error> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably do this in RBPF instead and have a set_config
or a copy constructor there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to push an update to rBPF crate for this?
We also need to backport it to v1.18. So maybe leave this here for time being, and remove it from master once rBPF change is available?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove it from master in the next RBPF release.
3f994fe
to
7de6428
Compare
448b611
to
2655981
Compare
42bb424
to
6b09337
Compare
Backports to the beta branch are to be avoided unless absolutely necessary for fixing bugs, security issues, and perf regressions. Changes intended for backport should be structured such that a minimum effective diff can be committed separately from any refactoring, plumbing, cleanup, etc that are not strictly necessary to achieve the goal. Any of the latter should go only into master and ride the normal stabilization schedule. Exceptions include CI/metrics changes, CLI improvements and documentation updates on a case by case basis. |
…101) * Fix: deploy program on last slot of epoch during environment change * solana-runtime: deploy at last epoch slot test * disable deployment of sol_alloc_free * Move tx-batch-constructor to its own function * use new_from_cache --------- Co-authored-by: Alessandro Decina <[email protected]> (cherry picked from commit 91b1ee3) # Conflicts: # ledger-tool/src/program.rs # runtime/src/bank/tests.rs # svm/src/transaction_processor.rs
…101) * Fix: deploy program on last slot of epoch during environment change * solana-runtime: deploy at last epoch slot test * disable deployment of sol_alloc_free * Move tx-batch-constructor to its own function * use new_from_cache --------- Co-authored-by: Alessandro Decina <[email protected]> (cherry picked from commit 91b1ee3)
…hange (backport of anza-xyz#101) (anza-xyz#387)
Problem
On runtime environment change, the program deployed in the last slot of the prior epoch will use incorrect environment. This will also prevent the loading of the program in future epochs with the correct runtime environment.
Summary of Changes
The problem happens because the effective slot for the deployed program is in the next epoch, where the new environment becomes effective.
This change updates the program deployment procedure, to use the environment of the epoch where the program actually becomes effective.
Fixes #