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

Reverify programs that are extended using ExtendProgram #31886

Merged
merged 8 commits into from
Jun 1, 2023

Conversation

pgarg66
Copy link
Contributor

@pgarg66 pgarg66 commented May 30, 2023

Problem

The programs extended via ExtendProgram instruction need re-verification, as the updated program may return different verification result than the original program.

Summary of Changes

  • Compile and verify the program with the extended size
  • Add a cooldown of 1 slot to prevent repeated extension of the program in the same slot
  • Add a new unit test for the cooldown
  • Update existing tests to deploy a program and extend it

Fixes #

@pgarg66 pgarg66 requested a review from Lichtso May 30, 2023 22:54
@codecov
Copy link

codecov bot commented May 30, 2023

Codecov Report

Merging #31886 (034ed90) into master (8203c6e) will decrease coverage by 0.1%.
The diff coverage is 78.7%.

@@            Coverage Diff            @@
##           master   #31886     +/-   ##
=========================================
- Coverage    81.9%    81.9%   -0.1%     
=========================================
  Files         752      753      +1     
  Lines      206799   206885     +86     
=========================================
+ Hits       169480   169501     +21     
- Misses      37319    37384     +65     

@Lichtso
Copy link
Contributor

Lichtso commented May 31, 2023

Maybe we should actually perform the verification / compilation inside the instruction (like we do for upgrades) so that it can fail the TX if the verification fails.

@mvines mvines added the v1.16 PRs that should be backported to v1.16 label May 31, 2023
@pgarg66 pgarg66 requested a review from Lichtso May 31, 2023 20:21
Lichtso
Lichtso previously approved these changes May 31, 2023
@pgarg66 pgarg66 requested a review from Lichtso May 31, 2023 22:29
@pgarg66 pgarg66 merged commit 449f92e into solana-labs:master Jun 1, 2023
@pgarg66 pgarg66 deleted the re-verify-program-extend branch June 1, 2023 13:18
mergify bot pushed a commit that referenced this pull request Jun 1, 2023
@jstarry
Copy link
Contributor

jstarry commented Jul 3, 2023

Note that since this change now updates the program data clock slot, it's no longer possible to extend and update a program in the same slot (or transaction for that matter). I don't think it's a great dev experience that two separate transactions will need to be created for program upgrades but the extend program instruction is still an improvement over the current dev experience so I think it's ok for now.

invoke_context,
program_key,
&program_id,
UpgradeableLoaderState::size_of_program().saturating_add(new_len),
Copy link
Contributor

Choose a reason for hiding this comment

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

I think new_len should already be the full account size, why is size_of_program added here as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you are right, this is a bug, probably copy pasta.
A fix should be backported before the feature is activated.

@pgarg66 Thoughts?

Copy link
Contributor

@Lichtso Lichtso Jul 3, 2023

Choose a reason for hiding this comment

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

Taking it back, this is correct behavior (consistent with v1.14). This is the sum of the proxy account plus the data account. The value is used in transaction loading for the TX wide loading limit and both accounts contribute to that.

https://github.com/pgarg66/solana/blob/034ed90aca470fbde2719e982b5b13d0680876e2/runtime/src/accounts.rs#L400

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
v1.16 PRs that should be backported to v1.16
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants