Skip to content

Commit

Permalink
Update chiavdf to 1.1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
emlowe committed Dec 23, 2024
1 parent a7bd676 commit 7c0dbaf
Show file tree
Hide file tree
Showing 16 changed files with 79 additions and 77 deletions.
6 changes: 3 additions & 3 deletions chia/_tests/blockchain/test_augmented_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ async def test_augmented_chain(default_10000_blocks: list[FullBlock]) -> None:
with pytest.raises(KeyError):
await abc.prev_block_hash([blocks[2].header_hash])

with pytest.raises(ValueError, match="Err.GENERATOR_REF_HAS_NO_GENERATOR"):
with pytest.raises(ValueError, match="Err\\.GENERATOR_REF_HAS_NO_GENERATOR"):
await abc.lookup_block_generators(blocks[3].header_hash, {uint32(3)})

block_records = []
Expand All @@ -103,11 +103,11 @@ async def test_augmented_chain(default_10000_blocks: list[FullBlock]) -> None:

assert abc.height_to_block_record(uint32(1)) == block_records[1]

with pytest.raises(ValueError, match="Err.GENERATOR_REF_HAS_NO_GENERATOR"):
with pytest.raises(ValueError, match="Err\\.GENERATOR_REF_HAS_NO_GENERATOR"):
await abc.lookup_block_generators(blocks[10].header_hash, {uint32(3), uint32(10)})

# block 1 exists in the chain, but it doesn't have a generator
with pytest.raises(ValueError, match="Err.GENERATOR_REF_HAS_NO_GENERATOR"):
with pytest.raises(ValueError, match="Err\\.GENERATOR_REF_HAS_NO_GENERATOR"):
await abc.lookup_block_generators(blocks[1].header_hash, {uint32(1)})

expect_gen = blocks[2].transactions_generator
Expand Down
8 changes: 4 additions & 4 deletions chia/_tests/blockchain/test_blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -4120,24 +4120,24 @@ async def test_lookup_block_generators(
# make sure we don't cross the forks
if clear_cache:
b.clean_block_records()
with pytest.raises(ValueError, match="Err.GENERATOR_REF_HAS_NO_GENERATOR"):
with pytest.raises(ValueError, match="Err\\.GENERATOR_REF_HAS_NO_GENERATOR"):
await b.lookup_block_generators(peak_1.prev_header_hash, {uint32(516)})

if clear_cache:
b.clean_block_records()
with pytest.raises(ValueError, match="Err.GENERATOR_REF_HAS_NO_GENERATOR"):
with pytest.raises(ValueError, match="Err\\.GENERATOR_REF_HAS_NO_GENERATOR"):
await b.lookup_block_generators(peak_2.prev_header_hash, {uint32(503)})

# make sure we fail when looking up a non-transaction block from the main
# chain, regardless of which chain we start at
if clear_cache:
b.clean_block_records()
with pytest.raises(ValueError, match="Err.GENERATOR_REF_HAS_NO_GENERATOR"):
with pytest.raises(ValueError, match="Err\\.GENERATOR_REF_HAS_NO_GENERATOR"):
await b.lookup_block_generators(peak_1.prev_header_hash, {uint32(8)})

if clear_cache:
b.clean_block_records()
with pytest.raises(ValueError, match="Err.GENERATOR_REF_HAS_NO_GENERATOR"):
with pytest.raises(ValueError, match="Err\\.GENERATOR_REF_HAS_NO_GENERATOR"):
await b.lookup_block_generators(peak_2.prev_header_hash, {uint32(8)})

# if we try to look up generators starting from a disconnected block, we
Expand Down
4 changes: 2 additions & 2 deletions chia/_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ def blockchain_constants(consensus_mode: ConsensusMode) -> ConsensusConstants:
@pytest.fixture(scope="session", name="bt")
async def block_tools_fixture(get_keychain, blockchain_constants, anyio_backend) -> BlockTools:
# Note that this causes a lot of CPU and disk traffic - disk, DB, ports, process creation ...
_shared_block_tools = await create_block_tools_async(constants=blockchain_constants, keychain=get_keychain)
return _shared_block_tools
shared_block_tools = await create_block_tools_async(constants=blockchain_constants, keychain=get_keychain)
return shared_block_tools


# if you have a system that has an unusual hostname for localhost and you want
Expand Down
2 changes: 1 addition & 1 deletion chia/_tests/core/data_layer/test_data_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2272,7 +2272,7 @@ async def test_unsubscribe_unknown(
bare_data_layer_api: DataLayerRpcApi,
seeded_random: random.Random,
) -> None:
with pytest.raises(RuntimeError, match="No subscription found for the given store_id."):
with pytest.raises(RuntimeError, match="No subscription found for the given store_id\\."):
await bare_data_layer_api.unsubscribe(request={"id": bytes32.random(seeded_random).hex(), "retain": False})


Expand Down
2 changes: 1 addition & 1 deletion chia/_tests/core/data_layer/test_data_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ async def test_ancestor_table_unique_inserts(data_store: DataStore, store_id: by
hash_2 = bytes32.from_hexstr("924be8ff27e84cba17f5bc918097f8410fab9824713a4668a21c8e060a8cab40")
await data_store._insert_ancestor_table(hash_1, hash_2, store_id, 2)
await data_store._insert_ancestor_table(hash_1, hash_2, store_id, 2)
with pytest.raises(Exception, match="^Requested insertion of ancestor"):
with pytest.raises(Exception, match=r"^Requested insertion of ancestor"):
await data_store._insert_ancestor_table(hash_1, hash_1, store_id, 2)
await data_store._insert_ancestor_table(hash_1, hash_2, store_id, 2)

Expand Down
2 changes: 1 addition & 1 deletion chia/_tests/core/full_node/test_address_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ async def test_addrman_eviction_works(self):
# use tmp_path pytest fixture to create a temporary directory
async def test_serialization(self, tmp_path: Path):
addrman = AddressManagerTest()
now = int(math.floor(time.time()))
now = math.floor(time.time())
t_peer1 = TimestampedPeerInfo("250.7.1.1", uint16(8333), uint64(now - 10000))
t_peer2 = TimestampedPeerInfo("250.7.2.2", uint16(9999), uint64(now - 20000))
t_peer3 = TimestampedPeerInfo("250.7.3.3", uint16(9999), uint64(now - 30000))
Expand Down
2 changes: 1 addition & 1 deletion chia/_tests/core/mempool/test_singleton_fast_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ async def get_unspent_lineage_info_for_puzzle_hash(puzzle_hash: bytes32) -> Opti
eligible_coin_spends = EligibleCoinSpends()
# We have no fast forward records yet, so we'll process this coin for the
# first time here, but the DB lookup will return None
with pytest.raises(ValueError, match="Cannot proceed with singleton spend fast forward."):
with pytest.raises(ValueError, match="Cannot proceed with singleton spend fast forward\\."):
await eligible_coin_spends.process_fast_forward_spends(
mempool_item=internal_mempool_item,
get_unspent_lineage_info_for_puzzle_hash=get_unspent_lineage_info_for_puzzle_hash,
Expand Down
8 changes: 5 additions & 3 deletions chia/_tests/pools/test_pool_puzzles_lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def test_pool_lifecycle(self):
)
# Spend it and hope it fails!
with pytest.raises(
BadSpendBundleError, match="condition validation failure Err.ASSERT_ANNOUNCE_CONSUMED_FAILED"
BadSpendBundleError, match="condition validation failure Err\\.ASSERT_ANNOUNCE_CONSUMED_FAILED"
):
coin_db.update_coin_store_for_spend_bundle(
SpendBundle([singleton_coinsol], G2Element()), time, DEFAULT_CONSTANTS.MAX_BLOCK_COST_CLVM
Expand All @@ -270,7 +270,7 @@ def test_pool_lifecycle(self):
)
# Spend it and hope it fails!
with pytest.raises(
BadSpendBundleError, match="condition validation failure Err.ASSERT_ANNOUNCE_CONSUMED_FAILED"
BadSpendBundleError, match="condition validation failure Err\\.ASSERT_ANNOUNCE_CONSUMED_FAILED"
):
coin_db.update_coin_store_for_spend_bundle(
SpendBundle([singleton_coinsol, bad_coinsol], G2Element()), time, DEFAULT_CONSTANTS.MAX_BLOCK_COST_CLVM
Expand Down Expand Up @@ -321,7 +321,9 @@ def test_pool_lifecycle(self):
(data + singleton.name() + DEFAULT_CONSTANTS.AGG_SIG_ME_ADDITIONAL_DATA),
)
# Spend it and hope it fails!
with pytest.raises(BadSpendBundleError, match="condition validation failure Err.ASSERT_HEIGHT_RELATIVE_FAILED"):
with pytest.raises(
BadSpendBundleError, match="condition validation failure Err\\.ASSERT_HEIGHT_RELATIVE_FAILED"
):
coin_db.update_coin_store_for_spend_bundle(
SpendBundle([return_coinsol], sig), time, DEFAULT_CONSTANTS.MAX_BLOCK_COST_CLVM
)
Expand Down
20 changes: 10 additions & 10 deletions chia/_tests/util/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def test_split_manager_raises_on_second_entry() -> None:
split = SplitManager(manager=sync_manager(y=x), object=None)
split.enter()

with pytest.raises(Exception, match="^already entered$"):
with pytest.raises(Exception, match=r"^already entered$"):
split.enter()


Expand All @@ -193,7 +193,7 @@ def test_split_manager_raises_on_second_entry_after_exiting() -> None:
split.enter()
split.exit()

with pytest.raises(Exception, match="^already entered, already exited$"):
with pytest.raises(Exception, match=r"^already entered, already exited$"):
split.enter()


Expand All @@ -204,7 +204,7 @@ def test_split_manager_raises_on_second_exit() -> None:
split.enter()
split.exit()

with pytest.raises(Exception, match="^already exited$"):
with pytest.raises(Exception, match=r"^already exited$"):
split.exit()


Expand All @@ -213,7 +213,7 @@ def test_split_manager_raises_on_exit_without_entry() -> None:

split = SplitManager(manager=sync_manager(y=x), object=None)

with pytest.raises(Exception, match="^not yet entered$"):
with pytest.raises(Exception, match=r"^not yet entered$"):
split.exit()


Expand Down Expand Up @@ -274,7 +274,7 @@ async def test_split_async_manager_raises_on_second_entry() -> None:
split = SplitAsyncManager(manager=async_manager(y=x), object=None)
await split.enter()

with pytest.raises(Exception, match="^already entered$"):
with pytest.raises(Exception, match=r"^already entered$"):
await split.enter()


Expand All @@ -286,7 +286,7 @@ async def test_split_async_manager_raises_on_second_entry_after_exiting() -> Non
await split.enter()
await split.exit()

with pytest.raises(Exception, match="^already entered, already exited$"):
with pytest.raises(Exception, match=r"^already entered, already exited$"):
await split.enter()


Expand All @@ -298,7 +298,7 @@ async def test_split_async_manager_raises_on_second_exit() -> None:
await split.enter()
await split.exit()

with pytest.raises(Exception, match="^already exited$"):
with pytest.raises(Exception, match=r"^already exited$"):
await split.exit()


Expand All @@ -308,7 +308,7 @@ async def test_split_async_manager_raises_on_exit_without_entry() -> None:

split = SplitAsyncManager(manager=async_manager(y=x), object=None)

with pytest.raises(Exception, match="^not yet entered$"):
with pytest.raises(Exception, match=r"^not yet entered$"):
await split.exit()


Expand Down Expand Up @@ -390,7 +390,7 @@ async def test_valued_event_set_again_raises_and_does_not_change_value() -> None
value = 37
valued_event.set(value)

with pytest.raises(Exception, match="^Value already set$"):
with pytest.raises(Exception, match=r"^Value already set$"):
valued_event.set(value + 1)

with anyio.fail_after(adjusted_timeout(10)):
Expand All @@ -404,7 +404,7 @@ async def test_valued_event_wait_raises_if_not_set() -> None:
valued_event = ValuedEvent[int]()
valued_event._event.set()

with pytest.raises(Exception, match="^Value not set despite event being set$"):
with pytest.raises(Exception, match=r"^Value not set despite event being set$"):
with anyio.fail_after(adjusted_timeout(10)):
await valued_event.wait()

Expand Down
2 changes: 1 addition & 1 deletion chia/_tests/wallet/cat_wallet/test_cat_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ async def check_all_there() -> bool:
assert action_scope.side_effects.transactions[0].amount == uint64(max_sent_amount)

# 3) Generate transaction that is greater than limit
with pytest.raises(ValueError, match="Can't select amount higher than our spendable balance."):
with pytest.raises(ValueError, match="Can't select amount higher than our spendable balance\\."):
async with cat_wallet.wallet_state_manager.new_action_scope(
wallet_environments.tx_config, push=False
) as action_scope:
Expand Down
2 changes: 1 addition & 1 deletion chia/_tests/wallet/nft_wallet/test_nft_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ async def test_nft_wallet_rpc_creation_and_list(wallet_environments: WalletTestF
assert resp["count"] == 2
resp = await wait_rpc_state_condition(10, env.rpc_client.fetch, ["nft_count_nfts", {}], lambda x: x["success"])
assert resp["count"] == 2
with pytest.raises(ResponseFailureError, match="Wallet 50 not found."):
with pytest.raises(ResponseFailureError, match="Wallet 50 not found\\."):
resp = await wait_rpc_state_condition(
10, env.rpc_client.fetch, ["nft_count_nfts", {"wallet_id": 50}], lambda x: x["success"] is False
)
Expand Down
10 changes: 5 additions & 5 deletions chia/cmds/cmd_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,10 @@ def _generate_command_parser(cls: type[ChiaCommand]) -> _CommandParsingStage:
needs_context: bool = False

hints = get_type_hints(cls)
_fields = fields(cls) # type: ignore[arg-type]
fields_ = fields(cls) # type: ignore[arg-type]

for _field in _fields:
field_name = _field.name
for field_ in fields_:
field_name = field_.name
if getattr(hints[field_name], COMMAND_HELPER_ATTRIBUTE_NAME, False):
members[field_name] = _generate_command_parser(hints[field_name])
elif field_name == "context":
Expand All @@ -192,9 +192,9 @@ def _generate_command_parser(cls: type[ChiaCommand]) -> _CommandParsingStage:
else:
needs_context = True
kwarg_names.append(field_name)
elif "option_args" in _field.metadata:
elif "option_args" in field_.metadata:
option_args: dict[str, Any] = {"multiple": False, "required": False}
option_args.update(_field.metadata["option_args"])
option_args.update(field_.metadata["option_args"])

if "type" not in option_args:
origin = get_origin(hints[field_name])
Expand Down
10 changes: 5 additions & 5 deletions chia/plotting/check_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ def process_plot(plot_path: Path, plot_info: PlotInfo, num_start: int, num_end:
challenge = std_hash(i.to_bytes(32, "big"))
# Some plot errors cause get_qualities_for_challenge to throw a RuntimeError
try:
quality_start_time = int(round(time() * 1000))
quality_start_time = round(time() * 1000)
for index, quality_str in enumerate(pr.get_qualities_for_challenge(challenge)):
quality_spent_time = int(round(time() * 1000)) - quality_start_time
quality_spent_time = round(time() * 1000) - quality_start_time
if quality_spent_time > 8000:
log.warning(
f"\tLooking up qualities took: {quality_spent_time} ms. This should be below 8 seconds "
Expand All @@ -183,9 +183,9 @@ def process_plot(plot_path: Path, plot_info: PlotInfo, num_start: int, num_end:

# Other plot errors cause get_full_proof or validate_proof to throw an AssertionError
try:
proof_start_time = int(round(time() * 1000))
proof_start_time = round(time() * 1000)
proof = pr.get_full_proof(challenge, index, parallel_read)
proof_spent_time = int(round(time() * 1000)) - proof_start_time
proof_spent_time = round(time() * 1000) - proof_start_time
if proof_spent_time > 15000:
log.warning(
f"\tFinding proof took: {proof_spent_time} ms. This should be below 15 seconds "
Expand All @@ -207,7 +207,7 @@ def process_plot(plot_path: Path, plot_info: PlotInfo, num_start: int, num_end:
f"{type(e)}: {e} error in proving/verifying for plot {plot_path}. Filepath: {plot_path}"
)
caught_exception = True
quality_start_time = int(round(time() * 1000))
quality_start_time = round(time() * 1000)
except KeyboardInterrupt:
log.warning("Interrupted, closing")
return
Expand Down
6 changes: 3 additions & 3 deletions chia/server/address_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def get_bucket_position(self, key: int, is_new: bool, nBucket: int) -> int:

def is_terrible(self, now: Optional[int] = None) -> bool:
if now is None:
now = int(math.floor(time.time()))
now = math.floor(time.time())
# never remove things tried in the last minute
if self.last_try > 0 and self.last_try >= now - 60:
return False
Expand All @@ -145,7 +145,7 @@ def is_terrible(self, now: Optional[int] = None) -> bool:

def get_selection_chance(self, now: Optional[int] = None) -> float:
if now is None:
now = int(math.floor(time.time()))
now = math.floor(time.time())
chance = 1.0
since_last_try = max(now - self.last_try, 0)
# deprioritize very recent attempts away
Expand Down Expand Up @@ -565,7 +565,7 @@ def get_peers_(self) -> list[TimestampedPeerInfo]:
return addr

def cleanup(self, max_timestamp_difference: int, max_consecutive_failures: int) -> None:
now = int(math.floor(time.time()))
now = math.floor(time.time())
for bucket in range(NEW_BUCKET_COUNT):
for pos in range(BUCKET_SIZE):
if self.new_matrix[bucket][pos] != -1:
Expand Down
16 changes: 8 additions & 8 deletions chia/wallet/wallet_state_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1484,14 +1484,14 @@ async def handle_nft(
nft_data.parent_coin_spend.solution,
)
if uncurried_nft.supports_did:
_new_did_id = get_new_owner_did(uncurried_nft, nft_data.parent_coin_spend.solution.to_program())
new_did_id_ = get_new_owner_did(uncurried_nft, nft_data.parent_coin_spend.solution.to_program())
old_did_id = uncurried_nft.owner_did
if _new_did_id is None:
if new_did_id_ is None:
new_did_id = old_did_id
elif _new_did_id == b"":
elif new_did_id_ == b"":
new_did_id = None
else:
new_did_id = _new_did_id
new_did_id = new_did_id_
self.log.debug(
"Handling NFT: %s, old DID:%s, new DID:%s, old P2:%s, new P2:%s",
nft_data.parent_coin_spend,
Expand Down Expand Up @@ -2658,16 +2658,16 @@ async def gather_signing_info(self, coin_spends: list[Spend]) -> SigningInstruct
pks: list[bytes] = []
signing_targets: list[SigningTarget] = []
for coin_spend in coin_spends:
_coin_spend = coin_spend.as_coin_spend()
coin_spend_ = coin_spend.as_coin_spend()
# Get AGG_SIG conditions
conditions_dict = conditions_dict_for_solution(
_coin_spend.puzzle_reveal.to_program(),
_coin_spend.solution.to_program(),
coin_spend_.puzzle_reveal.to_program(),
coin_spend_.solution.to_program(),
self.constants.MAX_BLOCK_COST_CLVM,
)
# Create signature
for pk, msg in pkm_pairs_for_conditions_dict(
conditions_dict, _coin_spend.coin, self.constants.AGG_SIG_ME_ADDITIONAL_DATA
conditions_dict, coin_spend_.coin, self.constants.AGG_SIG_ME_ADDITIONAL_DATA
):
pk_bytes = bytes(pk)
pks.append(pk_bytes)
Expand Down
Loading

0 comments on commit 7c0dbaf

Please sign in to comment.