Skip to content
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

Implement macro for Digest creation from long hex string #984

Merged
merged 3 commits into from
Nov 26, 2024

Conversation

Fumuran
Copy link
Contributor

@Fumuran Fumuran commented Nov 25, 2024

This PR implements a new digest_from_hex! macro for convenient creation of Digest from long hex string.

Closes: #872

@Fumuran Fumuran linked an issue Nov 25, 2024 that may be closed by this pull request

// KERNEL V0 PROCEDURES
// ================================================================================================

/// Hashes of all dynamically executed procedures from the kernel 0.
pub const KERNEL0_PROCEDURES: [Digest; 32] = [
// account_vault_add_asset
digest!(0xa9fe41a58d609bc6, 0xca49c09c352213a4, 0x30f55868815fc5, 0x84f2f2540b3d335e),
digest_from_hex!("0xc69b608da541fea9a41322359cc049cac55f816858f530005e333d0b54f2f284"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be a test for these macros and its validations? Maybe comparing the old digest macro with the new one as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about it, but in fact every test which internally uses the kernel procedures is checking the correctness of this macro, otherwise it will fail. That's why I wasn't sure whether do we need to create a dedicated tests for this macro.

Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thank you! I left a few small comments/questions inline.

objects/src/lib.rs Outdated Show resolved Hide resolved
objects/src/lib.rs Outdated Show resolved Hide resolved
objects/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@PhilippGackstatter PhilippGackstatter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

Comment on lines 87 to 88
mut hex_bytes: &[u8],
mut upper_limit: usize,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mut hex_bytes: &[u8],
mut upper_limit: usize,
hex_bytes: &[u8],
upper_limit: usize,

Nit: These don't need to be mutable.

Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good! Thank you!

@bobbinth bobbinth merged commit d50c50d into next Nov 26, 2024
9 checks passed
@bobbinth bobbinth deleted the andrew-macro-for-digest branch November 26, 2024 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Macro for Digest creation from long hex string
5 participants