Skip to content

Commit c0410e9

Browse files
arvidnmatt-o-how
andauthored
Bump chia rs >=0.24, <0.25 (#19615)
* bump chia_rs * update db_graftroot test * update SerializedProgram and Program use, to accommodate new chia_rs interface * review comments * review comments --------- Co-authored-by: Matthew Howard <[email protected]>
1 parent ddbce32 commit c0410e9

File tree

72 files changed

+386
-269
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+386
-269
lines changed

chia/_tests/blockchain/test_blockchain.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,7 +1156,7 @@ async def test_bad_pos(self, empty_blockchain: Blockchain, bt: BlockTools) -> No
11561156
)
11571157
await _validate_and_add_block(empty_blockchain, block_bad, expected_error=Err.INVALID_POSPACE)
11581158

1159-
block_bad = recursive_replace(blocks[-1], "reward_chain_block.proof_of_space.size", 62)
1159+
block_bad = recursive_replace(blocks[-1], "reward_chain_block.proof_of_space.version_and_size", 62)
11601160
await _validate_and_add_block(empty_blockchain, block_bad, expected_error=Err.INVALID_POSPACE)
11611161

11621162
block_bad = recursive_replace(
@@ -1167,14 +1167,14 @@ async def test_bad_pos(self, empty_blockchain: Blockchain, bt: BlockTools) -> No
11671167
await _validate_and_add_block(empty_blockchain, block_bad, expected_error=Err.INVALID_POSPACE)
11681168
block_bad = recursive_replace(
11691169
blocks[-1],
1170-
"reward_chain_block.proof_of_space.size",
1170+
"reward_chain_block.proof_of_space.version_and_size",
11711171
32,
11721172
)
11731173
await _validate_and_add_block(empty_blockchain, block_bad, expected_error=Err.INVALID_POSPACE)
11741174
block_bad = recursive_replace(
11751175
blocks[-1],
11761176
"reward_chain_block.proof_of_space.proof",
1177-
bytes([1] * int(blocks[-1].reward_chain_block.proof_of_space.size * 64 / 8)),
1177+
bytes([1] * int((blocks[-1].reward_chain_block.proof_of_space.version_and_size & 0x7F) * 64 / 8)),
11781178
)
11791179
await _validate_and_add_block(empty_blockchain, block_bad, expected_error=Err.INVALID_POSPACE)
11801180

chia/_tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1236,7 +1236,7 @@ async def farmer_harvester_2_simulators_zero_bits_plot_filter(
12361236
]
12371237
]:
12381238
zero_bit_plot_filter_consts = test_constants_modified.replace(
1239-
NUMBER_ZERO_BITS_PLOT_FILTER=uint8(0),
1239+
NUMBER_ZERO_BITS_PLOT_FILTER_V1=uint8(0),
12401240
NUM_SPS_SUB_SLOT=uint32(8),
12411241
)
12421242

chia/_tests/core/custom_types/test_proof_of_space.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class ProofOfSpaceCase:
2727
marks: Marks = ()
2828

2929

30+
# TODO: test v2 plots
3031
@datacases(
3132
ProofOfSpaceCase(
3233
id="Neither pool public key nor pool contract puzzle hash",
@@ -108,7 +109,7 @@ def test_verify_and_get_quality_string(caplog: pytest.LogCaptureFixture, case: P
108109
pool_public_key=case.pool_public_key,
109110
pool_contract_puzzle_hash=case.pool_contract_puzzle_hash,
110111
plot_public_key=case.plot_public_key,
111-
size=case.plot_size,
112+
version_and_size=case.plot_size,
112113
proof=b"1",
113114
)
114115
quality_string = verify_and_get_quality_string(
@@ -125,7 +126,7 @@ def test_verify_and_get_quality_string(caplog: pytest.LogCaptureFixture, case: P
125126

126127

127128
class TestProofOfSpace:
128-
@pytest.mark.parametrize("prefix_bits", [DEFAULT_CONSTANTS.NUMBER_ZERO_BITS_PLOT_FILTER, 8, 7, 6, 5, 1, 0])
129+
@pytest.mark.parametrize("prefix_bits", [DEFAULT_CONSTANTS.NUMBER_ZERO_BITS_PLOT_FILTER_V1, 8, 7, 6, 5, 1, 0])
129130
def test_can_create_proof(self, prefix_bits: int, seeded_random: random.Random) -> None:
130131
"""
131132
Tests that the change of getting a correct proof is exactly 1/target_filter.

chia/_tests/core/full_node/test_conditions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ async def check_conditions(
104104
blocks = await initial_blocks(bt)
105105
coin = blocks[spend_reward_index].get_included_reward_coins()[0]
106106

107-
coin_spend = make_spend(coin, EASY_PUZZLE, SerializedProgram.from_program(condition_solution))
107+
coin_spend = make_spend(coin, EASY_PUZZLE, condition_solution)
108108
spend_bundle = SpendBundle([coin_spend], aggsig)
109109

110110
# now let's try to create a block with the spend bundle and ensure that it doesn't validate

chia/_tests/core/full_node/test_full_node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1621,7 +1621,7 @@ async def test_unfinished_block_with_replaced_generator(
16211621
pos.pool_public_key,
16221622
pos.pool_contract_puzzle_hash,
16231623
public_key,
1624-
pos.size,
1624+
pos.version_and_size,
16251625
pos.proof,
16261626
)
16271627

chia/_tests/core/make_block_generator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def int_to_public_key(index: int) -> G1Element:
2424

2525
def puzzle_hash_for_index(index: int, puzzle_hash_db: dict[bytes32, SerializedProgram]) -> bytes32:
2626
public_key: G1Element = int_to_public_key(index)
27-
puzzle = SerializedProgram.from_program(puzzle_for_pk(public_key))
27+
puzzle = puzzle_for_pk(public_key).to_serialized()
2828
puzzle_hash: bytes32 = puzzle.get_tree_hash()
2929
puzzle_hash_db[puzzle_hash] = puzzle
3030
return puzzle_hash
@@ -56,7 +56,7 @@ def make_spend_bundle(count: int) -> SpendBundle:
5656
for coin in coins:
5757
puzzle_reveal = puzzle_hash_db[coin.puzzle_hash]
5858
conditions = conditions_for_payment(coin)
59-
solution = SerializedProgram.from_program(solution_for_conditions(conditions))
59+
solution = solution_for_conditions(conditions).to_serialized()
6060
coin_spend = make_spend(coin, puzzle_reveal, solution)
6161
coin_spends.append(coin_spend)
6262

chia/_tests/core/mempool/test_mempool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2866,7 +2866,7 @@ async def test_invalid_coin_spend_coin(
28662866
new_bundle = recursive_replace(spend_bundle, "coin_spends", [coin_spend_0, *spend_bundle.coin_spends[1:]])
28672867
assert spend_bundle is not None
28682868
res = await full_node_1.full_node.add_transaction(new_bundle, new_bundle.name(), test=True)
2869-
assert res == (MempoolInclusionStatus.FAILED, Err.INVALID_SPEND_BUNDLE)
2869+
assert res == (MempoolInclusionStatus.FAILED, Err.WRONG_PUZZLE_HASH)
28702870

28712871

28722872
coins = make_test_coins()

chia/_tests/core/mempool/test_mempool_manager.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2378,17 +2378,15 @@ def make_singleton_spend(
23782378
from chia.wallet.lineage_proof import LineageProof
23792379
from chia.wallet.puzzles.singleton_top_layer_v1_1 import puzzle_for_singleton, solution_for_singleton
23802380

2381-
singleton_puzzle = SerializedProgram.from_program(puzzle_for_singleton(launcher_id, Program.to(1)))
2381+
singleton_puzzle = puzzle_for_singleton(launcher_id, Program.to(1)).to_serialized()
23822382

23832383
PARENT_COIN = Coin(parent_parent_id, singleton_puzzle.get_tree_hash(), uint64(1))
23842384
COIN = Coin(PARENT_COIN.name(), singleton_puzzle.get_tree_hash(), uint64(1))
23852385

23862386
lineage_proof = LineageProof(parent_parent_id, IDENTITY_PUZZLE_HASH, uint64(1))
23872387

23882388
inner_solution = Program.to([[ConditionOpcode.CREATE_COIN, IDENTITY_PUZZLE_HASH, uint64(child_amount)]])
2389-
singleton_solution = SerializedProgram.from_program(
2390-
solution_for_singleton(lineage_proof, uint64(1), inner_solution)
2391-
)
2389+
singleton_solution = solution_for_singleton(lineage_proof, uint64(1), inner_solution).to_serialized()
23922390

23932391
ret = CoinSpend(COIN, singleton_puzzle, singleton_solution)
23942392

chia/_tests/core/mempool/test_singleton_fast_forward.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,9 @@ def make_singleton_coin_spend(
257257
solution = singleton_top_layer.solution_for_singleton(lineage_proof, uint64(coin_to_spend.amount), inner_solution)
258258
if is_eve_spend:
259259
# Parent here is the launcher coin
260-
puzzle_reveal = SerializedProgram.from_program(
261-
singleton_top_layer.puzzle_for_singleton(parent_coin_spend.coin.name(), inner_puzzle)
262-
)
260+
puzzle_reveal = singleton_top_layer.puzzle_for_singleton(
261+
parent_coin_spend.coin.name(), inner_puzzle
262+
).to_serialized()
263263
else:
264264
puzzle_reveal = parent_coin_spend.puzzle_reveal
265265
return make_spend(coin_to_spend, puzzle_reveal, solution), delegated_puzzle
@@ -413,8 +413,8 @@ async def test_singleton_fast_forward_different_block(is_eligible_for_ff: bool)
413413
eve_coin_spend, singleton, inner_puzzle, inner_conditions
414414
)
415415
# Spend also a remaining coin
416-
remaining_spend_solution = SerializedProgram.from_program(
417-
Program.to([[ConditionOpcode.CREATE_COIN, IDENTITY_PUZZLE_HASH, remaining_coin.amount]])
416+
remaining_spend_solution = SerializedProgram.to(
417+
[[ConditionOpcode.CREATE_COIN, IDENTITY_PUZZLE_HASH, remaining_coin.amount]]
418418
)
419419
remaining_coin_spend = CoinSpend(remaining_coin, IDENTITY_PUZZLE, remaining_spend_solution)
420420
await make_and_send_spend_bundle(
@@ -435,8 +435,8 @@ async def test_singleton_fast_forward_different_block(is_eligible_for_ff: bool)
435435
coin_id=singleton_child.name(), parent_id=singleton.name(), parent_parent_id=eve_coin_spend.coin.name()
436436
)
437437
# Now let's spend the first version again (despite being already spent by now)
438-
remaining_spend_solution = SerializedProgram.from_program(
439-
Program.to([[ConditionOpcode.CREATE_COIN, IDENTITY_PUZZLE_HASH, remaining_coin.amount]])
438+
remaining_spend_solution = SerializedProgram.to(
439+
[[ConditionOpcode.CREATE_COIN, IDENTITY_PUZZLE_HASH, remaining_coin.amount]]
440440
)
441441
remaining_coin_spend = CoinSpend(remaining_coin, IDENTITY_PUZZLE, remaining_spend_solution)
442442
status, error = await make_and_send_spend_bundle(
@@ -494,8 +494,8 @@ async def test_singleton_fast_forward_same_block() -> None:
494494
# Spend also a remaining coin. Change amount to create a new coin ID.
495495
# The test assumes any odd amount is a singleton, so we must keep it
496496
# even
497-
remaining_spend_solution = SerializedProgram.from_program(
498-
Program.to([[ConditionOpcode.CREATE_COIN, IDENTITY_PUZZLE_HASH, remaining_coin.amount - 2]])
497+
remaining_spend_solution = SerializedProgram.to(
498+
[[ConditionOpcode.CREATE_COIN, IDENTITY_PUZZLE_HASH, remaining_coin.amount - 2]]
499499
)
500500
remaining_coin_spend = CoinSpend(remaining_coin, IDENTITY_PUZZLE, remaining_spend_solution)
501501
await make_and_send_spend_bundle(sim, sim_client, [remaining_coin_spend, singleton_coin_spend], aggsig=sig)
@@ -567,8 +567,8 @@ async def test_mempool_items_immutability_on_ff() -> None:
567567
singleton_coin_spend, singleton_signing_puzzle = make_singleton_coin_spend(
568568
eve_coin_spend, singleton, inner_puzzle, inner_conditions
569569
)
570-
remaining_spend_solution = SerializedProgram.from_program(
571-
Program.to([[ConditionOpcode.CREATE_COIN, IDENTITY_PUZZLE_HASH, remaining_coin.amount]])
570+
remaining_spend_solution = SerializedProgram.to(
571+
[[ConditionOpcode.CREATE_COIN, IDENTITY_PUZZLE_HASH, remaining_coin.amount]]
572572
)
573573
remaining_coin_spend = CoinSpend(remaining_coin, IDENTITY_PUZZLE, remaining_spend_solution)
574574
await make_and_send_spend_bundle(
@@ -590,8 +590,8 @@ async def test_mempool_items_immutability_on_ff() -> None:
590590
)
591591
# Now let's spend the first version again (despite being already spent
592592
# by now) to exercise its fast forward.
593-
remaining_spend_solution = SerializedProgram.from_program(
594-
Program.to([[ConditionOpcode.CREATE_COIN, IDENTITY_PUZZLE_HASH, remaining_coin.amount]])
593+
remaining_spend_solution = SerializedProgram.to(
594+
[[ConditionOpcode.CREATE_COIN, IDENTITY_PUZZLE_HASH, remaining_coin.amount]]
595595
)
596596
remaining_coin_spend = CoinSpend(remaining_coin, IDENTITY_PUZZLE, remaining_spend_solution)
597597
sb = SpendBundle([remaining_coin_spend, singleton_coin_spend], sig)

chia/_tests/core/test_cost_calculation.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from chia.full_node.mempool_check_conditions import get_puzzle_and_solution_for_coin
2020
from chia.simulator.block_tools import BlockTools, test_constants
2121
from chia.types.blockchain_format.coin import Coin
22-
from chia.types.blockchain_format.program import Program
22+
from chia.types.blockchain_format.program import Program, run_with_cost
2323
from chia.types.blockchain_format.serialized_program import SerializedProgram
2424
from chia.types.generator_types import BlockGenerator
2525
from chia.wallet.puzzles import p2_delegated_puzzle_or_hidden_puzzle
@@ -171,7 +171,7 @@ async def test_mempool_mode(softfork_height: int, bt: BlockTools) -> None:
171171
uint64(300),
172172
)
173173
spend_info = get_puzzle_and_solution_for_coin(generator, coin, softfork_height, bt.constants)
174-
assert spend_info.puzzle.to_program() == puzzle
174+
assert spend_info.puzzle == puzzle.to_serialized()
175175

176176

177177
@pytest.mark.anyio
@@ -276,7 +276,7 @@ async def test_standard_tx(benchmark_runner: BenchmarkRunner) -> None:
276276
with benchmark_runner.assert_runtime(seconds=0.1):
277277
total_cost = 0
278278
for i in range(0, 1000):
279-
cost, _result = puzzle_program.run_with_cost(test_constants.MAX_BLOCK_COST_CLVM, solution_program)
279+
cost, _result = run_with_cost(puzzle_program, test_constants.MAX_BLOCK_COST_CLVM, solution_program)
280280
total_cost += cost
281281

282282

@@ -287,8 +287,8 @@ async def test_get_puzzle_and_solution_for_coin_performance(benchmark_runner: Be
287287

288288
assert LARGE_BLOCK.transactions_generator is not None
289289
# first, list all spent coins in the block
290-
_, result = LARGE_BLOCK.transactions_generator.run_with_cost(
291-
DEFAULT_CONSTANTS.MAX_BLOCK_COST_CLVM, [DESERIALIZE_MOD, []]
290+
_, result = run_with_cost(
291+
LARGE_BLOCK.transactions_generator, DEFAULT_CONSTANTS.MAX_BLOCK_COST_CLVM, [DESERIALIZE_MOD, []]
292292
)
293293

294294
coin_spends = result.first()

0 commit comments

Comments
 (0)