-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Refactor: Removes Rc
from Refcell<AccountSharedData>
in the program-runtime
#21927
Refactor: Removes Rc
from Refcell<AccountSharedData>
in the program-runtime
#21927
Conversation
7ebd593
to
bfbbc8e
Compare
bfbbc8e
to
c829e3e
Compare
c829e3e
to
6d19ba1
Compare
Codecov Report
@@ Coverage Diff @@
## master #21927 +/- ##
========================================
Coverage 81.2% 81.3%
========================================
Files 516 516
Lines 144353 144777 +424
========================================
+ Hits 117315 117772 +457
+ Misses 27038 27005 -33 |
@@ -847,50 +847,38 @@ pub struct MockInvokeContextPreparation { | |||
pub fn prepare_mock_invoke_context( | |||
program_indices: &[usize], | |||
instruction_data: &[u8], | |||
keyed_accounts: &[(bool, bool, Pubkey, Rc<RefCell<AccountSharedData>>)], | |||
transaction_accounts: Vec<(Pubkey, AccountSharedData)>, | |||
instruction_accounts: Vec<AccountMeta>, |
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 we need pubkey in both of these vectors? Would an index suffice?
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.
An index would suffice for the instruction_accounts
, but then AccountMeta
would have to go.
So, as that is only for the tests / mocks I think we can live with that inefficiency for now.
Once #21706 has landed I can extend its structures to the tests as well.
@@ -847,50 +847,38 @@ pub struct MockInvokeContextPreparation { | |||
pub fn prepare_mock_invoke_context( | |||
program_indices: &[usize], | |||
instruction_data: &[u8], | |||
keyed_accounts: &[(bool, bool, Pubkey, Rc<RefCell<AccountSharedData>>)], | |||
transaction_accounts: Vec<(Pubkey, AccountSharedData)>, |
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.
Is this same paradign going to be extended beyond mock? If so, are we going to be allocating a lot of vectors as we pass this information around?
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.
No, the Vec
allocation only happens this way for the tests / mocks, and only for now, as it might be refined to become index based as well (see comment above). The rest of the program-runtime will be directly migrated to the new structs defined in #21706 and they work based on references and indices, so there should not be more allocation happening than what we had until now.
Problem
Continuation of #21882.
keyed_accounts
parameter ofmock_process_instruction()
to be split intransaction_accounts
andinstruction_accounts
.keyed_account
parameter should be replaced by the structAccountMeta
andinstruction_accounts
(see discussion in #20448).accounts
variable.transaction_accounts
mapping should always be bijective.Summary of Changes
Rc
fromRefcell<AccountSharedData>
in the program-runtimeTransactionError::AccountBorrowOutstanding
obsolete, but does not remove it yetFixes #