Simplify compute_asset_desc_hash function#161
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR simplifies the compute_asset_desc_hash function in accordance with the new ZIP227 spec by requiring nonempty asset descriptions and removing now-unneeded error variants.
- Converts asset_desc from a slice to a NonEmpty type in several modules.
- Eliminates error handling for invalid sizes by using NonEmpty::from_slice with an expect message.
- Removes the is_asset_desc_of_valid_size helper and related error variants.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/zsa.rs | Updated compute_asset_desc_hash call to use NonEmpty rather than unwrap a Result. |
| tests/issuance_global_state.rs | Adjusted multiple compute_asset_desc_hash calls to adopt the NonEmpty approach. |
| src/note/asset_base.rs | Modified random asset generation to use NonEmpty and removed the unused asset_desc size check. |
| src/issuance.rs | Simplified compute_asset_desc_hash; updated tests and removed error propagation. |
| src/bundle/burn_validation.rs | Updated compute_asset_desc_hash invocation to use NonEmpty. |
52c3063 to
784dd06
Compare
|
I just rebased on zsa1 branch |
PaulLaux
left a comment
There was a problem hiding this comment.
added some comments for extra consistency. Also:
- please fix
issue_bundle_asset_desc_roundtrip()I'm not sure what it checks now but it is surly not seet_desc roundtrip. Let's simplify it to check one asset_desc roundtrip. The end of the test should compute the hash again and check that we can get it viaget_action_by_desc_hash()
Separate " // Not well-formed as per Unicode 15.0 specification, Section 3.9, D92" to a different test. We want to fail on non-unicode strings. right?
PaulLaux
left a comment
There was a problem hiding this comment.
approved with minor comments
| get_burn_tuple(b"Asset 1", 20), | ||
| get_burn_tuple(b"Asset 3", 10), | ||
| get_burn_tuple( | ||
| &compute_asset_desc_hash(&NonEmpty::from_slice(b"Asset 1").unwrap()), |
There was a problem hiding this comment.
can we add a From<> trait for NonEmpty in our code so we can do b"Asset 1".into() ?
There was a problem hiding this comment.
I think it is not possible because neither From nor NonEmpty are defined in the current crate.

Update compute_asset_desc_hash function
Update get_burn_tuple function
Cleanup unused code