-
Notifications
You must be signed in to change notification settings - Fork 4.7k
dcou: BorrowedAccount::set_data() #32424
dcou: BorrowedAccount::set_data() #32424
Conversation
befc183
to
2b1bf2a
Compare
/// | ||
/// Currently only used by tests and the program-test crate. |
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 need for these kinds of hopeful comments anymore. :)
Codecov Report
@@ Coverage Diff @@
## master #32424 +/- ##
=========================================
- Coverage 82.1% 82.1% -0.1%
=========================================
Files 778 778
Lines 210107 210106 -1
=========================================
- Hits 172596 172580 -16
- Misses 37511 37526 +15 |
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.
This is great. Thank you for fixing this!
@@ -64,7 +64,7 @@ where | |||
return Err(InstructionError::InvalidAccountData); | |||
} | |||
|
|||
proof_context_account.set_data(context_state_data)?; | |||
proof_context_account.set_data_from_slice(&context_state_data)?; |
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.
given
impl<T: Pod> ProofContextState<T> {
pub fn encode(
context_state_authority: &Pubkey,
proof_type: ProofType,
proof_context: &T,
) -> Vec<u8> {
let mut buf = Vec::with_capacity(size_of::<Self>());
buf.extend_from_slice(context_state_authority.as_ref());
buf.push(ToPrimitive::to_u8(&proof_type).unwrap());
buf.extend_from_slice(bytes_of(proof_context));
buf
}
Shoudn't we make encode write directly into the account, skipping the temporary vec + another memcpy?
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.
heh, i wasn't bothered enough to erase the newly extra memcpy. ;) sounds nice suggestion. @samkim-crypto could you address this after this pr is merged? or, should i do that in this pr? (if could, i want to offload to you.. thanks in advance!)
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.
Oh yes, sorry I missed this. Yes, I can definitely address this on a follow-up!
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.
Oh yes, sorry I missed this. Yes, I can definitely address this on a follow-up!
thanks very much! I just merged this.
btw, i also wondering this pr (sans dcou stuff) should be back ported to v1.16. (i guess these codes falls under some code path which is planned to activated for v1.16 release line?) I'm just guessing from rather active bp activities related to confidential tokens. |
Oh right, this addresses the proof program, so I think it should technically be backported. |
(this is the first use of the shiny
dev-context-only-utils
, introduced at #32169.)Problem
BorrowedAccount::set_data()
(which is demoted to test-only use at #28053) is still called in production code inzk-token-proof
program.Summary of Changes
cfg
-guard::set_data()
underdev-context-only-utils
for compile-time safety against these kinds of misuse in foreseeable future.Also, switch to use alternate fn for the call-site in the
zk-token-proof
program.