Make the sized bytes types hint compatible (#9369)

* Rework sized bytes for type hinting compatibility

* add a bunch of type: ignores

* this will be handled elsewhere

* noqa E501 instead of changing code

* normalize comment plurality

* @classmethod

* Revert "@classmethod"

This reverts commit 95db80e339.

* add ignore in benchmarks

* just E501 again...

* add some new type: ignores
This commit is contained in:
Kyle Altendorf 2021-12-02 12:43:39 -05:00 committed by GitHub
parent ae8bdbc3c7
commit 8291f0221a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
58 changed files with 870 additions and 241 deletions

View File

@ -27,7 +27,9 @@ random.seed(123456789)
def rand_class_group_element() -> ClassgroupElement:
return ClassgroupElement(rand_bytes(100))
# TODO: address hint errors and remove ignores
# error: Argument 1 to "ClassgroupElement" has incompatible type "bytes"; expected "bytes100" [arg-type]
return ClassgroupElement(rand_bytes(100)) # type: ignore[arg-type]
def rand_vdf() -> VDFInfo:

View File

@ -31,7 +31,9 @@ def rand_bytes(num) -> bytes:
def rand_hash() -> bytes32:
return rand_bytes(32)
# TODO: address hint errors and remove ignores
# error: Incompatible return value type (got "bytes", expected "bytes32") [return-value]
return rand_bytes(32) # type: ignore[return-value]
def rand_g1() -> G1Element:

View File

@ -109,7 +109,10 @@ class SpendSim:
return None
return simple_solution_generator(bundle)
async def farm_block(self, puzzle_hash: bytes32 = (b"0" * 32)):
# TODO: address hint error and remove ignore
# error: Incompatible default for argument "puzzle_hash" (default has type "bytes", argument has type
# "bytes32") [assignment]
async def farm_block(self, puzzle_hash: bytes32 = (b"0" * 32)): # type: ignore[assignment]
# Fees get calculated
fees = uint64(0)
if self.mempool_manager.mempool.spends:

View File

@ -84,8 +84,11 @@ async def create(args: dict, wallet_client: WalletRpcClient, fingerprint: int) -
if user_input.lower() == "y" or user_input.lower() == "yes":
try:
# TODO: address hint error and remove ignore
# error: Argument 1 to "create_new_pool_wallet" of "WalletRpcClient" has incompatible type
# "Optional[bytes]"; expected "Optional[bytes32]" [arg-type]
tx_record: TransactionRecord = await wallet_client.create_new_pool_wallet(
target_puzzle_hash,
target_puzzle_hash, # type: ignore[arg-type]
pool_url,
relative_lock_height,
"localhost:5000",
@ -161,7 +164,10 @@ async def pprint_pool_wallet_state(
print(f"Relative lock height: {pool_wallet_info.current.relative_lock_height} blocks")
payout_instructions: str = pool_state_dict[pool_wallet_info.launcher_id]["pool_config"]["payout_instructions"]
try:
payout_address = encode_puzzle_hash(bytes32.fromhex(payout_instructions), address_prefix)
# TODO: address hint error and remove ignore
# error: Argument 1 to "encode_puzzle_hash" has incompatible type "bytes"; expected "bytes32"
# [arg-type]
payout_address = encode_puzzle_hash(bytes32.fromhex(payout_instructions), address_prefix) # type: ignore[arg-type] # noqa: E501
print(f"Payout instructions (pool will pay to this address): {payout_address}")
except Exception:
print(f"Payout instructions (pool will pay you with this): {payout_instructions}")
@ -201,7 +207,10 @@ async def show(args: dict, wallet_client: WalletRpcClient, fingerprint: int) ->
await farmer_client.await_closed()
return
pool_state_dict: Dict[bytes32, Dict] = {
hexstr_to_bytes(pool_state_item["pool_config"]["launcher_id"]): pool_state_item
# TODO: address hint error and remove ignore
# error: Key expression in dictionary comprehension has incompatible type "bytes"; expected type "bytes32"
# [misc]
hexstr_to_bytes(pool_state_item["pool_config"]["launcher_id"]): pool_state_item # type: ignore[misc]
for pool_state_item in pool_state_list
}
if wallet_id_passed_in is not None:
@ -242,7 +251,10 @@ async def show(args: dict, wallet_client: WalletRpcClient, fingerprint: int) ->
async def get_login_link(launcher_id_str: str) -> None:
launcher_id: bytes32 = hexstr_to_bytes(launcher_id_str)
# TODO: address hint error and remove ignore
# error: Incompatible types in assignment (expression has type "bytes", variable has type "bytes32")
# [assignment]
launcher_id: bytes32 = hexstr_to_bytes(launcher_id_str) # type: ignore[assignment]
config = load_config(DEFAULT_ROOT_PATH, "config.yaml")
self_hostname = config["self_hostname"]
farmer_rpc_port = config["farmer"]["rpc_port"]

View File

@ -135,8 +135,11 @@ async def show_async(
peak_hash = "No Info"
if peak_height is None:
peak_height = 0
# TODO: address hint error and remove ignore
# error: On Python 3 '{}'.format(b'abc') produces "b'abc'", not 'abc'; use
# '{!r}'.format(b'abc') if this is desired behavior [str-bytes-safe]
con_str = (
f"{NodeType(con['type']).name:9} {host:38} "
f"{NodeType(con['type']).name:9} {host:38} " # type: ignore[str-bytes-safe]
f"{con['peer_port']:5}/{con['peer_server_port']:<5}"
f" {con['node_id'].hex()[:8]}... "
f"{last_connect} "

View File

@ -38,7 +38,10 @@ async def get_transaction(args: dict, wallet_client: WalletRpcClient, fingerprin
transaction_id = hexstr_to_bytes(args["tx_id"])
config = load_config(DEFAULT_ROOT_PATH, "config.yaml", SERVICE_NAME)
name = config["network_overrides"]["config"][config["selected_network"]]["address_prefix"]
tx: TransactionRecord = await wallet_client.get_transaction(wallet_id, transaction_id=transaction_id)
# TODO: address hint error and remove ignore
# error: Argument "transaction_id" to "get_transaction" of "WalletRpcClient" has incompatible type "bytes";
# expected "bytes32" [arg-type]
tx: TransactionRecord = await wallet_client.get_transaction(wallet_id, transaction_id=transaction_id) # type: ignore[arg-type] # noqa: E501
print_transaction(tx, verbose=(args["verbose"] > 0), name=name)

View File

@ -250,9 +250,15 @@ async def validate_block_body(
byte_array_tx: List[bytes32] = []
for coin in additions + coinbase_additions:
byte_array_tx.append(bytearray(coin.puzzle_hash))
# TODO: address hint error and remove ignore
# error: Argument 1 to "append" of "list" has incompatible type "bytearray"; expected "bytes32"
# [arg-type]
byte_array_tx.append(bytearray(coin.puzzle_hash)) # type: ignore[arg-type]
for coin_name in removals:
byte_array_tx.append(bytearray(coin_name))
# TODO: address hint error and remove ignore
# error: Argument 1 to "append" of "list" has incompatible type "bytearray"; expected "bytes32"
# [arg-type]
byte_array_tx.append(bytearray(coin_name)) # type: ignore[arg-type]
bip158: PyBIP158 = PyBIP158(byte_array_tx)
encoded_filter = bytes(bip158.GetEncoded())

View File

@ -35,6 +35,9 @@ from chia.util.recursive_replace import recursive_replace
log = logging.getLogger(__name__)
# TODO: address hint error and remove ignore
# error: Incompatible default for argument "seed" (default has type "bytes", argument has type "bytes32")
# [assignment]
def create_foliage(
constants: ConsensusConstants,
reward_block_unfinished: RewardChainBlockUnfinished,
@ -50,7 +53,7 @@ def create_foliage(
pool_target: PoolTarget,
get_plot_signature: Callable[[bytes32, G1Element], G2Element],
get_pool_signature: Callable[[PoolTarget, Optional[G1Element]], Optional[G2Element]],
seed: bytes32 = b"",
seed: bytes32 = b"", # type: ignore[assignment]
) -> Tuple[Foliage, Optional[FoliageTransactionBlock], Optional[TransactionsInfo]]:
"""
Creates a foliage for a given reward chain block. This may or may not be a tx block. In the case of a tx block,
@ -85,7 +88,10 @@ def create_foliage(
random.seed(seed)
# Use the extension data to create different blocks based on header hash
extension_data: bytes32 = random.randint(0, 100000000).to_bytes(32, "big")
# TODO: address hint error and remove ignore
# error: Incompatible types in assignment (expression has type "bytes", variable has type "bytes32")
# [assignment]
extension_data: bytes32 = random.randint(0, 100000000).to_bytes(32, "big") # type: ignore[assignment]
if prev_block is None:
height: uint32 = uint32(0)
else:
@ -187,10 +193,16 @@ def create_foliage(
additions.extend(reward_claims_incorporated.copy())
for coin in additions:
tx_additions.append(coin)
byte_array_tx.append(bytearray(coin.puzzle_hash))
# TODO: address hint error and remove ignore
# error: Argument 1 to "append" of "list" has incompatible type "bytearray"; expected "bytes32"
# [arg-type]
byte_array_tx.append(bytearray(coin.puzzle_hash)) # type: ignore[arg-type]
for coin in removals:
tx_removals.append(coin.name())
byte_array_tx.append(bytearray(coin.name()))
# TODO: address hint error and remove ignore
# error: Argument 1 to "append" of "list" has incompatible type "bytearray"; expected "bytes32"
# [arg-type]
byte_array_tx.append(bytearray(coin.name())) # type: ignore[arg-type]
bip158: PyBIP158 = PyBIP158(byte_array_tx)
encoded = bytes(bip158.GetEncoded())
@ -244,12 +256,17 @@ def create_foliage(
prev_transaction_block_hash = prev_transaction_block.header_hash
assert transactions_info is not None
# TODO: address hint error and remove ignore
# error: Argument 4 to "FoliageTransactionBlock" has incompatible type "bytes"; expected "bytes32"
# [arg-type]
# error: Argument 5 to "FoliageTransactionBlock" has incompatible type "bytes"; expected "bytes32"
# [arg-type]
foliage_transaction_block: Optional[FoliageTransactionBlock] = FoliageTransactionBlock(
prev_transaction_block_hash,
timestamp,
filter_hash,
additions_root,
removals_root,
additions_root, # type: ignore[arg-type]
removals_root, # type: ignore[arg-type]
transactions_info.get_hash(),
)
assert foliage_transaction_block is not None
@ -260,7 +277,10 @@ def create_foliage(
)
assert foliage_transaction_block_signature is not None
else:
foliage_transaction_block_hash = None
# TODO: address hint error and remove ignore
# error: Incompatible types in assignment (expression has type "None", variable has type "bytes32")
# [assignment]
foliage_transaction_block_hash = None # type: ignore[assignment]
foliage_transaction_block_signature = None
foliage_transaction_block = None
transactions_info = None
@ -278,6 +298,9 @@ def create_foliage(
return foliage, foliage_transaction_block, transactions_info
# TODO: address hint error and remove ignore
# error: Incompatible default for argument "seed" (default has type "bytes", argument has type "bytes32")
# [assignment]
def create_unfinished_block(
constants: ConsensusConstants,
sub_slot_start_total_iters: uint128,
@ -294,7 +317,7 @@ def create_unfinished_block(
signage_point: SignagePoint,
timestamp: uint64,
blocks: BlockchainInterface,
seed: bytes32 = b"",
seed: bytes32 = b"", # type: ignore[assignment]
block_generator: Optional[BlockGenerator] = None,
aggregate_sig: G2Element = G2Element(),
additions: Optional[List[Coin]] = None,

View File

@ -163,7 +163,10 @@ class Blockchain(BlockchainInterface):
if self._peak_height is None:
return None
""" Return list of FullBlocks that are peaks"""
block = await self.block_store.get_full_block(self.height_to_hash(self._peak_height))
# TODO: address hint error and remove ignore
# error: Argument 1 to "get_full_block" of "BlockStore" has incompatible type "Optional[bytes32]";
# expected "bytes32" [arg-type]
block = await self.block_store.get_full_block(self.height_to_hash(self._peak_height)) # type: ignore[arg-type]
assert block is not None
return block
@ -311,7 +314,10 @@ class Blockchain(BlockchainInterface):
if len(condition.vars) > 2 and condition.vars[2] != b"":
puzzle_hash, amount_bin = condition.vars[0], condition.vars[1]
amount = int_from_bytes(amount_bin)
coin_id = Coin(npc.coin_name, puzzle_hash, amount).name()
# TODO: address hint error and remove ignore
# error: Argument 2 to "Coin" has incompatible type "bytes"; expected "bytes32"
# [arg-type]
coin_id = Coin(npc.coin_name, puzzle_hash, amount).name() # type: ignore[arg-type]
h_list.append((coin_id, condition.vars[2]))
return h_list
@ -437,17 +443,29 @@ class Blockchain(BlockchainInterface):
for coin_id, hint in hint_list:
key = hint
if key not in hint_coin_state:
hint_coin_state[key] = {}
hint_coin_state[key][coin_id] = lastest_coin_state[coin_id]
# TODO: address hint error and remove ignore
# error: Invalid index type "bytes" for
# "Dict[bytes32, Dict[bytes32, CoinRecord]]"; expected type "bytes32" [index]
hint_coin_state[key] = {} # type: ignore[index]
# TODO: address hint error and remove ignore
# error: Invalid index type "bytes" for "Dict[bytes32, Dict[bytes32, CoinRecord]]";
# expected type "bytes32" [index]
hint_coin_state[key][coin_id] = lastest_coin_state[coin_id] # type: ignore[index]
# Changes the peak to be the new peak
await self.block_store.set_peak(block_record.header_hash)
# TODO: address hint error and remove ignore
# error: Incompatible return value type (got
# "Tuple[uint32, uint32, List[BlockRecord], Tuple[List[CoinRecord], Dict[bytes32, Dict[bytes32, CoinRecord]]]]", # noqa: E501
# expected
# "Tuple[Optional[uint32], Optional[uint32], List[BlockRecord], Tuple[List[CoinRecord], Dict[bytes, Dict[bytes32, CoinRecord]]]]" # noqa: E501
# ) [return-value]
return (
uint32(max(fork_height, 0)),
block_record.height,
records_to_add,
(list(lastest_coin_state.values()), hint_coin_state),
)
) # type: ignore[return-value]
# This is not a heavier block than the heaviest we have seen, so we don't change the coin set
return None, None, [], ([], {})
@ -669,7 +687,10 @@ class Blockchain(BlockchainInterface):
def height_to_block_record(self, height: uint32) -> BlockRecord:
header_hash = self.height_to_hash(height)
return self.block_record(header_hash)
# TODO: address hint error and remove ignore
# error: Argument 1 to "block_record" of "Blockchain" has incompatible type "Optional[bytes32]"; expected
# "bytes32" [arg-type]
return self.block_record(header_hash) # type: ignore[arg-type]
def get_ses_heights(self) -> List[uint32]:
return self.__height_map.get_ses_heights()
@ -746,7 +767,10 @@ class Blockchain(BlockchainInterface):
hashes = []
for height in range(start, stop + 1):
if self.contains_height(uint32(height)):
header_hash: bytes32 = self.height_to_hash(uint32(height))
# TODO: address hint error and remove ignore
# error: Incompatible types in assignment (expression has type "Optional[bytes32]", variable has
# type "bytes32") [assignment]
header_hash: bytes32 = self.height_to_hash(uint32(height)) # type: ignore[assignment]
hashes.append(header_hash)
blocks: List[FullBlock] = []
@ -796,12 +820,18 @@ class Blockchain(BlockchainInterface):
for height in heights:
hashes.append(self.height_to_hash(height))
if len(hashes) > batch_size:
res = await self.block_store.get_block_records_by_hash(hashes)
# TODO: address hint error and remove ignore
# error: Argument 1 to "get_block_records_by_hash" of "BlockStore" has incompatible type
# "List[Optional[bytes32]]"; expected "List[bytes32]" [arg-type]
res = await self.block_store.get_block_records_by_hash(hashes) # type: ignore[arg-type]
records.extend(res)
hashes = []
if len(hashes) > 0:
res = await self.block_store.get_block_records_by_hash(hashes)
# TODO: address hint error and remove ignore
# error: Argument 1 to "get_block_records_by_hash" of "BlockStore" has incompatible type
# "List[Optional[bytes32]]"; expected "List[bytes32]" [arg-type]
res = await self.block_store.get_block_records_by_hash(hashes) # type: ignore[arg-type]
records.extend(res)
return records
@ -825,12 +855,22 @@ class Blockchain(BlockchainInterface):
self.__heights_in_cache[block_record.height] = set()
self.__heights_in_cache[block_record.height].add(block_record.header_hash)
async def persist_sub_epoch_challenge_segments(
# TODO: address hint error and remove ignore
# error: Argument 1 of "persist_sub_epoch_challenge_segments" is incompatible with supertype
# "BlockchainInterface"; supertype defines the argument type as "uint32" [override]
# note: This violates the Liskov substitution principle
# note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
async def persist_sub_epoch_challenge_segments( # type: ignore[override]
self, ses_block_hash: bytes32, segments: List[SubEpochChallengeSegment]
):
return await self.block_store.persist_sub_epoch_challenge_segments(ses_block_hash, segments)
async def get_sub_epoch_challenge_segments(
# TODO: address hint error and remove ignore
# error: Argument 1 of "get_sub_epoch_challenge_segments" is incompatible with supertype
# "BlockchainInterface"; supertype defines the argument type as "uint32" [override]
# note: This violates the Liskov substitution principle
# note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
async def get_sub_epoch_challenge_segments( # type: ignore[override]
self,
ses_block_hash: bytes32,
) -> Optional[List[SubEpochChallengeSegment]]:
@ -873,7 +913,10 @@ class Blockchain(BlockchainInterface):
# We are not in a reorg, no need to look up alternate header hashes (we can get them from height_to_hash)
for ref_height in block.transactions_generator_ref_list:
header_hash = self.height_to_hash(ref_height)
ref_block = await self.get_full_block(header_hash)
# TODO: address hint error and remove ignore
# error: Argument 1 to "get_full_block" of "Blockchain" has incompatible type "Optional[bytes32]";
# expected "bytes32" [arg-type]
ref_block = await self.get_full_block(header_hash) # type: ignore[arg-type]
assert ref_block is not None
if ref_block.transactions_generator is None:
raise ValueError(Err.GENERATOR_REF_HAS_NO_GENERATOR)
@ -920,7 +963,10 @@ class Blockchain(BlockchainInterface):
ref_block = additional_height_dict[ref_height]
else:
header_hash = self.height_to_hash(ref_height)
ref_block = await self.get_full_block(header_hash)
# TODO: address hint error and remove ignore
# error: Argument 1 to "get_full_block" of "Blockchain" has incompatible type
# "Optional[bytes32]"; expected "bytes32" [arg-type]
ref_block = await self.get_full_block(header_hash) # type: ignore[arg-type]
assert ref_block is not None
if ref_block.transactions_generator is None:
raise ValueError(Err.GENERATOR_REF_HAS_NO_GENERATOR)

View File

@ -15,7 +15,9 @@ def pool_parent_id(block_height: uint32, genesis_challenge: bytes32) -> bytes32:
def farmer_parent_id(block_height: uint32, genesis_challenge: bytes32) -> uint32:
return bytes32(genesis_challenge[16:] + block_height.to_bytes(16, "big"))
# TODO: address hint error and remove ignore
# error: Incompatible return value type (got "bytes32", expected "uint32") [return-value]
return bytes32(genesis_challenge[16:] + block_height.to_bytes(16, "big")) # type: ignore[return-value]
def create_pool_coin(block_height: uint32, puzzle_hash: bytes32, reward: uint64, genesis_challenge: bytes32):
@ -25,4 +27,6 @@ def create_pool_coin(block_height: uint32, puzzle_hash: bytes32, reward: uint64,
def create_farmer_coin(block_height: uint32, puzzle_hash: bytes32, reward: uint64, genesis_challenge: bytes32):
parent_id = farmer_parent_id(block_height, genesis_challenge)
return Coin(parent_id, puzzle_hash, reward)
# TODO: address hint error and remove ignore
# error: Argument 1 to "Coin" has incompatible type "uint32"; expected "bytes32" [arg-type]
return Coin(parent_id, puzzle_hash, reward) # type: ignore[arg-type]

View File

@ -87,9 +87,12 @@ def batch_pre_validate_blocks(
removals, tx_additions = tx_removals_and_additions(npc_result.npc_list)
header_block = get_block_header(block, tx_additions, removals)
# TODO: address hint error and remove ignore
# error: Argument 1 to "BlockCache" has incompatible type "Dict[bytes, BlockRecord]"; expected
# "Dict[bytes32, BlockRecord]" [arg-type]
required_iters, error = validate_finished_header_block(
constants,
BlockCache(blocks),
BlockCache(blocks), # type: ignore[arg-type]
header_block,
check_filter,
expected_difficulty[i],
@ -108,9 +111,12 @@ def batch_pre_validate_blocks(
for i in range(len(header_blocks_pickled)):
try:
header_block = HeaderBlock.from_bytes(header_blocks_pickled[i])
# TODO: address hint error and remove ignore
# error: Argument 1 to "BlockCache" has incompatible type "Dict[bytes, BlockRecord]"; expected
# "Dict[bytes32, BlockRecord]" [arg-type]
required_iters, error = validate_finished_header_block(
constants,
BlockCache(blocks),
BlockCache(blocks), # type: ignore[arg-type]
header_block,
check_filter,
expected_difficulty[i],

View File

@ -80,8 +80,14 @@ class BlockHeightMap:
# it's OK if this file doesn't exist, we can rebuild it
pass
peak: bytes32 = bytes.fromhex(row[0])
prev_hash: bytes32 = bytes.fromhex(row[1])
# TODO: address hint errors and remove ignores
# error: Incompatible types in assignment (expression has type "bytes", variable has type "bytes32")
# [assignment]
peak: bytes32 = bytes.fromhex(row[0]) # type: ignore[assignment]
# TODO: address hint errors and remove ignores
# error: Incompatible types in assignment (expression has type "bytes", variable has type "bytes32")
# [assignment]
prev_hash: bytes32 = bytes.fromhex(row[1]) # type: ignore[assignment]
height = row[2]
# allocate memory for height to hash map
@ -151,7 +157,12 @@ class BlockHeightMap:
# maps block-hash -> (height, prev-hash, sub-epoch-summary)
ordered: Dict[bytes32, Tuple[uint32, bytes32, Optional[bytes]]] = {}
for r in rows:
ordered[bytes.fromhex(r[0])] = (r[2], bytes.fromhex(r[1]), r[3])
# TODO: address hint errors and remove ignores
# error: Invalid index type "bytes" for "Dict[bytes32, Tuple[uint32, bytes32, Optional[bytes]]]";
# expected type "bytes32" [index]
# error: Incompatible types in assignment (expression has type "Tuple[Any, bytes, Any]", target
# has type "Tuple[uint32, bytes32, Optional[bytes]]") [assignment]
ordered[bytes.fromhex(r[0])] = (r[2], bytes.fromhex(r[1]), r[3]) # type: ignore[index,assignment]
while height > window_end:
entry = ordered[prev_hash]
@ -177,7 +188,9 @@ class BlockHeightMap:
def get_hash(self, height: uint32) -> bytes32:
idx = height * 32
assert idx + 32 <= len(self.__height_to_hash)
return bytes(self.__height_to_hash[idx : idx + 32])
# TODO: address hint errors and remove ignores
# error: Incompatible return value type (got "bytes", expected "bytes32") [return-value]
return bytes(self.__height_to_hash[idx : idx + 32]) # type: ignore[return-value]
def contains_height(self, height: uint32) -> bool:
return height * 32 < len(self.__height_to_hash)

View File

@ -219,7 +219,9 @@ class BlockStore:
for row in rows:
header_hash = bytes.fromhex(row[0])
full_block: FullBlock = FullBlock.from_bytes(row[1])
all_blocks[header_hash] = full_block
# TODO: address hint error and remove ignore
# error: Invalid index type "bytes" for "Dict[bytes32, FullBlock]"; expected type "bytes32" [index]
all_blocks[header_hash] = full_block # type: ignore[index]
self.block_cache.put(header_hash, full_block)
ret: List[FullBlock] = []
for hh in header_hashes:
@ -257,7 +259,9 @@ class BlockStore:
ret: Dict[bytes32, BlockRecord] = {}
for row in rows:
header_hash = bytes.fromhex(row[0])
ret[header_hash] = BlockRecord.from_bytes(row[1])
# TODO: address hint error and remove ignore
# error: Invalid index type "bytes" for "Dict[bytes32, BlockRecord]"; expected type "bytes32" [index]
ret[header_hash] = BlockRecord.from_bytes(row[1]) # type: ignore[index]
return ret
@ -282,8 +286,13 @@ class BlockStore:
ret: Dict[bytes32, BlockRecord] = {}
for row in rows:
header_hash = bytes.fromhex(row[0])
ret[header_hash] = BlockRecord.from_bytes(row[1])
return ret, bytes.fromhex(peak_row[0])
# TODO: address hint error and remove ignore
# error: Invalid index type "bytes" for "Dict[bytes32, BlockRecord]"; expected type "bytes32" [index]
ret[header_hash] = BlockRecord.from_bytes(row[1]) # type: ignore[index]
# TODO: address hint error and remove ignore
# error: Incompatible return value type (got "Tuple[Dict[bytes32, BlockRecord], bytes]", expected
# "Tuple[Dict[bytes32, BlockRecord], Optional[bytes32]]") [return-value]
return ret, bytes.fromhex(peak_row[0]) # type: ignore[return-value]
async def set_peak(self, header_hash: bytes32) -> None:
# We need to be in a sqlite transaction here.

View File

@ -388,8 +388,12 @@ class FullNode:
mempool_new_peak_result, fns_peak_result = await self.peak_post_processing(
peak_fb, peak, fork_height, peer, coin_changes[0]
)
# TODO: address hint error and remove ignore
# error: Argument 5 to "peak_post_processing_2" of "FullNode" has incompatible type
# "Tuple[List[CoinRecord], Dict[bytes, Dict[bytes, CoinRecord]]]"; expected
# "Tuple[List[CoinRecord], Dict[bytes, Dict[bytes32, CoinRecord]]]" [arg-type]
await self.peak_post_processing_2(
peak_fb, peak, fork_height, peer, coin_changes, mempool_new_peak_result, fns_peak_result
peak_fb, peak, fork_height, peer, coin_changes, mempool_new_peak_result, fns_peak_result # type: ignore[arg-type] # noqa: E501
)
except asyncio.CancelledError:
# Still do post processing after cancel
@ -993,7 +997,10 @@ class FullNode:
for hint, records in hint_state.items():
if hint in self.ph_subscriptions:
subscribed_peers = self.ph_subscriptions[hint]
# TODO: address hint error and remove ignore
# error: Invalid index type "bytes" for "Dict[bytes32, Set[bytes32]]"; expected type "bytes32"
# [index]
subscribed_peers = self.ph_subscriptions[hint] # type: ignore[index]
for peer in subscribed_peers:
if peer not in changes_for_peer:
changes_for_peer[peer] = set()
@ -1080,7 +1087,13 @@ class FullNode:
f"Total time for {len(blocks_to_validate)} blocks: {time.time() - pre_validate_start}, "
f"advanced: {advanced_peak}"
)
return True, advanced_peak, fork_height, (list(all_coin_changes.values()), all_hint_changes)
# TODO: address hint error and remove ignore
# error: Incompatible return value type (got
# "Tuple[bool, bool, Optional[uint32], Tuple[List[CoinRecord], Dict[bytes, Dict[bytes32, CoinRecord]]]]",
# expected
# "Tuple[bool, bool, Optional[uint32], Tuple[List[CoinRecord], Dict[bytes, Dict[bytes, CoinRecord]]]]")
# [return-value]
return True, advanced_peak, fork_height, (list(all_coin_changes.values()), all_hint_changes) # type: ignore[return-value] # noqa: E501
async def _finish_sync(self):
"""
@ -1223,7 +1236,10 @@ class FullNode:
fork_block: Optional[BlockRecord] = None
if fork_height != block.height - 1 and block.height != 0:
# This is a reorg
fork_block = self.blockchain.block_record(self.blockchain.height_to_hash(fork_height))
# TODO: address hint error and remove ignore
# error: Argument 1 to "block_record" of "Blockchain" has incompatible type "Optional[bytes32]";
# expected "bytes32" [arg-type]
fork_block = self.blockchain.block_record(self.blockchain.height_to_hash(fork_height)) # type: ignore[arg-type] # noqa: E501
fns_peak_result: FullNodeStorePeakResult = self.full_node_store.new_peak(
record,
@ -1858,10 +1874,13 @@ class FullNode:
!= self.constants.GENESIS_CHALLENGE
):
# If we don't have the prev, request the prev instead
# TODO: address hint error and remove ignore
# error: Argument 3 to "RequestSignagePointOrEndOfSubSlot" has incompatible type "bytes"; expected
# "bytes32" [arg-type]
full_node_request = full_node_protocol.RequestSignagePointOrEndOfSubSlot(
request.end_of_slot_bundle.challenge_chain.challenge_chain_end_of_slot_vdf.challenge,
uint8(0),
bytes([0] * 32),
bytes([0] * 32), # type: ignore[arg-type]
)
return (
make_msg(ProtocolMessageTypes.request_signage_point_or_end_of_sub_slot, full_node_request),

View File

@ -203,7 +203,9 @@ class FullNodeAPI:
fetch_task = asyncio.create_task(
tx_request_and_timeout(self.full_node, transaction.transaction_id, task_id)
)
self.full_node.full_node_store.tx_fetch_tasks[task_id] = fetch_task
# TODO: address hint error and remove ignore
# error: Invalid index type "bytes" for "Dict[bytes32, Task[Any]]"; expected type "bytes32" [index]
self.full_node.full_node_store.tx_fetch_tasks[task_id] = fetch_task # type: ignore[index]
return None
return None
@ -310,7 +312,10 @@ class FullNodeAPI:
msg = make_msg(ProtocolMessageTypes.reject_block, reject)
return msg
header_hash = self.full_node.blockchain.height_to_hash(request.height)
block: Optional[FullBlock] = await self.full_node.block_store.get_full_block(header_hash)
# TODO: address hint error and remove ignore
# error: Argument 1 to "get_full_block" of "BlockStore" has incompatible type "Optional[bytes32]";
# expected "bytes32" [arg-type]
block: Optional[FullBlock] = await self.full_node.block_store.get_full_block(header_hash) # type: ignore[arg-type] # noqa: E501
if block is not None:
if not request.include_transaction_block and block.transactions_generator is not None:
block = dataclasses.replace(block, transactions_generator=None)
@ -335,8 +340,11 @@ class FullNodeAPI:
if not request.include_transaction_block:
blocks: List[FullBlock] = []
for i in range(request.start_height, request.end_height + 1):
# TODO: address hint error and remove ignore
# error: Argument 1 to "get_full_block" of "BlockStore" has incompatible type "Optional[bytes32]";
# expected "bytes32" [arg-type]
block: Optional[FullBlock] = await self.full_node.block_store.get_full_block(
self.full_node.blockchain.height_to_hash(uint32(i))
self.full_node.blockchain.height_to_hash(uint32(i)) # type: ignore[arg-type]
)
if block is None:
reject = RejectBlocks(request.start_height, request.end_height)
@ -351,8 +359,11 @@ class FullNodeAPI:
else:
blocks_bytes: List[bytes] = []
for i in range(request.start_height, request.end_height + 1):
# TODO: address hint error and remove ignore
# error: Argument 1 to "get_full_block_bytes" of "BlockStore" has incompatible type
# "Optional[bytes32]"; expected "bytes32" [arg-type]
block_bytes: Optional[bytes] = await self.full_node.block_store.get_full_block_bytes(
self.full_node.blockchain.height_to_hash(uint32(i))
self.full_node.blockchain.height_to_hash(uint32(i)) # type: ignore[arg-type]
)
if block_bytes is None:
reject = RejectBlocks(request.start_height, request.end_height)
@ -887,6 +898,9 @@ class FullNodeAPI:
timestamp = uint64(int(curr.timestamp + 1))
self.log.info("Starting to make the unfinished block")
# TODO: address hint error and remove ignore
# error: Argument 16 to "create_unfinished_block" has incompatible type "bytes"; expected "bytes32"
# [arg-type]
unfinished_block: UnfinishedBlock = create_unfinished_block(
self.full_node.constants,
total_iters_pos_slot,
@ -903,7 +917,7 @@ class FullNodeAPI:
sp_vdfs,
timestamp,
self.full_node.blockchain,
b"",
b"", # type: ignore[arg-type]
block_generator,
aggregate_signature,
additions,
@ -922,17 +936,26 @@ class FullNodeAPI:
if unfinished_block.is_transaction_block():
foliage_transaction_block_hash = unfinished_block.foliage.foliage_transaction_block_hash
else:
foliage_transaction_block_hash = bytes([0] * 32)
# TODO: address hint error and remove ignore
# error: Incompatible types in assignment (expression has type "bytes", variable has type
# "Optional[bytes32]") [assignment]
foliage_transaction_block_hash = bytes([0] * 32) # type: ignore[assignment]
# TODO: address hint error and remove ignore
# error: Argument 3 to "RequestSignedValues" has incompatible type "Optional[bytes32]"; expected
# "bytes32" [arg-type]
message = farmer_protocol.RequestSignedValues(
quality_string,
foliage_sb_data_hash,
foliage_transaction_block_hash,
foliage_transaction_block_hash, # type: ignore[arg-type]
)
await peer.send_message(make_msg(ProtocolMessageTypes.request_signed_values, message))
# Adds backup in case the first one fails
if unfinished_block.is_transaction_block() and unfinished_block.transactions_generator is not None:
# TODO: address hint error and remove ignore
# error: Argument 16 to "create_unfinished_block" has incompatible type "bytes"; expected
# "bytes32" [arg-type]
unfinished_block_backup = create_unfinished_block(
self.full_node.constants,
total_iters_pos_slot,
@ -949,7 +972,7 @@ class FullNodeAPI:
sp_vdfs,
timestamp,
self.full_node.blockchain,
b"",
b"", # type: ignore[arg-type]
None,
G2Element(),
None,
@ -1019,10 +1042,13 @@ class FullNodeAPI:
self.full_node.full_node_store.add_candidate_block(
farmer_request.quality_string, height, unfinished_block, False
)
# TODO: address hint error and remove ignore
# error: Argument 3 to "RequestSignedValues" has incompatible type "Optional[bytes32]"; expected
# "bytes32" [arg-type]
message = farmer_protocol.RequestSignedValues(
farmer_request.quality_string,
unfinished_block.foliage.foliage_block_data.get_hash(),
unfinished_block.foliage.foliage_transaction_block_hash,
unfinished_block.foliage.foliage_transaction_block_hash, # type: ignore[arg-type]
)
await peer.send_message(make_msg(ProtocolMessageTypes.request_signed_values, message))
return None
@ -1101,7 +1127,10 @@ class FullNodeAPI:
@api_request
async def request_additions(self, request: wallet_protocol.RequestAdditions) -> Optional[Message]:
block: Optional[FullBlock] = await self.full_node.block_store.get_full_block(request.header_hash)
# TODO: address hint error and remove ignore
# error: Argument 1 to "get_full_block" of "BlockStore" has incompatible type "Optional[bytes32]";
# expected "bytes32" [arg-type]
block: Optional[FullBlock] = await self.full_node.block_store.get_full_block(request.header_hash) # type: ignore[arg-type] # noqa: E501
# We lock so that the coin store does not get modified
if (
@ -1109,7 +1138,10 @@ class FullNodeAPI:
or block.is_transaction_block() is False
or self.full_node.blockchain.height_to_hash(block.height) != request.header_hash
):
reject = wallet_protocol.RejectAdditionsRequest(request.height, request.header_hash)
# TODO: address hint error and remove ignore
# error: Argument 2 to "RejectAdditionsRequest" has incompatible type "Optional[bytes32]"; expected
# "bytes32" [arg-type]
reject = wallet_protocol.RejectAdditionsRequest(request.height, request.header_hash) # type: ignore[arg-type] # noqa: E501
msg = make_msg(ProtocolMessageTypes.reject_additions_request, reject)
return msg
@ -1272,7 +1304,10 @@ class FullNodeAPI:
return reject_msg
header_hash = self.full_node.blockchain.height_to_hash(height)
block: Optional[FullBlock] = await self.full_node.block_store.get_full_block(header_hash)
# TODO: address hint error and remove ignore
# error: Argument 1 to "get_full_block" of "BlockStore" has incompatible type "Optional[bytes32]";
# expected "bytes32" [arg-type]
block: Optional[FullBlock] = await self.full_node.block_store.get_full_block(header_hash) # type: ignore[arg-type] # noqa: E501
if block is None or block.transactions_generator is None:
return reject_msg
@ -1307,7 +1342,10 @@ class FullNodeAPI:
return msg
header_hashes.append(self.full_node.blockchain.height_to_hash(uint32(i)))
blocks: List[FullBlock] = await self.full_node.block_store.get_blocks_by_hash(header_hashes)
# TODO: address hint error and remove ignore
# error: Argument 1 to "get_blocks_by_hash" of "BlockStore" has incompatible type
# "List[Optional[bytes32]]"; expected "List[bytes32]" [arg-type]
blocks: List[FullBlock] = await self.full_node.block_store.get_blocks_by_hash(header_hashes) # type: ignore[arg-type] # noqa: E501
header_blocks = []
for block in blocks:
added_coins_records = await self.full_node.coin_store.get_coins_added_at_height(block.height)

View File

@ -57,11 +57,17 @@ def validate_clvm_and_signature(
pks: List[G1Element] = []
msgs: List[bytes32] = []
pks, msgs = pkm_pairs(result.npc_list, additional_data)
# TODO: address hint error and remove ignore
# error: Incompatible types in assignment (expression has type "List[bytes]", variable has type
# "List[bytes32]") [assignment]
pks, msgs = pkm_pairs(result.npc_list, additional_data) # type: ignore[assignment]
# Verify aggregated signature
cache: LRUCache = LRUCache(10000)
if not cached_bls.aggregate_verify(pks, msgs, bundle.aggregated_signature, True, cache):
# TODO: address hint error and remove ignore
# error: Argument 2 to "aggregate_verify" has incompatible type "List[bytes32]"; expected "List[bytes]"
# [arg-type]
if not cached_bls.aggregate_verify(pks, msgs, bundle.aggregated_signature, True, cache): # type: ignore[arg-type] # noqa: E501
return Err.BAD_AGGREGATE_SIGNATURE, b"", {}
new_cache_entries: Dict[bytes, bytes] = {}
for k, v in cache.cache.items():

View File

@ -107,7 +107,10 @@ class WeightProofHandler:
return None
summary_heights = self.blockchain.get_ses_heights()
prev_ses_block = await self.blockchain.get_block_record_from_db(self.blockchain.height_to_hash(uint32(0)))
# TODO: address hint error and remove ignore
# error: Argument 1 to "get_block_record_from_db" of "BlockchainInterface" has incompatible type
# "Optional[bytes32]"; expected "bytes32" [arg-type]
prev_ses_block = await self.blockchain.get_block_record_from_db(self.blockchain.height_to_hash(uint32(0))) # type: ignore[arg-type] # noqa: E501
if prev_ses_block is None:
return None
sub_epoch_data = self.get_sub_epoch_data(tip_rec.height, summary_heights)
@ -137,7 +140,10 @@ class WeightProofHandler:
if _sample_sub_epoch(prev_ses_block.weight, ses_block.weight, weight_to_check): # type: ignore
sample_n += 1
segments = await self.blockchain.get_sub_epoch_challenge_segments(ses_block.header_hash)
# TODO: address hint error and remove ignore
# error: Argument 1 to "get_sub_epoch_challenge_segments" of "BlockchainInterface" has
# incompatible type "bytes32"; expected "uint32" [arg-type]
segments = await self.blockchain.get_sub_epoch_challenge_segments(ses_block.header_hash) # type: ignore[arg-type] # noqa: E501
if segments is None:
segments = await self.__create_sub_epoch_segments(ses_block, prev_ses_block, uint32(sub_epoch_n))
if segments is None:
@ -145,7 +151,10 @@ class WeightProofHandler:
f"failed while building segments for sub epoch {sub_epoch_n}, ses height {ses_height} "
)
return None
await self.blockchain.persist_sub_epoch_challenge_segments(ses_block.header_hash, segments)
# TODO: address hint error and remove ignore
# error: Argument 1 to "persist_sub_epoch_challenge_segments" of "BlockchainInterface" has
# incompatible type "bytes32"; expected "uint32" [arg-type]
await self.blockchain.persist_sub_epoch_challenge_segments(ses_block.header_hash, segments) # type: ignore[arg-type] # noqa: E501
log.debug(f"sub epoch {sub_epoch_n} has {len(segments)} segments")
sub_epoch_segments.extend(segments)
prev_ses_block = ses_block
@ -186,7 +195,10 @@ class WeightProofHandler:
if curr_height == 0:
break
# add to needed reward chain recent blocks
header_block = headers[self.blockchain.height_to_hash(curr_height)]
# TODO: address hint error and remove ignore
# error: Invalid index type "Optional[bytes32]" for "Dict[bytes32, HeaderBlock]"; expected type
# "bytes32" [index]
header_block = headers[self.blockchain.height_to_hash(curr_height)] # type: ignore[index]
block_rec = blocks[header_block.header_hash]
if header_block is None:
log.error("creating recent chain failed")
@ -197,7 +209,10 @@ class WeightProofHandler:
curr_height = uint32(curr_height - 1)
blocks_n += 1
header_block = headers[self.blockchain.height_to_hash(curr_height)]
# TODO: address hint error and remove ignore
# error: Invalid index type "Optional[bytes32]" for "Dict[bytes32, HeaderBlock]"; expected type "bytes32"
# [index]
header_block = headers[self.blockchain.height_to_hash(curr_height)] # type: ignore[index]
recent_chain.insert(0, header_block)
log.info(
@ -294,7 +309,10 @@ class WeightProofHandler:
first = False
else:
height = height + uint32(1) # type: ignore
curr = header_blocks[self.blockchain.height_to_hash(height)]
# TODO: address hint error and remove ignore
# error: Invalid index type "Optional[bytes32]" for "Dict[bytes32, HeaderBlock]"; expected type
# "bytes32" [index]
curr = header_blocks[self.blockchain.height_to_hash(height)] # type: ignore[index]
if curr is None:
return None
log.debug(f"next sub epoch starts at {height}")
@ -313,7 +331,10 @@ class WeightProofHandler:
if end - curr_rec.height == batch_size - 1:
blocks = await self.blockchain.get_block_records_in_range(curr_rec.height - batch_size, curr_rec.height)
end = curr_rec.height
curr_rec = blocks[self.blockchain.height_to_hash(uint32(curr_rec.height - 1))]
# TODO: address hint error and remove ignore
# error: Invalid index type "Optional[bytes32]" for "Dict[bytes32, BlockRecord]"; expected type
# "bytes32" [index]
curr_rec = blocks[self.blockchain.height_to_hash(uint32(curr_rec.height - 1))] # type: ignore[index]
return curr_rec.height
async def _create_challenge_segment(
@ -426,7 +447,10 @@ class WeightProofHandler:
curr.total_iters,
)
tmp_sub_slots_data.append(ssd)
curr = header_blocks[self.blockchain.height_to_hash(uint32(curr.height + 1))]
# TODO: address hint error and remove ignore
# error: Invalid index type "Optional[bytes32]" for "Dict[bytes32, HeaderBlock]"; expected type
# "bytes32" [index]
curr = header_blocks[self.blockchain.height_to_hash(uint32(curr.height + 1))] # type: ignore[index]
if len(tmp_sub_slots_data) > 0:
sub_slots_data.extend(tmp_sub_slots_data)
@ -455,7 +479,10 @@ class WeightProofHandler:
) -> Tuple[Optional[List[SubSlotData]], uint32]:
# gets all vdfs first sub slot after challenge block to last sub slot
log.debug(f"slot end vdf start height {start_height}")
curr = header_blocks[self.blockchain.height_to_hash(start_height)]
# TODO: address hint error and remove ignore
# error: Invalid index type "Optional[bytes32]" for "Dict[bytes32, HeaderBlock]"; expected type "bytes32"
# [index]
curr = header_blocks[self.blockchain.height_to_hash(start_height)] # type: ignore[index]
curr_header_hash = curr.header_hash
sub_slots_data: List[SubSlotData] = []
tmp_sub_slots_data: List[SubSlotData] = []
@ -474,7 +501,10 @@ class WeightProofHandler:
tmp_sub_slots_data = []
tmp_sub_slots_data.append(self.handle_block_vdfs(curr, blocks))
curr = header_blocks[self.blockchain.height_to_hash(uint32(curr.height + 1))]
# TODO: address hint error and remove ignore
# error: Invalid index type "Optional[bytes32]" for "Dict[bytes32, HeaderBlock]"; expected type
# "bytes32" [index]
curr = header_blocks[self.blockchain.height_to_hash(uint32(curr.height + 1))] # type: ignore[index]
curr_header_hash = curr.header_hash
if len(tmp_sub_slots_data) > 0:

View File

@ -216,7 +216,10 @@ async def create_plots(
if args.memo is not None:
log.info(f"Debug memo: {args.memo}")
plot_memo = bytes.fromhex(args.memo)
# TODO: address hint error and remove ignore
# error: Incompatible types in assignment (expression has type "bytes", variable has type "bytes32")
# [assignment]
plot_memo = bytes.fromhex(args.memo) # type: ignore[assignment]
# Uncomment next two lines if memo is needed for dev debug
plot_memo_str: str = plot_memo.hex()

View File

@ -44,12 +44,19 @@ def load_pool_config(root_path: Path) -> List[PoolWalletConfig]:
if "pool_list" in config["pool"]:
for pool_config_dict in config["pool"]["pool_list"]:
try:
# TODO: address hint errors and remove ignores
# error: Argument 1 to "PoolWalletConfig" has incompatible type "bytes"; expected "bytes32"
# [arg-type]
# error: Argument 4 to "PoolWalletConfig" has incompatible type "bytes"; expected "bytes32"
# [arg-type]
# error: Argument 5 to "PoolWalletConfig" has incompatible type "bytes"; expected "bytes32"
# [arg-type]
pool_config = PoolWalletConfig(
hexstr_to_bytes(pool_config_dict["launcher_id"]),
hexstr_to_bytes(pool_config_dict["launcher_id"]), # type: ignore[arg-type]
pool_config_dict["pool_url"],
pool_config_dict["payout_instructions"],
hexstr_to_bytes(pool_config_dict["target_puzzle_hash"]),
hexstr_to_bytes(pool_config_dict["p2_singleton_puzzle_hash"]),
hexstr_to_bytes(pool_config_dict["target_puzzle_hash"]), # type: ignore[arg-type]
hexstr_to_bytes(pool_config_dict["p2_singleton_puzzle_hash"]), # type: ignore[arg-type]
G1Element.from_bytes(hexstr_to_bytes(pool_config_dict["owner_public_key"])),
G1Element.from_bytes(hexstr_to_bytes(pool_config_dict["authentication_public_key"])),
)

View File

@ -77,7 +77,10 @@ class FarmerRpcApi:
async def get_signage_points(self, _: Dict) -> Dict[str, Any]:
result: List[Dict[str, Any]] = []
for _, sps in self.service.sps.items():
# TODO: address hint error and remove ignore
# error: Incompatible types in assignment (expression has type "bytes32", variable has type
# "Dict[Any, Any]") [assignment]
for _, sps in self.service.sps.items(): # type: ignore[assignment]
for sp in sps:
pospaces = self.service.proofs_of_space.get(sp.challenge_chain_sp, [])
result.append(
@ -118,7 +121,10 @@ class FarmerRpcApi:
return {"pool_state": pools_list}
async def set_payout_instructions(self, request: Dict) -> Dict:
launcher_id: bytes32 = hexstr_to_bytes(request["launcher_id"])
# TODO: address hint error and remove ignore
# error: Incompatible types in assignment (expression has type "bytes", variable has type "bytes32")
# [assignment]
launcher_id: bytes32 = hexstr_to_bytes(request["launcher_id"]) # type: ignore[assignment]
await self.service.set_payout_instructions(launcher_id, request["payout_instructions"])
return {}

View File

@ -175,7 +175,10 @@ class FullNodeRpcApi:
async def get_recent_signage_point_or_eos(self, request: Dict):
if "sp_hash" not in request:
challenge_hash: bytes32 = hexstr_to_bytes(request["challenge_hash"])
# TODO: address hint error and remove ignore
# error: Incompatible types in assignment (expression has type "bytes", variable has type "bytes32")
# [assignment]
challenge_hash: bytes32 = hexstr_to_bytes(request["challenge_hash"]) # type: ignore[assignment]
# This is the case of getting an end of slot
eos_tuple = self.service.full_node_store.recent_eos.get(challenge_hash)
if not eos_tuple:
@ -208,7 +211,10 @@ class FullNodeRpcApi:
return {"eos": eos, "time_received": time_received, "reverted": True}
# Now we handle the case of getting a signage point
sp_hash: bytes32 = hexstr_to_bytes(request["sp_hash"])
# TODO: address hint error and remove ignore
# error: Incompatible types in assignment (expression has type "bytes", variable has type "bytes32")
# [assignment]
sp_hash: bytes32 = hexstr_to_bytes(request["sp_hash"]) # type: ignore[assignment]
sp_tuple = self.service.full_node_store.recent_signage_points.get(sp_hash)
if sp_tuple is None:
raise ValueError(f"Did not find sp {sp_hash.hex()} in cache")
@ -267,7 +273,10 @@ class FullNodeRpcApi:
raise ValueError("No header_hash in request")
header_hash = hexstr_to_bytes(request["header_hash"])
block: Optional[FullBlock] = await self.service.block_store.get_full_block(header_hash)
# TODO: address hint error and remove ignore
# error: Argument 1 to "get_full_block" of "BlockStore" has incompatible type "bytes"; expected "bytes32"
# [arg-type]
block: Optional[FullBlock] = await self.service.block_store.get_full_block(header_hash) # type: ignore[arg-type] # noqa: E501
if block is None:
raise ValueError(f"Block {header_hash.hex()} not found")
@ -313,7 +322,10 @@ class FullNodeRpcApi:
if peak_height < uint32(a):
self.service.log.warning("requested block is higher than known peak ")
break
header_hash: bytes32 = self.service.blockchain.height_to_hash(uint32(a))
# TODO: address hint error and remove ignore
# error: Incompatible types in assignment (expression has type "Optional[bytes32]", variable has type
# "bytes32") [assignment]
header_hash: bytes32 = self.service.blockchain.height_to_hash(uint32(a)) # type: ignore[assignment]
record: Optional[BlockRecord] = self.service.blockchain.try_block_record(header_hash)
if record is None:
# Fetch from DB
@ -348,10 +360,16 @@ class FullNodeRpcApi:
raise ValueError("header_hash not in request")
header_hash_str = request["header_hash"]
header_hash = hexstr_to_bytes(header_hash_str)
record: Optional[BlockRecord] = self.service.blockchain.try_block_record(header_hash)
# TODO: address hint error and remove ignore
# error: Argument 1 to "try_block_record" of "BlockchainInterface" has incompatible type "bytes"; expected
# "bytes32" [arg-type]
record: Optional[BlockRecord] = self.service.blockchain.try_block_record(header_hash) # type: ignore[arg-type]
if record is None:
# Fetch from DB
record = await self.service.blockchain.block_store.get_block_record(header_hash)
# TODO: address hint error and remove ignore
# error: Argument 1 to "get_block_record" of "BlockStore" has incompatible type "bytes"; expected
# "bytes32" [arg-type]
record = await self.service.blockchain.block_store.get_block_record(header_hash) # type: ignore[arg-type]
if record is None:
raise ValueError(f"Block {header_hash.hex()} does not exist")
@ -394,10 +412,16 @@ class FullNodeRpcApi:
newer_block_bytes = hexstr_to_bytes(newer_block_hex)
older_block_bytes = hexstr_to_bytes(older_block_hex)
newer_block = await self.service.block_store.get_block_record(newer_block_bytes)
# TODO: address hint error and remove ignore
# error: Argument 1 to "get_block_record" of "BlockStore" has incompatible type "bytes"; expected
# "bytes32" [arg-type]
newer_block = await self.service.block_store.get_block_record(newer_block_bytes) # type: ignore[arg-type]
if newer_block is None:
raise ValueError("Newer block not found")
older_block = await self.service.block_store.get_block_record(older_block_bytes)
# TODO: address hint error and remove ignore
# error: Argument 1 to "get_block_record" of "BlockStore" has incompatible type "bytes"; expected
# "bytes32" [arg-type]
older_block = await self.service.block_store.get_block_record(older_block_bytes) # type: ignore[arg-type]
if older_block is None:
raise ValueError("Newer block not found")
delta_weight = newer_block.weight - older_block.weight
@ -463,7 +487,10 @@ class FullNodeRpcApi:
raise ValueError("Name not in request")
name = hexstr_to_bytes(request["name"])
coin_record: Optional[CoinRecord] = await self.service.blockchain.coin_store.get_coin_record(name)
# TODO: address hint error and remove ignore
# error: Argument 1 to "get_coin_record" of "CoinStore" has incompatible type "bytes"; expected "bytes32"
# [arg-type]
coin_record: Optional[CoinRecord] = await self.service.blockchain.coin_store.get_coin_record(name) # type: ignore[arg-type] # noqa: E501
if coin_record is None:
raise ValueError(f"Coin record 0x{name.hex()} not found")
@ -539,14 +566,20 @@ class FullNodeRpcApi:
}
async def get_puzzle_and_solution(self, request: Dict) -> Optional[Dict]:
coin_name: bytes32 = hexstr_to_bytes(request["coin_id"])
# TODO: address hint error and remove ignore
# error: Incompatible types in assignment (expression has type "bytes", variable has type "bytes32")
# [assignment]
coin_name: bytes32 = hexstr_to_bytes(request["coin_id"]) # type: ignore[assignment]
height = request["height"]
coin_record = await self.service.coin_store.get_coin_record(coin_name)
if coin_record is None or not coin_record.spent or coin_record.spent_block_index != height:
raise ValueError(f"Invalid height {height}. coin record {coin_record}")
header_hash = self.service.blockchain.height_to_hash(height)
block: Optional[FullBlock] = await self.service.block_store.get_full_block(header_hash)
# TODO: address hint error and remove ignore
# error: Argument 1 to "get_full_block" of "BlockStore" has incompatible type "Optional[bytes32]";
# expected "bytes32" [arg-type]
block: Optional[FullBlock] = await self.service.block_store.get_full_block(header_hash) # type: ignore[arg-type] # noqa: E501
if block is None or block.transactions_generator is None:
raise ValueError("Invalid block or block generator")
@ -568,7 +601,10 @@ class FullNodeRpcApi:
raise ValueError("No header_hash in request")
header_hash = hexstr_to_bytes(request["header_hash"])
block: Optional[FullBlock] = await self.service.block_store.get_full_block(header_hash)
# TODO: address hint error and remove ignore
# error: Argument 1 to "get_full_block" of "BlockStore" has incompatible type "bytes"; expected "bytes32"
# [arg-type]
block: Optional[FullBlock] = await self.service.block_store.get_full_block(header_hash) # type: ignore[arg-type] # noqa: E501
if block is None:
raise ValueError(f"Block {header_hash.hex()} not found")
@ -593,7 +629,10 @@ class FullNodeRpcApi:
async def get_mempool_item_by_tx_id(self, request: Dict) -> Optional[Dict]:
if "tx_id" not in request:
raise ValueError("No tx_id in request")
tx_id: bytes32 = hexstr_to_bytes(request["tx_id"])
# TODO: address hint error and remove ignore
# error: Incompatible types in assignment (expression has type "bytes", variable has type "bytes32")
# [assignment]
tx_id: bytes32 = hexstr_to_bytes(request["tx_id"]) # type: ignore[assignment]
item = self.service.mempool_manager.get_mempool_item(tx_id)
if item is None:

View File

@ -587,13 +587,16 @@ class WalletRpcApi:
delayed_address = None
if "p2_singleton_delayed_ph" in request:
delayed_address = hexstr_to_bytes(request["p2_singleton_delayed_ph"])
# TODO: address hint error and remove ignore
# error: Argument 6 to "create_new_pool_wallet_transaction" of "PoolWallet" has
# incompatible type "Optional[bytes]"; expected "Optional[bytes32]" [arg-type]
tr, p2_singleton_puzzle_hash, launcher_id = await PoolWallet.create_new_pool_wallet_transaction(
wallet_state_manager,
main_wallet,
initial_target_state,
fee,
request.get("p2_singleton_delay_time", None),
delayed_address,
delayed_address, # type: ignore[arg-type]
)
except Exception as e:
raise ValueError(str(e))
@ -916,9 +919,15 @@ class WalletRpcApi:
async with self.service.wallet_state_manager.lock:
if secure:
await wsm.trade_manager.cancel_pending_offer_safely(trade_id)
# TODO: address hint error and remove ignore
# error: Argument 1 to "cancel_pending_offer_safely" of "TradeManager" has incompatible type
# "bytes"; expected "bytes32" [arg-type]
await wsm.trade_manager.cancel_pending_offer_safely(trade_id) # type: ignore[arg-type]
else:
await wsm.trade_manager.cancel_pending_offer(trade_id)
# TODO: address hint error and remove ignore
# error: Argument 1 to "cancel_pending_offer" of "TradeManager" has incompatible type "bytes";
# expected "bytes32" [arg-type]
await wsm.trade_manager.cancel_pending_offer(trade_id) # type: ignore[arg-type]
return {}
async def get_backup_info(self, request: Dict):
@ -1208,9 +1217,12 @@ class WalletRpcApi:
target_puzzlehash = None
if "target_puzzlehash" in request:
target_puzzlehash = bytes32(hexstr_to_bytes(request["target_puzzlehash"]))
# TODO: address hint error and remove ignore
# error: Argument 2 to "create_pool_state" has incompatible type "Optional[bytes32]"; expected "bytes32"
# [arg-type]
new_target_state: PoolState = create_pool_state(
FARMING_TO_POOL,
target_puzzlehash,
target_puzzlehash, # type: ignore[arg-type]
owner_pubkey,
request["pool_url"],
uint32(request["relative_lock_height"]),

View File

@ -613,10 +613,14 @@ class ChiaServer:
task_id = token_bytes()
api_task = asyncio.create_task(api_call(payload_inc, connection_inc, task_id))
self.api_tasks[task_id] = api_task
# TODO: address hint error and remove ignore
# error: Invalid index type "bytes" for "Dict[bytes32, Task[Any]]"; expected type "bytes32" [index]
self.api_tasks[task_id] = api_task # type: ignore[index]
if connection_inc.peer_node_id not in self.tasks_from_peer:
self.tasks_from_peer[connection_inc.peer_node_id] = set()
self.tasks_from_peer[connection_inc.peer_node_id].add(task_id)
# TODO: address hint error and remove ignore
# error: Argument 1 to "add" of "set" has incompatible type "bytes"; expected "bytes32" [arg-type]
self.tasks_from_peer[connection_inc.peer_node_id].add(task_id) # type: ignore[arg-type]
async def send_to_others(
self,

View File

@ -342,7 +342,10 @@ class WSChiaConnection:
message = Message(message_no_id.type, request_id, message_no_id.data)
self.pending_requests[message.id] = event
# TODO: address hint error and remove ignore
# error: Invalid index type "Optional[uint16]" for "Dict[bytes32, Event]"; expected type "bytes32"
# [index]
self.pending_requests[message.id] = event # type: ignore[index]
await self.outgoing_queue.put(message)
# If the timeout passes, we set the event
@ -357,16 +360,34 @@ class WSChiaConnection:
raise
timeout_task = asyncio.create_task(time_out(message.id, timeout))
self.pending_timeouts[message.id] = timeout_task
# TODO: address hint error and remove ignore
# error: Invalid index type "Optional[uint16]" for "Dict[bytes32, Task[Any]]"; expected type "bytes32"
# [index]
self.pending_timeouts[message.id] = timeout_task # type: ignore[index]
await event.wait()
self.pending_requests.pop(message.id)
# TODO: address hint error and remove ignore
# error: No overload variant of "pop" of "MutableMapping" matches argument type "Optional[uint16]"
# [call-overload]
# note: Possible overload variants:
# note: def pop(self, key: bytes32) -> Event
# note: def [_T] pop(self, key: bytes32, default: Union[Event, _T] = ...) -> Union[Event, _T]
self.pending_requests.pop(message.id) # type: ignore[call-overload]
result: Optional[Message] = None
if message.id in self.request_results:
result = self.request_results[message.id]
# TODO: address hint error and remove ignore
# error: Invalid index type "Optional[uint16]" for "Dict[bytes32, Message]"; expected type "bytes32"
# [index]
result = self.request_results[message.id] # type: ignore[index]
assert result is not None
self.log.debug(f"<- {ProtocolMessageTypes(result.type).name} from: {self.peer_host}:{self.peer_port}")
self.request_results.pop(result.id)
# TODO: address hint error and remove ignore
# error: No overload variant of "pop" of "MutableMapping" matches argument type "Optional[uint16]"
# [call-overload]
# note: Possible overload variants:
# note: def pop(self, key: bytes32) -> Message
# note: def [_T] pop(self, key: bytes32, default: Union[Message, _T] = ...) -> Union[Message, _T]
self.request_results.pop(result.id) # type: ignore[call-overload]
return result

View File

@ -6,6 +6,9 @@ if __name__ == "__main__":
with TempKeyring() as keychain:
# TODO: mariano: fix this with new consensus
bt = create_block_tools(root_path=DEFAULT_ROOT_PATH, keychain=keychain)
new_genesis_block = bt.create_genesis_block(test_constants, b"0")
# TODO: address hint error and remove ignore
# error: Argument 2 to "create_genesis_block" of "BlockTools" has incompatible type "bytes"; expected
# "bytes32" [arg-type]
new_genesis_block = bt.create_genesis_block(test_constants, b"0") # type: ignore[arg-type]
print(bytes(new_genesis_block))

View File

@ -104,7 +104,10 @@ class LastState:
else:
assert False
self.reward_challenge_cache.append((self.get_challenge(Chain.REWARD_CHAIN), self.total_iters))
# TODO: address hint error and remove ignore
# error: Argument 1 to "append" of "list" has incompatible type "Tuple[Optional[bytes32], uint128]";
# expected "Tuple[bytes32, uint128]" [arg-type]
self.reward_challenge_cache.append((self.get_challenge(Chain.REWARD_CHAIN), self.total_iters)) # type: ignore[arg-type] # noqa: E501
log.info(f"Updated timelord peak to {self.get_challenge(Chain.REWARD_CHAIN)}, total iters: {self.total_iters}")
while len(self.reward_challenge_cache) > 2 * self.constants.MAX_SUB_SLOT_BLOCKS:
self.reward_challenge_cache.pop(0)

View File

@ -28,7 +28,10 @@ class ProofOfSpace(Streamable):
def get_plot_id(self) -> bytes32:
assert self.pool_public_key is None or self.pool_contract_puzzle_hash is None
if self.pool_public_key is None:
return self.calculate_plot_id_ph(self.pool_contract_puzzle_hash, self.plot_public_key)
# TODO: address hint error and remove ignore
# error: Argument 1 to "calculate_plot_id_ph" of "ProofOfSpace" has incompatible type
# "Optional[bytes32]"; expected "bytes32" [arg-type]
return self.calculate_plot_id_ph(self.pool_contract_puzzle_hash, self.plot_public_key) # type: ignore[arg-type] # noqa: E501
return self.calculate_plot_id_pk(self.pool_public_key, self.plot_public_key)
def verify_and_get_quality_string(

View File

@ -1,9 +1,29 @@
from chia.util.byte_types import make_sized_bytes
from chia.util.byte_types import SizedBytes
bytes4 = make_sized_bytes(4)
bytes8 = make_sized_bytes(8)
bytes32 = make_sized_bytes(32)
bytes48 = make_sized_bytes(48)
bytes96 = make_sized_bytes(96)
bytes100 = make_sized_bytes(100)
bytes480 = make_sized_bytes(480)
class bytes4(SizedBytes):
_size = 4
class bytes8(SizedBytes):
_size = 8
class bytes32(SizedBytes):
_size = 32
class bytes48(SizedBytes):
_size = 48
class bytes96(SizedBytes):
_size = 96
class bytes100(SizedBytes):
_size = 100
class bytes480(SizedBytes):
_size = 480

View File

@ -106,7 +106,9 @@ def convertbits(data: List[int], frombits: int, tobits: int, pad: bool = True) -
def encode_puzzle_hash(puzzle_hash: bytes32, prefix: str) -> str:
encoded = bech32_encode(prefix, convertbits(puzzle_hash, 8, 5))
# TODO: address hint error and remove ignore
# Argument 1 to "convertbits" has incompatible type "bytes32"; expected "List[int]" [arg-type]
encoded = bech32_encode(prefix, convertbits(puzzle_hash, 8, 5)) # type: ignore[arg-type]
return encoded
@ -116,4 +118,6 @@ def decode_puzzle_hash(address: str) -> bytes32:
raise ValueError("Invalid Address")
decoded = convertbits(data, 5, 8, False)
decoded_bytes = bytes(decoded)
return decoded_bytes
# TODO: address hint error and remove ignore
# error: Incompatible return value type (got "bytes", expected "bytes32") [return-value]
return decoded_bytes # type: ignore[return-value]

View File

@ -36,7 +36,10 @@ class BlockCache(BlockchainInterface):
def height_to_block_record(self, height: uint32, check_db: bool = False) -> BlockRecord:
header_hash = self.height_to_hash(height)
return self.block_record(header_hash)
# TODO: address hint error and remove ignore
# error: Argument 1 to "block_record" of "BlockCache" has incompatible type "Optional[bytes32]"; expected
# "bytes32" [arg-type]
return self.block_record(header_hash) # type: ignore[arg-type]
def get_ses_heights(self) -> List[uint32]:
return sorted(self._sub_epoch_summaries.keys())

View File

@ -1,5 +1,7 @@
import io
from typing import Any, BinaryIO
from typing import BinaryIO, Type, TypeVar
_T_SizedBytes = TypeVar("_T_SizedBytes", bound="SizedBytes")
def hexstr_to_bytes(input_str: str) -> bytes:
@ -11,37 +13,38 @@ def hexstr_to_bytes(input_str: str) -> bytes:
return bytes.fromhex(input_str)
def make_sized_bytes(size: int):
class SizedBytes(bytes):
"""A streamable type that subclasses "bytes" but requires instances
to be a certain, fixed size specified by the `._size` class attribute.
"""
Create a streamable type that subclasses "bytes" but requires instances
to be a certain, fixed size.
"""
name = "bytes%d" % size
def __new__(cls, v):
_size = 0
@staticmethod
def __new__(cls: Type[_T_SizedBytes], v) -> _T_SizedBytes:
v = bytes(v)
if not isinstance(v, bytes) or len(v) != size:
raise ValueError("bad %s initializer %s" % (name, v))
if not isinstance(v, bytes) or len(v) != cls._size:
raise ValueError("bad %s initializer %s" % (cls.__name__, v))
return bytes.__new__(cls, v)
@classmethod # type: ignore
def parse(cls, f: BinaryIO) -> Any:
b = f.read(size)
assert len(b) == size
@classmethod
def parse(cls: Type[_T_SizedBytes], f: BinaryIO) -> _T_SizedBytes:
b = f.read(cls._size)
assert len(b) == cls._size
return cls(b)
def stream(self, f):
f.write(self)
@classmethod # type: ignore
def from_bytes(cls: Any, blob: bytes) -> Any:
@classmethod
def from_bytes(cls: Type[_T_SizedBytes], blob: bytes) -> _T_SizedBytes:
# pylint: disable=no-member
f = io.BytesIO(blob)
result = cls.parse(f)
assert f.read() == b""
return result
def __bytes__(self: Any) -> bytes:
def __bytes__(self) -> bytes:
f = io.BytesIO()
self.stream(f)
return bytes(f.getvalue())
@ -51,15 +54,3 @@ def make_sized_bytes(size: int):
def __repr__(self):
return "<%s: %s>" % (self.__class__.__name__, str(self))
namespace = dict(
__new__=__new__,
parse=parse,
stream=stream,
from_bytes=from_bytes,
__bytes__=__bytes__,
__str__=__str__,
__repr__=__repr__,
)
return type(name, (bytes,), namespace)

View File

@ -114,7 +114,9 @@ def created_outputs_for_conditions_dict(
for cvp in conditions_dict.get(ConditionOpcode.CREATE_COIN, []):
puzzle_hash, amount_bin = cvp.vars[0], cvp.vars[1]
amount = int_from_bytes(amount_bin)
coin = Coin(input_coin_name, puzzle_hash, uint64(amount))
# TODO: address hint error and remove ignore
# error: Argument 2 to "Coin" has incompatible type "bytes"; expected "bytes32" [arg-type]
coin = Coin(input_coin_name, puzzle_hash, uint64(amount)) # type: ignore[arg-type]
output_coins.append(coin)
return output_coins

View File

@ -15,9 +15,15 @@ def get_block_header(block: FullBlock, tx_addition_coins: List[Coin], removals_n
addition_coins = tx_addition_coins + list(block.get_included_reward_coins())
if block.is_transaction_block():
for coin in addition_coins:
byte_array_tx.append(bytearray(coin.puzzle_hash))
# TODO: address hint error and remove ignore
# error: Argument 1 to "append" of "list" has incompatible type "bytearray"; expected "bytes32"
# [arg-type]
byte_array_tx.append(bytearray(coin.puzzle_hash)) # type: ignore[arg-type]
for name in removals_names:
byte_array_tx.append(bytearray(name))
# TODO: address hint error and remove ignore
# error: Argument 1 to "append" of "list" has incompatible type "bytearray"; expected "bytes32"
# [arg-type]
byte_array_tx.append(bytearray(name)) # type: ignore[arg-type]
bip158: PyBIP158 = PyBIP158(byte_array_tx)
encoded_filter: bytes = bytes(bip158.GetEncoded())

View File

@ -246,7 +246,10 @@ def spendable_cc_list_from_coin_spend(coin_spend: CoinSpend, hash_to_puzzle_f) -
genesis_coin_id = genesis_coin_id_for_genesis_coin_checker(genesis_coin_checker)
cc_spend_info = SpendableCC(new_coin, genesis_coin_id, inner_puzzle, lineage_proof)
# TODO: address hint error and remove ignore
# error: Argument 2 to "SpendableCC" has incompatible type "Optional[bytes32]"; expected "bytes32"
# [arg-type]
cc_spend_info = SpendableCC(new_coin, genesis_coin_id, inner_puzzle, lineage_proof) # type: ignore[arg-type]
spendable_cc_list.append(cc_spend_info)
return spendable_cc_list

View File

@ -115,6 +115,9 @@ class CCWallet:
if cc_coin is None:
raise ValueError("Internal Error, unable to generate new coloured coin")
# TODO: address hint error and remove ignore
# error: Argument "name" to "TransactionRecord" has incompatible type "bytes"; expected "bytes32"
# [arg-type]
regular_record = TransactionRecord(
confirmed_at_height=uint32(0),
created_at_time=uint64(int(time.time())),
@ -130,8 +133,11 @@ class CCWallet:
sent_to=[],
trade_id=None,
type=uint32(TransactionType.OUTGOING_TX.value),
name=token_bytes(),
name=token_bytes(), # type: ignore[arg-type]
)
# TODO: address hint error and remove ignore
# error: Argument "name" to "TransactionRecord" has incompatible type "bytes"; expected "bytes32"
# [arg-type]
cc_record = TransactionRecord(
confirmed_at_height=uint32(0),
created_at_time=uint64(int(time.time())),
@ -147,7 +153,7 @@ class CCWallet:
sent_to=[],
trade_id=None,
type=uint32(TransactionType.INCOMING_TX.value),
name=token_bytes(),
name=token_bytes(), # type: ignore[arg-type]
)
await self.standard_wallet.push_transaction(regular_record)
await self.standard_wallet.push_transaction(cc_record)
@ -416,6 +422,9 @@ class CCWallet:
await self.add_lineage(eve_coin.parent_coin_info, Program.to((0, [origin.as_list(), 1])))
if send:
# TODO: address hint error and remove ignore
# error: Argument "name" to "TransactionRecord" has incompatible type "bytes"; expected "bytes32"
# [arg-type]
regular_record = TransactionRecord(
confirmed_at_height=uint32(0),
created_at_time=uint64(int(time.time())),
@ -431,7 +440,7 @@ class CCWallet:
sent_to=[],
trade_id=None,
type=uint32(TransactionType.INCOMING_TX.value),
name=token_bytes(),
name=token_bytes(), # type: ignore[arg-type]
)
cc_record = TransactionRecord(
confirmed_at_height=uint32(0),
@ -634,7 +643,10 @@ class CCWallet:
innersol_list.append(innersol)
lineage_proof = await self.get_lineage_proof_for_coin(coin)
assert lineage_proof is not None
spendable_cc_list.append(SpendableCC(coin, genesis_id, inner_puzzle, lineage_proof))
# TODO: address hint error and remove ignore
# error: Argument 2 to "SpendableCC" has incompatible type "Optional[bytes32]"; expected "bytes32"
# [arg-type]
spendable_cc_list.append(SpendableCC(coin, genesis_id, inner_puzzle, lineage_proof)) # type: ignore[arg-type] # noqa: E501
sigs = sigs + await self.get_sigs(coin_inner_puzzle, innersol, coin.name())
spend_bundle = spend_bundle_for_spendable_ccs(

View File

@ -97,6 +97,9 @@ class DIDWallet:
self.did_info.current_inner, self.did_info.origin_coin.name()
).get_tree_hash()
# TODO: address hint error and remove ignore
# error: Argument "name" to "TransactionRecord" has incompatible type "bytes"; expected "bytes32"
# [arg-type]
did_record = TransactionRecord(
confirmed_at_height=uint32(0),
created_at_time=uint64(int(time.time())),
@ -112,8 +115,11 @@ class DIDWallet:
sent_to=[],
trade_id=None,
type=uint32(TransactionType.INCOMING_TX.value),
name=token_bytes(),
name=token_bytes(), # type: ignore[arg-type]
)
# TODO: address hint error and remove ignore
# error: Argument "name" to "TransactionRecord" has incompatible type "bytes"; expected "bytes32"
# [arg-type]
regular_record = TransactionRecord(
confirmed_at_height=uint32(0),
created_at_time=uint64(int(time.time())),
@ -129,7 +135,7 @@ class DIDWallet:
sent_to=[],
trade_id=None,
type=uint32(TransactionType.OUTGOING_TX.value),
name=token_bytes(),
name=token_bytes(), # type: ignore[arg-type]
)
await self.standard_wallet.push_transaction(regular_record)
await self.standard_wallet.push_transaction(did_record)
@ -323,7 +329,14 @@ class DIDWallet:
f = open(filename, "r")
details = f.readline().split(":")
f.close()
origin = Coin(bytes.fromhex(details[0]), bytes.fromhex(details[1]), uint64(int(details[2])))
# TODO: address hint errors and remove ignores
# error: Argument 1 to "Coin" has incompatible type "bytes"; expected "bytes32" [arg-type]
# error: Argument 2 to "Coin" has incompatible type "bytes"; expected "bytes32" [arg-type]
origin = Coin(
bytes.fromhex(details[0]), # type: ignore[arg-type]
bytes.fromhex(details[1]), # type: ignore[arg-type]
uint64(int(details[2])),
)
backup_ids = []
for d in details[3].split(","):
backup_ids.append(bytes.fromhex(d))
@ -433,7 +446,9 @@ class DIDWallet:
if self.did_info.origin_coin is not None:
return did_wallet_puzzles.create_fullpuz(innerpuz, self.did_info.origin_coin.name())
else:
return did_wallet_puzzles.create_fullpuz(innerpuz, 0x00)
# TODO: address hint error and remove ignore
# error: Argument 2 to "create_fullpuz" has incompatible type "int"; expected "bytes32" [arg-type]
return did_wallet_puzzles.create_fullpuz(innerpuz, 0x00) # type: ignore[arg-type]
async def get_new_puzzle(self) -> Program:
return self.puzzle_for_pk(
@ -559,6 +574,9 @@ class DIDWallet:
aggsig = AugSchemeMPL.aggregate(sigs)
spend_bundle = SpendBundle(list_of_solutions, aggsig)
# TODO: address hint error and remove ignore
# error: Argument "name" to "TransactionRecord" has incompatible type "bytes"; expected "bytes32"
# [arg-type]
did_record = TransactionRecord(
confirmed_at_height=uint32(0),
created_at_time=uint64(int(time.time())),
@ -574,7 +592,7 @@ class DIDWallet:
sent_to=[],
trade_id=None,
type=uint32(TransactionType.OUTGOING_TX.value),
name=token_bytes(),
name=token_bytes(), # type: ignore[arg-type]
)
await self.standard_wallet.push_transaction(did_record)
return spend_bundle
@ -625,6 +643,9 @@ class DIDWallet:
aggsig = AugSchemeMPL.aggregate(sigs)
spend_bundle = SpendBundle(list_of_solutions, aggsig)
# TODO: address hint error and remove ignore
# error: Argument "name" to "TransactionRecord" has incompatible type "bytes"; expected "bytes32"
# [arg-type]
did_record = TransactionRecord(
confirmed_at_height=uint32(0),
created_at_time=uint64(int(time.time())),
@ -640,7 +661,7 @@ class DIDWallet:
sent_to=[],
trade_id=None,
type=uint32(TransactionType.OUTGOING_TX.value),
name=token_bytes(),
name=token_bytes(), # type: ignore[arg-type]
)
await self.standard_wallet.push_transaction(did_record)
return spend_bundle
@ -693,6 +714,9 @@ class DIDWallet:
signature = AugSchemeMPL.sign(private, message)
# assert signature.validate([signature.PkMessagePair(pubkey, message)])
spend_bundle = SpendBundle(list_of_solutions, signature)
# TODO: address hint error and remove ignore
# error: Argument "name" to "TransactionRecord" has incompatible type "bytes"; expected "bytes32"
# [arg-type]
did_record = TransactionRecord(
confirmed_at_height=uint32(0),
created_at_time=uint64(int(time.time())),
@ -708,7 +732,7 @@ class DIDWallet:
sent_to=[],
trade_id=None,
type=uint32(TransactionType.INCOMING_TX.value),
name=token_bytes(),
name=token_bytes(), # type: ignore[arg-type]
)
await self.standard_wallet.push_transaction(did_record)
if filename is not None:
@ -833,6 +857,9 @@ class DIDWallet:
else:
spend_bundle = spend_bundle.aggregate([spend_bundle, SpendBundle(list_of_solutions, aggsig)])
# TODO: address hint error and remove ignore
# error: Argument "name" to "TransactionRecord" has incompatible type "bytes"; expected "bytes32"
# [arg-type]
did_record = TransactionRecord(
confirmed_at_height=uint32(0),
created_at_time=uint64(int(time.time())),
@ -848,7 +875,7 @@ class DIDWallet:
sent_to=[],
trade_id=None,
type=uint32(TransactionType.OUTGOING_TX.value),
name=token_bytes(),
name=token_bytes(), # type: ignore[arg-type]
)
await self.standard_wallet.push_transaction(did_record)
new_did_info = DIDInfo(

View File

@ -45,8 +45,11 @@ def make_puzzle(amount: int) -> int:
for cvp in result_human:
assert len(cvp.vars) == 2
total_chia += int_from_bytes(cvp.vars[1])
# TODO: address hint error and remove ignore
# error: Argument 1 to "encode_puzzle_hash" has incompatible type "bytes"; expected "bytes32"
# [arg-type]
print(
f"{ConditionOpcode(cvp.opcode).name}: {encode_puzzle_hash(cvp.vars[0], prefix)},"
f"{ConditionOpcode(cvp.opcode).name}: {encode_puzzle_hash(cvp.vars[0], prefix)}," # type: ignore[arg-type] # noqa E501
f" amount: {int_from_bytes(cvp.vars[1])}"
)
return total_chia

View File

@ -40,7 +40,9 @@ def add_puzzles_to_puzzle_preimage_db(puzzles: List[Program]) -> None:
def int_as_bytes32(v: int) -> bytes32:
return v.to_bytes(32, byteorder="big")
# TODO: address hint error and remove ignore
# error: Incompatible return value type (got "bytes", expected "bytes32") [return-value]
return v.to_bytes(32, byteorder="big") # type: ignore[return-value]
def generate_farmed_coin(

View File

@ -234,9 +234,12 @@ class RLWallet:
admin_pubkey_bytes = hexstr_to_bytes(admin_pubkey)
assert self.rl_info.user_pubkey is not None
# TODO: address hint errors and remove ignores
# error: Argument 1 to "Coin" has incompatible type "bytes"; expected "bytes32" [arg-type]
# error: Argument 2 to "Coin" has incompatible type "bytes"; expected "bytes32" [arg-type]
origin = Coin(
hexstr_to_bytes(origin_parent_id),
hexstr_to_bytes(origin_puzzle_hash),
hexstr_to_bytes(origin_parent_id), # type: ignore[arg-type]
hexstr_to_bytes(origin_puzzle_hash), # type: ignore[arg-type]
origin_amount,
)
rl_puzzle = rl_puzzle_for_pk(
@ -303,10 +306,13 @@ class RLWallet:
rl_coin = await self._get_rl_coin()
puzzle_hash = rl_coin.puzzle_hash if rl_coin is not None else None
# TODO: address hint error and remove ignore
# error: Argument "to_puzzle_hash" to "TransactionRecord" has incompatible type "Optional[bytes32]";
# expected "bytes32" [arg-type]
tx_record = TransactionRecord(
confirmed_at_height=uint32(0),
created_at_time=uint64(int(time.time())),
to_puzzle_hash=puzzle_hash,
to_puzzle_hash=puzzle_hash, # type: ignore[arg-type]
amount=uint64(0),
fee_amount=uint64(0),
confirmed=False,

View File

@ -28,8 +28,11 @@ async def sign_coin_spends(
raise ValueError(error_msg)
# Create signature
# TODO: address hint error and remove ignore
# error: Argument 2 to "pkm_pairs_for_conditions_dict" has incompatible type "bytes"; expected "bytes32"
# [arg-type]
for pk_bytes, msg in pkm_pairs_for_conditions_dict(
conditions_dict, bytes(coin_spend.coin.name()), additional_data
conditions_dict, bytes(coin_spend.coin.name()), additional_data # type: ignore[arg-type]
):
pk = blspy.G1Element.from_bytes(pk_bytes)
pk_list.append(pk)

View File

@ -179,7 +179,10 @@ class TradeManager:
return all
async def get_trade_by_id(self, trade_id: bytes) -> Optional[TradeRecord]:
record = await self.trade_store.get_trade_record(trade_id)
# TODO: address hint error and remove ignore
# error: Argument 1 to "get_trade_record" of "TradeStore" has incompatible type "bytes"; expected
# "bytes32" [arg-type]
record = await self.trade_store.get_trade_record(trade_id) # type: ignore[arg-type]
return record
async def get_locked_coins_in_spend_bundle(self, bundle: SpendBundle) -> Dict[bytes32, WalletCoinRecord]:
@ -466,7 +469,10 @@ class TradeManager:
aggsig = AugSchemeMPL.aggregate(sigs)
lineage_proof = await wallets[colour].get_lineage_proof_for_coin(coloured_coin)
spendable_cc_list.append(SpendableCC(coloured_coin, genesis_id, inner_puzzle, lineage_proof))
# TODO: address hint error and remove ignore
# error: Argument 2 to "SpendableCC" has incompatible type "Optional[bytes32]"; expected "bytes32"
# [arg-type]
spendable_cc_list.append(SpendableCC(coloured_coin, genesis_id, inner_puzzle, lineage_proof)) # type: ignore[arg-type] # noqa: E501
innersol_list.append(inner_solution)
# Create SpendableCC for each of the coloured coins received
@ -480,7 +486,10 @@ class TradeManager:
mod_hash, genesis_coin_checker, inner_puzzle = r
inner_solution = solution.first()
lineage_proof = solution.rest().rest().first()
spendable_cc_list.append(SpendableCC(cc_coinsol.coin, genesis_id, inner_puzzle, lineage_proof))
# TODO: address hint error and remove ignore
# error: Argument 2 to "SpendableCC" has incompatible type "Optional[bytes32]"; expected
# "bytes32" [arg-type]
spendable_cc_list.append(SpendableCC(cc_coinsol.coin, genesis_id, inner_puzzle, lineage_proof)) # type: ignore[arg-type] # noqa: E501
innersol_list.append(inner_solution)
# Finish the output coin SpendableCC with new information
@ -493,7 +502,10 @@ class TradeManager:
assert inner_puzzle is not None
lineage_proof = await wallets[colour].get_lineage_proof_for_coin(my_output_coin)
spendable_cc_list.append(SpendableCC(my_output_coin, genesis_id, inner_puzzle, lineage_proof))
# TODO: address hint error and remove ignore
# error: Argument 2 to "SpendableCC" has incompatible type "Optional[bytes32]"; expected "bytes32"
# [arg-type]
spendable_cc_list.append(SpendableCC(my_output_coin, genesis_id, inner_puzzle, lineage_proof)) # type: ignore[arg-type] # noqa: E501
innersol_list.append(inner_solution)
sigs = await wallets[colour].get_sigs(inner_puzzle, inner_solution, my_output_coin.name())
@ -532,10 +544,13 @@ class TradeManager:
if chia_spend_bundle is not None:
spend_bundle = SpendBundle.aggregate([spend_bundle, chia_spend_bundle])
if chia_discrepancy < 0:
# TODO: address hint error and remove ignore
# error: Argument "to_puzzle_hash" to "TransactionRecord" has incompatible type "bytes"; expected
# "bytes32" [arg-type]
tx_record = TransactionRecord(
confirmed_at_height=uint32(0),
created_at_time=now,
to_puzzle_hash=token_bytes(),
to_puzzle_hash=token_bytes(), # type: ignore[arg-type]
amount=uint64(abs(chia_discrepancy)),
fee_amount=uint64(0),
confirmed=False,
@ -550,10 +565,13 @@ class TradeManager:
name=chia_spend_bundle.name(),
)
else:
# TODO: address hint error and remove ignore
# error: Argument "to_puzzle_hash" to "TransactionRecord" has incompatible type "bytes"; expected
# "bytes32" [arg-type]
tx_record = TransactionRecord(
confirmed_at_height=uint32(0),
created_at_time=uint64(int(time.time())),
to_puzzle_hash=token_bytes(),
to_puzzle_hash=token_bytes(), # type: ignore[arg-type]
amount=uint64(abs(chia_discrepancy)),
fee_amount=uint64(0),
confirmed=False,
@ -572,10 +590,13 @@ class TradeManager:
for colour, amount in cc_discrepancies.items():
wallet = wallets[colour]
if chia_discrepancy > 0:
# TODO: address hint error and remove ignore
# error: Argument "to_puzzle_hash" to "TransactionRecord" has incompatible type "bytes"; expected
# "bytes32" [arg-type]
tx_record = TransactionRecord(
confirmed_at_height=uint32(0),
created_at_time=uint64(int(time.time())),
to_puzzle_hash=token_bytes(),
to_puzzle_hash=token_bytes(), # type: ignore[arg-type]
amount=uint64(abs(amount)),
fee_amount=uint64(0),
confirmed=False,
@ -590,10 +611,15 @@ class TradeManager:
name=spend_bundle.name(),
)
else:
# TODO: address hint errors and remove ignores
# error: Argument "to_puzzle_hash" to "TransactionRecord" has incompatible type "bytes"; expected
# "bytes32" [arg-type]
# error: Argument "name" to "TransactionRecord" has incompatible type "bytes"; expected "bytes32"
# [arg-type]
tx_record = TransactionRecord(
confirmed_at_height=uint32(0),
created_at_time=uint64(int(time.time())),
to_puzzle_hash=token_bytes(),
to_puzzle_hash=token_bytes(), # type: ignore[arg-type]
amount=uint64(abs(amount)),
fee_amount=uint64(0),
confirmed=False,
@ -605,14 +631,17 @@ class TradeManager:
sent_to=[],
trade_id=std_hash(spend_bundle.name() + bytes(now)),
type=uint32(TransactionType.INCOMING_TRADE.value),
name=token_bytes(),
name=token_bytes(), # type: ignore[arg-type]
)
my_tx_records.append(tx_record)
# TODO: address hint error and remove ignore
# error: Argument "to_puzzle_hash" to "TransactionRecord" has incompatible type "bytes"; expected
# "bytes32" [arg-type]
tx_record = TransactionRecord(
confirmed_at_height=uint32(0),
created_at_time=uint64(int(time.time())),
to_puzzle_hash=token_bytes(),
to_puzzle_hash=token_bytes(), # type: ignore[arg-type]
amount=uint64(0),
fee_amount=uint64(0),
confirmed=False,

View File

@ -348,15 +348,21 @@ class Wallet:
for primary in primaries:
message_list.append(Coin(coin.name(), primary["puzzlehash"], primary["amount"]).name())
message: bytes32 = std_hash(b"".join(message_list))
# TODO: address hint error and remove ignore
# error: Argument "coin_announcements_to_assert" to "make_solution" of "Wallet" has incompatible
# type "Optional[Set[Announcement]]"; expected "Optional[Set[bytes32]]" [arg-type]
solution: Program = self.make_solution(
primaries=primaries,
fee=fee,
coin_announcements={message},
coin_announcements_to_assert=announcements_to_consume,
coin_announcements_to_assert=announcements_to_consume, # type: ignore[arg-type]
)
primary_announcement_hash = Announcement(coin.name(), message).name()
else:
solution = self.make_solution(coin_announcements_to_assert={primary_announcement_hash})
# TODO: address hint error and remove ignore
# error: Argument 1 to <set> has incompatible type "Optional[bytes32]"; expected "bytes32"
# [arg-type]
solution = self.make_solution(coin_announcements_to_assert={primary_announcement_hash}) # type: ignore[arg-type] # noqa: E501
spends.append(
CoinSpend(
@ -393,10 +399,15 @@ class Wallet:
if primaries is None:
non_change_amount = amount
else:
non_change_amount = uint64(amount + sum(p["amount"] for p in primaries))
# TODO: address hint error and remove ignore
# error: Generator has incompatible item type "bytes32"; expected "int" [misc]
non_change_amount = uint64(amount + sum(p["amount"] for p in primaries)) # type: ignore[misc]
# TODO: address hint error and remove ignore
# error: Argument 8 to "_generate_unsigned_transaction" of "Wallet" has incompatible type
# "Optional[Set[bytes32]]"; expected "Optional[Set[Announcement]]" [arg-type]
transaction = await self._generate_unsigned_transaction(
amount, puzzle_hash, fee, origin_id, coins, primaries, ignore_max_send_amount, announcements_to_consume
amount, puzzle_hash, fee, origin_id, coins, primaries, ignore_max_send_amount, announcements_to_consume # type: ignore[arg-type] # noqa: E501
)
assert len(transaction) > 0

View File

@ -192,10 +192,15 @@ class WalletBlockStore:
for row in rows:
header_hash_bytes, block_record_bytes, is_peak = row
header_hash = bytes.fromhex(header_hash_bytes)
ret[header_hash] = BlockRecord.from_bytes(block_record_bytes)
# TODO: address hint error and remove ignore
# error: Invalid index type "bytes" for "Dict[bytes32, BlockRecord]"; expected type "bytes32" [index]
ret[header_hash] = BlockRecord.from_bytes(block_record_bytes) # type: ignore[index]
if is_peak:
assert peak is None # Sanity check, only one peak
peak = header_hash
# TODO: address hint error and remove ignore
# error: Incompatible types in assignment (expression has type "bytes", variable has type
# "Optional[bytes32]") [assignment]
peak = header_hash # type: ignore[assignment]
return ret, peak
def rollback_cache_block(self, header_hash: bytes32):
@ -234,7 +239,9 @@ class WalletBlockStore:
for row in rows:
header_hash_bytes, block_record_bytes = row
header_hash = bytes.fromhex(header_hash_bytes)
ret[header_hash] = BlockRecord.from_bytes(block_record_bytes)
# TODO: address hint error and remove ignore
# error: Invalid index type "bytes" for "Dict[bytes32, BlockRecord]"; expected type "bytes32" [index]
ret[header_hash] = BlockRecord.from_bytes(block_record_bytes) # type: ignore[index]
return ret, peak
async def get_header_blocks_in_range(
@ -252,7 +259,9 @@ class WalletBlockStore:
for row in rows:
header_hash_bytes, block_record_bytes = row
header_hash = bytes.fromhex(header_hash_bytes)
ret[header_hash] = HeaderBlock.from_bytes(block_record_bytes)
# TODO: address hint error and remove ignore
# error: Invalid index type "bytes" for "Dict[bytes32, HeaderBlock]"; expected type "bytes32" [index]
ret[header_hash] = HeaderBlock.from_bytes(block_record_bytes) # type: ignore[index]
return ret
@ -275,7 +284,9 @@ class WalletBlockStore:
for row in rows:
header_hash_bytes, block_record_bytes = row
header_hash = bytes.fromhex(header_hash_bytes)
ret[header_hash] = BlockRecord.from_bytes(block_record_bytes)
# TODO: address hint error and remove ignore
# error: Invalid index type "bytes" for "Dict[bytes32, BlockRecord]"; expected type "bytes32" [index]
ret[header_hash] = BlockRecord.from_bytes(block_record_bytes) # type: ignore[index]
return ret
@ -291,7 +302,10 @@ class WalletBlockStore:
if row is None:
return {}, {}
peak: bytes32 = bytes.fromhex(row[0])
# TODO: address hint error and remove ignore
# error: Incompatible types in assignment (expression has type "bytes", variable has type "bytes32")
# [assignment]
peak: bytes32 = bytes.fromhex(row[0]) # type: ignore[assignment]
cursor = await self.db.execute("SELECT header_hash,prev_hash,height,sub_epoch_summary from block_records")
rows = await cursor.fetchall()
await cursor.close()
@ -300,10 +314,19 @@ class WalletBlockStore:
hash_to_summary: Dict[bytes32, SubEpochSummary] = {}
for row in rows:
hash_to_prev_hash[bytes.fromhex(row[0])] = bytes.fromhex(row[1])
hash_to_height[bytes.fromhex(row[0])] = row[2]
# TODO: address hint error and remove ignore
# error: Invalid index type "bytes" for "Dict[bytes32, bytes32]"; expected type "bytes32" [index]
# error: Incompatible types in assignment (expression has type "bytes", target has type "bytes32")
# [assignment]
hash_to_prev_hash[bytes.fromhex(row[0])] = bytes.fromhex(row[1]) # type: ignore[index,assignment]
# TODO: address hint error and remove ignore
# error: Invalid index type "bytes" for "Dict[bytes32, uint32]"; expected type "bytes32" [index]
hash_to_height[bytes.fromhex(row[0])] = row[2] # type: ignore[index]
if row[3] is not None:
hash_to_summary[bytes.fromhex(row[0])] = SubEpochSummary.from_bytes(row[3])
# TODO: address hint error and remove ignore
# error: Invalid index type "bytes" for "Dict[bytes32, SubEpochSummary]"; expected type "bytes32"
# [index]
hash_to_summary[bytes.fromhex(row[0])] = SubEpochSummary.from_bytes(row[3]) # type: ignore[index]
height_to_hash: Dict[uint32, bytes32] = {}
sub_epoch_summaries: Dict[uint32, SubEpochSummary] = {}

View File

@ -396,7 +396,10 @@ class WalletBlockchain(BlockchainInterface):
def height_to_block_record(self, height: uint32, check_db=False) -> BlockRecord:
header_hash = self.height_to_hash(height)
return self.block_record(header_hash)
# TODO: address hint error and remove ignore
# error: Argument 1 to "block_record" of "WalletBlockchain" has incompatible type "Optional[bytes32]";
# expected "bytes32" [arg-type]
return self.block_record(header_hash) # type: ignore[arg-type]
def get_ses_heights(self) -> List[uint32]:
return sorted(self.__sub_epoch_summaries.keys())

View File

@ -348,7 +348,10 @@ class WalletNode:
for peer, status, _ in record.sent_to:
if status == MempoolInclusionStatus.SUCCESS.value:
already_sent.add(hexstr_to_bytes(peer))
messages.append((msg, already_sent))
# TODO: address hint error and remove ignore
# error: Argument 1 to "append" of "list" has incompatible type "Tuple[Message, Set[bytes]]"; expected
# "Tuple[Message, Set[bytes32]]" [arg-type]
messages.append((msg, already_sent)) # type: ignore[arg-type]
return messages
@ -804,8 +807,14 @@ class WalletNode:
for i in range(len(coins)):
assert coins[i][0] == proofs[i][0]
coin_list_1: List[Coin] = coins[i][1]
puzzle_hash_proof: bytes32 = proofs[i][1]
coin_list_proof: Optional[bytes32] = proofs[i][2]
# TODO: address hint error and remove ignore
# error: Incompatible types in assignment (expression has type "bytes", variable has type
# "bytes32") [assignment]
puzzle_hash_proof: bytes32 = proofs[i][1] # type: ignore[assignment]
# TODO: address hint error and remove ignore
# error: Incompatible types in assignment (expression has type "Optional[bytes]", variable has
# type "Optional[bytes32]") [assignment]
coin_list_proof: Optional[bytes32] = proofs[i][2] # type: ignore[assignment]
if len(coin_list_1) == 0:
# Verify exclusion proof for puzzle hash
not_included = confirm_not_included_already_hashed(
@ -818,10 +827,13 @@ class WalletNode:
else:
try:
# Verify inclusion proof for coin list
# TODO: address hint error and remove ignore
# error: Argument 3 to "confirm_included_already_hashed" has incompatible type
# "Optional[bytes32]"; expected "bytes32" [arg-type]
included = confirm_included_already_hashed(
root,
hash_coin_list(coin_list_1),
coin_list_proof,
coin_list_proof, # type: ignore[arg-type]
)
if included is False:
return False

View File

@ -125,9 +125,12 @@ class WalletPuzzleStore:
await cursor.close()
if row is not None and row[0] is not None:
# TODO: address hint error and remove ignore
# error: Argument 2 to "DerivationRecord" has incompatible type "bytes"; expected "bytes32"
# [arg-type]
return DerivationRecord(
uint32(row[0]),
bytes32.fromhex(row[2]),
bytes32.fromhex(row[2]), # type: ignore[arg-type]
G1Element.from_bytes(bytes.fromhex(row[1])),
WalletType(row[3]),
uint32(row[4]),
@ -147,9 +150,12 @@ class WalletPuzzleStore:
await cursor.close()
if row is not None and row[0] is not None:
# TODO: address hint error and remove ignore
# error: Argument 2 to "DerivationRecord" has incompatible type "bytes"; expected "bytes32"
# [arg-type]
return DerivationRecord(
uint32(row[0]),
bytes32.fromhex(row[2]),
bytes32.fromhex(row[2]), # type: ignore[arg-type]
G1Element.from_bytes(bytes.fromhex(row[1])),
WalletType(row[3]),
uint32(row[4]),

View File

@ -292,7 +292,10 @@ class BlockTools:
assert len(created) == 0
plot_id_new, path_new = list(existed.items())[0]
self.expected_plots[plot_id_new] = path_new
# TODO: address hint error and remove ignore
# error: Invalid index type "Optional[bytes32]" for "Dict[bytes32, Path]"; expected type "bytes32"
# [index]
self.expected_plots[plot_id_new] = path_new # type: ignore[index]
# create_plots() updates plot_directories. Ensure we refresh our config to reflect the updated value
self._config["harvester"]["plot_directories"] = load_config(self.root_path, "config.yaml", "harvester")[
@ -420,9 +423,12 @@ class BlockTools:
if force_plot_id is not None:
raise ValueError("Cannot specify plot_id for genesis block")
initial_block_list_len = 0
# TODO: address hint error and remove ignore
# error: Argument 2 to "create_genesis_block" of "BlockTools" has incompatible type "bytes"; expected
# "bytes32" [arg-type]
genesis = self.create_genesis_block(
constants,
seed,
seed, # type: ignore[arg-type]
force_overflow=force_overflow,
skip_slots=skip_slots,
timestamp=(uint64(int(time.time())) if genesis_timestamp is None else genesis_timestamp),
@ -443,7 +449,9 @@ class BlockTools:
latest_block: BlockRecord = blocks[block_list[-1].header_hash]
curr = latest_block
while not curr.is_transaction_block:
curr = blocks[curr.prev_hash]
# TODO: address hint error and remove ignore
# error: Invalid index type "bytes32" for "Dict[uint32, BlockRecord]"; expected type "uint32" [index]
curr = blocks[curr.prev_hash] # type: ignore[index]
start_timestamp = curr.timestamp
start_height = curr.height
@ -451,7 +459,9 @@ class BlockTools:
blocks_added_this_sub_slot = 1
while not curr.first_in_sub_slot:
curr = blocks[curr.prev_hash]
# TODO: address hint error and remove ignore
# error: Invalid index type "bytes32" for "Dict[uint32, BlockRecord]"; expected type "uint32" [index]
curr = blocks[curr.prev_hash] # type: ignore[index]
blocks_added_this_sub_slot += 1
finished_sub_slots_at_sp: List[EndOfSubSlotBundle] = [] # Sub-slots since last block, up to signage point
@ -484,7 +494,10 @@ class BlockTools:
):
if curr.height == 0:
break
curr = blocks[curr.prev_hash]
# TODO: address hint error and remove ignore
# error: Invalid index type "bytes32" for "Dict[uint32, BlockRecord]"; expected type
# "uint32" [index]
curr = blocks[curr.prev_hash] # type: ignore[index]
if curr.total_iters > sub_slot_start_total_iters:
finished_sub_slots_at_sp = []
@ -493,9 +506,12 @@ class BlockTools:
# Ignore this signage_point because it's in the past
continue
# TODO: address hint error and remove ignore
# error: Argument 1 to "BlockCache" has incompatible type "Dict[uint32, BlockRecord]";
# expected "Dict[bytes32, BlockRecord]" [arg-type]
signage_point: SignagePoint = get_signage_point(
constants,
BlockCache(blocks),
BlockCache(blocks), # type: ignore[arg-type]
latest_block,
sub_slot_start_total_iters,
uint8(signage_point_index),
@ -561,6 +577,9 @@ class BlockTools:
block_generator = None
aggregate_signature = G2Element()
# TODO: address hint error and remove ignore
# error: Argument 27 to "get_full_block_and_block_record" has incompatible type "bool";
# expected "Optional[bytes32]" [arg-type]
full_block, block_record = get_full_block_and_block_record(
constants,
blocks,
@ -588,7 +607,7 @@ class BlockTools:
signage_point,
latest_block,
seed,
normalized_to_identity_cc_ip,
normalized_to_identity_cc_ip, # type: ignore[arg-type]
current_time=current_time,
)
if block_record.is_transaction_block:
@ -645,12 +664,15 @@ class BlockTools:
eos_deficit: uint8 = (
latest_block.deficit if latest_block.deficit > 0 else constants.MIN_BLOCKS_PER_CHALLENGE_BLOCK
)
# TODO: address hint error and remove ignore
# error: Argument 5 to "get_icc" has incompatible type "Dict[uint32, BlockRecord]"; expected
# "Dict[bytes32, BlockRecord]" [arg-type]
icc_eos_vdf, icc_ip_proof = get_icc(
constants,
uint128(sub_slot_start_total_iters + sub_slot_iters),
finished_sub_slots_at_ip,
latest_block,
blocks,
blocks, # type: ignore[arg-type]
sub_slot_start_total_iters,
eos_deficit,
)
@ -668,9 +690,14 @@ class BlockTools:
if pending_ses:
sub_epoch_summary: Optional[SubEpochSummary] = None
else:
# TODO: address hint error and remove ignore
# error: Argument 1 to "BlockCache" has incompatible type "Dict[uint32, BlockRecord]"; expected
# "Dict[bytes32, BlockRecord]" [arg-type]
# error: Argument 2 to "BlockCache" has incompatible type "Dict[uint32, bytes32]"; expected
# "Optional[Dict[bytes32, HeaderBlock]]" [arg-type]
sub_epoch_summary = next_sub_epoch_summary(
constants,
BlockCache(blocks, height_to_hash),
BlockCache(blocks, height_to_hash), # type: ignore[arg-type]
latest_block.required_iters,
block_list[-1],
False,
@ -684,7 +711,10 @@ class BlockTools:
log.info(f"Sub epoch summary: {sub_epoch_summary}")
else:
ses_hash = None
# TODO: address hint error and remove ignore
# error: Incompatible types in assignment (expression has type "None", variable has type
# "bytes32") [assignment]
ses_hash = None # type: ignore[assignment]
new_sub_slot_iters = None
new_difficulty = None
@ -694,7 +724,10 @@ class BlockTools:
# This means there are blocks in this sub-slot
curr = latest_block
while not curr.is_challenge_block(constants) and not curr.first_in_sub_slot:
curr = blocks[curr.prev_hash]
# TODO: address hint error and remove ignore
# error: Invalid index type "bytes32" for "Dict[uint32, BlockRecord]"; expected type
# "uint32" [index]
curr = blocks[curr.prev_hash] # type: ignore[index]
if curr.is_challenge_block(constants):
icc_eos_iters = uint64(sub_slot_start_total_iters + sub_slot_iters - curr.total_iters)
else:
@ -769,9 +802,12 @@ class BlockTools:
constants.NUM_SPS_SUB_SLOT,
):
# note that we are passing in the finished slots which include the last slot
# TODO: address hint error and remove ignore
# error: Argument 1 to "BlockCache" has incompatible type "Dict[uint32, BlockRecord]";
# expected "Dict[bytes32, BlockRecord]" [arg-type]
signage_point = get_signage_point(
constants,
BlockCache(blocks),
BlockCache(blocks), # type: ignore[arg-type]
latest_block_eos,
sub_slot_start_total_iters,
uint8(signage_point_index),
@ -893,10 +929,13 @@ class BlockTools:
sub_slot_iters = new_sub_slot_iters
difficulty = new_difficulty
# TODO: address hint error and remove ignore
# error: Incompatible default for argument "seed" (default has type "bytes", argument has type "bytes32")
# [assignment]
def create_genesis_block(
self,
constants: ConsensusConstants,
seed: bytes32 = b"",
seed: bytes32 = b"", # type: ignore[assignment]
timestamp: Optional[uint64] = None,
force_overflow: bool = False,
skip_slots: int = 0,
@ -1296,9 +1335,13 @@ def get_challenges(
if len(finished_sub_slots) == 0:
if prev_header_hash is None:
return constants.GENESIS_CHALLENGE, constants.GENESIS_CHALLENGE
curr: BlockRecord = blocks[prev_header_hash]
# TODO: address hint error and remove ignore
# error: Invalid index type "bytes32" for "Dict[uint32, BlockRecord]"; expected type "uint32" [index]
curr: BlockRecord = blocks[prev_header_hash] # type: ignore[index]
while not curr.first_in_sub_slot:
curr = blocks[curr.prev_hash]
# TODO: address hint error and remove ignore
# error: Invalid index type "bytes32" for "Dict[uint32, BlockRecord]"; expected type "uint32" [index]
curr = blocks[curr.prev_hash] # type: ignore[index]
assert curr.finished_challenge_slot_hashes is not None
assert curr.finished_reward_slot_hashes is not None
cc_challenge = curr.finished_challenge_slot_hashes[-1]
@ -1340,17 +1383,23 @@ def load_block_list(
quality_str = full_block.reward_chain_block.proof_of_space.verify_and_get_quality_string(
constants, challenge, sp_hash
)
# TODO: address hint error and remove ignore
# error: Argument 2 to "calculate_iterations_quality" has incompatible type "Optional[bytes32]"; expected
# "bytes32" [arg-type]
required_iters: uint64 = calculate_iterations_quality(
constants.DIFFICULTY_CONSTANT_FACTOR,
quality_str,
quality_str, # type: ignore[arg-type]
full_block.reward_chain_block.proof_of_space.size,
uint64(difficulty),
sp_hash,
)
# TODO: address hint error and remove ignore
# error: Argument 1 to "BlockCache" has incompatible type "Dict[uint32, BlockRecord]"; expected
# "Dict[bytes32, BlockRecord]" [arg-type]
blocks[full_block.header_hash] = block_to_block_record(
constants,
BlockCache(blocks),
BlockCache(blocks), # type: ignore[arg-type]
required_iters,
full_block,
None,
@ -1458,6 +1507,11 @@ def get_full_block_and_block_record(
sp_iters = calculate_sp_iters(constants, sub_slot_iters, signage_point_index)
ip_iters = calculate_ip_iters(constants, sub_slot_iters, signage_point_index, required_iters)
# TODO: address hint error and remove ignore
# error: Argument 1 to "BlockCache" has incompatible type "Dict[uint32, BlockRecord]"; expected
# "Dict[bytes32, BlockRecord]" [arg-type]
# error: Argument 16 to "create_test_unfinished_block" has incompatible type "bytes"; expected "bytes32"
# [arg-type]
unfinished_block = create_test_unfinished_block(
constants,
sub_slot_start_total_iters,
@ -1473,8 +1527,8 @@ def get_full_block_and_block_record(
get_pool_signature,
signage_point,
timestamp,
BlockCache(blocks),
seed,
BlockCache(blocks), # type: ignore[arg-type]
seed, # type: ignore[arg-type]
block_generator,
aggregate_signature,
additions,
@ -1487,9 +1541,12 @@ def get_full_block_and_block_record(
slot_cc_challenge = overflow_cc_challenge
slot_rc_challenge = overflow_rc_challenge
# TODO: address hint error and remove ignore
# error: Argument 2 to "finish_block" has incompatible type "Dict[uint32, BlockRecord]"; expected
# "Dict[bytes32, BlockRecord]" [arg-type]
full_block, block_record = finish_block(
constants,
blocks,
blocks, # type: ignore[arg-type]
height_to_hash,
finished_sub_slots,
sub_slot_start_total_iters,
@ -1530,6 +1587,9 @@ def compute_cost_test(generator: BlockGenerator, cost_per_byte: int) -> Tuple[Op
return uint16(Err.GENERATOR_RUNTIME_ERROR.value), uint64(0)
# TODO: address hint error and remove ignore
# error: Incompatible default for argument "seed" (default has type "bytes", argument has type "bytes32")
# [assignment]
def create_test_foliage(
constants: ConsensusConstants,
reward_block_unfinished: RewardChainBlockUnfinished,
@ -1545,7 +1605,7 @@ def create_test_foliage(
pool_target: PoolTarget,
get_plot_signature: Callable[[bytes32, G1Element], G2Element],
get_pool_signature: Callable[[PoolTarget, Optional[G1Element]], Optional[G2Element]],
seed: bytes32 = b"",
seed: bytes32 = b"", # type: ignore[assignment]
) -> Tuple[Foliage, Optional[FoliageTransactionBlock], Optional[TransactionsInfo]]:
"""
Creates a foliage for a given reward chain block. This may or may not be a tx block. In the case of a tx block,
@ -1580,7 +1640,10 @@ def create_test_foliage(
random.seed(seed)
# Use the extension data to create different blocks based on header hash
extension_data: bytes32 = random.randint(0, 100000000).to_bytes(32, "big")
# TODO: address hint error and remove ignore
# error: Incompatible types in assignment (expression has type "bytes", variable has type "bytes32")
# [assignment]
extension_data: bytes32 = random.randint(0, 100000000).to_bytes(32, "big") # type: ignore[assignment]
if prev_block is None:
height: uint32 = uint32(0)
else:
@ -1681,10 +1744,16 @@ def create_test_foliage(
additions.extend(reward_claims_incorporated.copy())
for coin in additions:
tx_additions.append(coin)
byte_array_tx.append(bytearray(coin.puzzle_hash))
# TODO: address hint error and remove ignore
# error: Argument 1 to "append" of "list" has incompatible type "bytearray"; expected "bytes32"
# [arg-type]
byte_array_tx.append(bytearray(coin.puzzle_hash)) # type: ignore[arg-type]
for coin in removals:
tx_removals.append(coin.name())
byte_array_tx.append(bytearray(coin.name()))
# TODO: address hint error and remove ignore
# error: Argument 1 to "append" of "list" has incompatible type "bytearray"; expected "bytes32"
# [arg-type]
byte_array_tx.append(bytearray(coin.name())) # type: ignore[arg-type]
bip158: PyBIP158 = PyBIP158(byte_array_tx)
encoded = bytes(bip158.GetEncoded())
@ -1738,19 +1807,27 @@ def create_test_foliage(
prev_transaction_block_hash = prev_transaction_block.header_hash
assert transactions_info is not None
# TODO: address hint error and remove ignore
# error: Argument 4 to "FoliageTransactionBlock" has incompatible type "bytes"; expected "bytes32"
# [arg-type]
# error: Argument 5 to "FoliageTransactionBlock" has incompatible type "bytes"; expected "bytes32"
# [arg-type]
foliage_transaction_block: Optional[FoliageTransactionBlock] = FoliageTransactionBlock(
prev_transaction_block_hash,
timestamp,
filter_hash,
additions_root,
removals_root,
additions_root, # type: ignore[arg-type]
removals_root, # type: ignore[arg-type]
transactions_info.get_hash(),
)
assert foliage_transaction_block is not None
foliage_transaction_block_hash: Optional[bytes32] = foliage_transaction_block.get_hash()
# TODO: address hint error and remove ignore
# error: Argument 1 has incompatible type "Optional[bytes32]"; expected "bytes32" [arg-type]
foliage_transaction_block_signature: Optional[G2Element] = get_plot_signature(
foliage_transaction_block_hash, reward_block_unfinished.proof_of_space.plot_public_key
foliage_transaction_block_hash, # type: ignore[arg-type]
reward_block_unfinished.proof_of_space.plot_public_key,
)
assert foliage_transaction_block_signature is not None
else:
@ -1772,6 +1849,9 @@ def create_test_foliage(
return foliage, foliage_transaction_block, transactions_info
# TODO: address hint error and remove ignore
# error: Incompatible default for argument "seed" (default has type "bytes", argument has type "bytes32")
# [assignment]
def create_test_unfinished_block(
constants: ConsensusConstants,
sub_slot_start_total_iters: uint128,
@ -1788,7 +1868,7 @@ def create_test_unfinished_block(
signage_point: SignagePoint,
timestamp: uint64,
blocks: BlockchainInterface,
seed: bytes32 = b"",
seed: bytes32 = b"", # type: ignore[assignment]
block_generator: Optional[BlockGenerator] = None,
aggregate_sig: G2Element = G2Element(),
additions: Optional[List[Coin]] = None,
@ -1860,7 +1940,12 @@ def create_test_unfinished_block(
rc_sp_hash = curr.finished_reward_slot_hashes[-1]
signage_point = SignagePoint(None, None, None, None)
cc_sp_signature: Optional[G2Element] = get_plot_signature(cc_sp_hash, proof_of_space.plot_public_key)
# TODO: address hint error and remove ignore
# error: Argument 1 has incompatible type "Optional[bytes32]"; expected "bytes32" [arg-type]
cc_sp_signature: Optional[G2Element] = get_plot_signature(
cc_sp_hash, # type: ignore[arg-type]
proof_of_space.plot_public_key,
)
rc_sp_signature: Optional[G2Element] = get_plot_signature(rc_sp_hash, proof_of_space.plot_public_key)
assert cc_sp_signature is not None
assert rc_sp_signature is not None

View File

@ -13,7 +13,9 @@ from chia.util.ints import uint8
def gen_block_hash(height: int) -> bytes32:
return struct.pack(">I", height + 1) * (32 // 4)
# TODO: address hint errors and remove ignores
# error: Incompatible return value type (got "bytes", expected "bytes32") [return-value]
return struct.pack(">I", height + 1) * (32 // 4) # type: ignore[return-value]
def gen_ses(height: int) -> SubEpochSummary:

View File

@ -305,10 +305,15 @@ class TestCoinStoreWithBlocks:
num_blocks = 20
farmer_ph = 32 * b"0"
pool_ph = 32 * b"1"
# TODO: address hint error and remove ignore
# error: Argument "farmer_reward_puzzle_hash" to "get_consecutive_blocks" of "BlockTools" has
# incompatible type "bytes"; expected "Optional[bytes32]" [arg-type]
# error: Argument "pool_reward_puzzle_hash" to "get_consecutive_blocks" of "BlockTools" has
# incompatible type "bytes"; expected "Optional[bytes32]" [arg-type]
blocks = bt.get_consecutive_blocks(
num_blocks,
farmer_reward_puzzle_hash=farmer_ph,
pool_reward_puzzle_hash=pool_ph,
farmer_reward_puzzle_hash=farmer_ph, # type: ignore[arg-type]
pool_reward_puzzle_hash=pool_ph, # type: ignore[arg-type]
guarantee_transaction_block=True,
)
coin_store = await CoinStore.create(db_wrapper, cache_size=uint32(cache_size))

View File

@ -418,7 +418,10 @@ class TestFullNodeStore:
)
# Get signage point by hash
assert store.get_signage_point(saved_sp_hash) is not None
# TODO: address hint error and remove ignore
# error: Argument 1 to "get_signage_point" of "FullNodeStore" has incompatible type "Optional[bytes32]";
# expected "bytes32" [arg-type]
assert store.get_signage_point(saved_sp_hash) is not None # type: ignore[arg-type]
assert store.get_signage_point(std_hash(b"2")) is None
# Test adding signage points before genesis

View File

@ -92,12 +92,14 @@ async def two_nodes():
def make_item(idx: int, cost: uint64 = uint64(80)) -> MempoolItem:
spend_bundle_name = bytes([idx] * 32)
# TODO: address hint error and remove ignore
# error: Argument 5 to "MempoolItem" has incompatible type "bytes"; expected "bytes32" [arg-type]
return MempoolItem(
SpendBundle([], G2Element()),
uint64(0),
NPCResult(None, [], cost),
cost,
spend_bundle_name,
spend_bundle_name, # type: ignore[arg-type]
[],
[],
SerializedProgram(),

View File

@ -37,7 +37,10 @@ def make_fake_coin(index: int, puzzle_hash_db: dict) -> Coin:
parent = index.to_bytes(32, "big")
puzzle_hash = puzzle_hash_for_index(index, puzzle_hash_db)
amount = 100000
return Coin(parent, puzzle_hash, uint64(amount))
# TODO: address hint error and remove ignore
# error: Argument 1 to "Coin" has incompatible type "bytes"; expected "bytes32" [arg-type]
# error: Argument 2 to "Coin" has incompatible type "bytes"; expected "bytes32" [arg-type]
return Coin(parent, puzzle_hash, uint64(amount)) # type: ignore[arg-type]
def conditions_for_payment(coin) -> Program:

View File

@ -24,7 +24,10 @@ def event_loop():
def make_child_solution(coin_spend: CoinSpend, new_coin: Optional[Coin] = None) -> CoinSpend:
new_puzzle_hash: bytes32 = token_bytes(32)
# TODO: address hint error and remove ignore
# error: Incompatible types in assignment (expression has type "bytes", variable has type "bytes32")
# [assignment]
new_puzzle_hash: bytes32 = token_bytes(32) # type: ignore[assignment]
solution = "()"
puzzle = f"(q . ((51 0x{new_puzzle_hash.hex()} 1)))"
puzzle_prog = Program.to(binutils.assemble(puzzle))

View File

@ -35,6 +35,9 @@ class KeyTool(dict):
for public_key, message_hash in pkm_pairs_for_conditions_dict(
conditions_dict, coin_spend.coin.name(), additional_data
):
signature = self.sign(public_key, message_hash)
# TODO: address hint error and remove ignore
# error: Argument 2 to "sign" of "KeyTool" has incompatible type "bytes"; expected "bytes32"
# [arg-type]
signature = self.sign(public_key, message_hash) # type: ignore[arg-type]
signatures.append(signature)
return AugSchemeMPL.aggregate(signatures)

View File

@ -66,8 +66,11 @@ proof_of_space = ProofOfSpace(
),
)
# TODO: address hint error and remove ignore
# error: Argument 1 to "PoolTarget" has incompatible type "bytes"; expected "bytes32" [arg-type]
pool_target = PoolTarget(
bytes.fromhex("d23da14695a188ae5708dd152263c4db883eb27edeb936178d4d988b8f3ce5fc"), uint32(421941852)
bytes.fromhex("d23da14695a188ae5708dd152263c4db883eb27edeb936178d4d988b8f3ce5fc"), # type: ignore[arg-type]
uint32(421941852),
)
g2_element = G2Element(
bytes.fromhex(

View File

@ -270,7 +270,13 @@ def launcher_conditions_and_spend_bundle(
puzzle_db.add_puzzle(launcher_puzzle)
launcher_puzzle_hash = launcher_puzzle.get_tree_hash()
launcher_coin = Coin(parent_coin_id, launcher_puzzle_hash, launcher_amount)
singleton_full_puzzle = singleton_puzzle(launcher_coin.name(), launcher_puzzle_hash, initial_singleton_inner_puzzle)
# TODO: address hint error and remove ignore
# error: Argument 1 to "singleton_puzzle" has incompatible type "bytes32"; expected "Program" [arg-type]
singleton_full_puzzle = singleton_puzzle(
launcher_coin.name(), # type: ignore[arg-type]
launcher_puzzle_hash,
initial_singleton_inner_puzzle,
)
puzzle_db.add_puzzle(singleton_full_puzzle)
singleton_full_puzzle_hash = singleton_full_puzzle.get_tree_hash()
message_program = Program.to([singleton_full_puzzle_hash, launcher_amount, metadata])
@ -427,7 +433,13 @@ def spend_coin_to_singleton(
assert_coin_spent(coin_store, launcher_coin)
assert_coin_spent(coin_store, farmed_coin)
singleton_expected_puzzle = singleton_puzzle(launcher_id, launcher_puzzle_hash, initial_singleton_puzzle)
# TODO: address hint error and remove ignore
# error: Argument 1 to "singleton_puzzle" has incompatible type "bytes32"; expected "Program" [arg-type]
singleton_expected_puzzle = singleton_puzzle(
launcher_id, # type: ignore[arg-type]
launcher_puzzle_hash,
initial_singleton_puzzle,
)
singleton_expected_puzzle_hash = singleton_expected_puzzle.get_tree_hash()
expected_singleton_coin = Coin(launcher_coin.name(), singleton_expected_puzzle_hash, launcher_amount)
assert_coin_spent(coin_store, expected_singleton_coin, is_spent=False)

View File

@ -75,7 +75,9 @@ class WalletTool:
def get_new_puzzlehash(self) -> bytes32:
puzzle = self.get_new_puzzle()
return puzzle.get_tree_hash()
# TODO: address hint error and remove ignore
# error: "bytes32" has no attribute "get_tree_hash" [attr-defined]
return puzzle.get_tree_hash() # type: ignore[attr-defined]
def sign(self, value: bytes, pubkey: bytes) -> G2Element:
privatekey: PrivateKey = master_sk_to_wallet_sk(self.private_key, self.pubkey_num_lookup[pubkey])
@ -139,7 +141,14 @@ class WalletTool:
if n == 0:
message_list = [c.name() for c in coins]
for outputs in condition_dic[ConditionOpcode.CREATE_COIN]:
message_list.append(Coin(coin.name(), outputs.vars[0], int_from_bytes(outputs.vars[1])).name())
# TODO: address hint error and remove ignore
# error: Argument 2 to "Coin" has incompatible type "bytes"; expected "bytes32" [arg-type]
coin_to_append = Coin(
coin.name(),
outputs.vars[0], # type: ignore[arg-type]
int_from_bytes(outputs.vars[1]),
)
message_list.append(coin_to_append.name())
message = std_hash(b"".join(message_list))
condition_dic[ConditionOpcode.CREATE_COIN_ANNOUNCEMENT].append(
ConditionWithArgs(ConditionOpcode.CREATE_COIN_ANNOUNCEMENT, [message])

View File

@ -113,8 +113,15 @@ async def load_blocks_dont_validate(
cc_sp,
)
# TODO: address hint error and remove ignore
# error: Argument 2 to "BlockCache" has incompatible type "Dict[uint32, bytes32]"; expected
# "Optional[Dict[bytes32, HeaderBlock]]" [arg-type]
sub_block = block_to_block_record(
test_constants, BlockCache(sub_blocks, height_to_hash), required_iters, block, None
test_constants,
BlockCache(sub_blocks, height_to_hash), # type: ignore[arg-type]
required_iters,
block,
None,
)
sub_blocks[block.header_hash] = sub_block
height_to_hash[block.height] = block.header_hash