-
Notifications
You must be signed in to change notification settings - Fork 155
Feat/blake pow #766
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
Feat/blake pow #766
Conversation
b821811
to
5e3e142
Compare
icicle/include/icicle/hash/pow.h
Outdated
false; /**< True to run the pow solver asynchronously, false to run synchronously. Default is false. */ | ||
ConfigExtension* ext = nullptr; /**< Pointer to backend-specific configuration extensions. Default is nullptr. */ | ||
}; | ||
const uint8_t BLOCK_LEN = 64; |
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.
why not in the config struct?
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 this value is unused, forgot to delete it
icicle/include/icicle/hash/pow.h
Outdated
|
||
eIcicleError pow_solver( | ||
Hash hasher, | ||
uint8_t* challenge, |
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.
for consistency maybe make it std::byte* like hash APIs
icicle/include/icicle/hash/pow.h
Outdated
uint32_t padding_size, | ||
uint8_t bits, | ||
const PowConfig& config, | ||
bool* found, |
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.
Other ICICLE APIs in C++ use reference for outputs, not pointers so probably better to make it consistent.
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.
(1) I now noticed that you support them being device memory. Also the found boolean? This is a little confusing I think.
(2) Please add description to the API. It's unclear what should be the size of nonce for example etc.
wrappers/rust/icicle-hash/src/pow.rs
Outdated
use icicle_core::hash::{Hasher, HasherHandle}; | ||
use icicle_runtime::{config::ConfigExtension, errors::eIcicleError, memory::HostOrDeviceSlice, IcicleStreamHandle}; | ||
|
||
const PADDING_SIZE: u32 = 24; |
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 should be in the config I think
wrappers/rust/icicle-hash/src/pow.rs
Outdated
#[derive(Debug, Clone)] | ||
pub struct PowConfig { | ||
pub stream: IcicleStreamHandle, // `icicleStreamHandle` is represented as a raw pointer. | ||
pub is_challenge_on_device: bool, |
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.
Can you make the 'on-device' fields private? We usually set them instead of the users so they don't need to care about it.
|
||
let hasher = Blake3::new(0).unwrap(); | ||
|
||
let err = pow_solver(&hasher, input_host, BITS, &cfg, found_host, nonce_host, mined_hash_host); |
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.
(1) I am not sure I understand this API. How do you define the threshold value for the hash result?
(2) can you verify that with the nonce you found, the hashing indeed succeeds? in this test I mean
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.
Overall looks good, I left a few comments.
Is it equivalent to other implementations? which?
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.
left a comment here and couple in cuda impl
added |
icicle/include/icicle/hash/pow.h
Outdated
* @return eIcicleError Error code indicating success or failure of the operation. | ||
*/ | ||
eIcicleError pow_solver( | ||
Hash& hasher, |
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.
why hasher and challenge not const?
icicle/include/icicle/hash/pow.h
Outdated
* @return eIcicleError Error code indicating success or failure of the verification process. | ||
*/ | ||
eIcicleError pow_check( | ||
Hash& hasher, |
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.
here too
icicle/include/icicle/hash/pow.h
Outdated
* | ||
* @return eIcicleError Error code indicating success or failure of the verification process. | ||
*/ | ||
eIcicleError pow_check( |
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.
mayber pow_verify? I think clearer than pow_check
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.
Left small comments and then I will approve
uint8_t solution_bits, | ||
const PowConfig& config, | ||
bool& found, | ||
uint64_t& nonce, |
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.
is this always on host?
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.
yeah, I changed it because they are just single values
This PR adds POW algorithm
cuda-backend-branch: feat/blake-pow