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

Remove chia-blockchain dependency for most of chia_rs #887

Open
wants to merge 42 commits into
base: main
Choose a base branch
from

Conversation

matt-o-how
Copy link
Contributor

@matt-o-how matt-o-how commented Jan 17, 2025

This PR removes imports from test_blscache.py and deletes test_program_fidelity.py.

It also removes the python running from block_record.rs by implementing pot_iterations.py inside the class, and porting the code to a new file called pot_iterations.rs.

There is a corresponding PR to import this code from here in chia-blockchain: Chia-Network/chia-blockchain#19197

@matt-o-how matt-o-how changed the title Remove chia-blockchain dependency in tests Remove chia-blockchain dependency for most of chia_rs Jan 17, 2025
Copy link

coveralls-official bot commented Jan 17, 2025

Pull Request Test Coverage Report for Build 13772159949

Warning: 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

  • 287 of 312 (91.99%) changed or added relevant lines in 4 files are covered.
  • 350 unchanged lines in 16 files lost coverage.
  • Overall coverage increased (+0.02%) to 84.438%

Changes Missing Coverage Covered Lines Changed/Added Lines %
crates/chia-protocol/src/block_record.rs 28 40 70.0%
crates/chia-protocol/src/pot_iterations.rs 231 244 94.67%
Files with Coverage Reduction New Missed Lines %
crates/chia-protocol/src/lazy_node.rs 1 90.91%
crates/chia-puzzle-types/src/puzzles/singleton.rs 3 29.17%
crates/chia-puzzle-types/src/puzzles/standard.rs 3 76.32%
crates/chia-ssl/src/ca.rs 3 0.0%
crates/chia-puzzle-types/src/puzzles/offer.rs 4 95.4%
crates/chia_streamable_macro/src/lib.rs 7 95.96%
wheel/src/run_program.rs 7 76.67%
crates/chia-consensus/src/fast_forward.rs 8 97.88%
crates/chia-consensus/src/gen/conditions.rs 14 99.48%
wheel/src/api.rs 20 85.43%
Totals Coverage Status
Change from base Build 12797692864: 0.02%
Covered Lines: 14004
Relevant Lines: 16585

💛 - 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]
Copy link
Contributor

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

@matt-o-how what happened with this? Did you try it and it didn't work?

Copy link
Contributor

@arvidn arvidn left a comment

Choose a reason for hiding this comment

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

I would suggest you have tests that attempt to overflow integers, and especially look at all as casts and see if there's a way to truncate integers, in tests

arvidn
arvidn previously approved these changes Mar 10, 2025
// is necessary to store the entries in the plot.
// """

expected_plot_size(k).map_err(Into::into)
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought clippy suggested Ok(call()?) over this. I think they do the same thing, as the ?-operator also implicitly converts the error type

@arvidn
Copy link
Contributor

arvidn commented Mar 10, 2025

we should squash this when landing it

// / ((1_u128 << 256) * plot_size as u128);

// Ok(iters.max(1) as u64)
// }
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the story with this? Is the TODO still relevant? If we don't need it, we should probably remove it

@@ -129,3 +129,28 @@ def wrap_call(expr: str, br: Any) -> str:
return f"V:{ret}"
except Exception as e:
return f"E:{e}"


# TODO: more thoroughly check these new functions which use self
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't quite get this comment. what does self refer to here? the BlockRecord?


from run_gen import DEFAULT_CONSTANTS

# from chia.consensus.pos_quality import _expected_plot_size
Copy link
Contributor

Choose a reason for hiding this comment

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

we can probably remove these commented-out import lines now

is_overflow_block,
)

# from chia.util.hash import std_hash
Copy link
Contributor

Choose a reason for hiding this comment

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

and here

Copy link
Contributor

Choose a reason for hiding this comment

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

are these tests copied from chia-blockchain?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

@@ -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]
Copy link
Contributor

Choose a reason for hiding this comment

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

@matt-o-how what happened with this? Did you try it and it didn't work?

}

fn sp_total_iters<'a>(
&self,
py: Python<'a>,
constants: &Bound<'_, PyAny>,
) -> PyResult<Bound<'a, PyAny>> {
ChiaToPython::to_python(&self.sp_total_iters_impl(py, constants)?, py)
ChiaToPython::to_python(&self.sp_total_iters_impl(constants)?, py)
Copy link
Contributor

Choose a reason for hiding this comment

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

it's not clear to me why we need these extra wrapper functions. I would expect we could have pure rust member functions and (when enabled) python wrappers that call the rust functions. This appears to add 2 layers of python wrapper around the rust functions

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.

3 participants