From 9b8c3917eaf58ae51ab0f9f2bd71e47cd120b036 Mon Sep 17 00:00:00 2001 From: arvidn Date: Mon, 16 Oct 2023 13:41:05 +0200 Subject: [PATCH] rename ClassgroupElement.from_bytes() to not clash with the Streamable class --- chia/full_node/weight_proof.py | 2 +- chia/timelord/timelord.py | 4 ++-- chia/types/blockchain_format/classgroup.py | 4 ++-- chia/util/vdf_prover.py | 2 +- tests/blockchain/test_blockchain.py | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/chia/full_node/weight_proof.py b/chia/full_node/weight_proof.py index 233257e783ce..a8acbde1d0e5 100644 --- a/chia/full_node/weight_proof.py +++ b/chia/full_node/weight_proof.py @@ -1618,7 +1618,7 @@ def _validate_vdf_batch( ) -> bool: for vdf_proof_bytes, class_group_bytes, info in vdf_list: vdf = VDFProof.from_bytes(vdf_proof_bytes) - class_group = ClassgroupElement.from_bytes(class_group_bytes) + class_group = ClassgroupElement.create(class_group_bytes) vdf_info = VDFInfo.from_bytes(info) if not vdf.is_valid(constants, class_group, vdf_info): return False diff --git a/chia/timelord/timelord.py b/chia/timelord/timelord.py index b42c26b0aacd..5922955900e4 100644 --- a/chia/timelord/timelord.py +++ b/chia/timelord/timelord.py @@ -1027,7 +1027,7 @@ async def _do_process_communication( # Verifies our own proof just in case form_size = ClassgroupElement.get_size(self.constants) - output = ClassgroupElement.from_bytes(y_bytes[:form_size]) + output = ClassgroupElement.create(y_bytes[:form_size]) # default value so that it's always set for state_changed later ips: float = 0 if not self.bluebox_mode: @@ -1180,7 +1180,7 @@ async def _manage_discriminant_queue_sanitizer_slow(self, pool: ProcessPoolExecu log.info(f"Finished compact proof: {picked_info.height}. Time: {delta}s. IPS: {ips}.") output = proof[:100] proof_part = proof[100:200] - if ClassgroupElement.from_bytes(output) != picked_info.new_proof_of_time.output: + if ClassgroupElement.create(output) != picked_info.new_proof_of_time.output: log.error("Expected vdf output different than produced one. Stopping.") return vdf_proof = VDFProof(uint8(0), proof_part, True) diff --git a/chia/types/blockchain_format/classgroup.py b/chia/types/blockchain_format/classgroup.py index 2aaab2b35fec..61f891408a20 100644 --- a/chia/types/blockchain_format/classgroup.py +++ b/chia/types/blockchain_format/classgroup.py @@ -19,7 +19,7 @@ class ClassgroupElement(Streamable): data: bytes100 @staticmethod - def from_bytes(data: bytes) -> ClassgroupElement: + def create(data: bytes) -> ClassgroupElement: if len(data) < 100: data += b"\x00" * (100 - len(data)) return ClassgroupElement(bytes100(data)) @@ -28,7 +28,7 @@ def from_bytes(data: bytes) -> ClassgroupElement: def get_default_element() -> "ClassgroupElement": # Bit 3 in the first byte of serialized compressed form indicates if # it's the default generator element. - return ClassgroupElement.from_bytes(b"\x08") + return ClassgroupElement.create(b"\x08") @staticmethod def get_size(constants: ConsensusConstants) -> int: diff --git a/chia/util/vdf_prover.py b/chia/util/vdf_prover.py index 455f7ad35844..7a6661dfa06d 100644 --- a/chia/util/vdf_prover.py +++ b/chia/util/vdf_prover.py @@ -26,6 +26,6 @@ def get_vdf_info_and_proof( number_iters, ) - output = ClassgroupElement.from_bytes(result[:form_size]) + output = ClassgroupElement.create(result[:form_size]) proof_bytes = result[form_size : 2 * form_size] return VDFInfo(challenge_hash, number_iters, output), VDFProof(uint8(0), proof_bytes, normalized_to_identity) diff --git a/tests/blockchain/test_blockchain.py b/tests/blockchain/test_blockchain.py index 7907cf318baf..7ffc52723240 100644 --- a/tests/blockchain/test_blockchain.py +++ b/tests/blockchain/test_blockchain.py @@ -60,7 +60,7 @@ from tests.util.blockchain import create_blockchain log = logging.getLogger(__name__) -bad_element = ClassgroupElement.from_bytes(b"\x00") +bad_element = ClassgroupElement.create(b"\x00") @asynccontextmanager