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

Restore ability for programs to upgrade themselves #20265

Merged
merged 4 commits into from
Sep 28, 2021

Conversation

CriesofCarrots
Copy link
Contributor

Problem

#20263 for master

In preventing inappropriate program write locks (#19637 + #19877 ), we assumed that programs would not need to upgrade themselves (ie. the program-id of a transaction is never writable). However, various governance programs depend on this ability, using their own governance mechanism for program upgrades.

Summary of Changes

Restore program-id write lock when the upgradeable loader id is present in the transaction; feature gate and require both restore_write_lock_when_upgradeable and demote_program_write_locks features for new functionality.
v1.6 vs v1.7/master compatibility will be restored when #20263 is released and these two features are activated on MNB

sdk/program/src/message/legacy.rs Outdated Show resolved Hide resolved
sdk/program/src/message/mapped.rs Outdated Show resolved Hide resolved
/// Inspect all message keys for the bpf upgradeable loader
pub fn is_upgradeable_loader_present(&self) -> bool {
match self {
Self::Legacy(message) => message.is_upgradeable_loader_present(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Side note, but @jstarry this might be clearer if the messages implemented a trait containing is_upgradeable_loader_present?

Copy link
Member

Choose a reason for hiding this comment

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

Sure, sounds good to me

jackcmay
jackcmay previously approved these changes Sep 27, 2021
runtime/src/accounts.rs Outdated Show resolved Hide resolved
@mergify mergify bot dismissed jackcmay’s stale review September 28, 2021 09:51

Pull request has been modified.

@codecov
Copy link

codecov bot commented Sep 28, 2021

Codecov Report

Merging #20265 (46957bc) into master (30bce9d) will increase coverage by 0.1%.
The diff coverage is 91.6%.

@@            Coverage Diff            @@
##           master   #20265     +/-   ##
=========================================
+ Coverage    82.6%    82.8%   +0.1%     
=========================================
  Files         522      487     -35     
  Lines      137655   135606   -2049     
  Branches      293        0    -293     
=========================================
- Hits       113755   112304   -1451     
+ Misses      23800    23302    -498     
+ Partials      100        0    -100     

@CriesofCarrots CriesofCarrots merged commit 2cd9dc9 into solana-labs:master Sep 28, 2021
mergify bot pushed a commit that referenced this pull request Sep 28, 2021
* Make helper associated fn

* Add feature definition

* Add handling to preserve program-id write lock when upgradeable loader is present; restore bpf upgrade-self test

* Use single feature

(cherry picked from commit 2cd9dc9)

# Conflicts:
#	runtime/src/accounts.rs
#	sdk/program/src/message.rs
#	sdk/program/src/message/mapped.rs
#	sdk/program/src/message/sanitized.rs
#	sdk/src/feature_set.rs
mergify bot added a commit that referenced this pull request Sep 29, 2021
…20295)

* Restore ability for programs to upgrade themselves (#20265)

* Make helper associated fn

* Add feature definition

* Add handling to preserve program-id write lock when upgradeable loader is present; restore bpf upgrade-self test

* Use single feature

(cherry picked from commit 2cd9dc9)

# Conflicts:
#	runtime/src/accounts.rs
#	sdk/program/src/message.rs
#	sdk/program/src/message/mapped.rs
#	sdk/program/src/message/sanitized.rs
#	sdk/src/feature_set.rs

* Fix conflicts

Co-authored-by: Tyera Eulberg <[email protected]>
Co-authored-by: Tyera Eulberg <[email protected]>
dankelleher pushed a commit to identity-com/solana that referenced this pull request Nov 24, 2021
* Make helper associated fn

* Add feature definition

* Add handling to preserve program-id write lock when upgradeable loader is present; restore bpf upgrade-self test

* Use single feature
frits-metalogix added a commit to identity-com/solana that referenced this pull request Nov 24, 2021
@CriesofCarrots CriesofCarrots deleted the upgrade-self branch March 17, 2023 17:14
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