Use bls from chia rs (#16715)

* replace blspy imports with chia_rs imports for BLS types

* remove blspy-stubs, since we're dropping the blspy dependency. chia_rs has type stubs already
This commit is contained in:
Arvid Norberg 2023-11-07 18:06:52 +01:00 committed by GitHub
parent a53652cfda
commit 95e5b97557
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
133 changed files with 169 additions and 375 deletions

View File

@ -10,11 +10,9 @@ param(
$ErrorActionPreference = "Stop"
$extras = @()
$blspy = $False
if ($d)
{
$extras += "dev"
$blspy = $True
}
$editable_cli = "--editable"
@ -118,11 +116,6 @@ venv\scripts\python -m pip install --upgrade pip setuptools wheel
venv\scripts\pip install --extra-index-url https://pypi.chia.net/simple/ miniupnpc==2.2.2
venv\scripts\pip install $editable_cli ".$extras_cli" --extra-index-url https://pypi.chia.net/simple/
if ($blspy)
{
venv\scripts\pip install $editable_cli .\blspy-stubs
}
if ($p)
{
$PREV_VIRTUAL_ENV = "$env:VIRTUAL_ENV"

View File

@ -5,7 +5,7 @@ from dataclasses import dataclass
from time import monotonic
from typing import Dict, Optional
from blspy import G2Element
from chia_rs import G2Element
from clvm.casts import int_to_bytes
from chia.consensus.cost_calculator import NPCResult

View File

@ -11,7 +11,7 @@ from typing import Any, Generic, Optional, Tuple, Type, TypeVar, Union
import aiosqlite
import click
from blspy import AugSchemeMPL, G1Element, G2Element
from chia_rs import AugSchemeMPL, G1Element, G2Element
from chia.consensus.coinbase import create_farmer_coin, create_pool_coin
from chia.consensus.default_constants import DEFAULT_CONSTANTS

View File

@ -1,118 +0,0 @@
from __future__ import annotations
class G1Element:
SIZE: ClassVar[int] = ...
def __new__(cls) -> G1Element: ...
def get_fingerprint(self) -> int: ...
@staticmethod
def from_bytes_unchecked(b: bytes) -> G1Element: ...
def pair(self, other: G2Element) -> GTElement: ...
@staticmethod
def generator() -> G1Element: ...
def __add__(self, other: G1Element) -> G1Element: ...
def __iadd__(self, other: G1Element) -> None: ...
def __init__(self) -> None: ...
def __hash__(self) -> int: ...
def __str__(self) -> str: ...
def __repr__(self) -> str: ...
def __richcmp__(self) -> Any: ...
def __deepcopy__(self) -> G1Element: ...
def __copy__(self) -> G1Element: ...
@staticmethod
def from_bytes(bytes) -> G1Element: ...
@staticmethod
def parse_rust(ReadableBuffer) -> Tuple[G1Element, int]: ...
def to_bytes(self) -> bytes: ...
def __bytes__(self) -> bytes: ...
def get_hash(self) -> bytes32: ...
def to_json_dict(self) -> Dict[str, Any]: ...
@staticmethod
def from_json_dict(o: Dict[str, Any]) -> G1Element: ...
class G2Element:
SIZE: ClassVar[int] = ...
def __new__(cls) -> G2Element: ...
def get_fingerprint(self) -> int: ...
@staticmethod
def from_bytes_unchecked(b: bytes) -> G2Element: ...
def pair(self, other: G1Element) -> GTElement: ...
@staticmethod
def generator() -> G2Element: ...
def __hash__(self) -> int: ...
def __str__(self) -> str: ...
def __repr__(self) -> str: ...
def __richcmp__(self) -> bool: ...
def __deepcopy__(self) -> G2Element: ...
def __copy__(self) -> G2Element: ...
@staticmethod
def from_bytes(bytes) -> G2Element: ...
@staticmethod
def parse_rust(ReadableBuffer) -> Tuple[G2Element, int]: ...
def to_bytes(self) -> bytes: ...
def __bytes__(self) -> bytes: ...
def get_hash(self) -> bytes32: ...
def to_json_dict(self) -> Dict[str, Any]: ...
@staticmethod
def from_json_dict(o: Dict[str, Any]) -> G2Element: ...
class GTElement:
SIZE: ClassVar[int] = ...
@staticmethod
def from_bytes_unchecked(b: bytes) -> GTElement: ...
def __mul__(self, rhs: GTElement) -> GTElement: ...
def __imul__(self, rhs: GTElement) -> None: ...
def __hash__(self) -> int: ...
def __str__(self) -> str: ...
def __repr__(self) -> str: ...
def __richcmp__(self) -> bool: ...
def __deepcopy__(self) -> GTElement: ...
def __copy__(self) -> GTElement: ...
@staticmethod
def from_bytes(bytes) -> GTElement: ...
@staticmethod
def parse_rust(ReadableBuffer) -> Tuple[GTElement, int]: ...
def to_bytes(self) -> bytes: ...
def __bytes__(self) -> bytes: ...
def get_hash(self) -> bytes32: ...
def to_json_dict(self) -> Dict[str, Any]: ...
@staticmethod
def from_json_dict(o: Dict[str, Any]) -> GTElement: ...
class PrivateKey:
PRIVATE_KEY_SIZE: ClassVar[int] = ...
def sign_g2(self, msg: bytes, dst: bytes) -> G2Element: ...
def get_g1(self) -> G1Element: ...
def __hash__(self) -> int: ...
def __str__(self) -> str: ...
def __repr__(self) -> str: ...
def __richcmp__(self) -> bool: ...
def __deepcopy__(self) -> PrivateKey: ...
def __copy__(self) -> PrivateKey: ...
@staticmethod
def from_bytes(bytes) -> PrivateKey: ...
@staticmethod
def parse_rust(ReadableBuffer) -> Tuple[PrivateKey, int]: ...
def to_bytes(self) -> bytes: ...
def __bytes__(self) -> bytes: ...
def get_hash(self) -> bytes32: ...
def to_json_dict(self) -> Dict[str, Any]: ...
@staticmethod
def from_json_dict(o: Dict[str, Any]) -> PrivateKey: ...
class AugSchemeMPL:
@staticmethod
def sign(pk: PrivateKey, msg: bytes, prepend_pk: G1Element = None) -> G2Element: ...
@staticmethod
def aggregate(sigs: Sequence[G2Element]) -> G2Element: ...
@staticmethod
def verify(pk: G1Element, msg: bytes, sig: G2Element) -> bool: ...
@staticmethod
def aggregate_verify(pks: Sequence[G1Element], msgs: Sequence[bytes], sig: G2Element) -> bool: ...
@staticmethod
def key_gen(seed: bytes) -> PrivateKey: ...
@staticmethod
def g2_from_message(msg: bytes) -> G2Element: ...
@staticmethod
def derive_child_sk(pk: PrivateKey, index: int) -> PrivateKey: ...
@staticmethod
def derive_child_sk_unhardened(pk: PrivateKey, index: int) -> PrivateKey: ...

View File

@ -1,9 +0,0 @@
from __future__ import annotations
from setuptools import setup
setup(
name="blspy-stubs",
packages=["blspy-stubs"],
package_data={"blspy-stubs": ["__init__.pyi"]},
)

View File

@ -318,7 +318,7 @@ def search_cmd(
) -> None:
import sys
from blspy import PrivateKey
from chia_rs import PrivateKey
from .keys_funcs import resolve_derivation_master_key, search_derive

View File

@ -7,7 +7,7 @@ from enum import Enum
from pathlib import Path
from typing import Any, Dict, List, Optional, Tuple, Union
from blspy import AugSchemeMPL, G1Element, G2Element, PrivateKey
from chia_rs import AugSchemeMPL, G1Element, G2Element, PrivateKey
from chia.cmds.passphrase_funcs import obtain_current_passphrase
from chia.consensus.coinbase import create_puzzlehash_for_pk

View File

@ -8,7 +8,7 @@ from random import randint
from typing import Any, Dict, List, Optional
from aiohttp import ClientConnectorError
from blspy import PrivateKey
from chia_rs import PrivateKey
from chia.cmds.cmds_util import get_any_service_client
from chia.cmds.start_funcs import async_start

View File

@ -5,9 +5,8 @@ import random
from dataclasses import replace
from typing import Callable, Dict, List, Optional, Tuple
import blspy
from blspy import G1Element, G2Element
from chia_rs import compute_merkle_set_root
import chia_rs
from chia_rs import G1Element, G2Element, compute_merkle_set_root
from chiabip158 import PyBIP158
from chia.consensus.block_record import BlockRecord
@ -367,7 +366,7 @@ def create_unfinished_block(
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
assert blspy.AugSchemeMPL.verify(proof_of_space.plot_public_key, cc_sp_hash, cc_sp_signature)
assert chia_rs.AugSchemeMPL.verify(proof_of_space.plot_public_key, cc_sp_hash, cc_sp_signature)
total_iters = uint128(sub_slot_start_total_iters + ip_iters + (sub_slot_iters if overflow else 0))

View File

@ -5,7 +5,7 @@ import logging
import time
from typing import Optional, Tuple
from blspy import AugSchemeMPL
from chia_rs import AugSchemeMPL
from chia.consensus.block_record import BlockRecord
from chia.consensus.blockchain_interface import BlockchainInterface

View File

@ -1,6 +1,6 @@
from __future__ import annotations
from blspy import G1Element
from chia_rs import G1Element
from chia.types.blockchain_format.coin import Coin
from chia.types.blockchain_format.sized_bytes import bytes32

View File

@ -7,7 +7,7 @@ from concurrent.futures import Executor
from dataclasses import dataclass
from typing import Awaitable, Callable, Dict, List, Optional, Sequence, Tuple
from blspy import AugSchemeMPL, G1Element
from chia_rs import AugSchemeMPL, G1Element
from chia.consensus.block_header_validation import validate_finished_header_block
from chia.consensus.block_record import BlockRecord

View File

@ -8,7 +8,7 @@ from pathlib import Path
from typing import Any, Dict, List, Optional, Tuple
from aiohttp import ClientConnectorError, ClientSession
from blspy import AugSchemeMPL, PrivateKey
from chia_rs import AugSchemeMPL, PrivateKey
from chia.cmds.init_funcs import check_keys
from chia.daemon.client import DaemonProxy

View File

@ -5,7 +5,7 @@ from dataclasses import dataclass, field
from pathlib import Path
from typing import Any, Dict, List, Optional, Type
from blspy import PrivateKey
from chia_rs import PrivateKey
from chia.cmds.init_funcs import check_keys
from chia.util.errors import KeychainException, KeychainFingerprintNotFound

View File

@ -18,7 +18,7 @@ from pathlib import Path
from types import FrameType
from typing import Any, AsyncIterator, Dict, List, Optional, Set, TextIO, Tuple
from blspy import G1Element
from chia_rs import G1Element
from typing_extensions import Protocol
from chia import __version__

View File

@ -6,7 +6,7 @@ import time
from operator import attrgetter
from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Set, Tuple, cast
from blspy import G1Element, G2Element
from chia_rs import G1Element, G2Element
from clvm.EvalError import EvalError
from typing_extensions import Unpack, final

View File

@ -10,7 +10,7 @@ from pathlib import Path
from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Set, Tuple, Union, cast
import aiohttp
from blspy import AugSchemeMPL, G1Element, G2Element, PrivateKey
from chia_rs import AugSchemeMPL, G1Element, G2Element, PrivateKey
from chia.consensus.constants import ConsensusConstants
from chia.daemon.keychain_proxy import KeychainProxy, connect_to_keychain_and_validate, wrap_local_keychain

View File

@ -6,7 +6,7 @@ import time
from typing import Any, Dict, List, Optional, Union
import aiohttp
from blspy import AugSchemeMPL, G2Element, PrivateKey
from chia_rs import AugSchemeMPL, G2Element, PrivateKey
from chia import __version__
from chia.consensus.pot_iterations import calculate_iterations_quality, calculate_sp_interval_iters

View File

@ -27,7 +27,7 @@ from typing import (
final,
)
from blspy import AugSchemeMPL
from chia_rs import AugSchemeMPL
from chia.consensus.block_creation import unfinished_block_to_full_block
from chia.consensus.block_record import BlockRecord

View File

@ -10,7 +10,7 @@ from concurrent.futures import ThreadPoolExecutor
from datetime import datetime, timezone
from typing import TYPE_CHECKING, Dict, List, Optional, Set, Tuple
from blspy import AugSchemeMPL, G1Element, G2Element
from chia_rs import AugSchemeMPL, G1Element, G2Element
from chiabip158 import PyBIP158
from chia.consensus.block_creation import create_unfinished_block

View File

@ -6,8 +6,7 @@ from datetime import datetime
from enum import Enum
from typing import Callable, Dict, Iterator, List, Optional, Tuple
from blspy import AugSchemeMPL, G2Element
from chia_rs import Coin
from chia_rs import AugSchemeMPL, Coin, G2Element
from chia.consensus.default_constants import DEFAULT_CONSTANTS
from chia.full_node.fee_estimation import FeeMempoolInfo, MempoolInfo, MempoolItemInfo

View File

@ -9,8 +9,7 @@ from dataclasses import dataclass
from multiprocessing.context import BaseContext
from typing import Awaitable, Callable, Dict, List, Optional, Set, Tuple, TypeVar
from blspy import GTElement
from chia_rs import ELIGIBLE_FOR_DEDUP
from chia_rs import ELIGIBLE_FOR_DEDUP, GTElement
from chiabip158 import PyBIP158
from chia.consensus.block_record import BlockRecordProtocol

View File

@ -6,7 +6,7 @@ import time
from pathlib import Path
from typing import List, Optional, Tuple
from blspy import AugSchemeMPL, G1Element, G2Element
from chia_rs import AugSchemeMPL, G1Element, G2Element
from chia.consensus.pot_iterations import calculate_iterations_quality, calculate_sp_interval_iters
from chia.harvester.harvester import Harvester

View File

@ -8,7 +8,7 @@ from math import ceil
from pathlib import Path
from typing import Dict, ItemsView, KeysView, List, Optional, Tuple, ValuesView
from blspy import G1Element
from chia_rs import G1Element
from chiapos import DiskProver
from chia.plotting.util import parse_plot_info

View File

@ -9,7 +9,7 @@ from threading import Lock
from time import sleep, time
from typing import List, Optional
from blspy import G1Element
from chia_rs import G1Element
from chiapos import Verifier
from chia.plotting.manager import PlotManager

View File

@ -5,7 +5,7 @@ from datetime import datetime
from pathlib import Path
from typing import Dict, List, Optional, Tuple
from blspy import AugSchemeMPL, G1Element, PrivateKey
from chia_rs import AugSchemeMPL, G1Element, PrivateKey
from chiapos import DiskPlotter
from chia.daemon.keychain_proxy import KeychainProxy, connect_to_keychain_and_validate, wrap_local_keychain

View File

@ -8,7 +8,7 @@ from concurrent.futures.thread import ThreadPoolExecutor
from pathlib import Path
from typing import Any, Callable, Dict, List, Optional, Set, Tuple
from blspy import G1Element
from chia_rs import G1Element
from chiapos import DiskProver, decompressor_context_queue
from chia.consensus.pos_quality import UI_ACTUAL_SPACE_CONSTANT_FACTOR, _expected_plot_size

View File

@ -6,7 +6,7 @@ from enum import Enum, IntEnum
from pathlib import Path
from typing import Any, Dict, List, Optional, Tuple, Union
from blspy import G1Element, PrivateKey
from chia_rs import G1Element, PrivateKey
from chiapos import DiskProver
from typing_extensions import final

View File

@ -5,7 +5,7 @@ from dataclasses import dataclass
from pathlib import Path
from typing import List
from blspy import G1Element
from chia_rs import G1Element
from chia.types.blockchain_format.sized_bytes import bytes32
from chia.util.byte_types import hexstr_to_bytes

View File

@ -3,7 +3,7 @@ from __future__ import annotations
import logging
from typing import List, Optional, Tuple
from blspy import G1Element
from chia_rs import G1Element
from clvm.casts import int_from_bytes, int_to_bytes
from chia.clvm.singleton import SINGLETON_LAUNCHER

View File

@ -5,7 +5,7 @@ import logging
import time
from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Set, Tuple, cast
from blspy import G1Element, G2Element, PrivateKey
from chia_rs import G1Element, G2Element, PrivateKey
from typing_extensions import final
from chia.clvm.singleton import SINGLETON_LAUNCHER

View File

@ -4,7 +4,7 @@ from dataclasses import dataclass
from enum import IntEnum
from typing import Any, Dict, Optional
from blspy import G1Element
from chia_rs import G1Element
from chia.protocols.pool_protocol import POOL_PROTOCOL_VERSION
from chia.types.blockchain_format.coin import Coin

View File

@ -3,7 +3,7 @@ from __future__ import annotations
from dataclasses import dataclass
from typing import Optional
from blspy import G2Element
from chia_rs import G2Element
from chia.types.blockchain_format.pool_target import PoolTarget
from chia.types.blockchain_format.proof_of_space import ProofOfSpace

View File

@ -3,7 +3,7 @@ from __future__ import annotations
from dataclasses import dataclass
from typing import List, Optional, Tuple
from blspy import G1Element, G2Element
from chia_rs import G1Element, G2Element
from chia.types.blockchain_format.proof_of_space import ProofOfSpace
from chia.types.blockchain_format.sized_bytes import bytes32

View File

@ -5,7 +5,7 @@ from dataclasses import dataclass
from enum import Enum
from typing import Optional
from blspy import G1Element, G2Element
from chia_rs import G1Element, G2Element
from chia.types.blockchain_format.proof_of_space import ProofOfSpace
from chia.types.blockchain_format.sized_bytes import bytes32

View File

@ -7,7 +7,7 @@ import zlib
from pathlib import Path
from typing import Any, ClassVar, Dict, List, Optional, Set, Tuple, Union
from blspy import AugSchemeMPL, G1Element, G2Element, PrivateKey
from chia_rs import AugSchemeMPL, G1Element, G2Element, PrivateKey
from clvm_tools.binutils import assemble
from chia.consensus.block_rewards import calculate_base_farmer_reward

View File

@ -15,8 +15,15 @@ from dataclasses import dataclass, replace
from pathlib import Path
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
from blspy import AugSchemeMPL, G1Element, G2Element, PrivateKey
from chia_rs import ALLOW_BACKREFS, MEMPOOL_MODE, compute_merkle_set_root
from chia_rs import (
ALLOW_BACKREFS,
MEMPOOL_MODE,
AugSchemeMPL,
G1Element,
G2Element,
PrivateKey,
compute_merkle_set_root,
)
from chiabip158 import PyBIP158
from clvm.casts import int_from_bytes

View File

@ -4,7 +4,7 @@ import sys
from pathlib import Path
from typing import Any, AsyncGenerator, Dict, Optional, Tuple
from blspy import PrivateKey
from chia_rs import PrivateKey
from chia.consensus.coinbase import create_puzzlehash_for_pk
from chia.daemon.server import WebSocketServer, daemon_launch_lock_path

View File

@ -2,7 +2,7 @@ from __future__ import annotations
from typing import Any, Dict, List, Optional, Tuple
from blspy import AugSchemeMPL, G1Element, G2Element, PrivateKey
from chia_rs import AugSchemeMPL, G1Element, G2Element, PrivateKey
from clvm.casts import int_from_bytes, int_to_bytes
from chia.consensus.constants import ConsensusConstants

View File

@ -3,7 +3,7 @@ from __future__ import annotations
from dataclasses import dataclass
from typing import List, Optional
from blspy import G2Element
from chia_rs import G2Element
from chia.types.blockchain_format.coin import Coin
from chia.types.blockchain_format.pool_target import PoolTarget

View File

@ -5,7 +5,7 @@ from dataclasses import dataclass
from typing import Optional, cast
from bitstring import BitArray
from blspy import AugSchemeMPL, G1Element, PrivateKey
from chia_rs import AugSchemeMPL, G1Element, PrivateKey
from chiapos import Verifier
from chia.consensus.constants import ConsensusConstants

View File

@ -3,7 +3,7 @@ from __future__ import annotations
from dataclasses import dataclass
from typing import Optional
from blspy import G2Element
from chia_rs import G2Element
from chia.types.blockchain_format.proof_of_space import ProofOfSpace
from chia.types.blockchain_format.sized_bytes import bytes32

View File

@ -3,7 +3,7 @@ from __future__ import annotations
from dataclasses import dataclass
from typing import Optional
from blspy import G2Element
from chia_rs import G2Element
from chia.types.blockchain_format.proof_of_space import ProofOfSpace
from chia.types.blockchain_format.sized_bytes import bytes32

View File

@ -4,7 +4,7 @@ import warnings
from dataclasses import dataclass
from typing import Any, Dict, List, cast
from blspy import AugSchemeMPL, G2Element
from chia_rs import AugSchemeMPL, G2Element
from chia.consensus.default_constants import DEFAULT_CONSTANTS
from chia.types.blockchain_format.coin import Coin

View File

@ -3,7 +3,7 @@ from __future__ import annotations
import functools
from typing import Dict, List, Optional, Sequence
from blspy import AugSchemeMPL, G1Element, G2Element, GTElement
from chia_rs import AugSchemeMPL, G1Element, G2Element, GTElement
from chia.types.blockchain_format.sized_bytes import bytes32, bytes48
from chia.util.hash import std_hash

View File

@ -4,8 +4,7 @@ import io
from dataclasses import dataclass
from typing import Callable, List, Optional, Tuple
from blspy import G1Element, G2Element
from chia_rs import serialized_length
from chia_rs import G1Element, G2Element, serialized_length
from chiabip158 import PyBIP158
from chia.types.blockchain_format.coin import Coin

View File

@ -9,7 +9,7 @@ from typing import Any, Dict, List, Optional, Tuple
import pkg_resources
from bitstring import BitArray # pyright: reportMissingImports=false
from blspy import AugSchemeMPL, G1Element, PrivateKey # pyright: reportMissingImports=false
from chia_rs import AugSchemeMPL, G1Element, PrivateKey # pyright: reportMissingImports=false
from typing_extensions import final
from chia.types.blockchain_format.sized_bytes import bytes32

View File

@ -23,7 +23,6 @@ from typing import (
get_type_hints,
)
from blspy import G1Element, G2Element, PrivateKey
from typing_extensions import Literal, get_args, get_origin
from chia.types.blockchain_format.sized_bytes import bytes32
@ -82,16 +81,7 @@ class ConversionError(StreamableError):
)
# TODO: Remove hack, this allows streaming these objects from binary
size_hints = {
"PrivateKey": PrivateKey.PRIVATE_KEY_SIZE,
"G1Element": G1Element.SIZE,
"G2Element": G2Element.SIZE,
}
unhashable_types = [
"PrivateKey",
"G1Element",
"G2Element",
"Program",
"SerializedProgram",
]
@ -402,15 +392,6 @@ def parse_tuple(f: BinaryIO, list_parse_inner_type_f: List[ParseFunctionType]) -
return tuple(full_list)
def parse_size_hints(f: BinaryIO, f_type: Type[Any], bytes_to_read: int, unchecked: bool) -> Any:
bytes_read = f.read(bytes_to_read)
assert bytes_read is not None and len(bytes_read) == bytes_to_read
if unchecked:
return f_type.from_bytes_unchecked(bytes_read)
else:
return f_type.from_bytes(bytes_read)
def parse_str(f: BinaryIO) -> str:
str_size = parse_uint32(f)
str_read_bytes = f.read(str_size)
@ -445,12 +426,6 @@ def function_to_parse_one_item(f_type: Type[Any]) -> ParseFunctionType:
inner_types = get_args(f_type)
list_parse_inner_type_f = [function_to_parse_one_item(_) for _ in inner_types]
return lambda f: parse_tuple(f, list_parse_inner_type_f)
if hasattr(f_type, "from_bytes_unchecked") and f_type.__name__ in size_hints:
bytes_to_read = size_hints[f_type.__name__]
return lambda f: parse_size_hints(f, f_type, bytes_to_read, unchecked=True)
if hasattr(f_type, "from_bytes") and f_type.__name__ in size_hints:
bytes_to_read = size_hints[f_type.__name__]
return lambda f: parse_size_hints(f, f_type, bytes_to_read, unchecked=False)
if f_type is str:
return parse_str
raise UnsupportedType(f"Type {f_type} does not have parse")

View File

@ -3,7 +3,7 @@ from __future__ import annotations
import dataclasses
from typing import Iterator, List, Optional
from blspy import G2Element
from chia_rs import G2Element
from chia.types.blockchain_format.coin import Coin, coin_as_list
from chia.types.blockchain_format.program import INFINITE_COST, Program

View File

@ -6,7 +6,7 @@ import time
import traceback
from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Set, Tuple, cast
from blspy import AugSchemeMPL, G1Element, G2Element
from chia_rs import AugSchemeMPL, G1Element, G2Element
from typing_extensions import Unpack
from chia.server.ws_connection import WSChiaConnection

View File

@ -5,7 +5,7 @@ import time
from secrets import token_bytes
from typing import TYPE_CHECKING, Any, ClassVar, List, Optional, Set, Tuple, cast
from blspy import G1Element
from chia_rs import G1Element
from chia.server.ws_connection import WSChiaConnection
from chia.types.blockchain_format.coin import Coin

View File

@ -4,7 +4,7 @@ from abc import ABC, abstractmethod
from dataclasses import dataclass, fields, replace
from typing import Any, Dict, Iterable, List, Optional, Set, Tuple, Type, TypeVar, Union, final, get_type_hints
from blspy import G1Element
from chia_rs import G1Element
from clvm.casts import int_from_bytes, int_to_bytes
from chia.types.blockchain_format.program import Program
@ -37,7 +37,7 @@ class AggSigParent(Condition):
parent_id: Optional[bytes32] = None
def to_program(self) -> Program:
condition: Program = Program.to([ConditionOpcode.AGG_SIG_PARENT, self.pubkey, self.msg])
condition: Program = Program.to([ConditionOpcode.AGG_SIG_PARENT, self.pubkey.to_bytes(), self.msg])
return condition
@classmethod
@ -58,7 +58,7 @@ class AggSigPuzzle(Condition):
puzzle_hash: Optional[bytes32] = None
def to_program(self) -> Program:
condition: Program = Program.to([ConditionOpcode.AGG_SIG_PUZZLE, self.pubkey, self.msg])
condition: Program = Program.to([ConditionOpcode.AGG_SIG_PUZZLE, self.pubkey.to_bytes(), self.msg])
return condition
@classmethod
@ -79,7 +79,7 @@ class AggSigAmount(Condition):
amount: Optional[uint64] = None
def to_program(self) -> Program:
condition: Program = Program.to([ConditionOpcode.AGG_SIG_AMOUNT, self.pubkey, self.msg])
condition: Program = Program.to([ConditionOpcode.AGG_SIG_AMOUNT, self.pubkey.to_bytes(), self.msg])
return condition
@classmethod
@ -101,7 +101,7 @@ class AggSigPuzzleAmount(Condition):
amount: Optional[uint64] = None
def to_program(self) -> Program:
condition: Program = Program.to([ConditionOpcode.AGG_SIG_PUZZLE_AMOUNT, self.pubkey, self.msg])
condition: Program = Program.to([ConditionOpcode.AGG_SIG_PUZZLE_AMOUNT, self.pubkey.to_bytes(), self.msg])
return condition
@classmethod
@ -129,7 +129,7 @@ class AggSigParentAmount(Condition):
amount: Optional[uint64] = None
def to_program(self) -> Program:
condition: Program = Program.to([ConditionOpcode.AGG_SIG_PARENT_AMOUNT, self.pubkey, self.msg])
condition: Program = Program.to([ConditionOpcode.AGG_SIG_PARENT_AMOUNT, self.pubkey.to_bytes(), self.msg])
return condition
@classmethod
@ -157,7 +157,7 @@ class AggSigParentPuzzle(Condition):
puzzle_hash: Optional[bytes32] = None
def to_program(self) -> Program:
condition: Program = Program.to([ConditionOpcode.AGG_SIG_PARENT_PUZZLE, self.pubkey, self.msg])
condition: Program = Program.to([ConditionOpcode.AGG_SIG_PARENT_PUZZLE, self.pubkey.to_bytes(), self.msg])
return condition
@classmethod
@ -183,7 +183,7 @@ class AggSigUnsafe(Condition):
msg: bytes
def to_program(self) -> Program:
condition: Program = Program.to([ConditionOpcode.AGG_SIG_UNSAFE, self.pubkey, self.msg])
condition: Program = Program.to([ConditionOpcode.AGG_SIG_UNSAFE, self.pubkey.to_bytes(), self.msg])
return condition
@classmethod
@ -204,7 +204,7 @@ class AggSigMe(Condition):
additional_data: Optional[bytes32] = None
def to_program(self) -> Program:
condition: Program = Program.to([ConditionOpcode.AGG_SIG_ME, self.pubkey, self.msg])
condition: Program = Program.to([ConditionOpcode.AGG_SIG_ME, self.pubkey.to_bytes(), self.msg])
return condition
@classmethod
@ -757,7 +757,7 @@ class AggSig(Condition):
def to_program(self) -> Program:
# We know we are an agg sig or we want to error
return CONDITION_DRIVERS[self.opcode](self.pubkey, self.msg).to_program() # type: ignore[call-arg]
return CONDITION_DRIVERS[self.opcode](self.pubkey.to_bytes(), self.msg).to_program() # type: ignore[call-arg]
@classmethod
def from_program(cls, program: Program, **kwargs: Optional[Union[uint64, bytes32]]) -> AggSig:

View File

@ -9,7 +9,7 @@ import time
from secrets import token_bytes
from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Set, Tuple, Union, cast
from blspy import AugSchemeMPL, G1Element, G2Element
from chia_rs import AugSchemeMPL, G1Element, G2Element
from clvm.casts import int_from_bytes
import chia.wallet.singleton

View File

@ -2,7 +2,7 @@ from __future__ import annotations
from dataclasses import dataclass
from blspy import G1Element
from chia_rs import G1Element
from chia.types.blockchain_format.sized_bytes import bytes32
from chia.util.ints import uint32

View File

@ -2,7 +2,7 @@ from __future__ import annotations
from typing import List, Optional, Set, Tuple
from blspy import AugSchemeMPL, G1Element, PrivateKey
from chia_rs import AugSchemeMPL, G1Element, PrivateKey
from chia.consensus.coinbase import create_puzzlehash_for_pk
from chia.types.blockchain_format.sized_bytes import bytes32

View File

@ -7,7 +7,7 @@ import re
import time
from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Set, Tuple, cast
from blspy import AugSchemeMPL, G1Element, G2Element
from chia_rs import AugSchemeMPL, G1Element, G2Element
from chia.protocols.wallet_protocol import CoinState
from chia.server.ws_connection import WSChiaConnection

View File

@ -2,7 +2,7 @@ from __future__ import annotations
from typing import Dict, Iterator, List, Optional, Tuple
from blspy import G1Element
from chia_rs import G1Element
from chia.types.blockchain_format.coin import Coin
from chia.types.blockchain_format.program import Program

View File

@ -7,7 +7,7 @@ import math
import time
from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Set, Tuple, Type, TypeVar, cast
from blspy import AugSchemeMPL, G1Element, G2Element
from chia_rs import AugSchemeMPL, G1Element, G2Element
from clvm.casts import int_from_bytes, int_to_bytes
from typing_extensions import Unpack

View File

@ -4,7 +4,7 @@ import dataclasses
import logging
from typing import Any, Dict, List, Optional, Set, Tuple
from blspy import G2Element
from chia_rs import G2Element
from chia.protocols.wallet_protocol import CoinState
from chia.types.announcement import Announcement

View File

@ -60,7 +60,7 @@ from __future__ import annotations
import hashlib
from typing import Union
from blspy import G1Element, PrivateKey
from chia_rs import G1Element, PrivateKey
from clvm.casts import int_from_bytes
from chia.types.blockchain_format.program import Program

View File

@ -2,7 +2,7 @@ from __future__ import annotations
import asyncio
from blspy import G2Element
from chia_rs import G2Element
from clvm_tools import binutils
from chia.consensus.block_rewards import calculate_base_farmer_reward, calculate_pool_reward

View File

@ -3,8 +3,7 @@ from __future__ import annotations
import inspect
from typing import Any, Callable, List
import blspy
from blspy import AugSchemeMPL
from chia_rs import AugSchemeMPL, G1Element, G2Element
from chia.types.blockchain_format.sized_bytes import bytes32
from chia.types.coin_spend import CoinSpend
@ -18,7 +17,7 @@ async def sign_coin_spends(
secret_key_for_puzzle_hash: Any, # Potentially awaitable function from bytes32 => Optional[PrivateKey]
additional_data: bytes,
max_cost: int,
potential_derivation_functions: List[Callable[[blspy.G1Element], bytes32]],
potential_derivation_functions: List[Callable[[G1Element], bytes32]],
) -> SpendBundle:
"""
Sign_coin_spends runs the puzzle code with the given argument and searches the
@ -37,15 +36,15 @@ async def sign_coin_spends(
derived keys (those returned by master_sk_to_wallet_sk from the ['sk'] member of
wallet rpc's get_private_key method).
"""
signatures: List[blspy.G2Element] = []
pk_list: List[blspy.G1Element] = []
signatures: List[G2Element] = []
pk_list: List[G1Element] = []
msg_list: List[bytes] = []
for coin_spend in coin_spends:
# Get AGG_SIG conditions
conditions_dict = conditions_dict_for_solution(coin_spend.puzzle_reveal, coin_spend.solution, max_cost)
# Create signature
for pk_bytes, msg in pkm_pairs_for_conditions_dict(conditions_dict, coin_spend.coin, additional_data):
pk = blspy.G1Element.from_bytes(pk_bytes)
pk = G1Element.from_bytes(pk_bytes)
pk_list.append(pk)
msg_list.append(msg)
if inspect.iscoroutinefunction(secret_key_for_public_key_f):

View File

@ -3,7 +3,7 @@ from __future__ import annotations
from dataclasses import dataclass, field
from typing import Any, BinaryIO, Dict, List, Optional, Set, Tuple, Union
from blspy import G2Element
from chia_rs import G2Element
from clvm_tools.binutils import disassemble
from chia.consensus.default_constants import DEFAULT_CONSTANTS

View File

@ -2,7 +2,7 @@ from __future__ import annotations
from typing import List
from blspy import AugSchemeMPL, G1Element
from chia_rs import AugSchemeMPL, G1Element
from clvm import KEYWORD_FROM_ATOM
from clvm_tools.binutils import disassemble as bu_disassemble

View File

@ -6,7 +6,7 @@ import time
import traceback
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Set, Tuple
from blspy import G1Element, G2Element
from chia_rs import G1Element, G2Element
from typing_extensions import Unpack
from chia.server.ws_connection import WSChiaConnection

View File

@ -6,7 +6,7 @@ import time
import traceback
from typing import TYPE_CHECKING, Dict, List, Optional, Set, Tuple, Type, TypeVar, Union
from blspy import G1Element, G2Element
from chia_rs import G1Element, G2Element
from clvm.casts import int_to_bytes
from typing_extensions import Unpack

View File

@ -4,7 +4,7 @@ import logging
import time
from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Set, Tuple, cast
from blspy import AugSchemeMPL, G1Element, G2Element
from chia_rs import AugSchemeMPL, G1Element, G2Element
from typing_extensions import Unpack
from chia.types.announcement import Announcement

View File

@ -12,7 +12,7 @@ from pathlib import Path
from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Set, Tuple, Union, cast
import aiosqlite
from blspy import AugSchemeMPL, G1Element, G2Element, PrivateKey
from chia_rs import AugSchemeMPL, G1Element, G2Element, PrivateKey
from packaging.version import Version
from chia.consensus.blockchain import AddBlockResult

View File

@ -2,7 +2,7 @@ from __future__ import annotations
from typing import TYPE_CHECKING, List, Optional, Set, Tuple, TypeVar
from blspy import G1Element
from chia_rs import G1Element
from typing_extensions import NotRequired, Protocol, TypedDict
from chia.server.ws_connection import WSChiaConnection

View File

@ -4,7 +4,7 @@ import asyncio
import logging
from typing import Dict, List, Optional, Set
from blspy import G1Element
from chia_rs import G1Element
from chia.types.blockchain_format.sized_bytes import bytes32
from chia.util.db_wrapper import DBWrapper2, execute_fetchone

View File

@ -24,7 +24,7 @@ from typing import (
)
import aiosqlite
from blspy import G1Element, G2Element, PrivateKey
from chia_rs import G1Element, G2Element, PrivateKey
from chia.consensus.block_rewards import calculate_base_farmer_reward, calculate_pool_reward
from chia.consensus.coinbase import farmer_parent_id, pool_parent_id

View File

@ -20,7 +20,6 @@ usage() {
PACMAN_AUTOMATED=
EXTRAS=
BLSPY_STUBS=
SKIP_PACKAGE_INSTALL=
PLOTTER_INSTALL=
EDITABLE='-e'
@ -31,7 +30,7 @@ do
# automated
a) PACMAN_AUTOMATED=--noconfirm;;
# development
d) EXTRAS=${EXTRAS}dev,;BLSPY_STUBS=1;;
d) EXTRAS=${EXTRAS}dev,;;
# non-editable
i) EDITABLE='';;
# legacy keyring
@ -335,10 +334,6 @@ python -m pip install wheel
python -m pip install --extra-index-url https://pypi.chia.net/simple/ miniupnpc==2.2.2
python -m pip install ${EDITABLE} ."${EXTRAS}" --extra-index-url https://pypi.chia.net/simple/
if [ -n "$BLSPY_STUBS" ]; then
python -m pip install ${EDITABLE} ./blspy-stubs
fi
if [ -n "$PLOTTER_INSTALL" ]; then
set +e
PREV_VENV="$VIRTUAL_ENV"

View File

@ -279,8 +279,7 @@ ignored-classes=optparse.Values,thread._local,_thread._local
# (useful for modules/projects where namespaces are manipulated during runtime
# and thus existing member attributes cannot be deduced by static analysis. It
# supports qualified module names, as well as Unix pattern matching.
ignored-modules=blspy,
chiabip158,
ignored-modules=chiabip158,
chiapos,
chiavdf,
chia_rs,

View File

@ -8,7 +8,6 @@ from setuptools import find_packages, setup
dependencies = [
"aiofiles==23.2.1", # Async IO for files
"anyio==4.0.0",
"blspy==2.0.2", # Signature library
"boto3==1.28.65", # AWS S3 for DL s3 plugin
"chiavdf==1.1.0", # timelord and vdf verification
"chiabip158==1.3", # bip158-style wallet filters

View File

@ -10,7 +10,7 @@ from dataclasses import replace
from typing import List
import pytest
from blspy import AugSchemeMPL, G2Element
from chia_rs import AugSchemeMPL, G2Element
from clvm.casts import int_to_bytes
from chia.consensus.block_header_validation import validate_finished_header_block

View File

@ -5,7 +5,7 @@ from dataclasses import dataclass
from typing import Callable, SupportsBytes
import pytest
from blspy import G1Element, G2Element
from chia_rs import G1Element, G2Element
from chia.types.blockchain_format.coin import Coin
from chia.types.blockchain_format.program import Program

View File

@ -2,7 +2,7 @@ from __future__ import annotations
from typing import Iterable, List, Tuple
from blspy import AugSchemeMPL, G1Element, G2Element
from chia_rs import AugSchemeMPL, G1Element, G2Element
from chia.consensus.default_constants import DEFAULT_CONSTANTS
from chia.types.blockchain_format.program import Program

View File

@ -3,7 +3,7 @@ from __future__ import annotations
from typing import List, Optional, Tuple
import pytest
from blspy import AugSchemeMPL, G1Element, G2Element, PrivateKey
from chia_rs import AugSchemeMPL, G1Element, G2Element, PrivateKey
from chia.clvm.spend_sim import CostLogger, SimClient, SpendSim, sim_and_client
from chia.consensus.default_constants import DEFAULT_CONSTANTS

View File

@ -1,7 +1,7 @@
from __future__ import annotations
import pytest
from blspy import G2Element
from chia_rs import G2Element
from chia.clvm.spend_sim import sim_and_client
from chia.types.blockchain_format.program import Program

View File

@ -6,8 +6,7 @@ from dataclasses import dataclass, field
from pathlib import Path
from typing import Any, AsyncIterator, Dict, Iterable, List, Optional, Tuple, Type, Union, cast
from blspy import G2Element
from chia_rs import Coin
from chia_rs import Coin, G2Element
import chia.cmds.wallet_funcs
from chia.cmds.chia import cli as chia_cli

View File

@ -1,7 +1,6 @@
from __future__ import annotations
from blspy import G2Element
from chia_rs import Coin
from chia_rs import Coin, G2Element
from chia.types.blockchain_format.sized_bytes import bytes32
from chia.types.spend_bundle import SpendBundle

View File

@ -3,8 +3,7 @@ from __future__ import annotations
from pathlib import Path
from typing import Any, Dict, List, Optional, Tuple, Union, cast
from blspy import G2Element
from chia_rs import Coin
from chia_rs import Coin, G2Element
from chia.server.outbound_message import NodeType
from chia.types.blockchain_format.program import Program

View File

@ -5,7 +5,7 @@ from dataclasses import dataclass
from typing import Optional
import pytest
from blspy import G1Element
from chia_rs import G1Element
from chia.consensus.default_constants import DEFAULT_CONSTANTS
from chia.types.blockchain_format.proof_of_space import ProofOfSpace, passes_plot_filter, verify_and_get_quality_string

View File

@ -6,7 +6,7 @@ import unittest
from typing import List, Tuple
import pytest
from blspy import G2Element
from chia_rs import G2Element
from chia.types.blockchain_format.coin import Coin
from chia.types.blockchain_format.program import Program

View File

@ -9,7 +9,7 @@ import logging
from typing import List, Optional, Tuple
import pytest
from blspy import G2Element
from chia_rs import G2Element
from clvm_tools.binutils import assemble
from chia.simulator.block_tools import BlockTools

View File

@ -9,7 +9,7 @@ import time
from typing import Coroutine, Dict, List, Optional, Tuple
import pytest
from blspy import AugSchemeMPL, G2Element, PrivateKey
from chia_rs import AugSchemeMPL, G2Element, PrivateKey
from clvm.casts import int_to_bytes
from chia.consensus.pot_iterations import is_overflow_block

View File

@ -2,7 +2,7 @@ from __future__ import annotations
from typing import Dict
import blspy
from chia_rs import G1Element, G2Element, PrivateKey
from chia.full_node.bundle_tools import simple_solution_generator
from chia.types.blockchain_format.coin import Coin
@ -18,14 +18,14 @@ from chia.wallet.puzzles.p2_delegated_puzzle_or_hidden_puzzle import puzzle_for_
GROUP_ORDER = 0x73EDA753299D7D483339D80809A1D80553BDA402FFFE5BFEFFFFFFFF00000001
def int_to_public_key(index: int) -> blspy.G1Element:
def int_to_public_key(index: int) -> G1Element:
index = index % GROUP_ORDER
private_key_from_int = blspy.PrivateKey.from_bytes(index.to_bytes(32, "big"))
private_key_from_int = PrivateKey.from_bytes(index.to_bytes(32, "big"))
return private_key_from_int.get_g1()
def puzzle_hash_for_index(index: int, puzzle_hash_db: dict) -> bytes32:
public_key: blspy.G1Element = int_to_public_key(index)
public_key: G1Element = int_to_public_key(index)
puzzle: Program = puzzle_for_pk(public_key)
puzzle_hash: bytes32 = puzzle.get_tree_hash()
puzzle_hash_db[puzzle_hash] = puzzle
@ -61,7 +61,7 @@ def make_spend_bundle(count: int) -> SpendBundle:
coin_spend = CoinSpend(coin, puzzle_reveal, solution)
coin_spends.append(coin_spend)
spend_bundle = SpendBundle(coin_spends, blspy.G2Element())
spend_bundle = SpendBundle(coin_spends, G2Element())
return spend_bundle

View File

@ -6,7 +6,7 @@ import random
from typing import Callable, Dict, List, Optional, Tuple
import pytest
from blspy import G2Element
from chia_rs import G2Element
from clvm.casts import int_to_bytes
from clvm_tools import binutils

View File

@ -4,8 +4,7 @@ from dataclasses import dataclass
from typing import Any, Awaitable, Callable, Dict, List, Optional, Set, Tuple
import pytest
from blspy import G1Element, G2Element
from chia_rs import ELIGIBLE_FOR_DEDUP
from chia_rs import ELIGIBLE_FOR_DEDUP, G1Element, G2Element
from chiabip158 import PyBIP158
from chia.consensus.constants import ConsensusConstants

View File

@ -5,7 +5,7 @@ import pathlib
from typing import List
import pytest
from blspy import G1Element
from chia_rs import G1Element
from clvm_tools import binutils
from chia.consensus.condition_costs import ConditionCost

View File

@ -4,8 +4,7 @@ from __future__ import annotations
from typing import List
import pytest
from blspy import AugSchemeMPL
from chia_rs import CoinSpend
from chia_rs import AugSchemeMPL
from clvm.casts import int_to_bytes
from chia.consensus.block_record import BlockRecord

View File

@ -1,6 +1,6 @@
from __future__ import annotations
from blspy import AugSchemeMPL, G1Element
from chia_rs import AugSchemeMPL, G1Element
from chia.util import cached_bls
from chia.util.hash import std_hash

View File

@ -7,7 +7,7 @@ from dataclasses import replace
from typing import Callable, List, Optional, Tuple
import pytest
from blspy import AugSchemeMPL, G1Element, PrivateKey
from chia_rs import AugSchemeMPL, G1Element, PrivateKey
import tests
from chia.simulator.keyring import TempKeyring

View File

@ -6,7 +6,7 @@ from dataclasses import dataclass, field, fields
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, get_type_hints
import pytest
from blspy import G1Element
from chia_rs import G1Element
from clvm_tools import binutils
from typing_extensions import Literal, get_args
@ -35,7 +35,6 @@ from chia.util.streamable import (
parse_bytes,
parse_list,
parse_optional,
parse_size_hints,
parse_str,
parse_tuple,
parse_uint32,
@ -204,35 +203,15 @@ class ConvertUnhashableTypeFailures(Streamable):
@pytest.mark.parametrize(
"input_dict, error, error_msg",
[
pytest.param({"a": 0}, InvalidTypeError, "Invalid type: Expected str, Actual: int"),
pytest.param({"a": []}, InvalidTypeError, "Invalid type: Expected str, Actual: list"),
pytest.param({"a": {}}, InvalidTypeError, "Invalid type: Expected str, Actual: dict"),
pytest.param({"a": "invalid"}, ConversionError, "non-hexadecimal number found in fromhex() arg at position 0"),
pytest.param(
{"a": "00" * (G1Element.SIZE - 1)},
ConversionError,
"from type bytes to G1Element: ValueError: Length of bytes object not equal to G1Element::SIZE",
),
pytest.param(
{"a": "00" * (G1Element.SIZE + 1)},
ConversionError,
"from type bytes to G1Element: ValueError: Length of bytes object not equal to G1Element::SIZE",
),
pytest.param(
{"a": b"\00" * (G1Element.SIZE - 1)},
ConversionError,
"from type bytes to G1Element: ValueError: Length of bytes object not equal to G1Element::SIZE",
),
pytest.param(
{"a": b"\00" * (G1Element.SIZE + 1)},
ConversionError,
"from type bytes to G1Element: ValueError: Length of bytes object not equal to G1Element::SIZE",
),
pytest.param(
{"a": b"\00" * G1Element.SIZE},
ConversionError,
"from type bytes to G1Element: ValueError: Given G1 non-infinity element must start with 0b10",
),
pytest.param({"a": 0}, TypeError, "invalid input type for PublicKey"),
pytest.param({"a": []}, ValueError, "PublicKey, invalid length 0 expected 48"),
pytest.param({"a": {}}, TypeError, "invalid input type for PublicKey"),
pytest.param({"a": "invalid"}, ValueError, "invalid hex"),
pytest.param({"a": "00" * (G1Element.SIZE - 1)}, ValueError, "PublicKey, invalid length 47 expected 48"),
pytest.param({"a": "00" * (G1Element.SIZE + 1)}, ValueError, "PublicKey, invalid length 49 expected 48"),
pytest.param({"a": b"\00" * (G1Element.SIZE - 1)}, ValueError, "PublicKey, invalid length 47 expected 48"),
pytest.param({"a": b"\00" * (G1Element.SIZE + 1)}, ValueError, "PublicKey, invalid length 49 expected 48"),
pytest.param({"a": b"\00" * G1Element.SIZE}, ValueError, "BLS Error G1InfinityInvalidBits"),
],
)
def test_convert_unhashable_type_failures(input_dict: Dict[str, Any], error: Any, error_msg: str) -> None:
@ -282,16 +261,14 @@ def test_convert_primitive_failures(input_dict: Dict[str, Any], error: Any) -> N
[
StreamableFromDict1,
{"a": 1, "b": "2", "c": "asd"},
ConversionError,
"Failed to convert 'asd' from type str to bytes: ValueError: non-hexadecimal number found in fromhex() arg "
"at position 1",
ValueError,
"invalid hex",
],
[
StreamableFromDict1,
{"a": 1, "b": "2", "c": "00" * G1Element.SIZE},
ConversionError,
f"Failed to convert {bytes.fromhex('00' * G1Element.SIZE)!r} from type bytes to G1Element: ValueError: "
"Given G1 non-infinity element must start with 0b10",
ValueError,
"BLS Error G1InfinityInvalidBits",
],
[
StreamableFromDict1,
@ -321,7 +298,7 @@ def test_convert_primitive_failures(input_dict: Dict[str, Any], error: Any) -> N
StreamableFromDict2,
{"a": {"a": 1, "b": "2", "c": G1Element()}, "b": {"a": 1, "b": "2"}},
ParameterMissingError,
"1 field missing for StreamableFromDict1: c",
"1 field missing for StreamableFromDict2: c",
],
[
StreamableFromDict2,
@ -828,18 +805,6 @@ class FailFromBytes:
raise ValueError()
def test_parse_size_hints() -> None:
assert parse_size_hints(io.BytesIO(b"1337"), TestFromBytes, 4, False).b == b"1337"
# EOF
with pytest.raises(AssertionError):
parse_size_hints(io.BytesIO(b"133"), TestFromBytes, 4, False)
# error in underlying type
with pytest.raises(ValueError):
parse_size_hints(io.BytesIO(b"1337"), FailFromBytes, 4, False)
def test_parse_str() -> None:
assert parse_str(io.BytesIO(b"\x00\x00\x00\x00")) == ""
assert parse_str(io.BytesIO(b"\x00\x00\x00\x01a")) == "a"

View File

@ -8,7 +8,7 @@ from types import TracebackType
from typing import Any, Dict, List, Optional, Tuple, Type, Union, cast
import pytest
from blspy import AugSchemeMPL, G1Element, G2Element, PrivateKey
from chia_rs import AugSchemeMPL, G1Element, G2Element, PrivateKey
from pytest_mock import MockerFixture
from chia.consensus.default_constants import DEFAULT_CONSTANTS

View File

@ -6,7 +6,7 @@ from pathlib import Path
from typing import Any, Dict, List, Optional, Tuple
import pytest
from blspy import G1Element
from chia_rs import G1Element
from chia.cmds.cmds_util import get_any_service_client
from chia.farmer.farmer import Farmer

View File

@ -5,8 +5,7 @@ import logging
from typing import Callable, List, Optional, Tuple
import pytest
from blspy import G2Element
from chia_rs import Coin
from chia_rs import Coin, G2Element
from chia.clvm.spend_sim import SimClient, SpendSim, sim_and_client
from chia.consensus.constants import ConsensusConstants

View File

@ -4,7 +4,7 @@ import logging
from typing import List
import pytest
from blspy import G1Element
from chia_rs import G1Element
from chia.plot_sync.delta import Delta, DeltaType, PathListDelta, PlotListDelta
from chia.protocols.harvester_protocol import Plot

View File

@ -8,7 +8,7 @@ from shutil import copy
from typing import Any, Callable, List, Optional, Tuple
import pytest
from blspy import G1Element
from chia_rs import G1Element
from chia.farmer.farmer import Farmer
from chia.farmer.farmer_api import FarmerAPI

View File

@ -7,7 +7,7 @@ import time
from typing import Any, Callable, List, Tuple, Type, Union
import pytest
from blspy import G1Element
from chia_rs import G1Element
from chia.consensus.pos_quality import UI_ACTUAL_SPACE_CONSTANT_FACTOR, _expected_plot_size
from chia.plot_sync.delta import Delta

Some files were not shown because too many files have changed in this diff Show More