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
4 changes: 2 additions & 2 deletions chia/_tests/core/full_node/stores/test_block_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,8 @@ def generator(i: int) -> SerializedProgram:
store = await BlockStore.create(db_wrapper, use_cache=use_cache)

new_blocks = []
for i, block in enumerate(blocks):
block = block.replace(transactions_generator=generator(i))
for i, original_block in enumerate(blocks):
block = original_block.replace(transactions_generator=generator(i))
block_record = header_block_to_sub_block_record(
DEFAULT_CONSTANTS, uint64(0), block, uint64(0), False, uint8(0), uint32(max(0, block.height - 1)), None
)
Expand Down
6 changes: 2 additions & 4 deletions chia/_tests/core/mempool/test_mempool_fee_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ async def test_basics() -> None:

cost = uint64(5000000)
for i in range(300, 700):
i = uint32(i)
items = []
for _ in range(2, 100):
fee = uint64(10000000)
Expand All @@ -50,7 +49,7 @@ async def test_basics() -> None:
)
items.append(mempool_item2)

fee_tracker.process_block(i, items)
fee_tracker.process_block(uint32(i), items)

short, med, long = fee_tracker.estimate_fees()

Expand All @@ -72,7 +71,6 @@ async def test_fee_increase() -> None:
estimator = SmartFeeEstimator(fee_tracker, uint64(test_constants.MAX_BLOCK_COST_CLVM))
random = Random(x=1)
for i in range(300, 700):
i = uint32(i)
items = []
for _ in range(20):
fee = uint64(0)
Expand All @@ -85,7 +83,7 @@ async def test_fee_increase() -> None:
)
items.append(mempool_item)

fee_tracker.process_block(i, items)
fee_tracker.process_block(uint32(i), items)

short, med, long = fee_tracker.estimate_fees()
mempool_info = mempool_manager.mempool.fee_estimator.get_mempool_info()
Expand Down
4 changes: 2 additions & 2 deletions chia/_tests/core/util/test_keychain.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ def test_bip39_test_vectors_short(self):
test_vectors_path = importlib_resources.files(chia._tests.util.__name__).joinpath("bip39_test_vectors.json")
all_vectors = json.loads(test_vectors_path.read_text(encoding="utf-8"))

for idx, [entropy_hex, full_mnemonic, seed, short_mnemonic] in enumerate(all_vectors["english"]):
for idx, [entropy_hex, full_mnemonic, seed_hex, short_mnemonic] in enumerate(all_vectors["english"]):
entropy_bytes = bytes.fromhex(entropy_hex)
seed = bytes.fromhex(seed)
seed = bytes.fromhex(seed_hex)

assert mnemonic_from_short_words(short_mnemonic) == full_mnemonic
assert bytes_from_mnemonic(short_mnemonic) == entropy_bytes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ def test_steady_fee_pressure() -> None:
estimates_during = []
start_from = 250
for height in range(start, end):
height = uint32(height)
items = make_block(height, 1, cost, fee, num_blocks_wait_in_mempool)
items = make_block(uint32(height), 1, cost, fee, num_blocks_wait_in_mempool)
estimator.new_block(FeeBlockInfo(uint32(height), items))
if height >= start_from:
estimation = estimator.estimate_fee_rate(time_offset_seconds=time_offset_seconds * (height - start_from))
Expand Down
4 changes: 2 additions & 2 deletions chia/_tests/wallet/test_signer_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -848,8 +848,8 @@ def run(self) -> None:
with open("some file", "wb") as file:
file.write(byte_serialize_clvm_streamable(coin, translation_layer=FOO_COIN_TRANSLATION))

with open("some file2", "wb") as file:
file.write(byte_serialize_clvm_streamable(coin, translation_layer=FOO_COIN_TRANSLATION))
with open("some file2", "wb") as file2:
file2.write(byte_serialize_clvm_streamable(coin, translation_layer=FOO_COIN_TRANSLATION))

result = runner.invoke(
cmd, ["temp_cmd", "--signer-protocol-input", "some file", "--signer-protocol-input", "some file2"]
Expand Down
6 changes: 4 additions & 2 deletions chia/cmds/plotnft_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,10 @@ async def change_payout_instructions(launcher_id: bytes32, address: CliAddress,
for pool_config in old_configs:
if pool_config.launcher_id == launcher_id:
id_found = True
pool_config = replace(pool_config, payout_instructions=puzzle_hash.hex())
new_pool_configs.append(pool_config)
new_pool_config = replace(pool_config, payout_instructions=puzzle_hash.hex())
else:
new_pool_config = pool_config
new_pool_configs.append(new_pool_config)
if id_found:
print(f"Launcher Id: {launcher_id.hex()} Found, Updating Config.")
await update_pool_config(root_path, new_pool_configs)
Expand Down
4 changes: 3 additions & 1 deletion chia/cmds/wallet_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,9 @@ async def get_transactions(
if len(coin_records["coin_records"]) > 0:
coin_record = coin_records["coin_records"][0]
else:
j -= 1
# Ignoring this because it seems useful to the loop
# But we should probably consider a better loop
j -= 1 # noqa: PLW2901
skipped += 1
continue
print_transaction(
Expand Down
8 changes: 5 additions & 3 deletions chia/data_layer/data_layer_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1137,9 +1137,11 @@ async def finish_graftroot_solutions(offer: Offer, solver: Solver) -> Offer:
]
)
)
new_spend: CoinSpend = spend.replace(solution=new_solution.to_serialized())
spend = new_spend
new_spends.append(spend)
new_spends.append(spend.replace(solution=new_solution.to_serialized()))
else:
new_spends.append(spend)
else:
new_spends.append(spend)

return Offer({}, WalletSpendBundle(new_spends, offer.aggregated_signature()), offer.driver_dict)

Expand Down
8 changes: 6 additions & 2 deletions chia/data_layer/data_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -1876,8 +1876,12 @@ async def get_tree_as_nodes(self, store_id: bytes32) -> Node:
hash_to_node: dict[bytes32, Node] = {}
for node in reversed(nodes):
if isinstance(node, InternalNode):
node = replace(node, left=hash_to_node[node.left_hash], right=hash_to_node[node.right_hash])
hash_to_node[node.hash] = node
node_entry: Node = replace(
node, left=hash_to_node[node.left_hash], right=hash_to_node[node.right_hash]
)
else:
node_entry = node
hash_to_node[node_entry.hash] = node_entry

root_node = hash_to_node[root_node.hash]

Expand Down
8 changes: 4 additions & 4 deletions chia/full_node/weight_proof.py
Original file line number Diff line number Diff line change
Expand Up @@ -1532,18 +1532,18 @@ def _get_last_ses_hash(
) -> tuple[Optional[bytes32], uint32]:
for idx, block in enumerate(reversed(recent_reward_chain)):
if (block.reward_chain_block.height % constants.SUB_EPOCH_BLOCKS) == 0:
idx = len(recent_reward_chain) - 1 - idx # reverse
reversed_idx = len(recent_reward_chain) - 1 - idx # reverse
# find first block after sub slot end
while idx < len(recent_reward_chain):
curr = recent_reward_chain[idx]
while reversed_idx < len(recent_reward_chain):
curr = recent_reward_chain[reversed_idx]
if len(curr.finished_sub_slots) > 0:
for slot in curr.finished_sub_slots:
if slot.challenge_chain.subepoch_summary_hash is not None:
return (
slot.challenge_chain.subepoch_summary_hash,
curr.reward_chain_block.height,
)
idx += 1
reversed_idx += 1
return None, uint32(0)


Expand Down
3 changes: 0 additions & 3 deletions chia/seeder/crawl_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,6 @@ def load_host_to_version(self) -> tuple[dict[str, str], dict[str, uint64]]:
handshake = {}

for host, record in self.host_to_records.items():
if host not in self.host_to_records:
continue
record = self.host_to_records[host]
if record.version == "undefined":
continue
if record.handshake_time < time.time() - 5 * 24 * 3600:
Expand Down
11 changes: 7 additions & 4 deletions chia/wallet/cat_wallet/cat_outer_puzzle.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,20 @@ def solve(self, constructor: PuzzleInfo, solver: Solver, inner_puzzle: Program,
parent_coin: Coin = parent_spend.coin
also = constructor.also()
if also is not None:
solution = self._solve(also, solver, puzzle, solution)
puzzle = self._construct(also, puzzle)
constructed_solution = self._solve(also, solver, puzzle, solution)
constructed_puzzle = self._construct(also, puzzle)
else:
constructed_solution = solution
constructed_puzzle = puzzle
args = match_cat_puzzle(uncurry_puzzle(parent_spend.puzzle_reveal))
assert args is not None
_, _, parent_inner_puzzle = args
spendable_cats.append(
SpendableCAT(
coin,
tail_hash,
puzzle,
solution,
constructed_puzzle,
constructed_solution,
lineage_proof=LineageProof(
parent_coin.parent_coin_info, parent_inner_puzzle.get_tree_hash(), uint64(parent_coin.amount)
),
Expand Down
4 changes: 2 additions & 2 deletions chia/wallet/util/merkle_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ def build_merkle_tree_from_binary_tree(tuples: TupleTree) -> tuple[bytes32, dict
proof.append(right_root)
new_proofs[name] = (path, proof)
for name, (path, proof) in right_proofs.items():
path |= 1 << len(proof)
appended_path = path | (1 << len(proof))
proof.append(left_root)
new_proofs[name] = (path, proof)
new_proofs[name] = (appended_path, proof)
return new_root, new_proofs


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 @@ -1945,8 +1945,8 @@ async def _add_coin_states(
# No more singleton (maybe destroyed?)
break

coin_name = new_singleton_coin.name()
existing = await self.coin_store.get_coin_record(coin_name)
new_singleton_name = new_singleton_coin.name()
existing = await self.coin_store.get_coin_record(new_singleton_name)
if existing is None:
await self.coin_added(
new_singleton_coin,
Expand All @@ -1955,15 +1955,15 @@ async def _add_coin_states(
uint32(record.wallet_id),
record.wallet_type,
peer,
coin_name,
new_singleton_name,
coin_data,
)
await self.coin_store.set_spent(
curr_coin_state.coin.name(), uint32(curr_coin_state.spent_height)
)
await self.add_interested_coin_ids([new_singleton_coin.name()])
new_coin_state: list[CoinState] = await self.wallet_node.get_coin_state(
[coin_name], peer=peer, fork_height=fork_height
[new_singleton_name], peer=peer, fork_height=fork_height
)
assert len(new_coin_state) == 1
curr_coin_state = new_coin_state[0]
Expand Down Expand Up @@ -2039,8 +2039,8 @@ async def _add_coin_states(
launcher_spend_additions = compute_additions(launcher_spend)
assert len(launcher_spend_additions) == 1
coin_added = launcher_spend_additions[0]
coin_name = coin_added.name()
existing = await self.coin_store.get_coin_record(coin_name)
coin_added_name = coin_added.name()
existing = await self.coin_store.get_coin_record(coin_added_name)
if existing is None:
await self.coin_added(
coin_added,
Expand All @@ -2049,10 +2049,10 @@ async def _add_coin_states(
pool_wallet.id(),
pool_wallet.type(),
peer,
coin_name,
coin_added_name,
coin_data,
)
await self.add_interested_coin_ids([coin_name])
await self.add_interested_coin_ids([coin_added_name])

else:
raise RuntimeError("All cases already handled") # Logic error, all cases handled
Expand Down
1 change: 0 additions & 1 deletion ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ ignore = [
# Pylint warning
"PLW1641", # eq-without-hash
# Should probably fix these
"PLW2901", # redefined-loop-name
"PLW1514", # unspecified-encoding
"PLW0603", # global-statement

Expand Down
3 changes: 2 additions & 1 deletion tools/cpu_utilization.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ def main(pid: int, output: str, threads: bool) -> None:
out.write(f" {(c[row].system_time - c[row - 1].system_time) * 100 / time_delta:6.2f}% ")
else:
out.write(" 0.00% 0.00% ")
row += 1
# Ignoring this because it seems like I could delete it but there's no test so I'm unsure
row += 1 # noqa: PLW2901
out.write("\n")

with open("plot-cpu.gnuplot", "w+") as out:
Expand Down
Loading