Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -114,7 +114,7 @@ def test_win_percentage(self):
quality = std_hash(slot_index.to_bytes(4, "big") + k.to_bytes(1, "big") + bytes(farmer_index))
# TODO: todo_v2_plots
required_iters = calculate_iterations_quality(
constants, quality, PlotSize.make_v1(k), difficulty, sp_hash, uint64(100000000), uint32(0)
constants, quality, PlotSize.make_v1(k), difficulty, sp_hash
)
if required_iters < sp_interval_iters:
wins[k] += 1
Expand Down
17 changes: 6 additions & 11 deletions chia/_tests/core/custom_types/test_proof_of_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import Optional

import pytest
from chia_rs import G1Element, PlotSize, ProofOfSpace
from chia_rs import G1Element, ProofOfSpace
from chia_rs.sized_bytes import bytes32, bytes48
from chia_rs.sized_ints import uint8, uint32

Expand Down Expand Up @@ -156,6 +156,7 @@ def test_verify_and_get_quality_string(caplog: pytest.LogCaptureFixture, case: P
assert len(caplog.text) == 0 if case.expected_error is None else case.expected_error in caplog.text


@pytest.mark.skip("v2 plots")
@datacases(
ProofOfSpaceCase(
id="v2 plot are not implemented",
Expand Down Expand Up @@ -242,12 +243,9 @@ def test_can_create_proof(self, prefix_bits: int, seeded_random: random.Random)


@pytest.mark.parametrize("height,expected", [(0, 3), (5496000, 2), (10542000, 1), (15592000, 0), (20643000, 0)])
@pytest.mark.parametrize("plot_size", [PlotSize.make_v1(32), PlotSize.make_v2(28)])
def test_calculate_prefix_bits_clamp_zero(height: uint32, expected: int, plot_size: PlotSize) -> None:
def test_calculate_prefix_bits_clamp_zero(height: uint32, expected: int) -> None:
constants = DEFAULT_CONSTANTS.replace(NUMBER_ZERO_BITS_PLOT_FILTER_V1=uint8(3))
if plot_size.size_v2 is not None:
expected = constants.NUMBER_ZERO_BITS_PLOT_FILTER_V2
assert calculate_prefix_bits(constants, height, plot_size) == expected
assert calculate_prefix_bits(constants, height) == expected


@pytest.mark.parametrize(
Expand All @@ -264,9 +262,6 @@ def test_calculate_prefix_bits_clamp_zero(height: uint32, expected: int, plot_si
(20643000, 5),
],
)
@pytest.mark.parametrize("plot_size", [PlotSize.make_v1(32), PlotSize.make_v2(28)])
def test_calculate_prefix_bits_default(height: uint32, expected: int, plot_size: PlotSize) -> None:
def test_calculate_prefix_bits_default(height: uint32, expected: int) -> None:
constants = DEFAULT_CONSTANTS
if plot_size.size_v2 is not None:
expected = DEFAULT_CONSTANTS.NUMBER_ZERO_BITS_PLOT_FILTER_V2
assert calculate_prefix_bits(constants, height, plot_size) == expected
assert calculate_prefix_bits(constants, height) == expected
2 changes: 1 addition & 1 deletion chia/_tests/core/farmer/test_farmer_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async def test_farmer_ignores_concurrent_duplicate_signage_points(
assert ProtocolMessageTypes(response).name == "harvester_handshake"

sp = farmer_protocol.NewSignagePoint(
std_hash(b"1"), std_hash(b"2"), std_hash(b"3"), uint64(1), uint64(1000000), uint8(2), uint32(1), uint32(0)
std_hash(b"1"), std_hash(b"2"), std_hash(b"3"), uint64(1), uint64(1000000), uint8(2), uint32(1)
)
await gather(
farmer_api.new_signage_point(sp),
Expand Down
4 changes: 2 additions & 2 deletions chia/_tests/core/test_farmer_harvester_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ async def have_signage_points() -> bool:
return len(await farmer_rpc_client.get_signage_points()) > 0

sp = farmer_protocol.NewSignagePoint(
std_hash(b"1"), std_hash(b"2"), std_hash(b"3"), uint64(1), uint64(1000000), uint8(2), uint32(1), uint32(0)
std_hash(b"1"), std_hash(b"2"), std_hash(b"3"), uint64(1), uint64(1000000), uint8(2), uint32(1)
)
await farmer_api.new_signage_point(sp)

Expand Down Expand Up @@ -241,7 +241,7 @@ async def test_farmer_get_pool_state(
pool_dict[key].insert(0, before_24h)

sp = farmer_protocol.NewSignagePoint(
std_hash(b"1"), std_hash(b"2"), std_hash(b"3"), uint64(1), uint64(1000000), uint8(2), uint32(1), uint32(0)
std_hash(b"1"), std_hash(b"2"), std_hash(b"3"), uint64(1), uint64(1000000), uint8(2), uint32(1)
)
await farmer_api.new_signage_point(sp)
client_pool_state = await farmer_rpc_client.get_pool_state()
Expand Down
2 changes: 0 additions & 2 deletions chia/_tests/farmer_harvester/test_farmer.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,6 @@ async def test_farmer_new_proof_of_space_for_pool_stats(
sub_slot_iters=case.sub_slot_iters,
signage_point_index=case.signage_point_index,
peak_height=uint32(1),
last_tx_height=uint32(0),
)
pos = ProofOfSpace(
challenge=case.plot_challenge,
Expand Down Expand Up @@ -712,7 +711,6 @@ def create_valid_pos(farmer: Farmer) -> tuple[farmer_protocol.NewSignagePoint, P
sub_slot_iters=case.sub_slot_iters,
signage_point_index=case.signage_point_index,
peak_height=uint32(1),
last_tx_height=uint32(0),
)
pos = ProofOfSpace(
challenge=case.plot_challenge,
Expand Down
1 change: 0 additions & 1 deletion chia/_tests/farmer_harvester/test_farmer_harvester.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ def create_sp(index: int, challenge_hash: bytes32) -> tuple[uint64, farmer_proto
uint64(1000000),
uint8(index),
uint32(1),
uint32(0),
)
return time, sp

Expand Down
1 change: 0 additions & 1 deletion chia/_tests/farmer_harvester/test_filter_prefix_bits.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ def state_has_changed() -> bool:
sub_slot_iters=uint64(1000000),
signage_point_index=uint8(2),
peak_height=peak_height,
last_tx_height=uint32(0),
)
await farmer_api.new_signage_point(sp)
await time_out_assert(5, state_has_changed, True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ def prepare_sp_and_pos_for_fee_test(
sub_slot_iters=uint64(0),
signage_point_index=uint8(0),
peak_height=uint32(1),
last_tx_height=uint32(0),
)

pos = harvester_protocol.NewProofOfSpace(
Expand Down
4 changes: 1 addition & 3 deletions chia/_tests/util/network_protocol_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
uint64(8265724497259558930),
uint8(194),
uint32(1),
uint32(0),
)

proof_of_space = ProofOfSpace(
Expand Down Expand Up @@ -795,8 +794,7 @@
uint8(148),
bytes32(bytes.fromhex("b78c9fca155e9742df835cbe84bb7e518bee70d78b6be6e39996c0a02e0cfe4c")),
[pool_difficulty],
uint32(0),
uint32(0),
uint8(9),
)

new_proof_of_space = harvester_protocol.NewProofOfSpace(
Expand Down
Binary file modified chia/_tests/util/protocol_messages_bytes-v1.0
Binary file not shown.
4 changes: 1 addition & 3 deletions chia/_tests/util/protocol_messages_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"sub_slot_iters": 8265724497259558930,
"signage_point_index": 194,
"peak_height": 1,
"last_tx_height": 0,
"sp_source_data": None,
}

Expand Down Expand Up @@ -2160,8 +2159,7 @@
"pool_contract_puzzle_hash": "0xc9423123ea65e6923e973b95531b4874570dae942cb757a2daec4a6971753886",
}
],
"peak_height": 0,
"last_tx_height": 0,
"filter_prefix_bits": 9,
}

new_proof_of_space_json: dict[str, Any] = {
Expand Down
2 changes: 0 additions & 2 deletions chia/_tests/weight_proof/test_weight_proof.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ async def load_blocks_dont_validate(
cc_sp,
block.height,
difficulty,
sub_slot_iters,
uint32(0), # prev_tx_block(blocks, prev_b), todo need to get height of prev tx block somehow here
)
assert required_iters is not None

Expand Down
4 changes: 1 addition & 3 deletions chia/consensus/block_header_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from chia.consensus.blockchain_interface import BlockRecordsProtocol
from chia.consensus.deficit import calculate_deficit
from chia.consensus.difficulty_adjustment import can_finish_sub_and_full_epoch
from chia.consensus.get_block_challenge import final_eos_is_already_included, get_block_challenge, prev_tx_block
from chia.consensus.get_block_challenge import final_eos_is_already_included, get_block_challenge
from chia.consensus.make_sub_epoch_summary import make_sub_epoch_summary
from chia.consensus.pot_iterations import (
calculate_ip_iters,
Expand Down Expand Up @@ -506,8 +506,6 @@ def validate_unfinished_header_block(
cc_sp_hash,
height,
expected_vs.difficulty,
expected_vs.ssi,
prev_tx_block(blocks, prev_b),
)
if required_iters is None:
return None, ValidationError(Err.INVALID_POSPACE)
Expand Down
4 changes: 1 addition & 3 deletions chia/consensus/multiprocess_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from chia.consensus.blockchain_interface import BlockRecordsProtocol
from chia.consensus.full_block_to_block_record import block_to_block_record
from chia.consensus.generator_tools import get_block_header, tx_removals_and_additions
from chia.consensus.get_block_challenge import get_block_challenge, prev_tx_block
from chia.consensus.get_block_challenge import get_block_challenge
from chia.consensus.get_block_generator import get_block_generator
from chia.consensus.pot_iterations import (
is_overflow_block,
Expand Down Expand Up @@ -220,8 +220,6 @@ async def return_error(error_code: Err) -> PreValidationResult:
cc_sp_hash,
block.height,
vs.difficulty,
vs.ssi,
prev_tx_block(blockchain, prev_b),
)
if required_iters is None:
return return_error(Err.INVALID_POSPACE)
Expand Down
18 changes: 4 additions & 14 deletions chia/consensus/pot_iterations.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ def validate_pospace_and_get_required_iters(
cc_sp_hash: bytes32,
height: uint32,
difficulty: uint64,
sub_slot_iters: uint64,
prev_transaction_block_height: uint32, # this is the height of the last tx block before the current block SP
) -> Optional[uint64]:
q_str: Optional[bytes32] = verify_and_get_quality_string(
proof_of_space, constants, challenge, cc_sp_hash, height=height
Expand All @@ -93,8 +91,6 @@ def validate_pospace_and_get_required_iters(
proof_of_space.size(),
difficulty,
cc_sp_hash,
sub_slot_iters,
prev_transaction_block_height,
)


Expand All @@ -104,8 +100,6 @@ def calculate_iterations_quality(
size: PlotSize,
difficulty: uint64,
cc_sp_output_hash: bytes32,
ssi: uint64,
prev_transaction_block_height: uint32, # this is the height of the last tx block before the current block SP
) -> uint64:
"""
Calculates the number of iterations from the quality. This is derives as the difficulty times the constant factor
Expand All @@ -114,15 +108,11 @@ def calculate_iterations_quality(
if size.size_v1 is not None:
assert size.size_v2 is None
sp_quality_string: bytes32 = std_hash(quality_string + cc_sp_output_hash)
phase_out = calculate_phase_out(constants, ssi, prev_transaction_block_height)
iters = uint64(
(
int(difficulty)
* int(constants.DIFFICULTY_CONSTANT_FACTOR)
* int.from_bytes(sp_quality_string, "big", signed=False)
// (int(pow(2, 256)) * int(_expected_plot_size(size.size_v1)))
)
+ phase_out
int(difficulty)
* int(constants.DIFFICULTY_CONSTANT_FACTOR)
* int.from_bytes(sp_quality_string, "big", signed=False)
// (int(pow(2, 256)) * int(_expected_plot_size(size.size_v1)))
)
return max(iters, uint64(1))
else:
Expand Down
8 changes: 2 additions & 6 deletions chia/farmer/farmer_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from chia.server.ws_connection import WSChiaConnection
from chia.ssl.create_ssl import get_mozilla_ca_crt
from chia.types.blockchain_format.proof_of_space import (
calculate_prefix_bits,
generate_plot_public_key,
generate_taproot_sk,
get_plot_id,
Expand Down Expand Up @@ -114,8 +115,6 @@ async def new_proof_of_space(
new_proof_of_space.proof.size(),
sp.difficulty,
new_proof_of_space.sp_hash,
sp.sub_slot_iters,
sp.last_tx_height,
)

# If the iters are good enough to make a block, proceed with the block making flow
Expand Down Expand Up @@ -223,8 +222,6 @@ async def new_proof_of_space(
new_proof_of_space.proof.size(),
pool_state_dict["current_difficulty"],
new_proof_of_space.sp_hash,
sp.sub_slot_iters,
sp.last_tx_height,
)
if required_iters >= calculate_sp_interval_iters(
self.farmer.constants, self.farmer.constants.POOL_SUB_SLOT_ITERS
Expand Down Expand Up @@ -535,8 +532,7 @@ async def new_signage_point(self, new_signage_point: farmer_protocol.NewSignageP
new_signage_point.signage_point_index,
new_signage_point.challenge_chain_sp,
pool_difficulties,
new_signage_point.peak_height,
new_signage_point.last_tx_height,
uint8(calculate_prefix_bits(self.farmer.constants, new_signage_point.peak_height)),
)

msg = make_msg(ProtocolMessageTypes.new_signage_point_harvester, message)
Expand Down
4 changes: 0 additions & 4 deletions chia/full_node/full_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -1817,7 +1817,6 @@ async def signage_point_post_processing(
difficulty = self.constants.DIFFICULTY_STARTING
sub_slot_iters = self.constants.SUB_SLOT_ITERS_STARTING

tx_peak = self.blockchain.get_tx_peak()
# Notify farmers of the new signage point
broadcast_farmer = farmer_protocol.NewSignagePoint(
request.challenge_chain_vdf.challenge,
Expand All @@ -1827,7 +1826,6 @@ async def signage_point_post_processing(
sub_slot_iters,
request.index_from_challenge,
uint32(0) if peak is None else peak.height,
tx_peak.height if tx_peak is not None else uint32(0),
sp_source_data=SignagePointSourceData(
vdf_data=SPVDFSourceData(request.challenge_chain_vdf.output, request.reward_chain_vdf.output)
),
Expand Down Expand Up @@ -2724,7 +2722,6 @@ async def add_end_of_sub_slot(

for infusion in new_infusions:
await self.new_infusion_point_vdf(infusion)
tx_peak = self.blockchain.get_tx_peak()
# Notify farmers of the new sub-slot
broadcast_farmer = farmer_protocol.NewSignagePoint(
end_of_slot_bundle.challenge_chain.get_hash(),
Expand All @@ -2734,7 +2731,6 @@ async def add_end_of_sub_slot(
next_sub_slot_iters,
uint8(0),
uint32(0) if peak is None else peak.height,
tx_peak.height if tx_peak is not None else uint32(0),
sp_source_data=SignagePointSourceData(
sub_slot_data=SPSubSlotSourceData(
end_of_slot_bundle.challenge_chain, end_of_slot_bundle.reward_chain
Expand Down
3 changes: 0 additions & 3 deletions chia/full_node/full_node_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -982,15 +982,12 @@ def get_pool_sig(_1: PoolTarget, _2: Optional[G1Element]) -> Optional[G2Element]
if sub_slot.challenge_chain.new_sub_slot_iters is not None:
sub_slot_iters = sub_slot.challenge_chain.new_sub_slot_iters

tx_peak = self.full_node.blockchain.get_tx_peak()
required_iters: uint64 = calculate_iterations_quality(
self.full_node.constants,
quality_string,
request.proof_of_space.size(),
difficulty,
request.challenge_chain_sp,
sub_slot_iters,
tx_peak.height if tx_peak is not None else uint32(0),
)
sp_iters: uint64 = calculate_sp_iters(self.full_node.constants, sub_slot_iters, request.signage_point_index)
ip_iters: uint64 = calculate_ip_iters(
Expand Down
3 changes: 1 addition & 2 deletions chia/full_node/full_node_rpc_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
BlockRecord,
CoinSpend,
FullBlock,
PlotSize,
SpendBundle,
SpendBundleConditions,
run_block_generator2,
Expand Down Expand Up @@ -602,7 +601,7 @@ async def get_network_space(self, request: dict[str, Any]) -> EndpointResult:

# TODO: todo_v2_plots Update this calculation to take v2 plots into
# account
plot_filter_size = calculate_prefix_bits(self.service.constants, newer_block.height, PlotSize.make_v1(32))
plot_filter_size = calculate_prefix_bits(self.service.constants, newer_block.height)
delta_iters = newer_block.total_iters - older_block.total_iters
weight_div_iters = delta_weight / delta_iters
additional_difficulty_constant = self.service.constants.DIFFICULTY_CONSTANT_FACTOR
Expand Down
5 changes: 0 additions & 5 deletions chia/full_node/weight_proof.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
from chia.consensus.blockchain_interface import BlockchainInterface
from chia.consensus.deficit import calculate_deficit
from chia.consensus.full_block_to_block_record import header_block_to_sub_block_record
from chia.consensus.get_block_challenge import prev_tx_block
from chia.consensus.pot_iterations import (
calculate_ip_iters,
calculate_sp_iters,
Expand Down Expand Up @@ -1329,8 +1328,6 @@ def _validate_pospace_recent_chain(
cc_sp_hash,
block.height,
diff,
ssi,
prev_tx_block(blocks, blocks.block_record(block.prev_header_hash)),
)
if required_iters is None:
log.error(f"could not verify proof of space block {block.height} {overflow}")
Expand Down Expand Up @@ -1378,8 +1375,6 @@ def __validate_pospace(
cc_sp_hash,
height,
curr_diff,
curr_sub_slot_iters,
uint32(0), # prev_tx_block(blocks, prev_b), todo need to get height of prev tx block somehow here
)
if required_iters is None:
log.error("could not verify proof of space")
Expand Down
Loading
Loading