Skip to content

Commit

Permalink
migrate pos_quality
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-o-how committed Jan 28, 2025
1 parent 9b7a1ab commit f641e8e
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 19 deletions.
2 changes: 1 addition & 1 deletion chia/_tests/core/consensus/test_pot_iterations.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
calculate_sp_iters,
is_overflow_block,
)
from chia_rs import expected_plot_size as _expected_plot_size
from pytest import raises

from chia.consensus.default_constants import DEFAULT_CONSTANTS
from chia.consensus.pos_quality import _expected_plot_size
from chia.consensus.pot_iterations import (
calculate_iterations_quality,
)
Expand Down
3 changes: 2 additions & 1 deletion chia/_tests/plot_sync/test_receiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

import pytest
from chia_rs import G1Element
from chia_rs import expected_plot_size as _expected_plot_size

from chia._tests.plot_sync.util import get_dummy_connection
from chia.consensus.pos_quality import UI_ACTUAL_SPACE_CONSTANT_FACTOR, _expected_plot_size
from chia.consensus.pos_quality import UI_ACTUAL_SPACE_CONSTANT_FACTOR
from chia.plot_sync.delta import Delta
from chia.plot_sync.receiver import Receiver, Sync, get_list_or_len
from chia.plot_sync.util import ErrorCodes, State
Expand Down
14 changes: 0 additions & 14 deletions chia/consensus/pos_quality.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
from __future__ import annotations

from chia.util.ints import uint64

# The actual space in bytes of a plot, is _expected_plot_size(k) * UI_ACTUAL_SPACE_CONSTANT_FACTO
# This is not used in consensus, only for display purposes
UI_ACTUAL_SPACE_CONSTANT_FACTOR = 0.78


def _expected_plot_size(k: int) -> uint64:
"""
Given the plot size parameter k (which is between 32 and 59), computes the
expected size of the plot in bytes (times a constant factor). This is based on efficient encoding
of the plot, and aims to be scale agnostic, so larger plots don't
necessarily get more rewards per byte. The +1 is added to give half a bit more space per entry, which
is necessary to store the entries in the plot.
"""

return uint64(((2 * k) + 1) * (2 ** (k - 1)))
3 changes: 2 additions & 1 deletion chia/consensus/pot_iterations.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

from chia.consensus.pos_quality import _expected_plot_size
from chia_rs import expected_plot_size as _expected_plot_size

from chia.types.blockchain_format.sized_bytes import bytes32
from chia.util.hash import std_hash
from chia.util.ints import uint64, uint128
Expand Down
3 changes: 2 additions & 1 deletion chia/plot_sync/receiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
from dataclasses import dataclass, field
from typing import Any, Callable, Optional, Union

from chia_rs import expected_plot_size as _expected_plot_size
from typing_extensions import Protocol

from chia.consensus.pos_quality import UI_ACTUAL_SPACE_CONSTANT_FACTOR, _expected_plot_size
from chia.consensus.pos_quality import UI_ACTUAL_SPACE_CONSTANT_FACTOR
from chia.plot_sync.delta import Delta, PathListDelta, PlotListDelta
from chia.plot_sync.exceptions import (
InvalidIdentifierError,
Expand Down
3 changes: 2 additions & 1 deletion chia/plotting/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
from typing import Any, Callable, Optional

from chia_rs import G1Element
from chia_rs import expected_plot_size as _expected_plot_size
from chiapos import DiskProver, decompressor_context_queue

from chia.consensus.pos_quality import UI_ACTUAL_SPACE_CONSTANT_FACTOR, _expected_plot_size
from chia.consensus.pos_quality import UI_ACTUAL_SPACE_CONSTANT_FACTOR
from chia.plotting.cache import Cache, CacheEntry
from chia.plotting.util import (
HarvestingMode,
Expand Down

0 comments on commit f641e8e

Please sign in to comment.