-
Notifications
You must be signed in to change notification settings - Fork 302
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
MemoPlaintext string length enforced, TransactionPlan panic avoided #3585
Conversation
let memo_hash = self | ||
.memo | ||
.as_ref() | ||
.map(|memo_plan| { | ||
memo_plan | ||
.memo() | ||
.expect("can compute memo ciphertext") | ||
.effect_hash() | ||
}) | ||
// If the memo is not present, use the all-zero hash to record its absence in | ||
// the overall effect hash. | ||
.unwrap_or_default(); | ||
let memo_hash = match self.memo { | ||
Some(ref memo) => memo.memo()?.effect_hash(), | ||
None => EffectHash::default(), | ||
}; |
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 a significant change in style compared to the previous implementation, not sure if that's appropriate
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 like the result of the change better, it's more succinct this way.
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 like this a lot; I feel like it would be worth it to refactor MemoPlaintext to have a guarded constructor, but I'll take care of that in a separate PR.
identified a panic when working on web transactions.
added checks to verify text length is under maximum when deserializing from
pbt::MemoPlaintext
orVec<u8>
, to prevent the creation of impossible memos. perhapsMemoPlaintext
should use private fields and a constructor to enforce format limitations that cannot be specified by protobuf, but this is a smaller change.ultimately the source of the panic was an
expect
used inTransactionPlan::effect_hash
to unwrap a potential error, this is now bubbled asanyhow::Result