-
Notifications
You must be signed in to change notification settings - Fork 27
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
Remove chia-blockchain dependency for most of chia_rs #887
base: main
Are you sure you want to change the base?
Conversation
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 really nice change. However, I think it would be good to check the correctness of this against the existing python implementation. One way to do that would be to break this off into a separate PR that still relies on the chia-blockchain
dependency to compare the result between the rust and python implementation. Can you think of another way to be confident in the correctness of this port?
Pull Request Test Coverage Report for Build 12992847296Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
@@ -4,7 +4,9 @@ | |||
pub const UI_ACTUAL_SPACE_CONSTANT_FACTOR: f32 = 0.78; | |||
|
|||
// TODO: Update this when new plot format releases | |||
pub fn expected_plot_size(k: u32) -> u64 { | |||
#[cfg(feature = "py-bindings")] | |||
#[pyo3::pyfunction] |
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 think you have to do #[cfg_attr(feature = "py-bindings", pyo3::pyfunction)]
instead?
fn sp_total_iters_impl(&self, py: Python<'_>, constants: &Bound<'_, PyAny>) -> PyResult<u128> { | ||
self.sp_sub_slot_total_iters_impl(py, constants)? | ||
.checked_add(self.sp_iters_impl(py, constants)? as u128) | ||
fn sp_iters_impl(&self, constants: &Bound<'_, PyAny>) -> PyResult<u64> { |
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.
now that these are implemented in rust, I don't think they should be limited to just the python bindings anymore. I imagine you put them here to simplify error handling, so make them return PyResult<>
. If you make them part of the rust type and make them return chia_error::Result<>
you could map those errors with map_err()
|
||
#[cfg(feature = "py-bindings")] | ||
#[pyo3::pyfunction] | ||
pub fn calculate_ip_iters( |
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.
do you feel like the unit tests below are sufficient to be confident that this is correct and identical to the python implementation?
I'm especially worried about integer width overflow
num_sps_sub_slot: int, | ||
num_sp_intervals_extra: int, | ||
sub_slot_iters: int, | ||
signage_point_index: int, | ||
required_iters: int, | ||
) -> int: ... |
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.
are all of these plain int
in the python implementation? it seems like it might make sense to make them sized ints
) | ||
assert sp_iters > ip_iters | ||
|
||
# def test_win_percentage(self): |
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 think this commented-out code can be removed, right?
|
||
br = get_block_record(rng, ssi=ssi, spi=13, ri=1) | ||
res = br.ip_iters_impl(DEFAULT_CONSTANTS) | ||
assert res is not None |
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.
not None
, it seems like the wrong value would also pass here
This PR removes imports from
test_blscache.py
and deletestest_program_fidelity.py
.It also removes the python running from
block_record.rs
by implementingpot_iterations.py
inside the class