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 |
| 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.
Do we need pubkey in both of these vectors? Would an index suffice?
There was a problem hiding this comment.
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.
| 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.
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.
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_accountsparameter ofmock_process_instruction()to be split intransaction_accountsandinstruction_accounts.keyed_accountparameter should be replaced by the structAccountMetaandinstruction_accounts(see discussion in #20448).accountsvariable.transaction_accountsmapping should always be bijective.Summary of Changes
RcfromRefcell<AccountSharedData>in the program-runtimeTransactionError::AccountBorrowOutstandingobsolete, but does not remove it yetFixes #