Skip to content

Commit 0764c8d

Browse files
authored
Bump chia rs 0.14.0 (#18643)
* bump chia_rs to 0.14.0 * update tests covering negative division (allowed since the hard fork) and infinity G1 keys (disallowed with soft fork 5) * BLSCache.update() takes GTElement now * use get_conditions_from_spendbundle() in test_mempool_manager, to get the ANALYZE_SPENDS behavior * fix mypy warnings
1 parent 4383b6f commit 0764c8d

File tree

9 files changed

+61
-67
lines changed

9 files changed

+61
-67
lines changed

chia/_tests/clvm/test_program.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import annotations
22

33
import pytest
4-
from chia_rs import ENABLE_FIXED_DIV
54
from clvm.EvalError import EvalError
65
from clvm.operators import KEYWORD_TO_ATOM
76
from clvm_tools.binutils import assemble, disassemble
@@ -120,27 +119,32 @@ def test_run() -> None:
120119
assert ret.atom == bytes([0xFE])
121120

122121
# run()
123-
with pytest.raises(ValueError, match="div operator with negative operands is deprecated"):
124-
cost, ret = div.run_with_cost(100000, [10, -5], 0)
122+
cost, ret = div.run_with_cost(100000, [10, -5], 0)
123+
assert cost == 1107
124+
print(ret)
125+
assert ret.atom == bytes([0xFE])
125126

126-
cost, ret = div.run_with_cost(100000, [10, -5], ENABLE_FIXED_DIV)
127+
cost, ret = div.run_with_cost(100000, [10, -5], 0)
127128
assert cost == 1107
128129
print(ret)
129130
assert ret.atom == bytes([0xFE])
130131

131132
# run_with_flags()
132-
with pytest.raises(ValueError, match="div operator with negative operands is deprecated"):
133-
cost, ret = div.run_with_flags(100000, 0, [10, -5])
133+
cost, ret = div.run_with_flags(100000, 0, [10, -5])
134+
assert cost == 1107
135+
print(ret)
136+
assert ret.atom == bytes([0xFE])
134137

135-
cost, ret = div.run_with_flags(100000, ENABLE_FIXED_DIV, [10, -5])
138+
cost, ret = div.run_with_flags(100000, 0, [10, -5])
136139
assert cost == 1107
137140
print(ret)
138141
assert ret.atom == bytes([0xFE])
139142

140143
# run_with_cost()
141-
with pytest.raises(ValueError, match="div operator with negative operands is deprecated"):
142-
ret = div.run([10, -5], 100000, 0)
144+
ret = div.run([10, -5], 100000, 0)
145+
print(ret)
146+
assert ret.atom == bytes([0xFE])
143147

144-
ret = div.run([10, -5], 100000, ENABLE_FIXED_DIV)
148+
ret = div.run([10, -5], 100000, 0)
145149
print(ret)
146150
assert ret.atom == bytes([0xFE])

chia/_tests/core/full_node/test_conditions.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -480,10 +480,7 @@ async def test_agg_sig_infinity(
480480
)
481481

482482
# infinity is disallowed after soft-fork-5 activates
483-
if consensus_mode >= ConsensusMode.SOFT_FORK_5:
484-
expected_error = Err.INVALID_CONDITION
485-
else:
486-
expected_error = None
483+
expected_error = Err.INVALID_CONDITION
487484
await check_conditions(bt, conditions, expected_error)
488485

489486
@pytest.mark.anyio

chia/_tests/core/mempool/test_mempool_manager.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@
55
from typing import Any, Awaitable, Callable, Collection, Dict, List, Optional, Set, Tuple
66

77
import pytest
8-
from chia_rs import ELIGIBLE_FOR_DEDUP, ELIGIBLE_FOR_FF, AugSchemeMPL, G2Element
8+
from chia_rs import ELIGIBLE_FOR_DEDUP, ELIGIBLE_FOR_FF, AugSchemeMPL, G2Element, get_conditions_from_spendbundle
99
from chiabip158 import PyBIP158
1010

1111
from chia._tests.conftest import ConsensusMode
1212
from chia._tests.util.misc import invariant_check_mempool
1313
from chia._tests.util.setup_nodes import OldSimulatorsAndWallets, setup_simulators_and_wallets
1414
from chia.consensus.constants import ConsensusConstants
1515
from chia.consensus.default_constants import DEFAULT_CONSTANTS
16-
from chia.full_node.bundle_tools import simple_solution_generator
1716
from chia.full_node.mempool import MAX_SKIPPED_ITEMS, PRIORITY_TX_THRESHOLD
18-
from chia.full_node.mempool_check_conditions import get_name_puzzle_conditions, mempool_check_time_locks
17+
from chia.full_node.mempool_check_conditions import mempool_check_time_locks
1918
from chia.full_node.mempool_manager import (
2019
MEMPOOL_MIN_FEE_INCREASE,
2120
QUOTE_BYTES,
@@ -442,16 +441,12 @@ def make_bundle_spends_map_and_fee(
442441

443442

444443
def mempool_item_from_spendbundle(spend_bundle: SpendBundle) -> MempoolItem:
445-
generator = simple_solution_generator(spend_bundle)
446-
npc_result = get_name_puzzle_conditions(
447-
generator=generator, max_cost=INFINITE_COST, mempool_mode=True, height=uint32(0), constants=DEFAULT_CONSTANTS
448-
)
449-
assert npc_result.conds is not None
450-
bundle_coin_spends, fee = make_bundle_spends_map_and_fee(spend_bundle, npc_result.conds)
444+
conds = get_conditions_from_spendbundle(spend_bundle, INFINITE_COST, DEFAULT_CONSTANTS, uint32(0))
445+
bundle_coin_spends, fee = make_bundle_spends_map_and_fee(spend_bundle, conds)
451446
return MempoolItem(
452447
spend_bundle=spend_bundle,
453448
fee=fee,
454-
conds=npc_result.conds,
449+
conds=conds,
455450
spend_bundle_name=spend_bundle.name(),
456451
height_added_to_mempool=TEST_HEIGHT,
457452
bundle_coin_spends=bundle_coin_spends,

chia/_tests/wallet/test_signer_protocol.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ async def test_p2dohp_wallet_signer_protocol(wallet_environments: WalletTestFram
152152
)
153153
assert derivation_record is not None
154154
pubkey: G1Element = derivation_record.pubkey
155-
synthetic_pubkey: G1Element = G1Element.from_bytes(puzzle.uncurry()[1].at("f").atom)
155+
atom = puzzle.uncurry()[1].at("f").atom
156+
assert atom is not None
157+
synthetic_pubkey: G1Element = G1Element.from_bytes(atom)
156158
message: bytes = delegated_puzzle_hash + coin.name() + wallet_state_manager.constants.AGG_SIG_ME_ADDITIONAL_DATA
157159

158160
utx: UnsignedTransaction = UnsignedTransaction(

chia/consensus/multiprocess_validation.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ def batch_pre_validate_blocks(
106106
header_block = get_block_header(block, tx_additions, removals)
107107
prev_ses_block = None
108108
if prev_ses_block_bytes is not None and len(prev_ses_block_bytes) > 0:
109-
if prev_ses_block_bytes[i] is not None:
110-
prev_ses_block = BlockRecord.from_bytes_unchecked(prev_ses_block_bytes[i])
109+
buffer = prev_ses_block_bytes[i]
110+
if buffer is not None:
111+
prev_ses_block = BlockRecord.from_bytes_unchecked(buffer)
111112
required_iters, error = validate_finished_header_block(
112113
constants,
113114
BlockCache(blocks),

chia/full_node/mempool_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ async def pre_validate_spendbundle(
301301
self._worker_queue_size -= 1
302302

303303
if bls_cache is not None:
304-
bls_cache.update([(e[0], bytes(e[1])) for e in new_cache_entries])
304+
bls_cache.update(new_cache_entries)
305305

306306
ret = NPCResult(None, sbc)
307307

chia/types/blockchain_format/program.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,7 @@
33
import io
44
from typing import TYPE_CHECKING, Any, Callable, Dict, Optional, Set, Tuple, Type, TypeVar
55

6-
from chia_rs import (
7-
ALLOW_BACKREFS,
8-
DISALLOW_INFINITY_G1,
9-
ENABLE_BLS_OPS_OUTSIDE_GUARD,
10-
ENABLE_FIXED_DIV,
11-
MEMPOOL_MODE,
12-
run_chia_program,
13-
tree_hash,
14-
)
6+
from chia_rs import ALLOW_BACKREFS, MEMPOOL_MODE, run_chia_program, tree_hash
157
from clvm.casts import int_from_bytes
168
from clvm.CLVMObject import CLVMStorage
179
from clvm.EvalError import EvalError
@@ -26,7 +18,7 @@
2618

2719
INFINITE_COST = 11000000000
2820

29-
DEFAULT_FLAGS = ENABLE_BLS_OPS_OUTSIDE_GUARD | ENABLE_FIXED_DIV | DISALLOW_INFINITY_G1 | MEMPOOL_MODE
21+
DEFAULT_FLAGS = MEMPOOL_MODE
3022

3123
T_CLVMStorage = TypeVar("T_CLVMStorage", bound=CLVMStorage)
3224
T_Program = TypeVar("T_Program", bound="Program")

poetry.lock

Lines changed: 31 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ bitstring = "4.1.4" # Binary data management library
4646
boto3 = "1.34.143" # AWS S3 for Data Layer S3 plugin
4747
chiabip158 = "1.5.1" # bip158-style wallet filters
4848
chiapos = "2.0.4" # proof of space
49-
chia_rs = "0.13.0"
49+
chia_rs = "0.14.0"
5050
chiavdf = "1.1.4" # timelord and vdf verification
5151
click = "8.1.7" # For the CLI
5252
clvm = "0.9.10"

0 commit comments

Comments
 (0)