-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Cleanup load_program() in bank.rs #32146
Cleanup load_program() in bank.rs #32146
Conversation
d35b78b
to
2de326c
Compare
Codecov Report
@@ Coverage Diff @@
## master #32146 +/- ##
=======================================
Coverage 82.0% 82.0%
=======================================
Files 780 780
Lines 210860 210843 -17
=======================================
+ Hits 172944 172963 +19
+ Misses 37916 37880 -36 |
2de326c
to
cec962c
Compare
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.
Looks like we are missing a lot of test coverage for all the ways load_program()
can go wrong.
runtime/src/bank.rs
Outdated
}) = transaction_accounts[0].1.state() | ||
|
||
if !solana_bpf_loader_program::check_loader_id(program_account.owner()) { | ||
return ProgramAccountLoadResult::InvalidAccountData; |
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 this originally returned InstructionError::IncorrectProgramId
in load_program_from_account()
and all errors from there were turned into LoadedProgramType::FailedVerification
in load_program()
. But it should be unreachable, so try placing a debug_assert(solana_bpf_loader_program::check_loader_id();
here instead.
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.
The exact error codes between load_program_from_account()
and load_program()
might have changed but that is irrelevant since load_program()
corrects all of them again and load_program_from_account()
is not used anywhere else.
Problem
The load_program function can use some streamlining and cleanup. The old code was written because of executor cache usage of bpf_loader. Since then the executor cache code has been deleted.
Summary of Changes
load_program()
to remove the call toload_program_from_account()
load_program_from_account()
Fixes #